From nobody Sun Dec 28 06:42:04 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F5F9C4332F for ; Tue, 12 Dec 2023 13:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376727AbjLLNR3 (ORCPT ); Tue, 12 Dec 2023 08:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376673AbjLLNRU (ORCPT ); Tue, 12 Dec 2023 08:17:20 -0500 Received: from fzi-msx-e-01.fzi.de (fzi-msx-e-01.fzi.de [141.21.8.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992E6123 for ; Tue, 12 Dec 2023 05:17:21 -0800 (PST) From: Frederik Haxel CC: Vitaly Wool , Frederik Haxel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Stuebner , Greentime Hu , Conor Dooley , Andy Chiu , =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Sami Tolvanen , Guo Ren , Nam Cao , Alexandre Ghiti , Baoquan He , Andrew Jones , Chen Jiahao , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , , Subject: [PATCH 3/3] riscv: Allow disabling of BUILTIN_DTB for XIP Date: Tue, 12 Dec 2023 14:01:14 +0100 Message-ID: <20231212130116.848530-4-haxel@fzi.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212130116.848530-1-haxel@fzi.de> References: <20231212130116.848530-1-haxel@fzi.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [141.21.46.139] X-ClientProxiedBy: fzi-msx-05.fzi.de (2001:67c:2acc:8:141:21:17:45) To fzi-msx-05.fzi.de (2001:67c:2acc:8:141:21:17:45) To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3Dy CONFIG_XIP_KERNEL=3Dy CONFIG_XIP_PHYS_ADDR=3D0x20000000 CONFIG_PHYS_RAM_BASE=3D0x80200000 CONFIG_BUILTIN_DTB=3Dn ``` 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=3Dpflash0 \ -blockdev node-name=3Dpflash0,driver=3Dfile,read-only=3Don,\ filename=3Darch/riscv/boot/xipImage ``` Signed-off-by: Frederik Haxel --- 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". =20 -endmenu # "Boot options" - config BUILTIN_DTB - bool + bool "Built-in device tree" depends on OF && NONPORTABLE default y if XIP_KERNEL =20 +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 =20 - /* Restore a0 copy */ + /* Restore a0 & a1 copy */ mv a0, s0 + mv a1, s1 #endif =20 #ifndef CONFIG_XIP_KERNEL --=20 2.34.1