Skip to content

Commit d566bea

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Do not allow vmap pud mappings for 3-level page table
The vmalloc_fault() path was removed and to avoid syncing the vmalloc PGD mappings, they are now preallocated. But if the kernel can use a PUD mapping (which in sv39 is actually a PGD mapping) for large vmalloc allocation, it will free the current unused preallocated PGD mapping and install a new leaf one. Since there is no sync anymore, some page tables lack this new mapping and that triggers a panic. So only allow PUD mappings for sv48 and sv57. Fixes: 7d3332b ("riscv: mm: Pre-allocate PGD entries for vmalloc/modules area") Signed-off-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent d240204 commit d566bea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/riscv/include/asm/vmalloc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
55

6+
extern bool pgtable_l4_enabled, pgtable_l5_enabled;
7+
68
#define IOREMAP_MAX_ORDER (PUD_SHIFT)
79

810
#define arch_vmap_pud_supported arch_vmap_pud_supported
911
static inline bool arch_vmap_pud_supported(pgprot_t prot)
1012
{
11-
return true;
13+
return pgtable_l4_enabled || pgtable_l5_enabled;
1214
}
1315

1416
#define arch_vmap_pmd_supported arch_vmap_pmd_supported

0 commit comments

Comments
 (0)