Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4989054ybb; Tue, 24 Mar 2020 08:56:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtzegGw2nKFhmD9GHNFyxO4dGADEW1i6hxuHYbXENGuxMUg7iTYmjPsYkpCs4YfLUFvpUqj X-Received: by 2002:a05:6808:9bb:: with SMTP id e27mr3836364oig.36.1585065394764; Tue, 24 Mar 2020 08:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585065394; cv=none; d=google.com; s=arc-20160816; b=oLrOxlk212x3NOgiwb+/Spe5UjISIIfYuk6d6sCyC1qWWVNKULZgHeUqLoZXUt+zHI Cg3o7cydCGbQBCcGZ6syyqY2pmb+hej+46zIVViJ2mVFt1rpvx3tvdfUww04SQkQK2wx Zw9EwOugfXT90MhgIxoqzD7I4dtLlXeLLKLJhuqFQiJSUBlfo8ZYmnmQrlc7f2mbUuKj O769epWz8tIkoI4pmkPo/kSqDp37FbBVN0MZr4shppdSpZabr0STi/py7dgogaQQa/EM PCgeALfR/UhGA7EIoSXdNXnVm8fv8RhkHspkGGF36yue+LWMh9CV2DWi2OraUI5fNoxE k6OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WKfNG8umMlwkpQpy66f4+p/cJ7axBraMaD/gLOw+hwA=; b=g5ohIKL0AfDeVEO1Sb/IhuL2BBLe7AcaHf4O7UtP/hRopDYjADjfjwRGWEO6jitq7z e9lXaUcBn/Firus6mdordq4r/T109brn/dUmMG03kB0XvX14MBZ+bSFALLMtsLcIs09R nsOgMszswb+KOMXfMaTho20DB7ulgS+BqQ4MIze2OwsbGeGR7LJrw4sIxL/Oq6Sascvi g4CIxWdQH2qjyRB7MeWlWioFt5FjF+ssyPi9591WuoJYzpml5Gh6u4SxLB5yHevz7qD8 ceylAWo+nfcn8rdJ2YklFGP3DHNt0hpEMHYkcijFgZtkK/D6qEqzr57xTAXqP9zzctpY ryew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=MrGUEZ9I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si9791313otk.236.2020.03.24.08.56.21; Tue, 24 Mar 2020 08:56:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=MrGUEZ9I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgCXPzy (ORCPT + 99 others); Tue, 24 Mar 2020 11:55:54 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:34611 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727877AbgCXPzy (ORCPT ); Tue, 24 Mar 2020 11:55:54 -0400 Received: by mail-qk1-f196.google.com with SMTP id i6so10656744qke.1 for ; Tue, 24 Mar 2020 08:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WKfNG8umMlwkpQpy66f4+p/cJ7axBraMaD/gLOw+hwA=; b=MrGUEZ9IiQLdHGz08a8ugYDa8Kh9rXV8aSLNAnHozoNnLeKHJVRGMe9+8m1GlUnstf 5tQpZMpOzCfVJxw86gZz4WggoXB0Lk1BX8/uFnmjM+uCn92w4dRor82thwtliC5iP6y4 /VJADA5NAPnbZwi11s0UvCWYud5WVJaWD2G41vqNRnnaMZFarV6c/scEaRy4/utVW5io HuiW5m2mDE6YyHm6pmCHQqtyi6ePkAMcQR77qCpuFosHVAiGz+OrsD3/7tJilvvyxdrX +quF2ez8iVba7Sx8HThDueT1e16xa52eSqf8BciD/j7h9YlZibh9+FT85mFcIKgSVAjO +Ahw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WKfNG8umMlwkpQpy66f4+p/cJ7axBraMaD/gLOw+hwA=; b=PBtB1WyimPK6p+1GWoCL6swpOjsszCVUSopuyjQbVyhDKN9VxjuqRZrZUF912T2N8N PQjjK9uzXP+Fh/knAKrDFqT5wWWbnhpqaT9bBUwpAsfEH+i8ozVIjnOSD52ELjT6zQKM ASJyPU6lMKR0GCVkRTtNXonXbDwECaqnuUDSWW9GihNSNN//iKIqzkPGnPx5ZZcufqSh W+wk5PQzlXzK7ck6zRLCkNBeOk+ypwYCOgj54+gjxs/KfuwmE130p0ZaOHhTTFjKjkNJ kejm5R3699rPXBcITtC11zxy8jUCXVpbdRX6dkwCglUSTEdQnpWrBuxpNrkPEp2leqXT tUFw== X-Gm-Message-State: ANhLgQ1uGgYxy2vNavpXBuiY2xI1WW5V0+uTLG43c71oy31XiqILeTfX SL2dwDrxtCOTjuvUEVG8tgkBwg== X-Received: by 2002:a37:a70e:: with SMTP id q14mr23857810qke.41.1585065353693; Tue, 24 Mar 2020 08:55:53 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id v20sm12871207qth.10.2020.03.24.08.55.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 08:55:53 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jGluC-0004gw-I1; Tue, 24 Mar 2020 12:55:52 -0300 Date: Tue, 24 Mar 2020 12:55:52 -0300 From: Jason Gunthorpe To: Mike Kravetz Cc: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" , akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, arei.gonglei@huawei.com, weidong.huang@huawei.com, weifuqiang@huawei.com, kvm@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , Sean Christopherson , stable@vger.kernel.org Subject: Re: [PATCH v2] mm/hugetlb: fix a addressing exception caused by huge_pte_offset() Message-ID: <20200324155552.GK20941@ziepe.ca> References: <1582342427-230392-1-git-send-email-longpeng2@huawei.com> <51a25d55-de49-4c0a-c994-bf1a8cfc8638@oracle.com> <20200323160955.GY20941@ziepe.ca> <69055395-e7e5-a8e2-7f3e-f61607149318@oracle.com> <20200323180706.GC20941@ziepe.ca> <88698dd7-eb87-4b0b-7ba7-44ef6eab6a6c@oracle.com> <20200323225225.GF20941@ziepe.ca> <20200324115541.GH20941@ziepe.ca> <98d35563-8af0-2693-7e76-e6435da0bbee@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98d35563-8af0-2693-7e76-e6435da0bbee@oracle.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 08:25:09AM -0700, Mike Kravetz wrote: > On 3/24/20 4:55 AM, Jason Gunthorpe wrote: > > Also, since CH moved all the get_user_pages_fast code out of the > > arch's many/all archs can drop their arch specific version of this > > routine. This is really just a specialized version of gup_fast's > > algorithm.. > > > > (also the arch versions seem different, why do some return actual > > ptes, not null?) > > Not sure I understand that last question. The return value should be > a *pte or null. I mean the common code ends like this: pmd = pmd_offset(pud, addr); if (sz != PMD_SIZE && pmd_none(*pmd)) return NULL; /* hugepage or swap? */ if (pmd_huge(*pmd) || !pmd_present(*pmd)) return (pte_t *)pmd; return NULL; So it always returns a pointer into a PUD or PMD, while say, ppc in __find_linux_pte() ends like: return pte_offset_kernel(&pmd, ea); Which is pointing to a PTE So does sparc: pmd = pmd_offset(pud, addr); if (pmd_none(*pmd)) return NULL; if (is_hugetlb_pmd(*pmd)) return (pte_t *)pmd; return pte_offset_map(pmd, addr); Which is even worse because it is leaking a kmap.. etc > /* > * huge_pte_offset() - Walk the page table to resolve the hugepage > * entry at address @addr > * > * Return: Pointer to page table or swap entry (PUD or PMD) for ^^^^^^^^^^^^^^^^^^^ Ie the above is not followed by the archs I'm also scratching my head that a function that returns a pte_t * always returns a PUD or PMD. Strange bit of type casting.. Jason