From patchwork Mon Dec 14 14:03:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 343515 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3032277jai; Mon, 14 Dec 2020 06:15:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiJRZeKPSm6Yg7W7lPQ+A2QE4x2zNHgegjwvJ2WhBYVMlKsNdF7+vJ9z+RgZRoz+p37R9f X-Received: by 2002:a25:4686:: with SMTP id t128mr35857299yba.109.1607955348192; Mon, 14 Dec 2020 06:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607955348; cv=none; d=google.com; s=arc-20160816; b=E0hDqVl035NiX2LEu505cWrClziIApWtmR8XsPvsx1ZsJURf3VB/+0/+iesr/TaSlm pYByt7P+8fwy61qeqMgbEHaOh24yk1MEdCxkPJlf2ziCCT6Cj/ug5LMm4sk6eQR8Am+p GCVVha6imkyK75dSwYIZ5/rQfK6h6R5weUSIpASTQl5oi36xG5FphmQj+0wefBF3YyF3 RUsOUuXk9j8s3lLQpjjBYb9hktZcwusXfdTohhWdZhHsHU/TEhtFZeRRsgFBlVQLtZEA ualy3NFzoIG9HfGflSlMz6Ox82om5aQ0EWkeK/52GB87xwGQ/w5NCCJasHDkg3MpyO6D qTcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=dzE91XjmDQzNzDT0A4ZgxgCbx8eY9J/YkDFN8yEJ4w+gLdcvAl6qxard+4xt5P5V+2 JUYSiOU+BXRDAW1iPg3Js1cM3F088XNKDMnmnkGDU5Q/VMRW4hqTGSYTVSmiTixbFf7a E6cOe3qOc4hVeYVhmCQypNuEUW7Mjb74UwMCKD7Evh4TbmRLngCgHxV94jcIlK4yXm8I gMKHtLqVuSnQiqgbuY69NFb9+MZvlwxSnsS6vy7rjoOK6QJAbHSduiD6Gg4hA3SOcadt 4Zigl5XW5FYTG07mkkfjVTw0dRjzzhYU7NTEqlznpg8/rmG+mmjOFRukg21uX6bgG8a8 k+Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZYjn4RB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o13si16348899yba.386.2020.12.14.06.15.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Dec 2020 06:15:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZYjn4RB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koodc-0007Fv-Hm for patch@linaro.org; Mon, 14 Dec 2020 09:15:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kooSh-0002MP-Dj for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:27 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:38651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kooSd-00042Q-KE for qemu-devel@nongnu.org; Mon, 14 Dec 2020 09:04:27 -0500 Received: by mail-oi1-x242.google.com with SMTP id x13so10203090oic.5 for ; Mon, 14 Dec 2020 06:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=MZYjn4RB697EkkCaK4MQzT7k9JoSojr0sQdClHXHo1uJxLAaw31NWGGo/V9sHmS1sz 4IwRIfypPeEBr901puW0Rz7oWEei/u18kvMfXxfLbucsbSLlX8wHDLhm5gYntCIb3NFQ iZ5oBudFy/5dlys23+fE50nc+ZPr8yKC2qsJNjSrZNaPuFmYdGblB6pziopVnf2YhzEW MGM7UxZsvGwFh1rGDT5SvBi4bh7ej8Fp8lvoJ5rpKFZLa/zw0ohenxuKQoXRZGByMoy0 ncDZePvchnK6GqhKjgWqAhJXTE3xs7rB88aDKm0zUGFRjBJu3a9fDM++0fBSTXAH0ijJ dkCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9/TRkK1ohPG7NzFVdGar1E3FliGdhxt5t+NNXefLhVw=; b=Y0Yz9OKDQ03IshXNj4z48/G0PrkKdbq9C5wB/lxlA2UeuKU33nGQcZp1LrpqmtcGTL JLLnRPt7lUjH5PW79vLilu78YjKzvwVNnRqgp8T/s2GOS16nM4IczTCtuWHcgdlUD9Ug elsUZViCbWEzvnHQD1r0xiVHTNSuB6PHdI5q8o26FqubimSLNLuFd4Yg+bIdr3abA6lL /ZZAFSaHzjMb3ElLJco9dIVysZArZY5AA5rE2s0shblJFDkrEVgQEcaIjNl/xq0mARGV 4jRA+uFT2oZ2vtXtB+/ChAzVEdAZYoZZskcMYVvymgCChsCTqp3Q14Yzw5KSRH7gQDW8 PG0g== X-Gm-Message-State: AOAM530SnGZ5YKQ95K6CMYvufCH5M/2k3zhUPNL6Z/s6QGs1qNJ7gLUP DYRo3TWmUCJ8W32p5o5txL4tJ+QFqe1ZQWd1 X-Received: by 2002:aca:51d8:: with SMTP id f207mr10129136oib.20.1607954662058; Mon, 14 Dec 2020 06:04:22 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id t24sm3940146oou.4.2020.12.14.06.04.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 06:04:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 38/43] tcg/mips: Do not assert on relocation overflow Date: Mon, 14 Dec 2020 08:03:09 -0600 Message-Id: <20201214140314.18544-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201214140314.18544-1-richard.henderson@linaro.org> References: <20201214140314.18544-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x242.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This target was not updated with 7ecd02a06f8, and so did not allow re-compilation with relocation overflow. Remove reloc_26 and reloc_26_val as unused. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 53 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) -- 2.25.1 diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 52638e920c..37faf1356c 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -144,29 +144,15 @@ static tcg_insn_unit *bswap32_addr; static tcg_insn_unit *bswap32u_addr; static tcg_insn_unit *bswap64_addr; -static inline uint32_t reloc_pc16_val(tcg_insn_unit *pc, - const tcg_insn_unit *target) +static bool reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) { /* Let the compiler perform the right-shift as part of the arithmetic. */ ptrdiff_t disp = target - (pc + 1); - tcg_debug_assert(disp == (int16_t)disp); - return disp & 0xffff; -} - -static inline void reloc_pc16(tcg_insn_unit *pc, const tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 16, reloc_pc16_val(pc, target)); -} - -static inline uint32_t reloc_26_val(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - tcg_debug_assert((((uintptr_t)pc ^ (uintptr_t)target) & 0xf0000000) == 0); - return ((uintptr_t)target >> 2) & 0x3ffffff; -} - -static inline void reloc_26(tcg_insn_unit *pc, tcg_insn_unit *target) -{ - *pc = deposit32(*pc, 0, 26, reloc_26_val(pc, target)); + if (disp == (int16_t)disp) { + *pc = deposit32(*pc, 0, 16, disp); + return true; + } + return false; } static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -174,8 +160,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, { tcg_debug_assert(type == R_MIPS_PC16); tcg_debug_assert(addend == 0); - reloc_pc16(code_ptr, (tcg_insn_unit *)value); - return true; + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); } #define TCG_CT_CONST_ZERO 0x100 @@ -925,11 +910,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, } tcg_out_opc_br(s, b_opc, arg1, arg2); - if (l->has_value) { - reloc_pc16(s->code_ptr - 1, l->u.value_ptr); - } else { - tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); - } + tcg_out_reloc(s, s->code_ptr - 1, R_MIPS_PC16, l, 0); tcg_out_nop(s); } @@ -1316,9 +1297,10 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } i = 1; @@ -1346,7 +1328,9 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } tcg_out_opc_br(s, OPC_BEQ, TCG_REG_ZERO, TCG_REG_ZERO); - reloc_pc16(s->code_ptr - 1, l->raddr); + if (!reloc_pc16(s->code_ptr - 1, l->raddr)) { + return false; + } /* delay slot */ if (TCG_TARGET_REG_BITS == 64 && l->type == TCG_TYPE_I32) { @@ -1366,9 +1350,10 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int i; /* resolve label address */ - reloc_pc16(l->label_ptr[0], s->code_ptr); - if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - reloc_pc16(l->label_ptr[1], s->code_ptr); + if (!reloc_pc16(l->label_ptr[0], s->code_ptr) + || (TCG_TARGET_REG_BITS < TARGET_LONG_BITS + && !reloc_pc16(l->label_ptr[1], s->code_ptr))) { + return false; } i = 1;