Skip to contentSkip to conversation

linux-user: fix running programs with iwmmxt instructions

PATCH Superseded Lars Munch 2 participants 3 messages Mar 15, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lars Munch

author
#0 lore raw

PATCH 1/1 linux-user: fix running programs with iwmmxt instructions

When using linux-user for emulating an pxa270 we cannot generate an illegal instruction trap to the kernel to save/load the iwmmxt registers.

---
 target-arm/translate.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
target-arm/translate.c +2 -0
index cdfe946..6b621b1 100644
@@ -5802,9 +5802,11 @@ static int disas_coproc_insn(CPUState * env, DisasContext *s, uint32_t insn)
     int cpnum;
 
     cpnum = (insn >> 8) & 0xf;
+#if !defined(CONFIG_USER_ONLY)
     if (arm_feature(env, ARM_FEATURE_XSCALE)
 	    && ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum)))
 	return 1;
+#endif
 
     switch (cpnum) {
       case 0:
Signature · 1 line
1.7.0
#1 lore raw

target-arm/translate.c static int disas_coproc_insn(CPUState * env, DisasContext *s, uint32_t insn) · line 5809

Quoted 5 lines
target-arm/translate.c +2 -0
+#if !defined(CONFIG_USER_ONLY)
     if (arm_feature(env, ARM_FEATURE_XSCALE)
 	    && ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum)))
 	return 1;
+#endif

This is almost certainly the wrong way to fix this.

Paul

author
#2 lore raw
Quoted 10 lines · Paul Brook

Review

Quoted 5 lines
(quoted diff) +2 -0
+#if !defined(CONFIG_USER_ONLY)
     if (arm_feature(env, ARM_FEATURE_XSCALE)
 	    && ((env->cp15.c15_cpar ^ 0x3fff) & (1 << cpnum)))
 	return 1;
+#endif

This is almost certainly the wrong way to fix this.

Paul

Here is a different fix. Hopefully I am on the right track this time. This patch inits the cpu to have CP0 and/or CP1 accessible from the beginning if in linux-user mode.

---
 target-arm/helper.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
target-arm/helper.c +6 -0
index 1a181ac..3a55da2 100644
@@ -165,6 +165,9 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         /* JTAG_ID is ((id << 28) | 0x09265013) */
         env->cp15.c0_cachetype = 0xd172172;
         env->cp15.c1_sys = 0x00000078;
+#if defined (CONFIG_USER_ONLY)
+        env->cp15.c15_cpar = 0x00000001;
+#endif
         break;
     case ARM_CPUID_PXA270_A0:
     case ARM_CPUID_PXA270_A1:
@@ -178,6 +181,9 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
         env->cp15.c0_cachetype = 0xd172172;
         env->cp15.c1_sys = 0x00000078;
+#if defined (CONFIG_USER_ONLY)
+        env->cp15.c15_cpar = 0x00000003;
+#endif
         break;
     default:
         cpu_abort(env, "Bad CPU ID: %x\n", id);
Signature · 1 line
1.7.0