Skip to content

Commit 629db01

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Don't use PGD entries for the linear mapping
Propagating changes at this level is cumbersome as we need to go through all the page tables when that happens (either when changing the permissions or when splitting the mapping). Note that this prevents the use of 4MB mapping for sv32 and 1GB mapping for sv39 in the linear mapping. Signed-off-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 0bb80ec commit 629db01

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/riscv/mm/init.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,16 +664,16 @@ void __init create_pgd_mapping(pgd_t *pgdp,
664664
static uintptr_t __init best_map_size(phys_addr_t pa, uintptr_t va,
665665
phys_addr_t size)
666666
{
667-
if (!(pa & (PGDIR_SIZE - 1)) && !(va & (PGDIR_SIZE - 1)) && size >= PGDIR_SIZE)
668-
return PGDIR_SIZE;
669-
670-
if (!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
667+
if (pgtable_l5_enabled &&
668+
!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
671669
return P4D_SIZE;
672670

673-
if (!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
671+
if (pgtable_l4_enabled &&
672+
!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
674673
return PUD_SIZE;
675674

676-
if (!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
675+
if (IS_ENABLED(CONFIG_64BIT) &&
676+
!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
677677
return PMD_SIZE;
678678

679679
return PAGE_SIZE;

0 commit comments

Comments
 (0)