Skip to content

Commit 5f03d4f

Browse files
Alexandre Ghitigregkh
authored andcommitted
riscv: Don't use PGD entries for the linear mapping
[ Upstream commit 629db01 ] 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 <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20231108075930.7157-2-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Stable-dep-of: c67ddf5 ("riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 65ac09c commit 5f03d4f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

arch/riscv/mm/init.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,16 +668,16 @@ void __init create_pgd_mapping(pgd_t *pgdp,
668668
static uintptr_t __init best_map_size(phys_addr_t pa, uintptr_t va,
669669
phys_addr_t size)
670670
{
671-
if (!(pa & (PGDIR_SIZE - 1)) && !(va & (PGDIR_SIZE - 1)) && size >= PGDIR_SIZE)
672-
return PGDIR_SIZE;
673-
674-
if (!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
671+
if (pgtable_l5_enabled &&
672+
!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
675673
return P4D_SIZE;
676674

677-
if (!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
675+
if (pgtable_l4_enabled &&
676+
!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
678677
return PUD_SIZE;
679678

680-
if (!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
679+
if (IS_ENABLED(CONFIG_64BIT) &&
680+
!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
681681
return PMD_SIZE;
682682

683683
return PAGE_SIZE;

0 commit comments

Comments
 (0)