From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Frederik Haxel <haxel@fzi.de>,
Palmer Dabbelt <palmer@rivosinc.com>,
Sasha Levin <sashal@kernel.org>,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, conor.dooley@microchip.com,
andy.chiu@sifive.com, heiko@sntech.de, samitolvanen@google.com,
greentime.hu@sifive.com, samuel.holland@sifive.com,
cleger@rivosinc.com, guoren@kernel.org, namcaov@gmail.com,
alexghiti@rivosinc.com, anup@brainfault.org, bjorn@rivosinc.com,
bhe@redhat.com, chenjiahao16@huawei.com,
linux-riscv@lists.infradead.org
Subject: [PATCH AUTOSEL 6.7 10/13] riscv: Make XIP bootable again
Date: Wed, 24 Jan 2024 09:28:03 -0500 [thread overview]
Message-ID: <20240124142820.1283206-10-sashal@kernel.org> (raw)
In-Reply-To: <20240124142820.1283206-1-sashal@kernel.org>
From: Frederik Haxel <haxel@fzi.de>
[ Upstream commit 66f1e68093979816a23412a3fad066f5bcbc0360 ]
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>
Link: https://lore.kernel.org/r/20231212130116.848530-2-haxel@fzi.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 76ace1e0b46f..663881785b2b 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.43.0
next prev parent reply other threads:[~2024-01-24 14:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 14:27 [PATCH AUTOSEL 6.7 01/13] pinctrl: baytrail: Fix types of config value in byt_pin_config_set() Sasha Levin
2024-01-24 14:27 ` [PATCH AUTOSEL 6.7 02/13] leds: trigger: panic: Don't register panic notifier if creating the trigger failed Sasha Levin
2024-01-24 14:27 ` [PATCH AUTOSEL 6.7 03/13] um: Fix naming clash between UML and scheduler Sasha Levin
2024-01-24 14:27 ` [PATCH AUTOSEL 6.7 04/13] um: Don't use vfprintf() for os_info() Sasha Levin
2024-01-24 14:27 ` [PATCH AUTOSEL 6.7 05/13] um: net: Fix return type of uml_net_start_xmit() Sasha Levin
2024-01-24 14:27 ` [PATCH AUTOSEL 6.7 06/13] um: time-travel: fix time corruption Sasha Levin
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 07/13] i3c: master: cdns: Update maximum prescaler value for i2c clock Sasha Levin
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 08/13] ACPI: resource: Add DMI quirks for ASUS Vivobook E1504GA and E1504GAB Sasha Levin
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 09/13] ACPI: resource: Skip IRQ override on ASUS ExpertBook B1502CGA Sasha Levin
2024-01-24 14:28 ` Sasha Levin [this message]
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 11/13] xen/gntdev: Fix the abuse of underlying struct page in DMA-buf import Sasha Levin
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 12/13] mfd: ti_am335x_tscadc: Fix TI SoC dependencies Sasha Levin
2024-01-24 14:28 ` [PATCH AUTOSEL 6.7 13/13] mailbox: arm_mhuv2: Fix a bug for mhuv2_sender_interrupt Sasha Levin
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=20240124142820.1283206-10-sashal@kernel.org \
--to=sashal@kernel.org \
--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=haxel@fzi.de \
--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=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=samitolvanen@google.com \
--cc=samuel.holland@sifive.com \
--cc=stable@vger.kernel.org \
/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