Skip to content

Commit a7cfb99

Browse files
covanampalmer-dabbelt
authored andcommitted
riscv: drop the use of XIP_OFFSET in create_kernel_page_table()
XIP_OFFSET is the hard-coded offset of writable data section within the kernel. By hard-coding this value, the read-only section of the kernel (which is placed before the writable data section) is restricted in size. As a preparation to remove this hard-coded value entirely, stop using XIP_OFFSET in create_kernel_page_table(). Instead use _sdata and _start to do the same thing. Signed-off-by: Nam Cao <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/4ea3f222a7eb9f91c04b155ff2e4d3ef19158acc.1717789719.git.namcao@linutronix.de Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 75fdf79 commit a7cfb99

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/riscv/mm/init.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ static void __init relocate_kernel(void)
917917
static void __init create_kernel_page_table(pgd_t *pgdir,
918918
__always_unused bool early)
919919
{
920-
uintptr_t va, end_va;
920+
uintptr_t va, start_va, end_va;
921921

922922
/* Map the flash resident part */
923923
end_va = kernel_map.virt_addr + kernel_map.xiprom_sz;
@@ -927,10 +927,11 @@ static void __init create_kernel_page_table(pgd_t *pgdir,
927927
PMD_SIZE, PAGE_KERNEL_EXEC);
928928

929929
/* Map the data in RAM */
930+
start_va = kernel_map.virt_addr + (uintptr_t)&_sdata - (uintptr_t)&_start;
930931
end_va = kernel_map.virt_addr + kernel_map.size;
931-
for (va = kernel_map.virt_addr + XIP_OFFSET; va < end_va; va += PMD_SIZE)
932+
for (va = start_va; va < end_va; va += PMD_SIZE)
932933
create_pgd_mapping(pgdir, va,
933-
kernel_map.phys_addr + (va - (kernel_map.virt_addr + XIP_OFFSET)),
934+
kernel_map.phys_addr + (va - start_va),
934935
PMD_SIZE, PAGE_KERNEL);
935936
}
936937
#else

0 commit comments

Comments
 (0)