All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/2] target-openrisc: Correct wrong epcr register in interrupt handler
@ 2013-10-19  1:56 Sebastian Macke
  0 siblings, 0 replies; only message in thread
From: Sebastian Macke @ 2013-10-19  1:56 UTC (permalink / raw)
  To: qemu-devel, Jia Liu; +Cc: openrisc, openrisc@lists.opencores.org

This patch corrects several rare bugs during an interrupt process.
Most of the time the pc is already correct and therefore no special 
treatment of the exception type is necessary.

Tested by checking crashing programs which otherwise work in or1ksim.

Signed-off-by: Sebastian Macke <sebastian@macke.de>
---
  target-openrisc/interrupt.c |   25 +++++++------------------
  1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c
index 16ef4b3..2153e7e 100644
--- a/target-openrisc/interrupt.c
+++ b/target-openrisc/interrupt.c
@@ -30,26 +30,15 @@ void openrisc_cpu_do_interrupt(CPUState *cs)
      OpenRISCCPU *cpu = OPENRISC_CPU(cs);
      CPUOpenRISCState *env = &cpu->env;
  #ifndef CONFIG_USER_ONLY
-    if (env->flags & D_FLAG) { /* Delay Slot insn */
+
+    env->epcr = env->pc;
+    if (env->flags & D_FLAG) {
          env->flags &= ~D_FLAG;
          env->sr |= SR_DSX;
-        if (env->exception_index == EXCP_TICK    ||
-            env->exception_index == EXCP_INT     ||
-            env->exception_index == EXCP_SYSCALL ||
-            env->exception_index == EXCP_FPE) {
-            env->epcr = env->jmp_pc;
-        } else {
-            env->epcr = env->pc - 4;
-        }
-    } else {
-        if (env->exception_index == EXCP_TICK    ||
-            env->exception_index == EXCP_INT     ||
-            env->exception_index == EXCP_SYSCALL ||
-            env->exception_index == EXCP_FPE) {
-            env->epcr = env->npc;
-        } else {
-            env->epcr = env->pc;
-        }
+        env->epcr -= 4;
+    }
+    if (env->exception_index == EXCP_SYSCALL) {
+        env->epcr += 4;
      }
       /* For machine-state changed between user-mode and supervisor mode,
-- 
1.7.9.5

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

only message in thread, other threads:[~2013-10-19  1:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-19  1:56 [Qemu-devel] [PATCH 2/2] target-openrisc: Correct wrong epcr register in interrupt handler Sebastian Macke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.