From patchwork Fri Jan 12 21:06:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 124381 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2507713qgn; Fri, 12 Jan 2018 13:09:15 -0800 (PST) X-Google-Smtp-Source: ACJfBouWckJA0y2xnYgRNTbG6QQNlxiGHTlwR6tLwz8gsqwG+pBlh0bA90a+VWVXzHnQU/bhSr7S X-Received: by 10.13.202.20 with SMTP id m20mr2571578ywd.81.1515791355907; Fri, 12 Jan 2018 13:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515791355; cv=none; d=google.com; s=arc-20160816; b=GSB47xCLAnUk5FF2e9ya8HSrfh9jOGTcp6pRTvbg25cJL5XUzNzfxAB5DS7Panj6be T+9fwyvGEgqxneqff5Z0bQDjrCndZZ8MFG2USw9B+pkbuYgdz9j7QXMQBzgqy60Oczgn pIKt5YWtQB04ZGyHxvxIwiGgPTusrNcMJxdcmslsRHx0BA8DPLJc0llYtjK+SC4dE7DF WvhCqAiP/fKlYBJDgc/asgBYRkMISlLun0tRTkRJuCvVEy+TtH9gBrUes5ormfiYpU3+ 9C9PGNO7BhlziPy5XKvlf6hVjUra5MnUAZ/xPzlak8V9edoc69IoArAmBRJlx6zip6e3 vXqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=FUUWRYtwa278VZrUKwI2J5+6Tu8CghM2hw9X/xV8zwA=; b=Dm+HXEz50RAljGsqdS7JtoBDyRVOAjDnua5JW+Pf2FparMUI2IFNUTWHyDiVmkGrTx V4mtsD1h3lsuQy0sdOTZeFhY7bf8Ufl5/jTfW7e/oVUoTZWdXDcKnD8VZME8MgpTZoGf Ad+4z8QKab/yRE0KCAE1QIGHzqZFOmGCoz1CL6ZXw+fbA9o/KM3ZiacZkSdEecvV5dO2 rW8E6U9dxofXHc05WhwlwI5+0JQuuh1yfFQuoVo3VJ9ctza85ebvVPoujWs2/+Jp6V7C hglUatl5YXDyk7t+rYZX0cRG52TRAAgj9kntZlKhV6KfP+BDrasCkNlRu2CfOGuq98+J mEEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d0OJgcwf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r132si2611632ybc.627.2018.01.12.13.09.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 12 Jan 2018 13:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d0OJgcwf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ea6Zf-0002AU-Ek for patch@linaro.org; Fri, 12 Jan 2018 16:09:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ea6Wv-0008Og-3f for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ea6Wu-0002oP-1b for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:25 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:45435) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ea6Wt-0002nu-Rj for qemu-devel@nongnu.org; Fri, 12 Jan 2018 16:06:23 -0500 Received: by mail-pg0-x242.google.com with SMTP id c194so5319043pga.12 for ; Fri, 12 Jan 2018 13:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FUUWRYtwa278VZrUKwI2J5+6Tu8CghM2hw9X/xV8zwA=; b=d0OJgcwfUFpj+ZwVpj3oQFpWa4DHmM3/kAxCJICyyLs97+Egyz0tGspUwcWq2vJdK7 tn9B4hDaq2VC6R5dHKz8UVCefJt7DCg05KRN4lnhx5EnIlQSS+ASD1XPtClzmFbGsD6X NmcCbwUDL5tpb3zxHVs7h/JyHKDgG8PE9qU+Q= 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:in-reply-to :references; bh=FUUWRYtwa278VZrUKwI2J5+6Tu8CghM2hw9X/xV8zwA=; b=f5eXemkv5tW5Qxj0rzZZlDfaqD4/Ab3EUvgQUXxA+D7e8UvVv6/4JTFxJK//A2VHxe qr39UC7uTBKi4ZskFEabyxHSfWV1kRv+zwvZQfKQ8oeMZuCwzhbaPZANuqBI+RMUZIlD YWDmKuEqf84JEklOMTpactjUK+pQ7UAkPiWpif7W5iQ5tLQPSKBeAF6QOEyp/QIi8EhD /m0JTvkeR7e246MdjzrI5y7/dPTsO0hFntywQdy800/nSB1Dm4vcR3FIMKkrYHpKihA0 9ezB3WFbcOqBonBKokTaFnQ8Xr/gyWuqsS0YvlGvdg4Y42YjkM43uHkRQdUXRkHU3EWB T92A== X-Gm-Message-State: AKGB3mJCAbUnu1vtGPJv5/imYH2jmf8gjbo5dU+//Lh3xfmzifsAlzjy KdopkvEebuSvpGAGXthb0f8mxu3Ewyk= X-Received: by 10.101.65.71 with SMTP id x7mr21935777pgp.164.1515791182572; Fri, 12 Jan 2018 13:06:22 -0800 (PST) Received: from cloudburst.twiddle.net (50-78-183-178-static.hfc.comcastbusiness.net. [50.78.183.178]) by smtp.gmail.com with ESMTPSA id t80sm20197600pgb.88.2018.01.12.13.06.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jan 2018 13:06:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 12 Jan 2018 13:06:13 -0800 Message-Id: <20180112210613.14124-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180112210613.14124-1-richard.henderson@linaro.org> References: <20180112210613.14124-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PULL 4/4] tcg/ppc: Allow a 32-bit offset to the constant pool 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: peter.maydell@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We recently relaxed the limit of the number of opcodes that can appear in a TranslationBlock. In certain cases this has resulted in relocation overflow. Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.inc.c | 67 ++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 28 deletions(-) -- 2.14.3 diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 74f9b4aa34..86f7de5f7e 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -222,33 +222,6 @@ static inline void tcg_out_bc_noaddr(TCGContext *s, int insn) tcg_out32(s, insn | retrans); } -static void patch_reloc(tcg_insn_unit *code_ptr, int type, - intptr_t value, intptr_t addend) -{ - tcg_insn_unit *target; - tcg_insn_unit old; - - value += addend; - target = (tcg_insn_unit *)value; - - switch (type) { - case R_PPC_REL14: - reloc_pc14(code_ptr, target); - break; - case R_PPC_REL24: - reloc_pc24(code_ptr, target); - break; - case R_PPC_ADDR16: - assert(value == (int16_t)value); - old = *code_ptr; - old = deposit32(old, 0, 16, value); - *code_ptr = old; - break; - default: - tcg_abort(); - } -} - /* parse target specific constraints */ static const char *target_parse_constraint(TCGArgConstraint *ct, const char *ct_str, TCGType type) @@ -552,6 +525,43 @@ static const uint32_t tcg_to_isel[] = { [TCG_COND_GTU] = ISEL | BC_(7, CR_GT), }; +static void patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) +{ + tcg_insn_unit *target; + tcg_insn_unit old; + + value += addend; + target = (tcg_insn_unit *)value; + + switch (type) { + case R_PPC_REL14: + reloc_pc14(code_ptr, target); + break; + case R_PPC_REL24: + reloc_pc24(code_ptr, target); + break; + case R_PPC_ADDR16: + /* We are abusing this relocation type. This points to a pair + of insns, addis + load. If the displacement is small, we + can nop out the addis. */ + if (value == (int16_t)value) { + code_ptr[0] = NOP; + old = deposit32(code_ptr[1], 0, 16, value); + code_ptr[1] = deposit32(old, 16, 5, TCG_REG_TB); + } else { + int16_t lo = value; + int hi = value - lo; + assert(hi + lo == value); + code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16); + code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo); + } + break; + default: + g_assert_not_reached(); + } +} + static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, TCGReg base, tcg_target_long offset); @@ -690,7 +700,8 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, if (!in_prologue && USE_REG_TB) { new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr, -(intptr_t)s->code_gen_ptr); - tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0)); + tcg_out32(s, ADDIS | TAI(ret, TCG_REG_TB, 0)); + tcg_out32(s, LD | TAI(ret, ret, 0)); return; }