From patchwork Tue Jan 16 16:46:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 124746 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1076354lje; Tue, 16 Jan 2018 08:49:36 -0800 (PST) X-Google-Smtp-Source: ACJfBosnyf9PAkhAXiA1itAVY9TeqKnsUa3o5LjsXLF9Kjb4DqiRWl0DHxprE/6yCF3OmAAf7BpS X-Received: by 10.13.241.68 with SMTP id a65mr35927755ywf.205.1516121376142; Tue, 16 Jan 2018 08:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516121376; cv=none; d=google.com; s=arc-20160816; b=wPkDXU3XqRPpipJufmeopGzjIN4XIl5OglSLV65ky0JqYvR/bae56wHNFXcNe/ZDti WoSpX0CT+4udIyPVmqqDg7e1Us6hKMsGS4i9WUJvK+TKiE6hh/VZisIIa6R2k8ohF7ef 5YcY61FIIJl9bmw6rLCQAhQinywogLyfTDBCnsW9sZPU5d9COWLnF4PfrzI6Jd6eVyGj wC6AEChTwhUSJWmYJoYkCpZIXus81Lv+4miYyTg6lWSJtn10y7Eq3VKX5cZHzcXnjmLY kWlJFqvgcikr5vQc9gQhBBK29cBVx7RHGVaCMkasNxx72nIqXuks9GFiQMTyxaslMlOO Nmbg== 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=ejAxQWE2JqEWtHIQ0a5NmxOhMLmzF6ylqCWbWExnSLLYePn3ZZ6i09wcPUlWqMnyg/ FPtXZmQ01p1ru56Cs3XrcvzulRlBtgB0SvM7tQzhm+nMWUznreIV8zQXbe6iqZabmgM1 IBDihT30a51zR3s6fWa5x2BJiQ+xputWXEDHInZ+UyHvu1fo9qdW7gc37IfQhayC/7GJ c9SDmx7zeDRcHRSef4KGZwH0xu1SaypaUw6yW9J14hMiHLzhm4kGO/KbELwbdKMPv+DA GTWCELWxIeXCb+fBO2AGUdrPe7xdW8dlcpaBwy+2uAYe1sTlF3MFpXAwEYJJQVXY7NU1 edjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QG6ttO9J; 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 o6si600577ywm.109.2018.01.16.08.49.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 16 Jan 2018 08:49:36 -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=QG6ttO9J; 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]:48221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebUQZ-0001oP-H0 for patch@linaro.org; Tue, 16 Jan 2018 11:49:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebUNI-0000UL-D4 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebUNH-0008RK-8s for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:12 -0500 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:41196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebUNH-0008Qp-2J for qemu-devel@nongnu.org; Tue, 16 Jan 2018 11:46:11 -0500 Received: by mail-pl0-x242.google.com with SMTP id q3so6573727plr.8 for ; Tue, 16 Jan 2018 08:46:10 -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=QG6ttO9JU1DNfAmlIpgrCexIAQNBb/Su2KM4PYX6IAnN6/CrAHq5oXkAyhyO7AsxpG 3ef5so/sdcK84qVIwH2av0te20mZioWwzZqTWh3SDTolZ64U6dxVa0M5H5FeUfRq+l+o wMvlH7RFyiYciz41S7GHv/jNtJv1K4PevQuo4= 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=iBgdrQsj80NO4HKWKYtpIGC/6acLG+ml80GULOVy5OnZpNkJFc6Zfhy0hykeHkyg6Y yDDExm0pRDPIXOUjyW93j8SD5p2HtCwrcFLLfT54BOmJ3vETIFTNFB9VOB7J7v3KoWJJ inLS6aOsJNwsGIChCmLo7yutAOHs6XTEcBHjvzVrRJzu4BGCmiRKk4rKg+uHt+oWUdsa GxXTFtEdzaC7w/yMXhDXi8ymiTFD3BeOQV9ow2TkCCT3wjZkzkO5SgGOIn64iFS0EtXS 412m4xN5i1OuLhnAlqOhWUCbkYvs7BqGr8g+z6WS9VVcRWc/ov41u9iypC0pdNLoHKCo 4RUQ== X-Gm-Message-State: AKGB3mLC6JHNXW+un4liBeTavmxRBCQebukhKgT1jAD+patVmenj8DK1 ibsKDIY3K8BiQcmggmZDu+rJ10f3w6k= X-Received: by 10.84.151.70 with SMTP id i64mr40148525pli.337.1516121169671; Tue, 16 Jan 2018 08:46:09 -0800 (PST) Received: from cloudburst.twiddle.net.com (24-181-135-57.dhcp.knwc.wa.charter.com. [24.181.135.57]) by smtp.gmail.com with ESMTPSA id y7sm3875780pfe.48.2018.01.16.08.46.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jan 2018 08:46:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 08:46:00 -0800 Message-Id: <20180116164600.7480-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180116164600.7480-1-richard.henderson@linaro.org> References: <20180116164600.7480-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:c01::242 Subject: [Qemu-devel] [PULL v2 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 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; }