]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target-ppc: Fix SRR0 when taking unaligned exceptions
authorAnton Blanchard <anton@samba.org>
Thu, 2 Jul 2015 04:44:06 +0000 (14:44 +1000)
committerAlexander Graf <agraf@suse.de>
Sun, 20 Sep 2015 20:48:39 +0000 (22:48 +0200)
We are setting SRR0 to the instruction before the one causing the
unaligned exception. A quick testcase:

. = 0x100
.globl _start
_start:
/* Cause a 0x600 */
li 3,0x1
stwcx. 3,0,3
1: b 1b

. = 0x600
1: b 1b

Built into something we can load as a BIOS image:

gcc -mbig -c test.S
ld -EB -Ttext 0x0 -o test test.o
objcopy -O binary test test.bin

Run with:

qemu-system-ppc64 -nographic -bios test.bin

Shows an incorrect SRR0 (points at the li):

SRR0 0000000000000100

With the patch we get the correct SRR0:

SRR0 0000000000000104

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
linux-user/main.c
target-ppc/excp_helper.c

index 782037da84592f1ab9e83da311019b25e9c289b7..25cf8755ee8e456ca1f4ff2dd600972578512a71 100644 (file)
@@ -1650,7 +1650,7 @@ void cpu_loop(CPUPPCState *env)
             info.si_signo = TARGET_SIGBUS;
             info.si_errno = 0;
             info.si_code = TARGET_BUS_ADRALN;
-            info._sifields._sigfault._addr = env->nip - 4;
+            info._sifields._sigfault._addr = env->nip;
             queue_signal(env, info.si_signo, &info);
             break;
         case POWERPC_EXCP_PROGRAM:  /* Program exception                     */
index b803475060ed779ee86fc3e2990b61a669d61a12..4250106b34a2b0733df767575d0df2bb2a7be96a 100644 (file)
@@ -200,7 +200,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
         /* Get rS/rD and rA from faulting opcode */
         env->spr[SPR_DSISR] |= (cpu_ldl_code(env, (env->nip - 4))
                                 & 0x03FF0000) >> 16;
-        goto store_current;
+        goto store_next;
     case POWERPC_EXCP_PROGRAM:   /* Program exception                        */
         switch (env->error_code & ~0xF) {
         case POWERPC_EXCP_FP: