qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] m68k: fix usp processing on interrupt entry and exception exit
@ 2012-09-13  6:34 gerg
  0 siblings, 0 replies; only message in thread
From: gerg @ 2012-09-13  6:34 UTC (permalink / raw)
  To: qemu-devel, paul; +Cc: Greg Ungerer

From: Greg Ungerer <gerg@uclinux.org>

The action to potentially switch sp register is not occurring at the correct
point in the interrupt entry or exception exit sequences.

For the interrupt entry case the sp on entry is used to create the stack
exception frame - but this may well be the user stack pointer, since we
haven't done the switch yet. Re-order the flow to switch the sp regs then
use the current sp to create the exception frame.

For the return from exception case the code is unwinding the sp after
switching sp registers. But it should always unwind the supervisor sp
first, then carry out any required sp switch.

Note that these problems don't effect operation unless the user sp bit is
set in the CACR register. Only a single sp is used in the default power up
state. Previously Linux only used this single sp mode. But modern versions
of Linux use the user sp mode now, so we need correct behavior for Linux
to work.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 target-m68k/op_helper.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c
index 1971a57..ac1a063 100644
--- a/target-m68k/op_helper.c
+++ b/target-m68k/op_helper.c
@@ -90,8 +90,8 @@ static void do_rte(void)
     env->pc = ldl_kernel(sp + 4);
     sp |= (fmt >> 28) & 3;
     env->sr = fmt & 0xffff;
-    m68k_switch_sp(env);
     env->aregs[7] = sp + 8;
+    m68k_switch_sp(env);
 }
 
 static void do_interrupt_all(int is_hw)
@@ -134,10 +134,7 @@ static void do_interrupt_all(int is_hw)
 
     vector = env->exception_index << 2;
 
-    sp = env->aregs[7];
-
     fmt |= 0x40000000;
-    fmt |= (sp & 3) << 28;
     fmt |= vector << 16;
     fmt |= env->sr;
 
@@ -147,6 +144,8 @@ static void do_interrupt_all(int is_hw)
         env->sr &= ~SR_M;
     }
     m68k_switch_sp(env);
+    sp = env->aregs[7];
+    fmt |= (sp & 3) << 28;
 
     /* ??? This could cause MMU faults.  */
     sp &= ~3;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-09-13  6:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-13  6:34 [Qemu-devel] [PATCH] m68k: fix usp processing on interrupt entry and exception exit gerg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).