summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ghiti <alexghiti@rivosinc.com>2023-11-08 08:59:29 +0100
committerMarek Szyprowski <m.szyprowski@samsung.com>2024-09-12 17:48:03 +0200
commit8a21eae8649fa286ad376365cc3878a475b9963c (patch)
treea746986f0021eedaca143e421b778a41337c5301
parentfbe3c84395b592f5452b7a22ff3093650ab89be9 (diff)
downloadlinux-riscv-8a21eae8649fa286ad376365cc3878a475b9963c.tar.gz
linux-riscv-8a21eae8649fa286ad376365cc3878a475b9963c.tar.bz2
linux-riscv-8a21eae8649fa286ad376365cc3878a475b9963c.zip
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> [backport of the commit 629db01c64ff6cea08fc61b52426362689ef8618 from mainline] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Change-Id: I4b122a6d6e66d5454be7596746957942b3df01e8
-rw-r--r--arch/riscv/mm/init.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index ec02ea86aa39..5f136be9a390 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -667,16 +667,16 @@ void __init create_pgd_mapping(pgd_t *pgdp,
static uintptr_t __init best_map_size(phys_addr_t pa, uintptr_t va,
phys_addr_t size)
{
- if (!(pa & (PGDIR_SIZE - 1)) && !(va & (PGDIR_SIZE - 1)) && size >= PGDIR_SIZE)
- return PGDIR_SIZE;
-
- if (!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
+ if (pgtable_l5_enabled &&
+ !(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
return P4D_SIZE;
- if (!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
+ if (pgtable_l4_enabled &&
+ !(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
return PUD_SIZE;
- if (!(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
+ if (IS_ENABLED(CONFIG_64BIT) &&
+ !(pa & (PMD_SIZE - 1)) && !(va & (PMD_SIZE - 1)) && size >= PMD_SIZE)
return PMD_SIZE;
return PAGE_SIZE;