From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj8vy-0006T6-RC for qemu-devel@nongnu.org; Wed, 20 Nov 2013 09:39:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vj8vs-0003e7-CR for qemu-devel@nongnu.org; Wed, 20 Nov 2013 09:39:14 -0500 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:51604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vj8vr-0003db-W8 for qemu-devel@nongnu.org; Wed, 20 Nov 2013 09:39:08 -0500 Received: by mail-pd0-f176.google.com with SMTP id w10so7590315pde.35 for ; Wed, 20 Nov 2013 06:39:06 -0800 (PST) From: Jia Liu Date: Wed, 20 Nov 2013 22:38:35 +0800 Message-Id: <1384958318-9145-5-git-send-email-proljc@gmail.com> In-Reply-To: <1384958318-9145-1-git-send-email-proljc@gmail.com> References: <1384958318-9145-1-git-send-email-proljc@gmail.com> Content-Type: text/plain; charset="utf-8" Subject: [Qemu-devel] [PULL 4/7] target-openrisc: Correct wrong epcr register in interrupt handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, sebastian@macke.de, aliguori@amazon.com From: Sebastian Macke This patch corrects several misbehaviors during an interrupt process. Most of the time the pc is already correct and therefore no special treatment of the exceptions is necessary. Tested by checking crashing programs which otherwise work in or1ksim. Signed-off-by: Sebastian Macke Reviewed-by: Jia Liu Signed-off-by: Jia Liu --- 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.8.3.4 (Apple Git-47)