qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: "qemu-devel@nongnu.org qemu-devel" <qemu-devel@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>, Julio Guerra <guerr@julio.in>,
	"qemu-ppc@nongnu.org List" <qemu-ppc@nongnu.org>,
	Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 2/6] PPC: Fix missing TRACE exception
Date: Mon, 26 Nov 2012 19:55:53 +0100	[thread overview]
Message-ID: <1353956157-26879-3-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1353956157-26879-1-git-send-email-agraf@suse.de>

From: Julio Guerra <guerr@julio.in>

This patch fixes bug 1031698 :
https://bugs.launchpad.net/qemu/+bug/1031698

If we look at the (truncated) translation of the conditional branch
instruction in the test submitted in the bug post, the call to the
exception helper is missing in the "bne-false" chunk of translated
code :

IN:
bne-    0x1800278

OUT:
0xb544236d:  jne    0xb5442396

0xb5442373:  mov    %ebp,(%esp)
0xb5442376:  mov    $0x44,%ebx
0xb544237b:  mov    %ebx,0x4(%esp)
0xb544237f:  mov    $0x1800278,%ebx
0xb5442384:  mov    %ebx,0x25c(%ebp)
0xb544238a:  call   0x827475a
                     ^^^^^^^^^^^^^^^^^^

0xb5442396:  mov    %ebp,(%esp)
0xb5442399:  mov    $0x44,%ebx
0xb544239e:  mov    %ebx,0x4(%esp)
0xb54423a2:  mov    $0x1800270,%ebx
0xb54423a7:  mov    %ebx,0x25c(%ebp)

Indeed, gen_exception(ctx, excp) called by gen_goto_tb (called by
gen_bcond) changes ctx->exception's value to excp's :

gen_bcond()
{
  gen_goto_tb(ctx, 0, ctx->nip + li - 4);
  /* ctx->exception value is POWERPC_EXCP_BRANCH */

  gen_goto_tb(ctx, 1, ctx->nip);
  /* ctx->exception now value is POWERPC_EXCP_TRACE */
}

Making the following gen_goto_tb()'s test false during the second call :

if ((ctx->singlestep_enabled &
    (CPU_BRANCH_STEP | CPU_SINGLE_STEP)) &&
    ctx->exception == POWERPC_EXCP_BRANCH /* false...*/) {
         target_ulong tmp = ctx->nip;
         ctx->nip = dest;
         /* ... and this is the missing call */
         gen_exception(ctx, POWERPC_EXCP_TRACE);
         ctx->nip = tmp;
}

So the patch simply adds the missing matching case, fixing our problem.

Signed-off-by: Julio Guerra <guerr@julio.in>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/translate.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 16b9c5d..987b04e 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -3473,7 +3473,8 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)
         if (unlikely(ctx->singlestep_enabled)) {
             if ((ctx->singlestep_enabled &
                 (CPU_BRANCH_STEP | CPU_SINGLE_STEP)) &&
-                ctx->exception == POWERPC_EXCP_BRANCH) {
+                (ctx->exception == POWERPC_EXCP_BRANCH ||
+                 ctx->exception == POWERPC_EXCP_TRACE)) {
                 target_ulong tmp = ctx->nip;
                 ctx->nip = dest;
                 gen_exception(ctx, POWERPC_EXCP_TRACE);
-- 
1.6.0.2

  parent reply	other threads:[~2012-11-26 18:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 18:55 [Qemu-devel] [PULL 1.3 0/6] ppc 1.3 patch queue 2012-11-26 Alexander Graf
2012-11-26 18:55 ` [Qemu-devel] [PATCH 1/6] hw/ide/macio: Fix segfault caused by NULL DMAContext* Alexander Graf
2012-11-26 18:55 ` Alexander Graf [this message]
2012-11-26 18:55 ` [Qemu-devel] [PATCH 3/6] kvm: fix incorrect length in a loop over kvm dirty pages map Alexander Graf
2012-11-26 18:55 ` [Qemu-devel] [PATCH 4/6] pseries: Fix bug in PCI MSI allocation Alexander Graf
2012-11-26 18:55 ` [Qemu-devel] [PATCH 5/6] vl.c: Fix broken -usb option Alexander Graf
2012-11-26 18:55 ` [Qemu-devel] [PATCH 6/6] fbdev: fix pixman compile on old pixman Alexander Graf
2012-11-28 21:38 ` [Qemu-devel] [PULL 1.3 0/6] ppc 1.3 patch queue 2012-11-26 Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353956157-26879-3-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=aurelien@aurel32.net \
    --cc=blauwirbel@gmail.com \
    --cc=guerr@julio.in \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).