From patchwork Fri Apr 9 19:49:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 50161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CD162B7D16 for ; Thu, 15 Apr 2010 00:30:26 +1000 (EST) Received: from localhost ([127.0.0.1]:34297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O23bi-0000fm-UB for incoming@patchwork.ozlabs.org; Wed, 14 Apr 2010 10:30:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O23V9-0007ID-Ft for qemu-devel@nongnu.org; Wed, 14 Apr 2010 10:23:35 -0400 Received: from [140.186.70.92] (port=37288 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O23V5-0007Gm-Hk for qemu-devel@nongnu.org; Wed, 14 Apr 2010 10:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O23V2-0006cF-Hz for qemu-devel@nongnu.org; Wed, 14 Apr 2010 10:23:31 -0400 Received: from are.twiddle.net ([75.149.56.221]:43806) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O23V1-0006a4-Lf for qemu-devel@nongnu.org; Wed, 14 Apr 2010 10:23:27 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 2E8CAEC4; Wed, 14 Apr 2010 07:16:20 -0700 (PDT) Message-Id: <4dd01b0ae71e1afb79426e62e25c8cf4625c6ab0.1271253049.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Fri, 9 Apr 2010 21:49:00 +0200 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 5/6] tcg-hppa: Fix branch offset during retranslation. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Branch offsets should only be overwritten during relocation, to support partial retranslation. Signed-off-by: Richard Henderson --- tcg/hppa/tcg-target.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c index 6941e22..6536a42 100644 --- a/tcg/hppa/tcg-target.c +++ b/tcg/hppa/tcg-target.c @@ -723,8 +723,11 @@ static void tcg_out_branch(TCGContext *s, int label_index, int nul) tcg_out32(s, op | reassemble_17(val)); } else { + /* We need to keep the offset unchanged for retranslation. */ + uint32_t old_insn = *(uint32_t *)s->code_ptr; + tcg_out_reloc(s, s->code_ptr, R_PARISC_PCREL17F, label_index, 0); - tcg_out32(s, op); + tcg_out32(s, op | (old_insn & 0x1f1ffdu)); } } @@ -777,11 +780,14 @@ static void tcg_out_brcond(TCGContext *s, int cond, TCGArg c1, tcg_out32(s, op | reassemble_12(val)); tcg_out_nop(s); } else { + /* We need to keep the offset unchanged for retranslation. */ + uint32_t old_insn = *(uint32_t *)s->code_ptr; + tcg_out_reloc(s, s->code_ptr, R_PARISC_PCREL12F, label_index, 0); /* ??? Assume that all branches to undefined labels are forward. Which means that if the nul bit is set, the delay slot is not executed if the branch is taken, which is what we want. */ - tcg_out32(s, op | 2); + tcg_out32(s, op | 2 | (old_insn & 0x1ffdu)); } }