From nobody Tue Feb 10 19:17:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1631580679; cv=none; d=zohomail.com; s=zohoarc; b=V5wK9mPAEWg4k/3Ocg20Y4i4+uuw3do2KqR/QH2kyxp2581PXpA0ggx+eHQYAUF6dro4nue0IFQpTmRDhe9DJhsYXU2DCXTJPov4beX+tpdkZq9wBHuK3wq5XryOURs74778qlQbiZuLnppWqE+oxMjCj6flZZsJmc0a/gNcl8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631580679; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uTLZzqxs9XAa07bAQKkmrTrRThGv91dnwDKo1jmYb9Q=; b=NYhy3RU8SGhmOVhGbEYJkFOfbkGk49AzkdCqgp0Q91TnDpr/PavPuD/x0L1ZbGOLZ+RXML8oTd+nCSZNdNOl0BatXfOJvqWJ+Qda7GwIvJd6fTFSfFzBTSyWoaE7LLzXZ8rTWaUN960Ya/N+YsMn2m2YfCwUOi6cNftXuEomxAo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631580679625333.42424429101163; Mon, 13 Sep 2021 17:51:19 -0700 (PDT) Received: from localhost ([::1]:35310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPwfO-0000sM-Jo for importer@patchew.org; Mon, 13 Sep 2021 20:51:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPw6u-0001vI-BA for qemu-devel@nongnu.org; Mon, 13 Sep 2021 20:15:40 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:39808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPw6g-0007vY-JA for qemu-devel@nongnu.org; Mon, 13 Sep 2021 20:15:39 -0400 Received: by mail-pf1-x42b.google.com with SMTP id e16so10450072pfc.6 for ; Mon, 13 Sep 2021 17:15:25 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id m7sm9334179pgn.32.2021.09.13.17.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 17:15:24 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=uTLZzqxs9XAa07bAQKkmrTrRThGv91dnwDKo1jmYb9Q=; b=thcmJxM2l+P7OP9IoKLJ4QHcRwRI0+20avQnUyuQgHhOlKjXFylYKTxujIWqEmXJ/m Fwj0JwZp2TJunGiJFVyNDfwrI95HoCX5bjq8J7crfOf3xqNiSqBiNL8IRawJGej/BYJj iYJOTu/H6a0CGRbhaCncacqDeJcFxYoH1N0zsAB+lyvMF5yaiF8f7AT/Ox12WQG9cAuP JobdQITkvLqwQneq6i/IoPNC9rSQ808gfgRTF92Li/L4IwrJ2y+047CXQ8ICPlMXojis 9Ne90cj/Hn0aJPG0WByioR66vGxRVcVm/1Wj5u+rY750jRd8vqUtLiaLR38wD9RILT81 TK9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uTLZzqxs9XAa07bAQKkmrTrRThGv91dnwDKo1jmYb9Q=; b=bZpSFuriq9jIxol8UVL8lbDC8QbTGKt3s+vl9e+W4cHnvaPN/NJ74P86MbRc3Dbn33 dVewT1mKJ1Is3YIN2zLqFFnv9AERaHsRMUAFKeUH6NtylwWO7udMWIqm72cppdceC/YC Aa8FCoSB8o4cgcFRpk2slXvrdBW3Slah6po/gVUCQ4sigx8E0veAKZoCaGqN0BLoSwUK K2SXuNbgrw0T5Um7L6eabjrc8wiPuCyZg4oCRCLMvcv80GWYEB+Tbciwig3WOsvm2AGl /MZU5aB38lnvCYgzX/Tfe+M/+K/piOMmenLTNT5hp+64i5Y5JPVEkjsqp4ITfACQBAid HWiA== X-Gm-Message-State: AOAM532skCpye9fCSlWjoZIVrXiruZ5uMZKs/wRDkeBIoP3NLlVFO9gp ukC2wGE/FUKfINA7e8GUnuIzRU7tX6PVgQ== X-Google-Smtp-Source: ABdhPJzrz6hOElmtE1R1NRmwonrkFZanejcKdQuEcFrHGbuS0TL3lRamgYqUZQh4/vCfjAlxDuaz0g== X-Received: by 2002:aa7:88c9:0:b0:3fc:38d8:fc32 with SMTP id k9-20020aa788c9000000b003fc38d8fc32mr1986572pff.81.1631578525031; Mon, 13 Sep 2021 17:15:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 38/44] tcg/arm: Support armv4t in tcg_out_goto and tcg_out_call Date: Mon, 13 Sep 2021 17:14:50 -0700 Message-Id: <20210914001456.793490-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210914001456.793490-1-richard.henderson@linaro.org> References: <20210914001456.793490-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1631580680591100001 Content-Type: text/plain; charset="utf-8" ARMv4T has BX as its only interworking instruction. In order to support testing of different architecture revisions with a qemu binary that may have been built for, say ARMv6T2, fill in the blank required to make calls to helpers in thumb mode. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 49 ++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 7d15c36f85..852100bb80 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1211,7 +1211,8 @@ static inline void tcg_out_st8(TCGContext *s, int con= d, tcg_out_st8_12(s, cond, rd, rn, offset); } =20 -/* The _goto case is normally between TBs within the same code buffer, and +/* + * The _goto case is normally between TBs within the same code buffer, and * with the code buffer limited to 16MB we wouldn't need the long case. * But we also use it for the tail-call to the qemu_ld/st helpers, which d= oes. */ @@ -1219,38 +1220,56 @@ static void tcg_out_goto(TCGContext *s, int cond, c= onst tcg_insn_unit *addr) { intptr_t addri =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); + bool arm_mode =3D !(addri & 1); =20 - if ((addri & 1) =3D=3D 0 && disp - 8 < 0x01fffffd && disp - 8 > -0x01f= ffffd) { + if (arm_mode && disp - 8 < 0x01fffffd && disp - 8 > -0x01fffffd) { tcg_out_b_imm(s, cond, disp); return; } - tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); + + /* LDR is interworking from v5t. */ + if (arm_mode || use_armv5t_instructions) { + tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); + return; + } + + /* else v4t */ + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); + tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); } =20 -/* The call case is mostly used for helpers - so it's not unreasonable - * for them to be beyond branch range */ +/* + * The call case is mostly used for helpers - so it's not unreasonable + * for them to be beyond branch range. + */ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *addr) { intptr_t addri =3D (intptr_t)addr; ptrdiff_t disp =3D tcg_pcrel_diff(s, addr); + bool arm_mode =3D !(addri & 1); =20 if (disp - 8 < 0x02000000 && disp - 8 >=3D -0x02000000) { - if (addri & 1) { - /* Use BLX if the target is in Thumb mode */ - if (!use_armv5t_instructions) { - tcg_abort(); - } - tcg_out_blx_imm(s, disp); - } else { + if (arm_mode) { tcg_out_bl_imm(s, COND_AL, disp); + return; } - } else if (use_armv7_instructions) { + if (use_armv5t_instructions) { + tcg_out_blx_imm(s, disp); + return; + } + } + + if (use_armv5t_instructions) { tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); - } else { + } else if (arm_mode) { /* ??? Know that movi_pool emits exactly 1 insn. */ - tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R14, TCG_REG_PC, 0); + tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); tcg_out_movi_pool(s, COND_AL, TCG_REG_PC, addri); + } else { + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); + tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); + tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); } } =20 --=20 2.25.1