Skip to contentSkip to conversation

m68: fix exception stack frame for 68000

PATCH Superseded Pavel Dovgalyuk 3 participants 3 messages Apr 13, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68: fix exception stack frame for 68000

68000 CPUs do not save format in the exception stack frame. This patch adds feature checking to prevent format saving for 68000. m68k_ret() already includes this modification, this patch fixes the exception processing function too.

---
 target/m68k/op_helper.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
target/m68k/op_helper.c +5 -2
index 3a7f7f2..e367133 100644
@@ -301,8 +301,11 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
         cpu_stl_kernel(env, *sp, addr);
         break;
     }
-    *sp -= 2;
-    cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+    if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
+        /*  all except 68000 */
+        *sp -= 2;
+        cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+    }
     *sp -= 4;
     cpu_stl_kernel(env, *sp, retaddr);
     *sp -= 2;
#1 lore raw

Le 13/04/2018 à 13:12, Pavel Dovgalyuk a écrit :

Quoted 19 lines

68000 CPUs do not save format in the exception stack frame. This patch adds feature checking to prevent format saving for 68000. m68k_ret() already includes this modification, this patch fixes the exception processing function too.

---
 target/m68k/op_helper.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
target/m68k/op_helper.c +0 -0
index 3a7f7f2..e367133 100644
@@ -301,8 +301,11 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
         cpu_stl_kernel(env, *sp, addr);
         break;
     }

target/m68k/op_helper.c static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp, · line 311

Quoted 10 lines
target/m68k/op_helper.c +5 -2
-    *sp -= 2;
-    cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+    if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
+        /*  all except 68000 */
+        *sp -= 2;
+        cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+    }
     *sp -= 4;
     cpu_stl_kernel(env, *sp, retaddr);
     *sp -= 2;

To be the exact counterpart of m68k_rte(), I think you should include the "switch () { }" into the "if () { }".

Thanks,
Laurent

#2 lore raw
Quoted 26 lines

From: Laurent Vivier [mailto:[email protected]]

Quoted 24 lines · Pavel Dovgalyuk

68000 CPUs do not save format in the exception stack frame. This patch adds feature checking to prevent format saving for 68000. m68k_ret() already includes this modification, this patch fixes the exception processing function too.

---
 target/m68k/op_helper.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
target/m68k/op_helper.c +4 -2
index 3a7f7f2..e367133 100644
@@ -301,8 +301,11 @@ static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp,
         cpu_stl_kernel(env, *sp, addr);
         break;
     }
-    *sp -= 2;
-    cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
+    if (m68k_feature(env, M68K_FEATURE_QUAD_MULDIV)) {
+        /*  all except 68000 */
+        *sp -= 2;
+        cpu_stw_kernel(env, *sp, (format << 12) + (cs->exception_index << 2));
Quoted 8 lines

target/m68k/op_helper.c static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp, · line 311

Quoted 5 lines
target/m68k/op_helper.c +1 -0
+    }
     *sp -= 4;
     cpu_stl_kernel(env, *sp, retaddr);
     *sp -= 2;

To be the exact counterpart of m68k_rte(), I think you should include the "switch () { }" into the "if () { }".

That's right, thank you.

Pavel Dovgalyuk