From patchwork Tue Jan 17 23:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 643418 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1443129pvb; Tue, 17 Jan 2023 15:12:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuI7ZVRtHnpMsTcCdDzlDJnTFqAYhwD2sk6oyDizzFpDT7cXVlx072Le5TYiY6C4gX9d1Ao X-Received: by 2002:ac8:60c9:0:b0:3a8:15d2:6e8f with SMTP id i9-20020ac860c9000000b003a815d26e8fmr6043825qtm.44.1673997135386; Tue, 17 Jan 2023 15:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997135; cv=none; d=google.com; s=arc-20160816; b=Ah7TFHdBHthqgqjlo9CU0grFvzYVxPdvbDOG0f0S98M1/QRDHNpYpNYmEMCAN1+0sW aFfq1+rqpDzAEUweXGOFAyzVA6pKxZ6uwAD79N5Z/KhJ5mY2Ob2voQO0E9LEOmDME78P ImZszTnr8q0mOefQZweBYomTc5Ed6UYL+LYVpGWkU0qY2Qk/rBIVjEglf1SzDQev8/2u hnWYm+vGU2PeYlbhv0bJ2nafzFcfEnYwMYB5RJstAoJ5fw+Gg5/WL6szWlbkNm8KPSBk bfq4Y4/OJNpIFzXomvn3Zgmri5KGgo4HoWJ3BRcvPui9AQB8w/j+Qay2hxvf+q5VPOY1 QJrg== 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:cc:to :from:dkim-signature; bh=wm2x9VYi1GK8d/tbr4pBE9kGbjpSFNQ5bcLAS3uC+RE=; b=Qqm9G3YxXhFS9k9qLjdewHDALwnvD/degyO/xIQ5CpDurB3aAo/LtJ0K3SG+54wd/b yaRpiaUSjYSIfUfEijG1cibsx4i6+iQUCGfywlkji8rDWZBsoIzjvGY3bkh7ajOZgzBy RfNxEgrLz5hLVY2rNaz36QQCdXkEeq9TiV+WE7SpsiyOnJkZ3mDm5OcYcnRe0gX2xoVV Y7rNRGO1+OxOcH5SS7Ywk1J9o6sZMskHbj7iY3TOEDvBL/Z/5r4e771Mw8kzMJmdQQAt 3h1Cd2Kx6KHSQpyZDdTEvjhnv55rU1nTZ4veR9Iomm4EquyAAHlQ6Sd8CBOq3VjeCUf7 nwdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BMTPZnjA; 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 g18-20020ac87d12000000b003ad14d0e8aesi18690189qtb.432.2023.01.17.15.12.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Jan 2023 15:12:15 -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=BMTPZnjA; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHv6o-0003Ta-Nj; Tue, 17 Jan 2023 18:11:14 -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 1pHv6k-0003Pl-6l for qemu-devel@nongnu.org; Tue, 17 Jan 2023 18:11:10 -0500 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHv6i-0001Js-2G for qemu-devel@nongnu.org; Tue, 17 Jan 2023 18:11:09 -0500 Received: by mail-pg1-x531.google.com with SMTP id 141so23223860pgc.0 for ; Tue, 17 Jan 2023 15:11:07 -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=wm2x9VYi1GK8d/tbr4pBE9kGbjpSFNQ5bcLAS3uC+RE=; b=BMTPZnjAElD5zz9drLiCm51wUbXrfr0ElTuKLB/ZQKU6Pa/2unPXDZ6+YUuNkVLFks rM3wXinGoSCh2nc7rUpYQEc/v21epYy2vR6QYEiGIjWWtBhcTWQ/ycXsLksFxgN75g9I gCp0bY+LZHrDY4WeqpO876q4xv+Jxqv3frVrZ1qYvCVTfiD5VqrFJ4lTwdsUIjpM/Obj 65Gb/HV8ntcpHYPPT+cx0eLUnb/VGFo6liaixad44/FOKUFJgnqJu+Sc8QeV4z6PzNKu Sv1M9coa9iv+Q2PFmQE8IPKzmNEQrf3NqggjDR/j/TSUL61l899HpQdqsh2eaP3sVdLA lS8Q== 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=wm2x9VYi1GK8d/tbr4pBE9kGbjpSFNQ5bcLAS3uC+RE=; b=4W9vBVZDLB3jEmc/hK1o6bLme+obWSYuvWHP5hCS+RO0hhX7g8XhmC+070/1yvS3+P zybLnSrDieyuH5shxJwX2RlRG653HWXPjYU93eiLsuXlYBXwozg+9L2AoHXurb2sbdki XsoYX+1P1gGX96azit1l0GG8jb15sZM4+ToFkjWeGSUqriUJdPBQpK1b8pCU/rtuPJWp EcfzS1ONxpVOlCo/kUvFQlsvvT+V/7GyOONG0BfkgT58o77lNpeoIEFvV1AY7MWp7gN3 SLTDOdwVVrqRETZ0w0zI2Ub7Js69enxD5svIWmlGVOc41BLHYG/z7DtB/SAE5dotkt/V NHig== X-Gm-Message-State: AFqh2kqDtAXed/UW6DZU76wOdlCztDpxl5cpQBt51ek5x5oPcZrMA8kq oFDR3rHN4TaLdvvmcnfsw71is5EvfaboH7iT X-Received: by 2002:a05:6a00:a27:b0:566:900d:a1de with SMTP id p39-20020a056a000a2700b00566900da1demr6512210pfh.26.1673997066537; Tue, 17 Jan 2023 15:11:06 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id b193-20020a621bca000000b005810c4286d6sm20747070pfb.0.2023.01.17.15.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 15:11:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 07/22] tcg: Introduce get_jmp_target_addr Date: Tue, 17 Jan 2023 13:10:36 -1000 Message-Id: <20230117231051.354444-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117231051.354444-1-richard.henderson@linaro.org> References: <20230117231051.354444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Similar to the existing set_jmp_reset_offset. Include the rw->rx address space conversion done by arm and s390x, and forgotten by mips and riscv. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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/tci/tcg-target.c.inc | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 4092dac294..2a14fc2a97 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -323,6 +323,15 @@ static void G_GNUC_UNUSED set_jmp_insn_offset(TCGContext *s, int which) s->tb_jmp_insn_offset[which] = tcg_current_code_size(s); } +static uintptr_t G_GNUC_UNUSED get_jmp_target_addr(TCGContext *s, int which) +{ + /* + * 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 033ff90daa..83b6d77e2e 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1954,7 +1954,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGReg base = TCG_REG_PC; qemu_build_assert(!TCG_TARGET_HAS_direct_jump); - ptr = (intptr_t)tcg_splitwx_to_rx(s->tb_jmp_target_addr + args[0]); + ptr = get_jmp_target_addr(s, args[0]); dif = tcg_pcrel_diff(s, (void *)ptr) - 8; dil = sextract32(dif, 0, 12); if (dif != dil) { diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 02887d7cb1..c30173ab64 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1989,7 +1989,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 b977c8025d..5b2eac6ab8 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1314,7 +1314,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/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index ad356f1875..59daffc0a0 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -605,7 +605,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;