From patchwork Sun Apr 3 02:49:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12799452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E50CCC433F5 for ; Sun, 3 Apr 2022 02:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bcZnGJu8rIfDjF/FwuK+oJls5Gw29hXvG9o/fuuy1+4=; b=FUTeGcp26R7/TS LWyYnPrzpu+LrE2O9Ua7OtM73OEBlmrpSGHqnbPpC62Dzlcz3PD9V0FKyyjj0OxuQnHRdQ7ZbeNId aaedNsTw3daSuyLOi6cxMirc9dqcWVR0Nrx4bxLcv6MXfkZAviNelpsC5GnDZVYktzXzaEwTQrl1L LbHWbJQWt8jv1YCLqQT4zhh3dtm10WO2MbxOwJNT2f/DrgBcXuDVRh2EBJ/X2DjB4ojeNtynw2LXk Qw6fxqjT1JnIpSbXFdjFXz9j5nU0RqMTCmBAUJEHMQ9HaITLVYEKf96HTB30IhwQXnNJqA3HSo01+ qDiuUV8Eg9ex1ZZ4IWmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1naqJN-00AVjx-WA; Sun, 03 Apr 2022 02:49:54 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1naqJH-00AVj8-Ny for linux-arm-kernel@lists.infradead.org; Sun, 03 Apr 2022 02:49:49 +0000 Received: by mail-pg1-x532.google.com with SMTP id c11so5481169pgu.11 for ; Sat, 02 Apr 2022 19:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0edowekvp+uuabuvCBvmZKu7k9xu44C+w2QWuBKwXVg=; b=3dMnBV4kTdo2WSciKxJYmAvpw7AXg+p1T7qReeNIsAg9ObVb5KAqh/PpPL3m0fgd4Y oGduNrh4X484v+yN6pxoeKd7cankKPiivDqNTmf5+0a252b+RNt6r2rhIigXJcbAT8p7 WS7vsgnpJelzKwddJVQ3rnU7FyRQYaiOoLM5kLYgQkzm1OqLjkLDdyuedGTu8YzaXsNc ayZABioTmxF68JUvHh82NrI1seLWO5w4/bFU+0LrhB3p0iHP/n/C0lgKdH2BmU11Hcij ukj0Slag8wF6GzQVngme9rPCzCCVjvo7eDHN5bVtbUPY+m5boGvo06SVCzz0XWzOhEjB PtWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0edowekvp+uuabuvCBvmZKu7k9xu44C+w2QWuBKwXVg=; b=0NORM8h00NvgO8vUoHokTB/YFuKL6UeEp+80JaOoIlHc3YID2Pk+B5zPwC/nIY2iUX pLGihphORyTkHwyQ17V5p798j8IDXjxsfC1IHP4UXg/oZWshBdngww5OwuEOdfvio0Um ZZ26Yc2rQeDN+fZlnuA+kOgyvxNFy67zs6uQJqEBXRTtBz65GlGdZORUvFK4bz70A9sY kwetU9ylnXNMOuzrCfSbKvVq13KZxtJfnNrI23aQi/V3mcoR+QGua93QmpUv7LWLtC7N YyJKOQXOR8SNFr0+n2THTpE8Hm9nvDrfqIN5IZrENIz273dxRIRxeY7shi8VfbQ7uZTi 5Lpg== X-Gm-Message-State: AOAM531USmK4yJ65nuM5Tb+cZwg0hG86Bpn6mrtxAiRczssJVE1KSqaT 2iRanz421qMDISBd4O3eY0hWTQ== X-Google-Smtp-Source: ABdhPJyDRXDH8Tz4dAGJv60lUuLMHE7z7aPaZZDJTkLlzwE4WSvWneTIZD0ZfdfJklDfoH1bNBhFsA== X-Received: by 2002:a63:a555:0:b0:382:3ec:ee4f with SMTP id r21-20020a63a555000000b0038203ecee4fmr20547497pgu.79.1648954186335; Sat, 02 Apr 2022 19:49:46 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id d9-20020a056a00198900b004fafdb88076sm7600992pfl.117.2022.04.02.19.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 19:49:45 -0700 (PDT) From: Muchun Song To: catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, anshuman.khandual@arm.com, aneesh.kumar@linux.ibm.com, steven.price@arm.com, lengxujun2007@126.com, arnd@arndb.de Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, smuchun@gmail.com, duanxiongchun@bytedance.com, Muchun Song , Qian Cai Subject: [PATCH] arm64: mm: fix pmd_leaf() Date: Sun, 3 Apr 2022 10:49:28 +0800 Message-Id: <20220403024928.4125-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220402_194948_009745_77C5EDCA X-CRM114-Status: GOOD ( 10.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pmd_leaf() is used to test a leaf mapped PMD, however, it misses the PROT_NONE mapped PMD on arm64. Fix it. A real world issue [1] caused by this was reported by Qian Cai. Link: https://patchwork.kernel.org/comment/24798260/ [1] Fixes: 8aa82df3c123 ("arm64: mm: add p?d_leaf() definitions") Reported-by: Qian Cai Signed-off-by: Muchun Song --- arch/arm64/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 94e147e5456c..09eaae46a19b 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -535,7 +535,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, PMD_TYPE_TABLE) #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_SECT) -#define pmd_leaf(pmd) pmd_sect(pmd) +#define pmd_leaf(pmd) (pmd_present(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT)) #define pmd_bad(pmd) (!pmd_table(pmd)) #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE)