From patchwork Mon Dec 3 22:25:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 203467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 21B502C00A8 for ; Tue, 4 Dec 2012 09:31:33 +1100 (EST) Received: from localhost ([::1]:36719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeXz-00017b-A5 for incoming@patchwork.ozlabs.org; Mon, 03 Dec 2012 17:31:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeWq-0006M9-Ay for qemu-devel@nongnu.org; Mon, 03 Dec 2012 17:30:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfeWo-0007L5-I5 for qemu-devel@nongnu.org; Mon, 03 Dec 2012 17:30:20 -0500 Received: from mail-ie0-f177.google.com ([209.85.223.177]:65106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeWi-0007Ga-Ng; Mon, 03 Dec 2012 17:30:12 -0500 Received: by mail-ie0-f177.google.com with SMTP id k13so5670584iea.8 for ; Mon, 03 Dec 2012 14:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=LcgNz0NPTOTW6dVcDl5WSuZ7HS9XA7bI3e4gse6KaJc=; b=MW5m2qYQB/V9i8rS9y04rpoJjToGosAwZZxr1phlsXGSY+5dbibBjLxTx8/i3ctuEu KZO1lPKYN0QNMn7vYMY9iX6XAL5hIq+LFqNUtNnEE91WI37j35Y8gVyOlumlepqX0wBs JoPVoJklBSyy/BUPNsCKXik7aNeKvCqAPYaL6j6a6Gzr0HIyogWC+/vYbXy54icyJ9fN Pb/vreZ7b0YYGbFdGLgaHIHJKKJBVYZ4nxDmrgj8LdulS2EetE9Q7Cc6S9cisaAGZwn4 Ntw7/HU0yZdTfbbRN+E40lj2NfQEINIqujOsD4GvZdo2F+LJ+danBtw2CiKL08Ti4FRX KIZg== Received: by 10.50.153.137 with SMTP id vg9mr623671igb.40.1354573810949; Mon, 03 Dec 2012 14:30:10 -0800 (PST) Received: from localhost ([32.97.110.59]) by mx.google.com with ESMTPS id l8sm8881247igo.13.2012.12.03.14.30.09 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 14:30:10 -0800 (PST) From: Michael Roth To: qemu-stable@nongnu.org Date: Mon, 3 Dec 2012 16:25:47 -0600 Message-Id: <1354573559-26274-4-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354573559-26274-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1354572547-21271-1-git-send-email-mdroth@linux.vnet.ibm.com> <1354573559-26274-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.223.177 Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 31/43] PPC: Fix missing TRACE exception X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Julio Guerra 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 Signed-off-by: Alexander Graf (cherry picked from commit f0cc4aa8450376ca2aee3ebb09db71f9f2ff333b) Signed-off-by: Michael Roth --- target-ppc/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target-ppc/translate.c b/target-ppc/translate.c index ac915cc..3c49ca9 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -3466,7 +3466,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);