From nobody Tue Feb 10 12:13:58 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=1673228725; cv=none; d=zohomail.com; s=zohoarc; b=Fwm1aCfjnjW5HZgxTdYFe818Ng1LFGk6VDt2ImW/YgHWRqSfTAooIpMUiU8Se3mCd41mSTzXoDP1mADM6vAhLnA3AU+vYDXDtnj6abXmUkgaF8s1YhM0n5KooB0uFHPtKJhGWYPcNgUGn+67e9Nxt6VyEs2L139yJ7WUSyLFXt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673228725; h=Content-Transfer-Encoding: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=NEPoewYIYUX4/fFFzLfNsZVv8UqWZ3zn3T6sHH/Cx9k=; b=K/bNVxj0W1J1oSaMqWf80JO4Sy4F62RiHvpLGbkQJ0I4q4DP84vB30gV19oIVy053RAqgDRXouu6VM08+SFAveBSfxeruotyrbhNR+HXObvthN2yEB9mYBUDKFnQGK/Cx7femf7Bpvdc+FNGjYHvNa6NClqweuxQqE6s2tu5Vjk= 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 1673228725260391.33232911570906; Sun, 8 Jan 2023 17:45:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEhBo-0000oF-Nv; Sun, 08 Jan 2023 20:43:04 -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 1pEhBm-0000nI-Rs for qemu-devel@nongnu.org; Sun, 08 Jan 2023 20:43:02 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEhBl-0001Xz-0q for qemu-devel@nongnu.org; Sun, 08 Jan 2023 20:43:02 -0500 Received: by mail-pj1-x1034.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so11221511pjk.3 for ; Sun, 08 Jan 2023 17:43:00 -0800 (PST) Received: from stoup.. ([2602:47:d48c:8101:a909:891c:953d:a6b0]) by smtp.gmail.com with ESMTPSA id w13-20020a170902ca0d00b00178b77b7e71sm4743617pld.188.2023.01.08.17.42.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 17:42:59 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NEPoewYIYUX4/fFFzLfNsZVv8UqWZ3zn3T6sHH/Cx9k=; b=cqZY7Kfg+UCDjpxz9N6rHgaUUQ+ojPM7AAmXCfO53VZ3UVsRztL7W3VDhPFE/efpaK BNbvRtIWpU/4UMoyMuerb1zbV7a7aMQksBVX7cgbf6wwtZ7MJll22M2lBJDWutznpuaR C3fnJ2lHTmHGaj1WCxK61RwO1Auk+/BGyBguHwSkECdHfR0GwKRugkCxKIbjhqjAFx1s ggkMyz28GPeM5ay8b/mA3qvke343vmb7mztUlqv/lgK2UgdN0eCcVtinIxldjuMJF4Ty AmVnB6RZ9PYv2BaKKLNdJWkdnP8HXE/mOiJzyZp+OAJP/tvRlDnWp216RKLSrlgnG3Gn AyPg== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NEPoewYIYUX4/fFFzLfNsZVv8UqWZ3zn3T6sHH/Cx9k=; b=6G1ro4eARcQk5UwlqrqzvOvDOjSUaYwsSrktfU5d933KK2+15rHZgaIprgmNsJET1/ kf0tijnZQpxXl4MqVOqhZd3GnOgO+abbiwnYMgD+vZ7A/rs+wZynFJ6/PJ3UCpD5ZEqE fsGNo6SZDomw0DCMmqN+mY+7Q9WaRbfHnt9jxKT/RLHRkr9Z45UfwK4Y1lL0c3rlXu1n u36phK+k70HU2PRDXUnHrymZ3IacWkjm00cbx8hnxINXqyzWFnjf+Z1bPnGgeZiXPfg3 1OndkQ28BWOp0jP3AE1erT50NJ6Budi/ym3CySSC72oQz5bSyQEv4BzlOOOLk8DKrho5 hGQg== X-Gm-Message-State: AFqh2koRedvq6i5K/nXZU4lLVaEteg/MyySuYO/TOFuZLCkoMfnJjHB2 7O6O8blY+SHBWbO830STWdPYjggc5ofZR3/j X-Google-Smtp-Source: AMrXdXvvm9WUGR6ruAjfTZP4l4h7IJbVCd9oANkTopbJzDsV5bUHpuefAU53isfQ4vw1WqZWS1yUHw== X-Received: by 2002:a17:902:cad5:b0:193:12fd:a2e3 with SMTP id y21-20020a170902cad500b0019312fda2e3mr7718168pld.55.1673228579598; Sun, 08 Jan 2023 17:42:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/22] tcg: Add TranslationBlock.jmp_insn_offset Date: Sun, 8 Jan 2023 17:42:37 -0800 Message-Id: <20230109014248.2894281-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109014248.2894281-1-richard.henderson@linaro.org> References: <20230109014248.2894281-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::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: 1673228726098100001 Content-Type: text/plain; charset="utf-8" Stop overloading jmp_target_arg for both offset and address, depending on TCG_TARGET_HAS_direct_jump. Instead, add a new field to hold the jump insn offset and always set the target address in jmp_target_addr[]. This will allow a tcg backend to use either direct or indirect depending on displacement. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e --- include/exec/exec-all.h | 3 ++- accel/tcg/cpu-exec.c | 5 ++--- tcg/tcg.c | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index b4d09c89ab..54585a9954 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -587,7 +587,8 @@ struct TranslationBlock { */ #define TB_JMP_OFFSET_INVALID 0xffff /* indicates no jump generated */ uint16_t jmp_reset_offset[2]; /* offset of original jump target */ - uintptr_t jmp_target_arg[2]; /* target address or offset */ + uint16_t jmp_insn_offset[2]; /* offset of direct jump insn */ + uintptr_t jmp_target_addr[2]; /* target address */ =20 /* * Each TB has a NULL-terminated list (jmp_list_head) of incoming jump= s. diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 356fe348de..a87fbf74f4 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -572,14 +572,13 @@ void cpu_exec_step_atomic(CPUState *cpu) =20 void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) { + tb->jmp_target_addr[n] =3D addr; if (TCG_TARGET_HAS_direct_jump) { - uintptr_t offset =3D tb->jmp_target_arg[n]; + uintptr_t offset =3D tb->jmp_insn_offset[n]; uintptr_t tc_ptr =3D (uintptr_t)tb->tc.ptr; uintptr_t jmp_rx =3D tc_ptr + offset; uintptr_t jmp_rw =3D jmp_rx - tcg_splitwx_diff; tb_target_set_jmp_target(tc_ptr, jmp_rx, jmp_rw, addr); - } else { - tb->jmp_target_arg[n] =3D addr; } } =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index c1f77f4392..7b16af17da 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -320,7 +320,7 @@ static void G_GNUC_UNUSED set_jmp_insn_offset(TCGContex= t *s, int which) * tcg_gen_code, where we bound tcg_current_code_size to UINT16_MAX. */ tcg_debug_assert(TCG_TARGET_HAS_direct_jump); - s->gen_tb->jmp_target_arg[which] =3D tcg_current_code_size(s); + s->gen_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) @@ -329,7 +329,7 @@ static uintptr_t G_GNUC_UNUSED get_jmp_target_addr(TCGC= ontext *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->gen_tb->jmp_target_arg + which); + return (uintptr_t)tcg_splitwx_to_rx(&s->gen_tb->jmp_target_addr[which]= ); } =20 /* Signal overflow, starting over with fewer guest insns. */ @@ -4666,6 +4666,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb,= target_ulong pc_start) /* Initialize goto_tb jump offsets. */ tb->jmp_reset_offset[0] =3D TB_JMP_OFFSET_INVALID; tb->jmp_reset_offset[1] =3D TB_JMP_OFFSET_INVALID; + tb->jmp_insn_offset[0] =3D TB_JMP_OFFSET_INVALID; + tb->jmp_insn_offset[1] =3D TB_JMP_OFFSET_INVALID; =20 tcg_reg_alloc_start(s); =20 --=20 2.34.1