[PATCH 06/11] common: boards: qemu-virt: remap cfi-flash from 0 to 0x1000

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
Cc: Rouven Czerwinski <r.czerwinski@xxxxxxxxxxxxxx>
Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux