From patchwork Mon Jan 9 01:42:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 640565 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1914952pvb; Sun, 8 Jan 2023 17:45:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXsO3N4uCdZtadFQJ2hNvRikGCeJm4UFaGSCA4qO6Wu4h2Gt/Nr9+hOnNJ7A/WrsF9Lh3rz2 X-Received: by 2002:ad4:4b6f:0:b0:4c6:eb92:c97b with SMTP id m15-20020ad44b6f000000b004c6eb92c97bmr90196386qvx.50.1673228724769; Sun, 08 Jan 2023 17:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673228724; cv=none; d=google.com; s=arc-20160816; b=v5xuAFMuQ4gsVGi83gsHnPrtOr26F/hljIqihFFdpUlG2VCF0NH+AMZbyVcjK15S98 wdpY+686O8lRc8tuHgCSOTR+oiXIxUJVvIcpuTn91g8Re1vFabWfkHfigFbcyXkDVa5p l073/jK31dMNmzET3x2qg5AtO7q/N7gXojeOvapccT/XdBDqsrTwtf8osYxX/i3fgiAv 6IO2IOv56ge8xpW2NnvKpL0nHVJgQf54hNDQO8GU/c42F6jVm+WUNxf3caa9p25peLoV /OAUxooBKLLlLREoKDUbM7MCZrEOhO7bLb5xsDop9mIGYccVCohDcpqMdYb0lJ2RHZgZ 1phw== 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=NEPoewYIYUX4/fFFzLfNsZVv8UqWZ3zn3T6sHH/Cx9k=; b=rn+DOTWOdFezzfw5ygpQH0cxaigrcmjBbu3u+8HA7yU50V0GANE762NbGl/9PxnMsJ VO22nbkS/PvZBThZXnzUN6TGx7hjRFeNQFijouUdgoyucSDFcZUki0qfBvXdPLfxilTK MYWX2G/zX70shCT33SWEW7Iru0KcUOLubwoAqofXdeUmZpk5oIQs3QRd8UsfpcRSh24A jCjgTmmuO6YPncAYHds/wvMxo9necMWw4I7MlzyNoqXeJEuz9sHEp88JqZ/wO3Gd2pXw oxvgKir1CwzikCvQv12UIirwrFlp1AWZSte+VS4Mllpv32ahN9n9kV4bEmRph/zB/PC9 e7dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cqZY7Kfg; 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 14-20020a0562140d0e00b0053216803d28si3720999qvh.344.2023.01.08.17.45.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Jan 2023 17:45:24 -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=cqZY7Kfg; 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 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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ée --- 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 */ /* * Each TB has a NULL-terminated list (jmp_list_head) of incoming jumps. 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) void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr) { + tb->jmp_target_addr[n] = addr; if (TCG_TARGET_HAS_direct_jump) { - uintptr_t offset = tb->jmp_target_arg[n]; + uintptr_t offset = tb->jmp_insn_offset[n]; uintptr_t tc_ptr = (uintptr_t)tb->tc.ptr; uintptr_t jmp_rx = tc_ptr + offset; uintptr_t jmp_rw = jmp_rx - tcg_splitwx_diff; tb_target_set_jmp_target(tc_ptr, jmp_rx, jmp_rw, addr); - } else { - tb->jmp_target_arg[n] = addr; } } 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(TCGContext *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] = tcg_current_code_size(s); + s->gen_tb->jmp_insn_offset[which] = tcg_current_code_size(s); } static uintptr_t G_GNUC_UNUSED get_jmp_target_addr(TCGContext *s, int which) @@ -329,7 +329,7 @@ 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->gen_tb->jmp_target_arg + which); + return (uintptr_t)tcg_splitwx_to_rx(&s->gen_tb->jmp_target_addr[which]); } /* 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] = TB_JMP_OFFSET_INVALID; tb->jmp_reset_offset[1] = TB_JMP_OFFSET_INVALID; + tb->jmp_insn_offset[0] = TB_JMP_OFFSET_INVALID; + tb->jmp_insn_offset[1] = TB_JMP_OFFSET_INVALID; tcg_reg_alloc_start(s);