Skip to contentSkip to conversation

linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

PATCH In review Richard Henderson 3 participants 5 messages Aug 22, 2019 – Sep 10, 2019

lore
Share & tools
lore
#0 lore raw

cover linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

This is inspired by the discussion in

https://bugs.launchpad.net/qemu/+bug/1840922

Previously I suggested a new CPUClass hook, but when I went to implement that seemed like overkill.

r~

Richard Henderson (2):
linux-user: Pass CPUState to MAX_RESERVED_VA linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

 linux-user/arm/target_cpu.h | 24 ++++++++++++++++++---
 linux-user/main.c           | 43 +++++++++++++++++++++----------------
 2 files changed, 46 insertions(+), 21 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 linux-user: Pass CPUState to MAX_RESERVED_VA

Turn the scalar macro into a functional macro. Move the creation of the cpu up a bit within main() so that we can pass it to the invocation of MAX_RESERVED_VA. Delay the validation of the -R parameter until MAX_RESERVED_VA is computed.

So far no changes to any of the MAX_RESERVED_VA macros to actually use the cpu in any way, but ARM will need it.

---
 linux-user/arm/target_cpu.h |  2 +-
 linux-user/main.c           | 43 +++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 19 deletions(-)
linux-user/arm/target_cpu.h +1 -1
index 8a3764919a..279ea532d5 100644
@@ -21,7 +21,7 @@
 
 /* We need to be able to map the commpage.
    See validate_guest_space in linux-user/elfload.c.  */
-#define MAX_RESERVED_VA  0xffff0000ul
+#define MAX_RESERVED_VA(CPU)  0xffff0000ul
 
 static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
 {
linux-user/main.c +25 -18

75 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

In reply to Richard Henderson

Limit the virtual address space for M-profile cpus to 2GB, so that we avoid all of the magic addresses in the top half of the M-profile system map.

---
 linux-user/arm/target_cpu.h | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
linux-user/arm/target_cpu.h +21 -3
index 279ea532d5..3f79356a07 100644
@@ -19,9 +19,27 @@
 #ifndef ARM_TARGET_CPU_H
 #define ARM_TARGET_CPU_H
 
-/* We need to be able to map the commpage.
-   See validate_guest_space in linux-user/elfload.c.  */
-#define MAX_RESERVED_VA(CPU)  0xffff0000ul
+static inline unsigned long arm_max_reserved_va(CPUState *cs)
+{
+    ARMCPU *cpu = ARM_CPU(cs);
+
+    if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
+        /*
+         * There are magic return addresses above 0xfe000000,
+         * and in general a lot of M-profile system stuff in
+         * the high addresses.  Restrict linux-user to the
+         * cached write-back RAM in the system map.
+         */
+        return 0x80000000ul;
+    } else {
+        /*
+         * We need to be able to map the commpage.
+         * See validate_guest_space in linux-user/elfload.c.
+         */
+        return 0xffff0000ul;
+    }
+}
+#define MAX_RESERVED_VA  arm_max_reserved_va
 
 static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
 {
Signature · 1 line
2.17.1
Reviewed-by on the v1 series
#3 lore raw
In reply to Richard Henderson
Quoted 9 lines · Richard Henderson

This is inspired by the discussion in

   https://bugs.launchpad.net/qemu/+bug/1840922

Previously I suggested a new CPUClass hook, but when I went to implement that seemed like overkill.

Quoted 7 lines

r~

Richard Henderson (2):
linux-user: Pass CPUState to MAX_RESERVED_VA linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

thanks
-- PMM

#4 lore raw

Le 03/09/2019 à 15:35, Peter Maydell a écrit :

Quoted 14 lines
Quoted 12 lines · Richard Henderson

This is inspired by the discussion in

   https://bugs.launchpad.net/qemu/+bug/1840922

Previously I suggested a new CPUClass hook, but when I went to implement that seemed like overkill.

r~

Quoted 6 lines
Quoted 4 lines

Richard Henderson (2):
linux-user: Pass CPUState to MAX_RESERVED_VA linux-user/arm: Adjust MAX_RESERVED_VA for M-profile

Both applied to my linux-user branch.

Thanks,
Laurent