From patchwork Wed Jul 12 22:14:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 787444 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x7CvJ08fqz9s06 for ; Thu, 13 Jul 2017 08:15:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O6saMI3u"; dkim-atps=neutral Received: from localhost ([::1]:56200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVPuy-0000pC-Sb for incoming@patchwork.ozlabs.org; Wed, 12 Jul 2017 18:15:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVPuh-0000oz-T4 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 18:15:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVPue-0005v5-NR for qemu-devel@nongnu.org; Wed, 12 Jul 2017 18:15:19 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:34404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVPue-0005th-Ir for qemu-devel@nongnu.org; Wed, 12 Jul 2017 18:15:16 -0400 Received: by mail-yw0-f196.google.com with SMTP id a12so2118619ywh.1 for ; Wed, 12 Jul 2017 15:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xfSacyA5mLUBW/xUC6ytClXg8ZwAuuab8heoKw+izYs=; b=O6saMI3uOB5Cv1A3rnJsbqZq4JLPM3HhM+E2V0DGwuIVneZv4TzpRrFM/lvnSH164t SCdSI7dHi/kXskBD8JH/+qBeqBbfdm+3jxSG2QLnP4gM3L5cYL7NubcwM4I+yWShZeDy M/InTbsX7kFOq14VYH+pXcotesg/jzqAbTFgX+DJDZr/Ut3asGH0N3NdETZak6gWl8Oa 7/qQ71XUjunnZ2pdmvkI21I514uZTQ5gm6vbxrm8NFuSjMly0W19iTElFqzksAmiDx+D XoYV38yLxFVpV1NIpY58BWhBtheP6QUe8ymF5/MHZVAfxhvKKPRnlc54Xyj/jA5tqnzC npOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xfSacyA5mLUBW/xUC6ytClXg8ZwAuuab8heoKw+izYs=; b=IMCOy9H52TdxcQ/b8d+mDJuNDDUPzDPeyinrwLAMpLRvPs/rpCg8Soz6ltN4bbLRgW Wtnh8qSYhLX/o7GbZ7mjPb2v13tBNCFBCfTWm1ZIxIJhUXtfCAteBXX6x2441SALQbRQ 2gmLQRgsG892CZCRSl8gosJ4VGYKqHuimmjf2xS5Oau3gdKyDu8KXqg2v8coT5W6xQ0i h91nepAQQMYjtgQoVkm+Ldh+5dRCIpdW79X44CojDiRh6j14VHoVZjdIq9y693E8wW9Z 4FpOfUfL9xwFhR/sHlVW4M64i6Erq9tmAm8l3do5T45iUkHgld3YCIKzx23kMi2aVKHE Vh5Q== X-Gm-Message-State: AIVw112r2sdHy9py2QGINWrPXUX2mBOepOHRrtjO92M816eoenW1mfkg R2DiInvNvWvIQw== X-Received: by 10.129.220.5 with SMTP id h5mr655755ywj.224.1499897655949; Wed, 12 Jul 2017 15:14:15 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id a189sm1344536ywc.19.2017.07.12.15.14.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 15:14:15 -0700 (PDT) From: Pranith Kumar To: alex.bennee@linaro.org Date: Wed, 12 Jul 2017 18:14:14 -0400 Message-Id: <20170712221414.3867-1-bobby.prani@gmail.com> X-Mailer: git-send-email 2.13.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.161.196 Subject: [Qemu-devel] [PATCH] tcg/aarch64: Use ADR for shorter jumps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use ADR instruction for shorter jumps. I was going through rth's email and realized that I should have done this the first time. Signed-off-by: Pranith Kumar --- tcg/aarch64/tcg-target.inc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 04bc369a92..5121ebc1a1 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -886,12 +886,16 @@ void aarch64_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr) i1 = I3206_B | ((offset >> 2) & 0x3ffffff); i2 = NOP; } else { - offset = (addr >> 12) - (jmp_addr >> 12); + if (offset == sextract64(offset, 0, 21)) { + i1 = I3406_ADR; + i2 = NOP; + } else { + offset = (addr >> 12) - (jmp_addr >> 12); - /* patch ADRP */ - i1 = I3406_ADRP | (offset & 3) << 29 | (offset & 0x1ffffc) << (5 - 2) | rd; - /* patch ADDI */ - i2 = I3401_ADDI | rt << 31 | (addr & 0xfff) << 10 | rd << 5 | rd; + i1 = I3406_ADRP; + i2 = I3401_ADDI | rt << 31 | (addr & 0xfff) << 10 | rd << 5 | rd; + } + i1 |= (offset & 3) << 29 | (offset & 0x1ffffc) << (5 - 2) | rd; } pair = (uint64_t)i2 << 32 | i1; atomic_set((uint64_t *)jmp_addr, pair);