Skip to content

Commit 57d76bc

Browse files
covanampalmer-dabbelt
authored andcommitted
riscv: change XIP's kernel_map.size to be size of the entire kernel
With XIP kernel, kernel_map.size is set to be only the size of data part of the kernel. This is inconsistent with "normal" kernel, who sets it to be the size of the entire kernel. More importantly, XIP kernel fails to boot if CONFIG_DEBUG_VIRTUAL is enabled, because there are checks on virtual addresses with the assumption that kernel_map.size is the size of the entire kernel (these checks are in arch/riscv/mm/physaddr.c). Change XIP's kernel_map.size to be the size of the entire kernel. Signed-off-by: Nam Cao <[email protected]> Cc: <[email protected]> # v6.1+ Reviewed-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6111939 commit 57d76bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/mm/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ static void __init create_kernel_page_table(pgd_t *pgdir,
927927
PMD_SIZE, PAGE_KERNEL_EXEC);
928928

929929
/* Map the data in RAM */
930-
end_va = kernel_map.virt_addr + XIP_OFFSET + kernel_map.size;
930+
end_va = kernel_map.virt_addr + kernel_map.size;
931931
for (va = kernel_map.virt_addr + XIP_OFFSET; va < end_va; va += PMD_SIZE)
932932
create_pgd_mapping(pgdir, va,
933933
kernel_map.phys_addr + (va - (kernel_map.virt_addr + XIP_OFFSET)),
@@ -1096,7 +1096,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
10961096

10971097
phys_ram_base = CONFIG_PHYS_RAM_BASE;
10981098
kernel_map.phys_addr = (uintptr_t)CONFIG_PHYS_RAM_BASE;
1099-
kernel_map.size = (uintptr_t)(&_end) - (uintptr_t)(&_sdata);
1099+
kernel_map.size = (uintptr_t)(&_end) - (uintptr_t)(&_start);
11001100

11011101
kernel_map.va_kernel_xip_pa_offset = kernel_map.virt_addr - kernel_map.xiprom;
11021102
#else

0 commit comments

Comments
 (0)