All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 28/28] riscv: qemu: clear kernel-start/-end in device tree as workaround for BBL
Date: Fri, 9 Nov 2018 13:59:23 +0100	[thread overview]
Message-ID: <20181109125923.7034-29-lukas.auer@aisec.fraunhofer.de> (raw)
In-Reply-To: <20181109125923.7034-1-lukas.auer@aisec.fraunhofer.de>

QEMU specifies the location of Linux (supplied with the -kernel
argument) in the device tree using the riscv,kernel-start and
riscv,kernel-end properties. We currently rely on the SBI implementation
of BBL to run Linux and therefore embed Linux as payload in BBL. This
causes an issue, because BBL detects the kernel properties in the device
tree and ignores the Linux payload as a result.
Work around this issue by clearing the kernel properties in the device
tree before booting Linux.

Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v3: None
Changes in v2:
- New patch

 board/emulation/qemu-riscv/Kconfig      |  1 +
 board/emulation/qemu-riscv/qemu-riscv.c | 39 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
index be5839b7db..33ca253432 100644
--- a/board/emulation/qemu-riscv/Kconfig
+++ b/board/emulation/qemu-riscv/Kconfig
@@ -30,5 +30,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply CMD_EXT4
 	imply CMD_FAT
 	imply BOARD_LATE_INIT
+	imply OF_BOARD_SETUP
 
 endif
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index 587f2c4909..d6167aaef1 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -48,3 +48,42 @@ int board_late_init(void)
 
 	return 0;
 }
+
+/*
+ * QEMU specifies the location of Linux (supplied with the -kernel argument)
+ * in the device tree using the riscv,kernel-start and riscv,kernel-end
+ * properties. We currently rely on the SBI implementation of BBL to run
+ * Linux and therefore embed Linux as payload in BBL. This causes an issue,
+ * because BBL detects the kernel properties in the device tree and ignores
+ * the Linux payload as a result. To work around this issue, we clear the
+ * kernel properties before booting Linux.
+ *
+ * This workaround can be removed, once we do not require BBL for its SBI
+ * implementation anymore.
+ */
+int ft_board_setup(void *blob, bd_t *bd)
+{
+	int chosen_offset, ret;
+
+	chosen_offset = fdt_path_offset(blob, "/chosen");
+	if (chosen_offset < 0)
+		return 0;
+
+#ifdef CONFIG_ARCH_RV64I
+	ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-start", 0);
+#else
+	ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-start", 0);
+#endif
+	if (ret)
+		return ret;
+
+#ifdef CONFIG_ARCH_RV64I
+	ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-end", 0);
+#else
+	ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-end", 0);
+#endif
+	if (ret)
+		return ret;
+
+	return 0;
+}
-- 
2.17.2

  parent reply	other threads:[~2018-11-09 12:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09 12:58 [U-Boot] [PATCH v3 00/28] General fixes / cleanup for RISC-V and improvements to qemu-riscv Lukas Auer
2018-11-09 12:58 ` [U-Boot] [PATCH v3 01/28] tools: .gitignore: add prelink-riscv Lukas Auer
2018-11-09 12:58 ` [U-Boot] [PATCH v3 02/28] dts: riscv: update makefile to also clean the RISC-V dts directory Lukas Auer
2018-11-09 12:58 ` [U-Boot] [PATCH v3 03/28] riscv: rename CPU_RISCV_32/64 to match architecture names ARCH_RV32I/64I Lukas Auer
2018-11-09 12:58 ` [U-Boot] [PATCH v3 04/28] riscv: select CONFIG_PHYS_64BIT on RV64I systems Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 05/28] riscv: add Kconfig entries for the C and A ISA extensions Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 06/28] riscv: set -march and -mabi based on the Kconfig configuration Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 07/28] riscv: enable -fdata-sections Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 08/28] riscv: fix use of incorrectly sized variables Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 09/28] riscv: make use of the barrier functions from Linux Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 10/28] riscv: do not reimplement generic io functions Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 11/28] riscv: complete the list of exception codes Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 12/28] riscv: treat undefined exception codes as reserved Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 13/28] riscv: hang on unhandled exceptions Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 14/28] riscv: implement the invalidate_icache_* functions Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 15/28] riscv: fix inconsistent use of spaces and tabs in start.S Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 16/28] riscv: align mtvec on a 4-byte boundary Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 17/28] Drop CONFIG_INIT_CRITICAL Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 18/28] riscv: remove unused labels in start.S Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 19/28] riscv: do not blindly modify the mstatus CSR Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 20/28] riscv: save hart ID and device tree passed by prior boot stage Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 21/28] riscv: qemu: use " Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 22/28] riscv: qemu: support booting Linux Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 23/28] riscv: align bootm implementation with that of other architectures Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 24/28] distro_bootcmd: add VirtIO distro boot command Lukas Auer
2018-11-13  5:57   ` Bin Meng
2018-11-13  8:56   ` Alexander Graf
2018-11-09 12:59 ` [U-Boot] [PATCH v3 25/28] riscv: qemu: enable distro boot Lukas Auer
2018-11-13  5:57   ` Bin Meng
2018-11-13  8:57   ` Alexander Graf
2018-11-09 12:59 ` [U-Boot] [PATCH v3 26/28] dm: core: add missing prototype for ofnode_read_u64 Lukas Auer
2018-11-09 12:59 ` [U-Boot] [PATCH v3 27/28] riscv: qemu: detect and boot the kernel passed by QEMU Lukas Auer
2018-11-13  5:57   ` Bin Meng
2018-11-13  9:01   ` Alexander Graf
2018-11-13 22:00     ` Auer, Lukas
2018-11-09 12:59 ` Lukas Auer [this message]
     [not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA3A4887F@ATCPCS16.andestech.com>
2018-11-13  6:41   ` [U-Boot] [PATCH v3 00/28] General fixes / cleanup for RISC-V and improvements to qemu-riscv Rick Chen
2018-11-13  6:49     ` Bin Meng
2018-11-13  6:52       ` Rick Chen
2018-11-16 22:01         ` Auer, Lukas
2018-11-19  9:10           ` Rick Chen

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=20181109125923.7034-29-lukas.auer@aisec.fraunhofer.de \
    --to=lukas.auer@aisec.fraunhofer.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.