mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	lst@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>,
	rcz@pengutronix.de
Subject: [PATCH 06/11] common: boards: qemu-virt: remap cfi-flash from 0 to 0x1000
Date: Mon, 22 May 2023 07:28:30 +0200	[thread overview]
Message-ID: <20230522052835.1039143-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230522052835.1039143-1-a.fatoum@pengutronix.de>

When MMU is enabled, barebox maintains a single address space with
1:1 physical to virtual mapping by default. Furthermore, the zero
page is marked inaccessible to trap NULL pointer dereferences.

This is problematic on the Qemu ARM Virt platform, because the
cfi-flash is memory mapped starting with address zero, so users need
to decide whether they want the cfi-flash or the MMU.

Make everyone happy by shifting the virtual cfi-flash mapping by 4K:

    virt   ->    phys

    0x0000 ->    0x0000 [faulting]
    0x1000 ->    0x0000 [(uncached) alias]
    0x2000 ->    0x1000
           .
           .
           .
 0x7fff000 -> 0x7ffe000
 0x8000000 -> 0x7fff000

This eats one page into the memory region starting at 0x8000000.
That's ok though, because that's where the GIC is located on both
ARM32 and ARM64 and we don't do interrupts in barebox.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Cc: Lucas Stach <l.stach@pengutronix.de>
---
 common/boards/qemu-virt/Makefile             | 3 +++
 common/boards/qemu-virt/overlay-of-flash.dts | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/boards/qemu-virt/Makefile b/common/boards/qemu-virt/Makefile
index 8cacfafee734..c16727751550 100644
--- a/common/boards/qemu-virt/Makefile
+++ b/common/boards/qemu-virt/Makefile
@@ -5,6 +5,9 @@ obj-y += overlay-of-flash.dtb.o
 ifeq ($(CONFIG_RISCV),y)
 DTC_CPP_FLAGS_overlay-of-flash.dtb := -DRISCV_VIRT=1
 endif
+ifeq ($(CONFIG_ARM),y)
+DTC_CPP_FLAGS_overlay-of-flash.dtb := -DARM_VIRT=1
+endif
 
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
 clean-files += *.dtbo *.dtbo.S .*.dtso
diff --git a/common/boards/qemu-virt/overlay-of-flash.dts b/common/boards/qemu-virt/overlay-of-flash.dts
index 15c8cc450d49..16b1c7923d58 100644
--- a/common/boards/qemu-virt/overlay-of-flash.dts
+++ b/common/boards/qemu-virt/overlay-of-flash.dts
@@ -6,12 +6,15 @@
 #ifdef RISCV_VIRT
 #define PARTS_TARGET_PATH	/flash@20000000
 #define ENV_DEVICE_PATH		"/flash@20000000/partitions/partition@3c00000"
-#else
+#elif defined ARM_VIRT
 #define PARTS_TARGET_PATH	/flash@0
 #define ENV_DEVICE_PATH		"/flash@0/partitions/partition@3c00000"
 #endif
 
 &{PARTS_TARGET_PATH} {
+#ifdef ARM_VIRT
+	virtual-reg = <0x1000>;
+#endif
 	partitions {
 		compatible = "fixed-partitions";
 		#address-cells = <1>;
-- 
2.39.2




  parent reply	other threads:[~2023-05-22  5:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  5:28 [PATCH 00/11] ARM: " Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 01/11] treewide: use remap_range instead of arch_remap_range Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 02/11] mmu: add physical address parameter to arch_remap_range Ahmad Fatoum
2023-05-23  7:17   ` Sascha Hauer
2023-05-23  7:21     ` Ahmad Fatoum
2023-05-23  7:27       ` Sascha Hauer
2023-05-22  5:28 ` [PATCH 03/11] ARM: mmu32: support non-1:1 mappings in arch_remap_range Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 04/11] ARM: mmu64: " Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 05/11] of: platform: remap memory when encountering virtual-reg property Ahmad Fatoum
2023-05-22  5:28 ` Ahmad Fatoum [this message]
2023-05-22  5:28 ` [PATCH 07/11] ARM: prepare extending mmuinfo beyond ARMv7 Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 08/11] ARM64: mmu: implement ARMv8 mmuinfo command Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 09/11] common: memtest: prepare for reuse in self test Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 10/11] test: self: add MMU remapping " Ahmad Fatoum
2023-05-22  5:28 ` [PATCH 11/11] ARM: mmuinfo: add options for enabling/disabling zero page trapping Ahmad Fatoum
2023-05-23  7:21 ` [PATCH 00/11] ARM: qemu-virt: remap cfi-flash from 0 to 0x1000 Sascha Hauer

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=20230522052835.1039143-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=lst@pengutronix.de \
    --cc=r.czerwinski@pengutronix.de \
    --cc=rcz@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox