From: Frederik Haxel <haxel@fzi.de>
To: unlisted-recipients:; (no To-header on input)
Cc: "Vitaly Wool" <vitaly.wool@konsulko.com>,
"Frederik Haxel" <haxel@fzi.de>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Andy Chiu" <andy.chiu@sifive.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Greentime Hu" <greentime.hu@sifive.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Clément Léger" <cleger@rivosinc.com>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Nam Cao" <namcaov@gmail.com>, "Guo Ren" <guoren@kernel.org>,
"Alexandre Ghiti" <alexghiti@rivosinc.com>,
"Anup Patel" <anup@brainfault.org>,
"Björn Töpel" <bjorn@rivosinc.com>, "Baoquan He" <bhe@redhat.com>,
"Chen Jiahao" <chenjiahao16@huawei.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] riscv: Make XIP bootable again
Date: Tue, 12 Dec 2023 14:01:12 +0100 [thread overview]
Message-ID: <20231212130116.848530-2-haxel@fzi.de> (raw)
In-Reply-To: <20231212130116.848530-1-haxel@fzi.de>
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: Frederik Haxel <haxel@fzi.de>
---
arch/riscv/kernel/head.S | 1 +
arch/riscv/mm/init.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index b77397432403..a2e2f0dd3899 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -89,6 +89,7 @@ relocate_enable_mmu:
/* Compute satp for kernel page tables, but don't load it yet */
srl a2, a0, PAGE_SHIFT
la a1, satp_mode
+ XIP_FIXUP_OFFSET a1
REG_L a1, 0(a1)
or a2, a2, a1
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 2e011cbddf3a..a65937336cdc 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -174,6 +174,9 @@ void __init mem_init(void)
/* Limit the memory size via mem. */
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)
{
@@ -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
* 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
dtb_early_pa = dtb_pa;
@@ -1055,9 +1058,9 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
#endif
kernel_map.virt_addr = KERNEL_LINK_ADDR + kernel_map.virt_offset;
- kernel_map.page_offset = _AC(CONFIG_PAGE_OFFSET, UL);
#ifdef CONFIG_XIP_KERNEL
+ kernel_map.page_offset = PAGE_OFFSET_L3;
kernel_map.xiprom = (uintptr_t)CONFIG_XIP_PHYS_ADDR;
kernel_map.xiprom_sz = (uintptr_t)(&_exiprom) - (uintptr_t)(&_xiprom);
@@ -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;
#else
+ kernel_map.page_offset = _AC(CONFIG_PAGE_OFFSET, UL);
kernel_map.phys_addr = (uintptr_t)(&_start);
kernel_map.size = (uintptr_t)(&_end) - kernel_map.phys_addr;
#endif
--
2.34.1
next prev parent reply other threads:[~2023-12-12 13:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 13:01 [PATCH 0/3] Fix XIP boot and make XIP testable in QEMU Frederik Haxel
2023-12-12 13:01 ` Frederik Haxel [this message]
2023-12-12 13:01 ` [PATCH 2/3] riscv: Fixed wrong register in XIP_FIXUP_FLASH_OFFSET macro Frederik Haxel
2023-12-12 13:01 ` [PATCH 3/3] riscv: Allow disabling of BUILTIN_DTB for XIP Frederik Haxel
2023-12-12 13:22 ` [PATCH 0/3] Fix XIP boot and make XIP testable in QEMU Conor Dooley
[not found] ` <CAM4kBBKBC=ZSQPzAq5MFQvd1g9=Up_oRAK5CV74oJHt=SbcPqg@mail.gmail.com>
2023-12-12 15:14 ` Conor Dooley
2023-12-13 16:08 ` Palmer Dabbelt
2024-01-11 14:50 ` patchwork-bot+linux-riscv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231212130116.848530-2-haxel@fzi.de \
--to=haxel@fzi.de \
--cc=alexghiti@rivosinc.com \
--cc=andy.chiu@sifive.com \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=bhe@redhat.com \
--cc=bjorn@rivosinc.com \
--cc=chenjiahao16@huawei.com \
--cc=cleger@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@kernel.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=namcaov@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=samitolvanen@google.com \
--cc=vitaly.wool@konsulko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®