Skip to content

Commit d8a7190

Browse files
fltowilldeacon
authored andcommitted
Revert "mm/pgtable: add stubs for {pmd/pub}_{set/clear}_huge"
This reverts commit c742199. c742199 ("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. A simple revert breaks the build for 32-bit PowerPC 8xx machines, which rely on the default function definitions when the corresponding page-table levels are folded, since commit a6a8f7c ("powerpc/8xx: add support for huge pages on VMAP and VMALLOC"), eg: powerpc64-linux-ld: mm/vmalloc.o: in function `vunmap_pud_range': linux/mm/vmalloc.c:362: undefined reference to `pud_clear_huge' To avoid that, add stubs for pud_clear_huge() and pmd_clear_huge() in arch/powerpc/mm/nohash/8xx.c as suggested by Christophe. Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Fixes: c742199 ("mm/pgtable: add stubs for {pmd/pub}_{set/clear}_huge") Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Marc Zyngier <maz@kernel.org> [mpe: Fold in 8xx.c changes from Christophe and mention in change log] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> 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 Link: https://lore.kernel.org/r/87r1fs1762.fsf@mpe.ellerman.id.au Signed-off-by: Will Deacon <will@kernel.org>
1 parent a7c3acc commit d8a7190

File tree

4 files changed

+34
-56
lines changed

4 files changed

+34
-56
lines changed

arch/arm64/mm/mmu.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,6 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
13391339
return dt_virt;
13401340
}
13411341

1342-
#if CONFIG_PGTABLE_LEVELS > 3
13431342
int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot)
13441343
{
13451344
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)
13541353
return 1;
13551354
}
13561355

1357-
int pud_clear_huge(pud_t *pudp)
1358-
{
1359-
if (!pud_sect(READ_ONCE(*pudp)))
1360-
return 0;
1361-
pud_clear(pudp);
1362-
return 1;
1363-
}
1364-
#endif
1365-
1366-
#if CONFIG_PGTABLE_LEVELS > 2
13671356
int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot)
13681357
{
13691358
pmd_t new_pmd = pfn_pmd(__phys_to_pfn(phys), mk_pmd_sect_prot(prot));
@@ -1378,14 +1367,21 @@ int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot)
13781367
return 1;
13791368
}
13801369

1370+
int pud_clear_huge(pud_t *pudp)
1371+
{
1372+
if (!pud_sect(READ_ONCE(*pudp)))
1373+
return 0;
1374+
pud_clear(pudp);
1375+
return 1;
1376+
}
1377+
13811378
int pmd_clear_huge(pmd_t *pmdp)
13821379
{
13831380
if (!pmd_sect(READ_ONCE(*pmdp)))
13841381
return 0;
13851382
pmd_clear(pmdp);
13861383
return 1;
13871384
}
1388-
#endif
13891385

13901386
int pmd_free_pte_page(pmd_t *pmdp, unsigned long addr)
13911387
{

arch/powerpc/mm/nohash/8xx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,13 @@ void __init setup_kuap(bool disabled)
240240
mtspr(SPRN_MD_AP, MD_APG_KUAP);
241241
}
242242
#endif
243+
244+
int pud_clear_huge(pud_t *pud)
245+
{
246+
return 0;
247+
}
248+
249+
int pmd_clear_huge(pmd_t *pmd)
250+
{
251+
return 0;
252+
}

arch/x86/mm/pgtable.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,6 @@ int p4d_clear_huge(p4d_t *p4d)
682682
}
683683
#endif
684684

685-
#if CONFIG_PGTABLE_LEVELS > 3
686685
/**
687686
* pud_set_huge - setup kernel PUD mapping
688687
*
@@ -721,23 +720,6 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
721720
return 1;
722721
}
723722

724-
/**
725-
* pud_clear_huge - clear kernel PUD mapping when it is set
726-
*
727-
* Returns 1 on success and 0 on failure (no PUD map is found).
728-
*/
729-
int pud_clear_huge(pud_t *pud)
730-
{
731-
if (pud_large(*pud)) {
732-
pud_clear(pud);
733-
return 1;
734-
}
735-
736-
return 0;
737-
}
738-
#endif
739-
740-
#if CONFIG_PGTABLE_LEVELS > 2
741723
/**
742724
* pmd_set_huge - setup kernel PMD mapping
743725
*
@@ -768,6 +750,21 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
768750
return 1;
769751
}
770752

753+
/**
754+
* pud_clear_huge - clear kernel PUD mapping when it is set
755+
*
756+
* Returns 1 on success and 0 on failure (no PUD map is found).
757+
*/
758+
int pud_clear_huge(pud_t *pud)
759+
{
760+
if (pud_large(*pud)) {
761+
pud_clear(pud);
762+
return 1;
763+
}
764+
765+
return 0;
766+
}
767+
771768
/**
772769
* pmd_clear_huge - clear kernel PMD mapping when it is set
773770
*
@@ -782,7 +779,6 @@ int pmd_clear_huge(pmd_t *pmd)
782779

783780
return 0;
784781
}
785-
#endif
786782

787783
#ifdef CONFIG_X86_64
788784
/**

include/linux/pgtable.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,34 +1397,10 @@ static inline int p4d_clear_huge(p4d_t *p4d)
13971397
}
13981398
#endif /* !__PAGETABLE_P4D_FOLDED */
13991399

1400-
#ifndef __PAGETABLE_PUD_FOLDED
14011400
int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
1402-
int pud_clear_huge(pud_t *pud);
1403-
#else
1404-
static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
1405-
{
1406-
return 0;
1407-
}
1408-
static inline int pud_clear_huge(pud_t *pud)
1409-
{
1410-
return 0;
1411-
}
1412-
#endif /* !__PAGETABLE_PUD_FOLDED */
1413-
1414-
#ifndef __PAGETABLE_PMD_FOLDED
14151401
int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
1402+
int pud_clear_huge(pud_t *pud);
14161403
int pmd_clear_huge(pmd_t *pmd);
1417-
#else
1418-
static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
1419-
{
1420-
return 0;
1421-
}
1422-
static inline int pmd_clear_huge(pmd_t *pmd)
1423-
{
1424-
return 0;
1425-
}
1426-
#endif /* !__PAGETABLE_PMD_FOLDED */
1427-
14281404
int p4d_free_pud_page(p4d_t *p4d, unsigned long addr);
14291405
int pud_free_pmd_page(pud_t *pud, unsigned long addr);
14301406
int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);

0 commit comments

Comments
 (0)