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>,
"Heiko Stuebner" <heiko@sntech.de>,
"Greentime Hu" <greentime.hu@sifive.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Andy Chiu" <andy.chiu@sifive.com>,
"Clément Léger" <cleger@rivosinc.com>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Guo Ren" <guoren@kernel.org>, "Nam Cao" <namcaov@gmail.com>,
"Alexandre Ghiti" <alexghiti@rivosinc.com>,
"Baoquan He" <bhe@redhat.com>,
"Andrew Jones" <ajones@ventanamicro.com>,
"Chen Jiahao" <chenjiahao16@huawei.com>,
"Björn Töpel" <bjorn@rivosinc.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] riscv: Allow disabling of BUILTIN_DTB for XIP
Date: Tue, 12 Dec 2023 14:01:14 +0100 [thread overview]
Message-ID: <20231212130116.848530-4-haxel@fzi.de> (raw)
In-Reply-To: <20231212130116.848530-1-haxel@fzi.de>
This enables, among other things, testing with the QEMU virt machine.
To build an XIP kernel for the QEMU virt machine, configure the
the kernel as desired and apply the following configuration
```
CONFIG_NONPORTABLE=y
CONFIG_XIP_KERNEL=y
CONFIG_XIP_PHYS_ADDR=0x20000000
CONFIG_PHYS_RAM_BASE=0x80200000
CONFIG_BUILTIN_DTB=n
```
Since the QEMU virt flash memory expects a 32 MB file, the built image
must be padded. For example, with
`truncate -s 32M arch/riscv/boot/xipImage`
The kernel can be started using the following command in QEMU (v8+)
```
qemu-system-riscv64 -M virt,pflash0=pflash0 \
-blockdev node-name=pflash0,driver=file,read-only=on,\
filename=arch/riscv/boot/xipImage <optional parameters>
```
Signed-off-by: Frederik Haxel <haxel@fzi.de>
---
arch/riscv/Kconfig | 6 +++---
arch/riscv/kernel/head.S | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 95a2a06acc6a..72bc31b6eeb9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -904,13 +904,13 @@ config RISCV_ISA_FALLBACK
on the replacement properties, "riscv,isa-base" and
"riscv,isa-extensions".
-endmenu # "Boot options"
-
config BUILTIN_DTB
- bool
+ bool "Built-in device tree"
depends on OF && NONPORTABLE
default y if XIP_KERNEL
+endmenu # "Boot options"
+
config PORTABLE
bool
default !NONPORTABLE
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index a2e2f0dd3899..a8939558702c 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -266,10 +266,12 @@ SYM_CODE_START(_start_kernel)
la sp, _end + THREAD_SIZE
XIP_FIXUP_OFFSET sp
mv s0, a0
+ mv s1, a1
call __copy_data
- /* Restore a0 copy */
+ /* Restore a0 & a1 copy */
mv a0, s0
+ mv a1, s1
#endif
#ifndef CONFIG_XIP_KERNEL
--
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 ` [PATCH 1/3] riscv: Make XIP bootable again Frederik Haxel
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 ` Frederik Haxel [this message]
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-4-haxel@fzi.de \
--to=haxel@fzi.de \
--cc=ajones@ventanamicro.com \
--cc=alexghiti@rivosinc.com \
--cc=andy.chiu@sifive.com \
--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®