From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643F5C43331 for ; Tue, 24 Mar 2020 17:59:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 02EB320719 for ; Tue, 24 Mar 2020 17:59:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="IXdBQHqe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 02EB320719 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5C0F66B0003; Tue, 24 Mar 2020 13:59:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54BA16B0006; Tue, 24 Mar 2020 13:59:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4125D6B0007; Tue, 24 Mar 2020 13:59:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 1FCC46B0003 for ; Tue, 24 Mar 2020 13:59:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CA055B9F68 for ; Tue, 24 Mar 2020 17:59:21 +0000 (UTC) X-FDA: 76631017722.25.space33_6ed0365321703 X-HE-Tag: space33_6ed0365321703 X-Filterd-Recvd-Size: 5944 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Mar 2020 17:59:21 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id t17so5596065qtn.12 for ; Tue, 24 Mar 2020 10:59:21 -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=zH+BGadp4OmNkvzUZhTO73HLGjoJtfJzYl50kGaQ9wk=; b=IXdBQHqeUJOCCZkIgPOwwZgSnBKeFld/XRqmME+TSc3rxoiYnHV8EgAK6SY/rP6xlv U9fRw/vb55F1clIFXva7MNTzhItj4RSG2F+XGgFYAgrTipDRAZm8z5ZUkQovc4EumeOs zD6Kyyh5KWPcv5DLAV5hgqZQl1m9uaA/XaEvYSfKhMa9585c2w9rlfQpnoi7VQas3S8R UKKPXYTQuHwDenMlqq4JexbrdUBPTBkflax1BCdCMURi+HSFOLlzoah9ss0ZWBxd6OuC VrOBUG1xvv8OAVpd0tD11cCKbQ5FeCGEa/rZq5SnlOwIM5oAz3ohlQFSs9MH6AhA9HQa cZ2Q== 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=zH+BGadp4OmNkvzUZhTO73HLGjoJtfJzYl50kGaQ9wk=; b=A34Rel/5CtFpDkvPjOVN9rv/EtrJRrMBl7pYfNewr73Z8c1QHec3KlbkqoTv8RYUcn qSyrj3m51L3rr0EwCODwEV1xEfL+ySLBuwedkpsb3FPQBuNRYx7Jti/2ZoWyboSExCNw 2Q4l1q8ny4KpDXxiIiZo4GPuX0YGM4/gZQMnC3G03gT5EDgPB+iONtti8yTNvEJhJWbU NjrwPZSAAyy5BzIYr1EChP/koG68FYH9X4WnsopU1jm1HgTJeKgUmkB6YW6TuxuN4BH5 gI5mg+5/V4ArPAytCDPKvzQHUso/ZH205OEmoR4RVOA/dMGtk5DOZXGZqTfCGbfpYL7B Tr2w== X-Gm-Message-State: ANhLgQ2nlqy/yXbIrUhg/1DJSR1Qld+ywnO8VaePY4O/A2GUQgUK/yqD NghZCTaqrBI4b3oBjC9eQsBuHQ== X-Google-Smtp-Source: ADFU+vuQ4Q4V+mScJFlextfScElcSW54hioCdgee8HN9LPyP5FKMTC3Ckqq0+uSRdg0bOwuphm/SkA== X-Received: by 2002:ac8:1c17:: with SMTP id a23mr28141558qtk.239.1585072760748; Tue, 24 Mar 2020 10:59:20 -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 d72sm13434428qkg.102.2020.03.24.10.59.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 10:59:20 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jGnpe-0006sJ-Ql; Tue, 24 Mar 2020 14:59:18 -0300 Date: Tue, 24 Mar 2020 14:59:18 -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: <20200324175918.GL20941@ziepe.ca> References: <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> <20200324155552.GK20941@ziepe.ca> <66583587-ca4f-9847-c173-4a3d7938fec6@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66583587-ca4f-9847-c173-4a3d7938fec6@oracle.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Mar 24, 2020 at 09:19:29AM -0700, Mike Kravetz wrote: > On 3/24/20 8:55 AM, Jason Gunthorpe wrote: > > 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 > > Ok, now I understand the question. huge_pte_offset will/should only be > called for addresses that are in a vma backed by hugetlb pages. So, > pte_offset_kernel() will only return page table type (PUD/PMD/etc) associated > with a huge page supported by the particular arch. I thought pte_offset_kernel always returns PTEs (ie the 4k entries on x86), I suppose what you are saying is that since the caller knows this is always a PUD or PMD due to the VMA the pte_offset is dead code. > > 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.. Particularly here which is buggy dead code :) Jason