On Wed, Jan 6, 2010 at 11:57 PM, Igor Kovalenko
<igor.v.kovale...@gmail.com> wrote:
> On Thu, Jan 7, 2010 at 2:29 AM, Artyom Tarasenko
> <atar4q...@googlemail.com> wrote:
>> What's the effect of the patch? Don't we need it for sparc32 too? The
>> code looks similar.
>>
>> 2010/1/6 Blue Swirl <blauwir...@gmail.com>:
>>> Thanks, applied.
>>>
>>> On Tue, Jan 5, 2010 at 11:19 PM, Igor V. Kovalenko
>>> <igor.v.kovale...@gmail.com> wrote:
>>>> From: Igor V. Kovalenko <igor.v.kovale...@gmail.com>
>>>>
>>>> Signed-off-by: Igor V. Kovalenko <igor.v.kovale...@gmail.com>
>>>> ---
>>>>  target-sparc/op_helper.c |    2 +-
>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
>>>> index b1978cb..94f1c7a 100644
>>>> --- a/target-sparc/op_helper.c
>>>> +++ b/target-sparc/op_helper.c
>>>> @@ -3535,7 +3535,7 @@ void do_interrupt(CPUState *env)
>>>>     env->tbr |= ((env->tl > 1) ? 1 << 14 : 0) | (intno << 5);
>>>>     env->pc = env->tbr;
>>>>     env->npc = env->pc + 4;
>>>> -    env->exception_index = 0;
>>>> +    env->exception_index = -1;
>>>>  }
>>>>  #else
>>>>  #ifdef DEBUG_PCALL
>
> Right, but that's out of scope for this changeset.
>
> In fact sparc32 should have the same issue, as well as alpha, s390 and
> sh4. Check in cpu_exec() for valid exception_index is "greater or
> equal to zero" so all those targets should be corrected. On sh4 we
> even check for "invalid value of exception_index is -1"

Thanks, I applied the fix for Sparc32. Here's also an untested fix for
other architectures.
From c93e1ac4b8a862fc1a58cdb33bb07a51c5b30733 Mon Sep 17 00:00:00 2001
From: Blue Swirl <blauwirbel@gmail.com>
Date: Thu, 7 Jan 2010 20:02:12 +0000
Subject: [PATCH] Fix incorrect exception_index use

env->exception_index should be cleared with -1, not 0.

See also 821b19fe923ac49a24cdb4af902584fdd019cee6.

Spotted by Igor Kovalenko.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 target-alpha/helper.c |    2 +-
 target-s390x/kvm.c    |    4 ++--
 target-sh4/helper.c   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/target-alpha/helper.c b/target-alpha/helper.c
index be7d37b..1e0bc4a 100644
--- a/target-alpha/helper.c
+++ b/target-alpha/helper.c
@@ -467,7 +467,7 @@ void do_interrupt (CPUState *env)
 
     env->ipr[IPR_EXC_ADDR] = env->pc | 1;
     excp = env->exception_index;
-    env->exception_index = 0;
+    env->exception_index = -1;
     env->error_code = 0;
     /* XXX: disable interrupts and memory mapping */
     if (env->ipr[IPR_PAL_BASE] != -1ULL) {
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 0992563..0199a65 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -186,7 +186,7 @@ static void kvm_s390_interrupt_internal(CPUState *env, int type, uint32_t parm,
     }
 
     env->halted = 0;
-    env->exception_index = 0;
+    env->exception_index = -1;
 
     kvmint.type = type;
     kvmint.parm = parm;
@@ -325,7 +325,7 @@ static int s390_cpu_restart(CPUState *env)
 {
     kvm_s390_interrupt(env, KVM_S390_RESTART, 0);
     env->halted = 0;
-    env->exception_index = 0;
+    env->exception_index = -1;
     qemu_cpu_kick(env);
     dprintf("DONE: SIGP cpu restart: %p\n", env);
     return 0;
diff --git a/target-sh4/helper.c b/target-sh4/helper.c
index 088d36a..8c94564 100644
--- a/target-sh4/helper.c
+++ b/target-sh4/helper.c
@@ -38,7 +38,7 @@ int cpu_sh4_handle_mmu_fault(CPUState * env, target_ulong address, int rw,
 			     int mmu_idx, int is_softmmu)
 {
     env->tea = address;
-    env->exception_index = 0;
+    env->exception_index = -1;
     switch (rw) {
     case 0:
         env->exception_index = 0x0a0;
-- 
1.5.6.5

Reply via email to