Skip to contentSkip to conversation

target-ppc: set MSR_CM bit for BookE 2.06 MMU

PATCH In review Michael Walle 2 participants 4 messages Jul 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: set MSR_CM bit for BookE 2.06 MMU

64 bit user mode doesn't work for the e5500 core because the MSR_CM bit is not set which enables the 64 bit mode for this MMU model. Memory addresses are truncated to 32 bit, which results in "Invalid data memory access" error messages. Fix it by setting the MSR_CM bit for this MMU model.

---
 target-ppc/translate_init.c | 3 +++
 1 file changed, 3 insertions(+)
target-ppc/translate_init.c +3 -0
index 5ecafc7..1ebb143 100644
@@ -10218,6 +10218,9 @@ static void ppc_cpu_reset(CPUState *s)
     if (env->mmu_model & POWERPC_MMU_64) {
         msr |= (1ULL << MSR_SF);
     }
+    if (env->mmu_model == POWERPC_MMU_BOOKE206) {
+        msr |= (1ULL << MSR_CM);
+    }
 #endif
 
     hreg_store_msr(env, msr, 1);
Signature · 1 line
2.1.4
#1 lore raw
Quoted 18 lines · Michael Walle

64 bit user mode doesn't work for the e5500 core because the MSR_CM bit is not set which enables the 64 bit mode for this MMU model. Memory addresses are truncated to 32 bit, which results in "Invalid data memory access" error messages. Fix it by setting the MSR_CM bit for this MMU model.

---
target-ppc/translate_init.c | 3 +++

1 file changed, 3 insertions(+)
target-ppc/translate_init.c +0 -0
index 5ecafc7..1ebb143 100644

target-ppc/translate_init.c static void ppc_cpu_reset(CPUState *s) · line 10221

Quoted 4 lines
target-ppc/translate_init.c +1 -0
@@ -10218,6 +10218,9 @@ static void ppc_cpu_reset(CPUState *s)
    if (env->mmu_model & POWERPC_MMU_64) {
        msr |= (1ULL << MSR_SF);
    }
+    if (env->mmu_model == POWERPC_MMU_BOOKE206) {

Is this check correct? Doesn’t e500mc adhere to 2.06 as well? Running

qemu-system-ppc64 -M ppce500 -cpu e500mc …

is perfectly valid and should just work. With your patch, it would start in invalid 64bit mode :).

Alex

#2 lore raw

Am 2016-07-22 15:07, schrieb Alexander Graf:

Quoted 24 lines
Quoted 17 lines · Michael Walle

64 bit user mode doesn't work for the e5500 core because the MSR_CM bit is not set which enables the 64 bit mode for this MMU model. Memory addresses are truncated to 32 bit, which results in "Invalid data memory access" error messages. Fix it by setting the MSR_CM bit for this MMU model.

---
target-ppc/translate_init.c | 3 +++

1 file changed, 3 insertions(+)
target-ppc/translate_init.c +0 -0
index 5ecafc7..1ebb143 100644

target-ppc/translate_init.c static void ppc_cpu_reset(CPUState *s) · line 10221

Quoted 4 lines
target-ppc/translate_init.c +1 -0
@@ -10218,6 +10218,9 @@ static void ppc_cpu_reset(CPUState *s)
    if (env->mmu_model & POWERPC_MMU_64) {
        msr |= (1ULL << MSR_SF);
    }
+    if (env->mmu_model == POWERPC_MMU_BOOKE206) {

Is this check correct? Doesn’t e500mc adhere to 2.06 as well? Running

Quoted 7 lines

qemu-system-ppc64 -M ppce500 -cpu e500mc …

is perfectly valid and should just work. With your patch, it would start in invalid 64bit mode :).

Alex

Mhh, sorry I don't really have any understanding of the PPC state after reset. Should have flagged this as RFC.

Maybe I should explain my issue. I'm debugging a problem with the 64 bit linux-user variant (qemu-ppc64). There the first instructions causes an "Invalid data memory access" because the address is truncated to 32 bit. This is because the msr_is_64bit() returns false in my case. So first question here, is qemu-ppc64 supposed to set the MSR to 64bit mode? I guess so, because 32bit mode would be the qemu-ppc binary. What is the MSR state in full system emulation for a e5500 core? 64bit or 32bit?

If it is 32bit, the simple solution would be to put #ifdef CONFIG_USER_ONLY around my patch, right?
If the MMU is in 64bit mode after reset, I would have to check for the e5500, too. Mhh, I don't see that this information is available in ppc_cpu_reset().

-michael

#3 lore raw
Quoted 31 lines · Michael Walle

Am 2016-07-22 15:07, schrieb Alexander Graf:

Quoted 30 lines
Quoted 17 lines · Michael Walle

64 bit user mode doesn't work for the e5500 core because the MSR_CM bit is not set which enables the 64 bit mode for this MMU model. Memory addresses are truncated to 32 bit, which results in "Invalid data memory access" error messages. Fix it by setting the MSR_CM bit for this MMU model.

---
target-ppc/translate_init.c | 3 +++

1 file changed, 3 insertions(+)
target-ppc/translate_init.c +0 -0
index 5ecafc7..1ebb143 100644

target-ppc/translate_init.c static void ppc_cpu_reset(CPUState *s) · line 10221

Quoted 4 lines
target-ppc/translate_init.c +1 -0
@@ -10218,6 +10218,9 @@ static void ppc_cpu_reset(CPUState *s)
    if (env->mmu_model & POWERPC_MMU_64) {
        msr |= (1ULL << MSR_SF);
    }
+    if (env->mmu_model == POWERPC_MMU_BOOKE206) {

Is this check correct? Doesn’t e500mc adhere to 2.06 as well? Running

qemu-system-ppc64 -M ppce500 -cpu e500mc …

is perfectly valid and should just work. With your patch, it would start in invalid 64bit mode :).

Quoted 5 lines
Quoted 1 line

Alex

Mhh, sorry I don't really have any understanding of the PPC state after reset. Should have flagged this as RFC.

Maybe I should explain my issue. I'm debugging a problem with the 64 bit linux-user variant (qemu-ppc64). There the first instructions causes an "Invalid data memory access" because the address is truncated to 32 bit. This is because the msr_is_64bit() returns false in my case. So first question here, is qemu-ppc64 supposed to set the MSR to 64bit mode? I guess so, because 32bit mode would be the qemu-ppc binary. What is the MSR state in full system emulation for a e5500 core? 64bit or 32bit?

It depends on the target. Usually the reset vector is used for system emulation. But apparently you're targeting user mode emulation, so the reset MSR really goes to linux-user/main.c. We already set MSR_SF there for 64bit binaries, I guess you'd have to check on the cpu flavor and just set either SF or CM depending on cpu flags (PPC2_BOOKE206 maybe?) in there.

Alex

Quoted 6 lines

If it is 32bit, the simple solution would be to put #ifdef CONFIG_USER_ONLY around my patch, right?
If the MMU is in 64bit mode after reset, I would have to check for the e5500, too. Mhh, I don't see that this information is available in ppc_cpu_reset().

-michael