Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4512589pxv; Tue, 20 Jul 2021 05:37:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqOd5GdhE6vQhqvAhST0cSi+jPEvFqjAq9BzvUBhg/DWX+HwCIVakTMS6QjfjCsWDc9Ajx X-Received: by 2002:a17:906:a2c4:: with SMTP id by4mr13632335ejb.521.1626784674063; Tue, 20 Jul 2021 05:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626784674; cv=none; d=google.com; s=arc-20160816; b=eG8nDX2Bz4bAWkhQFe5Xr1+UxXIDCFJlUflZsXzv7r4x1rcF+dmIdCYCv0aByg7Ku1 hAdOlzHFd9DYQjeKGN1J2sNS19bIqeLC7F2myvPJe0AZD/ZRKReTG7sOzrDpdzlk2F4U p8Df3Ez7eyH77jxQ1DrKhFy0myk5boL/ZvnpNcLPG/c0JvRjKy7LnNY4W9b2S2e+t/6e 2N8lNhVJzqBtOhCQ2PEQokbeGBBvA4M3jKE2SdRhTq9tDEGxn7H5Nc6pHoKclkGP27AX LkM817ZR7vV2qluau4wDvcBATbfdsEFeWY3P2CiKWw1UQprkRQkpmtDPQURbNf3KkpOL pE1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8gMynMFmn8mhaVWx1H6nFFHSkrvuWeC6vYub981e9Hc=; b=IVE6JFYPtyuWeMnhOu7pSonpqmxQ1tVKlZJ9nyxn0KcWHbdMd4tuXysmBa0qlJqvjK 2FsxbFox+UUgtfnH7axjlFfM7r+oE5JWIwUThAcXcv56k1XsXkal7mm7/LxpkCSYYzyL UL6GZgfTH0rwvvg+pAKx85zl8GpVRDRNsOONralEYEQqqHxsRUsL5qBF5AWxvGRqtViK DsRUTtzbFsAvGjmCt7RAW9Frwz/Mmm2XbAOB/plDRFtAiN1dO8pBWXICuj6sGnw5mS35 qM4UIANa/FRJoTpAOSyikLqUgKFN9IhH7WK5PVpz8+NR3/WBHnd3onOE8wuhf/fmekze LLSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SNFULBFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si22353675edr.280.2021.07.20.05.37.30; Tue, 20 Jul 2021 05:37:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SNFULBFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238275AbhGTLzY (ORCPT + 99 others); Tue, 20 Jul 2021 07:55:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbhGTLzH (ORCPT ); Tue, 20 Jul 2021 07:55:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E88561208; Tue, 20 Jul 2021 12:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626784545; bh=GwfGyRUEV46aABYr56ARFGrKLvcz5cJwUqbzXNrCfU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNFULBFnBBsoQZHf3uR8j5jS4Oan/It40bN3jPeuE1c4CoxSyECi6FnI8p2zzSfUx 2DXJN2GQoG9pUBbAodh3nbqSutzkTKpdDDWobN1con2cOJ/kPoxkefwsaGgRydEHih H6t/+FrDA7TCHw6aJC7SaMMEOcmp5bDjoIrSoBRTSgMYambXQoJhfGBOPCafJnX9i5 G4lgUUtTZ7kSjcDppqp0IEoKZ2QvE6WUFF6tnT6eEQraL6rJZVshLpZEQ3h9J4LWdn ozRHgtziZ2Kg4QcpvWpniYjiO4uJgJNUtYroViktmRiKrQ5amMGy9ImJtMgFsPlz8i zHDm4p556oOgw== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: Will Deacon , Ard Biesheuvel , Michael Ellerman , Thomas Gleixner , Benjamin Herrenschmidt , Christophe Leroy , Paul Mackerras , Jonathan Marek , Catalin Marinas , Andrew Morton , Mike Rapoport , Mark Rutland , Geert Uytterhoeven , Marc Zyngier , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] Revert "mm/pgtable: add stubs for {pmd/pub}_{set/clear}_huge" Date: Tue, 20 Jul 2021 13:35:12 +0100 Message-Id: <20210720123512.8740-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210720123512.8740-1-will@kernel.org> References: <20210720123512.8740-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Marek This reverts commit c742199a014de23ee92055c2473d91fe5561ffdf. c742199a014d ("mm/pgtable: add stubs for {pmd/pub}_{set/clear}_huge") breaks arm64 in at least two ways for configurations where PUD or PMD folding occur: 1. We no longer install huge-vmap mappings and silently fall back to page-granular entries, despite being able to install block entries at what is effectively the PGD level. 2. If the linear map is backed with block mappings, these will now silently fail to be created in alloc_init_pud(), causing a panic early during boot. The pgtable selftests caught this, although a fix has not been forthcoming and Christophe is AWOL at the moment, so just revert the change for now to get a working -rc3 on which we can queue patches for 5.15. Cc: Ard Biesheuvel Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Christophe Leroy Cc: Paul Mackerras Cc: Catalin Marinas Cc: Andrew Morton Cc: Nicholas Piggin Cc: Mark Rutland Cc: Geert Uytterhoeven Cc: Marc Zyngier Link: https://lore.kernel.org/linux-arm-kernel/CAMuHMdXShORDox-xxaeUfDW3wx2PeggFSqhVSHVZNKCGK-y_vQ@mail.gmail.com/ Link: https://lore.kernel.org/r/20210717160118.9855-1-jonathan@marek.ca Fixes: c742199a014d ("mm/pgtable: add stubs for {pmd/pub}_{set/clear}_huge") Signed-off-by: Jonathan Marek Signed-off-by: Will Deacon --- arch/arm64/mm/mmu.c | 20 ++++++++------------ arch/x86/mm/pgtable.c | 34 +++++++++++++++------------------- include/linux/pgtable.h | 26 +------------------------- 3 files changed, 24 insertions(+), 56 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index d74586508448..9ff0de1b2b93 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1339,7 +1339,6 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot) return dt_virt; } -#if CONFIG_PGTABLE_LEVELS > 3 int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) { pud_t new_pud = pfn_pud(__phys_to_pfn(phys), mk_pud_sect_prot(prot)); @@ -1354,16 +1353,6 @@ int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) return 1; } -int pud_clear_huge(pud_t *pudp) -{ - if (!pud_sect(READ_ONCE(*pudp))) - return 0; - pud_clear(pudp); - return 1; -} -#endif - -#if CONFIG_PGTABLE_LEVELS > 2 int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot) { pmd_t new_pmd = pfn_pmd(__phys_to_pfn(phys), mk_pmd_sect_prot(prot)); @@ -1378,6 +1367,14 @@ int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot) return 1; } +int pud_clear_huge(pud_t *pudp) +{ + if (!pud_sect(READ_ONCE(*pudp))) + return 0; + pud_clear(pudp); + return 1; +} + int pmd_clear_huge(pmd_t *pmdp) { if (!pmd_sect(READ_ONCE(*pmdp))) @@ -1385,7 +1382,6 @@ int pmd_clear_huge(pmd_t *pmdp) pmd_clear(pmdp); return 1; } -#endif int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr) { diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 3364fe62b903..3481b35cb4ec 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -682,7 +682,6 @@ int p4d_clear_huge(p4d_t *p4d) } #endif -#if CONFIG_PGTABLE_LEVELS > 3 /** * pud_set_huge - setup kernel PUD mapping * @@ -721,23 +720,6 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) return 1; } -/** - * pud_clear_huge - clear kernel PUD mapping when it is set - * - * Returns 1 on success and 0 on failure (no PUD map is found). - */ -int pud_clear_huge(pud_t *pud) -{ - if (pud_large(*pud)) { - pud_clear(pud); - return 1; - } - - return 0; -} -#endif - -#if CONFIG_PGTABLE_LEVELS > 2 /** * pmd_set_huge - setup kernel PMD mapping * @@ -768,6 +750,21 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) return 1; } +/** + * pud_clear_huge - clear kernel PUD mapping when it is set + * + * Returns 1 on success and 0 on failure (no PUD map is found). + */ +int pud_clear_huge(pud_t *pud) +{ + if (pud_large(*pud)) { + pud_clear(pud); + return 1; + } + + return 0; +} + /** * pmd_clear_huge - clear kernel PMD mapping when it is set * @@ -782,7 +779,6 @@ int pmd_clear_huge(pmd_t *pmd) return 0; } -#endif #ifdef CONFIG_X86_64 /** diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index d147480cdefc..e24d2c992b11 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1397,34 +1397,10 @@ static inline int p4d_clear_huge(p4d_t *p4d) } #endif /* !__PAGETABLE_P4D_FOLDED */ -#ifndef __PAGETABLE_PUD_FOLDED int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot); -int pud_clear_huge(pud_t *pud); -#else -static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) -{ - return 0; -} -static inline int pud_clear_huge(pud_t *pud) -{ - return 0; -} -#endif /* !__PAGETABLE_PUD_FOLDED */ - -#ifndef __PAGETABLE_PMD_FOLDED int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot); +int pud_clear_huge(pud_t *pud); int pmd_clear_huge(pmd_t *pmd); -#else -static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) -{ - return 0; -} -static inline int pmd_clear_huge(pmd_t *pmd) -{ - return 0; -} -#endif /* !__PAGETABLE_PMD_FOLDED */ - int p4d_free_pud_page(p4d_t *p4d, unsigned long addr); int pud_free_pmd_page(pud_t *pud, unsigned long addr); int pmd_free_pte_page(pmd_t *pmd, unsigned long addr); -- 2.32.0.402.g57bb445576-goog