From nobody Tue Feb 10 07:23:19 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=1670300542; cv=none; d=zohomail.com; s=zohoarc; b=Z26bQu0zd/8dQ/V3NmMeMdwehVlQ8ZpiFdhOlWrb8dv8LShHqBCwbNLHFCD+WBu3LCzvjvecdWgNQLjqg0IpgMad0AnRqzT+lEwp16Iica2SWKEo/QbQiXY3UCm4Un9jKySquhdKTrypQRjjUxj8iuRxisOpNn3xACV06LViUzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670300542; 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=Uzpy7hdVQnCFhgoilIBmji9svrZHcvZGnbGwuPjB4fQ=; b=FntjCmohAbErYz08vrvQOoCofRn2xGExiAk2dIqnWToHbYGYow1xAc2E73B0lTBwF4eDyAIYfO7EZvdopCK82iGsNYy6OtBBoVI61f6y1wEkqSjMzYQuhEsJecSr/Z0MC8vivLMiBsYqFJi1ffpqfiynF21Asy1TruUiMRjrUVY= 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 1670300542029372.049730729968; Mon, 5 Dec 2022 20:22:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2POg-0003Nj-VP; Mon, 05 Dec 2022 23:17:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2POc-0003Lj-OF for qemu-devel@nongnu.org; Mon, 05 Dec 2022 23:17:31 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2POa-0006vs-19 for qemu-devel@nongnu.org; Mon, 05 Dec 2022 23:17:30 -0500 Received: by mail-oi1-x229.google.com with SMTP id e205so15552858oif.11 for ; Mon, 05 Dec 2022 20:17:27 -0800 (PST) Received: from stoup.. ([2806:102e:18:70b5:d104:21c2:8c7e:77e6]) by smtp.gmail.com with ESMTPSA id o35-20020a056870912300b0014185b2b3d5sm10162018oae.18.2022.12.05.20.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 20:17:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uzpy7hdVQnCFhgoilIBmji9svrZHcvZGnbGwuPjB4fQ=; b=dUZih/nV71gDz+EWXNNJZjssonPiG52ttjilS9hwgYGeuiToPMnQJxV0AFCHpCf3yq Xy4jN3MyxS/Q0zhwHjwJGzbtIN2DQKXBaJv59ucLBgfeoS51OVJb/Gmookf8GMeWa5y0 EPKeTf1INO5qsrWVGzPvi41BtCPLQBZJb9p3AocnmOoIAF3v1xgsqzmTL8abHpYU4FWv iHids5Jkf1GpgAk7DYAumODniU54HBGOpWq4YNzfp4xFrNkBsWuwaJ3sag62sjCH4usZ XnBvm4s7rA3kbLnvaJvsKaCyOUICKn4nVgd+Smx6ZO/utF7vFh/+1Kj28bmufK4VuPTU MySg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uzpy7hdVQnCFhgoilIBmji9svrZHcvZGnbGwuPjB4fQ=; b=35WVqO1lJNKFzYj5ryp+/daURm8Y6b4s1CF5W35IA3VvJ4vicza6TQPag1UXJmNYFe B2uyNzKjh6DAXRx13sPIDvNLmpLxCCXQFaNpFcINyZg1t4I1HK4iO3JTuTpitP0mvR8K 5kSD1hxDJZENX9Ha5YNJI0IJL37Iaq8D0FCSIrqtetYMTryG1SsO92PhH6cRA5fdcVJY gSR4fyEqnUccV8ThjOmr3tYPiiXkPJuAUeBn7K4VF7OtTpLwkSnzsiBWqI+KGDtHvris +3RLrFdGwW/67AxHtNtHfpJoyG6iS4XZq4DGIWU0X2RHSmjYnv6MU85HZ3uC+QK9yBvR d6Vg== X-Gm-Message-State: ANoB5pmH5KFnWNSNdB3JaWSpmyNlJicvd0ohkE4FnMvIosN8h7l1l2Tn NLVB4EZUf+HY5vFJqKYeBUtuQLuQ8Ud+w/FQ9q8= X-Google-Smtp-Source: AA0mqf74c2407MSKN0a8yMwiCumEeMdaAE2o3AdPIidEY3HXFrvZvLNa9uQqWeygEB/rT4lnkZWwgQ== X-Received: by 2002:a05:6808:617:b0:359:ef86:2f4f with SMTP id y23-20020a056808061700b00359ef862f4fmr41419016oih.14.1670300247342; Mon, 05 Dec 2022 20:17:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: r@hev.cc Subject: [PATCH 07/22] tcg: Introduce get_jmp_target_addr Date: Mon, 5 Dec 2022 22:17:00 -0600 Message-Id: <20221206041715.314209-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221206041715.314209-1-richard.henderson@linaro.org> References: <20221206041715.314209-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::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1670300544056100003 Content-Type: text/plain; charset="utf-8" Similar to the existing set_jmp_reset_offset. Include the rw->rx address space coversion done by arm and s390x, and forgotten by mips and riscv. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 9 +++++++++ tcg/arm/tcg-target.c.inc | 2 +- tcg/mips/tcg-target.c.inc | 2 +- tcg/riscv/tcg-target.c.inc | 2 +- tcg/s390x/tcg-target.c.inc | 2 +- tcg/tci/tcg-target.c.inc | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index df5a6cedf0..8bde8eb0d4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -330,6 +330,15 @@ static void G_GNUC_UNUSED set_jmp_insn_offset(TCGConte= xt *s, int which) s->tb_jmp_insn_offset[which] =3D tcg_current_code_size(s); } =20 +static uintptr_t G_GNUC_UNUSED get_jmp_target_addr(TCGContext *s, int whic= h) +{ + /* + * Return the read-execute version of the pointer, for the benefit + * of any pc-relative addressing mode. + */ + return (uintptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + which); +} + /* Signal overflow, starting over with fewer guest insns. */ static G_NORETURN void tcg_raise_tb_overflow(TCGContext *s) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 31f8c5b7a7..3a545f3707 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1948,7 +1948,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGReg base =3D TCG_REG_PC; =20 qemu_build_assert(!TCG_TARGET_HAS_direct_jump); - ptr =3D (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + ar= gs[0]); + ptr =3D get_jmp_target_addr(s, args[0]); dif =3D tcg_pcrel_diff(s, (void *)ptr) - 8; dil =3D sextract32(dif, 0, 12); if (dif !=3D dil) { diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 5fc96e4406..6b9c070f6b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1988,7 +1988,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, /* indirect jump method */ qemu_build_assert(!TCG_TARGET_HAS_direct_jump); tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, - (uintptr_t)(s->tb_jmp_target_addr + a0)); + get_jmp_target_addr(s, a0)); tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); tcg_out_nop(s); set_jmp_reset_offset(s, a0); diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 1e8406b8c1..091c44d071 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1289,7 +1289,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, qemu_build_assert(!TCG_TARGET_HAS_direct_jump); /* indirect jump method */ tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, TCG_REG_ZERO, - (uintptr_t)(s->tb_jmp_target_addr + a0)); + get_jmp_target_addr(s, a0)); tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_TMP0, 0); set_jmp_reset_offset(s, a0); break; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index ad6433fcf2..dba02db6ee 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -2110,7 +2110,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, } else { /* load address stored at s->tb_jmp_target_addr + a0 */ tcg_out_ld_abs(s, TCG_TYPE_PTR, TCG_REG_TB, - tcg_splitwx_to_rx(s->tb_jmp_target_addr + a0)); + (const void *)get_jmp_target_addr(s, a0)); /* and go there */ tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, TCG_REG_TB); } diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index d1cc41261a..baf3480c67 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -608,7 +608,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_goto_tb: qemu_build_assert(!TCG_TARGET_HAS_direct_jump); /* indirect jump method. */ - tcg_out_op_p(s, opc, s->tb_jmp_target_addr + args[0]); + tcg_out_op_p(s, opc, (void *)get_jmp_target_addr(s, args[0])); set_jmp_reset_offset(s, args[0]); break; =20 --=20 2.34.1