Commit 66f1e680 authored by Frederik Haxel's avatar Frederik Haxel Committed by Palmer Dabbelt

riscv: Make XIP bootable again

Currently, the XIP kernel seems to fail to boot due to missing
XIP_FIXUP and a wrong page_offset value. A superfluous XIP_FIXUP
has also been removed.
Signed-off-by: default avatarFrederik Haxel <haxel@fzi.de>
Link: https://lore.kernel.org/r/20231212130116.848530-2-haxel@fzi.deSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent b85ea95d
...@@ -89,6 +89,7 @@ relocate_enable_mmu: ...@@ -89,6 +89,7 @@ relocate_enable_mmu:
/* Compute satp for kernel page tables, but don't load it yet */ /* Compute satp for kernel page tables, but don't load it yet */
srl a2, a0, PAGE_SHIFT srl a2, a0, PAGE_SHIFT
la a1, satp_mode la a1, satp_mode
XIP_FIXUP_OFFSET a1
REG_L a1, 0(a1) REG_L a1, 0(a1)
or a2, a2, a1 or a2, a2, a1
......
...@@ -174,6 +174,9 @@ void __init mem_init(void) ...@@ -174,6 +174,9 @@ void __init mem_init(void)
/* Limit the memory size via mem. */ /* Limit the memory size via mem. */
static phys_addr_t memory_limit; static phys_addr_t memory_limit;
#ifdef CONFIG_XIP_KERNEL
#define memory_limit (*(phys_addr_t *)XIP_FIXUP(&memory_limit))
#endif /* CONFIG_XIP_KERNEL */
static int __init early_mem(char *p) static int __init early_mem(char *p)
{ {
...@@ -952,7 +955,7 @@ static void __init create_fdt_early_page_table(uintptr_t fix_fdt_va, ...@@ -952,7 +955,7 @@ static void __init create_fdt_early_page_table(uintptr_t fix_fdt_va,
* setup_vm_final installs the linear mapping. For 32-bit kernel, as the * setup_vm_final installs the linear mapping. For 32-bit kernel, as the
* kernel is mapped in the linear mapping, that makes no difference. * kernel is mapped in the linear mapping, that makes no difference.
*/ */
dtb_early_va = kernel_mapping_pa_to_va(XIP_FIXUP(dtb_pa)); dtb_early_va = kernel_mapping_pa_to_va(dtb_pa);
#endif #endif
dtb_early_pa = dtb_pa; dtb_early_pa = dtb_pa;
...@@ -1055,9 +1058,9 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) ...@@ -1055,9 +1058,9 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
#endif #endif
kernel_map.virt_addr = KERNEL_LINK_ADDR + kernel_map.virt_offset; kernel_map.virt_addr = KERNEL_LINK_ADDR + kernel_map.virt_offset;
kernel_map.page_offset = _AC(CONFIG_PAGE_OFFSET, UL);
#ifdef CONFIG_XIP_KERNEL #ifdef CONFIG_XIP_KERNEL
kernel_map.page_offset = PAGE_OFFSET_L3;
kernel_map.xiprom = (uintptr_t)CONFIG_XIP_PHYS_ADDR; kernel_map.xiprom = (uintptr_t)CONFIG_XIP_PHYS_ADDR;
kernel_map.xiprom_sz = (uintptr_t)(&_exiprom) - (uintptr_t)(&_xiprom); kernel_map.xiprom_sz = (uintptr_t)(&_exiprom) - (uintptr_t)(&_xiprom);
...@@ -1067,6 +1070,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) ...@@ -1067,6 +1070,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
kernel_map.va_kernel_xip_pa_offset = kernel_map.virt_addr - kernel_map.xiprom; kernel_map.va_kernel_xip_pa_offset = kernel_map.virt_addr - kernel_map.xiprom;
#else #else
kernel_map.page_offset = _AC(CONFIG_PAGE_OFFSET, UL);
kernel_map.phys_addr = (uintptr_t)(&_start); kernel_map.phys_addr = (uintptr_t)(&_start);
kernel_map.size = (uintptr_t)(&_end) - kernel_map.phys_addr; kernel_map.size = (uintptr_t)(&_end) - kernel_map.phys_addr;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment