From nobody Mon Nov 23 04:30:03 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=1793386622; cv=none; d=zohomail.com; s=zohoarc; b=YxqUPKLLzn4+emr7nDICQ4mtmU7P3PXgQgoVr07/Lp0jrfQjA08fegxDH92VcoDo7+qNLfis/hNg9X3AlUWqPamPJGtvxP2WC7DsUDLYQZGVh/VTFHGmfQ0DBsy7mSmrusr8gbGKM8ifIu5OQKlsDVwI/F2ZkxsTaDYr7rL9VPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386622; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CARmoio7bFJMgAwfHhr6lkrU83o62HGa9/lgyZJ+P9Q=; b=dODLRm6gLlu0svGyO3qhZiv50h1TUZ/io6DaiLOcC58zWDCBnTakLsWft+lbPkkRh348PpTYSvE/7viviGZc0f43inMalB6NmheCklPs6svO2QaLVodWGWm72vQDYR6CFGBJwxY1cZkBxhazTuh7OVHY585SbIeECKPwVvxrZ84= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386622980941.8683843739481; Fri, 30 Oct 2026 11:57:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrlm-0006ru-5R; Fri, 30 Oct 2026 14:56:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlg-0006qw-7D for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:00 -0400 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrld-0004n5-Jc for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:55:59 -0400 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-8b0f59a5fdeso9412407b3.1 for ; Fri, 30 Oct 2026 11:55:57 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386556; x=1793991356; darn=nongnu.org; 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:content-type; bh=CARmoio7bFJMgAwfHhr6lkrU83o62HGa9/lgyZJ+P9Q=; b=KrexsZNhKw1eAg126XxVwslTgXvX1/nPNeSCn6yV81Jipi6NIkDN4QT70W9iv1D7b3 IOGYRzdDHfj/BYXGsBipUz7+QRHZdtChk512wDU+2bMFIk/OhiCT4yf8682mnfUqrEWi gllmoM3KCWQ1iRRr5C5YrGcUp12tdTd9R2JgNlGoOd0ILk9mdUTloC3B9KwPnytZTEq7 fFdSFNNUSNICXsGkxG6LAip7M6cQACXICDHo2i7zYkjSEGYODCrzxWkiB5r8U4Z0mHwX eEXpo7NVFZGaB5Hm5TDI5eHdrRYtNLnOzICXdnghJdvEJGoMsRIg/SmNJZNdfa8L5jZk iEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386556; x=1793991356; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CARmoio7bFJMgAwfHhr6lkrU83o62HGa9/lgyZJ+P9Q=; b=Lk7nUcQjDIXUK3PvfNKntQ2gSDSsMRXWSWIq92j9xhaeBHH1rZQ/PejQwoipa9A1Ar Sd0XAEVW/g12Zw5hX4HVY7QJPWFNU7junwYouKQ4Ouq23YsNILg5iZzH9aetBB2uxSSr vaqrqq1gpZ5jIrLSayiM38kTDUm9P4juTy0nSU1dAYB6SgYXsHZFVwzFtL8n36H4jPkS IhADk8z44AyuOdj8aMRvsLRjlwUojPqyDL8/iGSyEUwUUUTzsJ1SsSHFQhRY5eFDAvAD QCIsNn0BgZMfTOHkUyVHL4hcQlo47D8qW2ByIUo9l8xylhklc3q7d7Z8BYUiBe0DAVDA 5Yow== X-Gm-Message-State: AFq9FYLYV4pX0eXGU1hR0DcBUpVPJPTXk5n3NftgjsDFiYVHyqKb5/fM tz3Ce8xUOqL290RvzLWiR1nfCv7f2ad4kySjGcC5ylLmBPexao0ru2KzOce6og6r1c5Lt7BXIEQ +/3ig X-Gm-Gg: AYBFou1QkWINraP4KshgqwY2+444kuH3tbloELwVUEDQ6xn5UCgQvUblfl7zHvPV58B EXlGvXFno93DBkevJrIrd8AHuQZsAsdOxja6zysCMC5BUFKDx9WZdPfPoONoaS7crEKJDS5gjGE /ArkmS4tUB9kDhwSZLyt3isE7h7X7bly4jWWGAdyabMbYicfQoDyFEkFuyUg954bp3TbYhDYGNk e18mv+nDlojEoNvjzFPAruIy9et7qlc2hW52CVQnV66bLWSizwT77JZxC3BV8rYWg809wsVJde0 Rnk14wkCqxHjnIOlCe+EM2wVeMlYC5XuGFEbWdVQi6f6IvFZ71A/E15+4isfznFXoIpp2DCn6xm nu0BBT6h5/P0IAy5tFNFB/ROstbNYb7xYCx4bef5Yh9Hp/8jcgVZnKDB0gla8MvSFabOKVtNiHf 0Rb3TgBZYbqSXD4qRk1zD9fkKXmqM8X4I8aimiSXSUpOR3ty7noTw5hvqrgVjCaRFdHNjGkD/Kc JU7qvX8EAuxwFE7736MW9dsMJkA9+GJPOglRnImQi6BIZfu31BVflWHVGO9+ZEKSi1FIX4x/4fd WaTnUEyEz0cSIvtye9uaysKK1Kd7lp0m0ReOWFwGRkCdS5HdxEILiB37 X-Received: by 2002:a05:690c:d88:b0:8b0:ac83:de9d with SMTP id 00721157ae682-8b2b6749586mr19919017b3.38.1793386556306; Fri, 30 Oct 2026 11:55:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 01/14] tcg: add tcg_gen_goto_jc{3}_{i32,i64,tl} Date: Fri, 30 Oct 2026 13:55:38 -0500 Message-ID: <20261030185551.193092-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112b.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: qemu development 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: 1793386624560154101 Content-Type: text/plain; charset="utf-8" From: Matt Turner At translation time the caller often already has the destination PC in a temp and knows the flags, cflags and cs_base any destination it may reach has to match because they are the same as the ones as the current block being generated. But the promise that the flags are known (or unchanged) is subtle. So add new entry points with new semantics and --enable-debug-tcg checks against get_tb_cpu_state() at run time. Signed-off-by: Matt Turner [rth: Split out target changes; add jc3 variant; expand via tcg-op-def.h.in= c] Signed-off-by: Richard Henderson --- accel/tcg/tcg-runtime.h | 4 ++++ include/tcg/tcg-op-common.h | 29 +++++++++++++++++++++++++++++ include/tcg/tcg-op.h | 4 ++++ tcg/tcg-internal.h | 2 ++ include/tcg/tcg-op-def.h.inc | 2 ++ accel/tcg/cpu-exec.c | 27 +++++++++++++++++++++++++++ tcg/tcg-op.c | 35 +++++++++++++++++++++++++++++++++++ 7 files changed, 103 insertions(+) diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 003c963bc7..b1755aae25 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -12,6 +12,10 @@ DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i= 64) =20 DEF_HELPER_FLAGS_1(lookup_tb_ptr, TCG_CALL_NO_WG_SE, cptr, env) =20 +#ifdef CONFIG_DEBUG_TCG +DEF_HELPER_FLAGS_4(goto_jc_check, TCG_CALL_NO_WG, void, env, i64, i64, i32) +#endif + DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) =20 #ifndef IN_HELPER_PROTO diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h index f80a895685..b16cee7860 100644 --- a/include/tcg/tcg-op-common.h +++ b/include/tcg/tcg-op-common.h @@ -100,6 +100,35 @@ void tcg_gen_goto_tb(unsigned idx); */ void tcg_gen_lookup_and_goto_ptr(void); =20 +/** + * tcg_gen_goto_jc3_i32() - dispatch to the destination TB via the jump ca= che + * tcg_gen_goto_jc3_i64() - dispatch to the destination TB via the jump ca= che + * @pc: temp holding the destination guest PC + * @cs_base: temp holding the destination guest cs_base + * @flags: the destination guest flags + * + * The contract is that the values provided inline are exactly the + * cpu state that would be returned by TCGCPUOps::get_tb_cpu_state. + * --enable-debug-tcg checks the contract at runtime. + * + * Using those values, the lookup may be done inline. + * + * Actually declared and defined via tcg-op-def.h.inc. + */ + +/** + * tcg_gen_goto_jc_i32() - dispatch to the destination TB via the jump cac= he + * tcg_gen_goto_jc_i64() - dispatch to the destination TB via the jump cac= he + * @pc: temp holding the destination guest PC + * + * Similar, but cs_base and flags are taken from the current TB. + * + * Thus the contract is that no cpu state changes have occurred + * that affect the translation block flags. + * + * Actually declared and defined via tcg-op-def.h.inc. + */ + void tcg_gen_plugin_cb(unsigned from); QEMU_ARG_NONNULL void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo); diff --git a/include/tcg/tcg-op.h b/include/tcg/tcg-op.h index a7d001c959..02732652b8 100644 --- a/include/tcg/tcg-op.h +++ b/include/tcg/tcg-op.h @@ -175,6 +175,8 @@ typedef TCGv_i64 TCGv; #define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i64 #define tcg_gen_dup_tl_vec tcg_gen_dup_i64_vec #define tcg_gen_dup_tl tcg_gen_dup_i64 +#define tcg_gen_goto_jc_tl tcg_gen_goto_jc_i64 +#define tcg_gen_goto_jc3_tl tcg_gen_goto_jc3_i64 #define dup_const_tl dup_const #else #define tcg_gen_movi_tl tcg_gen_movi_i32 @@ -299,6 +301,8 @@ typedef TCGv_i64 TCGv; #define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i32 #define tcg_gen_dup_tl_vec tcg_gen_dup_i32_vec #define tcg_gen_dup_tl tcg_gen_dup_i32 +#define tcg_gen_goto_jc_tl tcg_gen_goto_jc_i32 +#define tcg_gen_goto_jc3_tl tcg_gen_goto_jc3_i32 =20 #define dup_const_tl(VECE, C) \ (__builtin_constant_p(VECE) \ diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index da1b9c9bab..ae0a19a2f7 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -196,12 +196,14 @@ bool tcg_op_imm_match(TCGOpcode op, TCGType type, tcg= _target_ulong imm); #define TCGV TCGTemp * #define TINT int64_t #define TCGv_ptr TCGTemp * +#define TCGv_i64 TCGTemp * =20 #include "tcg/tcg-op-def.h.inc" =20 #undef TINT #undef TCGV #undef TCGv_ptr +#undef TCGv_i64 =20 #undef DEF1 #undef DEF2 diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc index c9caab2138..accff4a781 100644 --- a/include/tcg/tcg-op-def.h.inc +++ b/include/tcg/tcg-op-def.h.inc @@ -32,6 +32,8 @@ DEF2(ext16u, TCGV, TCGV) DEF4(extract, TCGV, TCGV, unsigned, unsigned) DEF4(extract2, TCGV, TCGV, TCGV, unsigned) DEF3(eqv, TCGV, TCGV, TCGV) +DEF1(goto_jc, TCGV) +DEF3(goto_jc3, TCGV, TCGv_i64, unsigned) DEF3(ld, TCGV, TCGv_ptr, tcg_target_long) DEF3(ld8s, TCGV, TCGv_ptr, tcg_target_long) DEF3(ld8u, TCGV, TCGv_ptr, tcg_target_long) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 4497701486..cf690e0e11 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -407,6 +407,33 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) return tb->tc.ptr; } =20 +#ifdef CONFIG_DEBUG_TCG +/** + * helper_goto_jc_check: check the contract of tcg_gen_goto_jc_*() + * @env: current cpu state + * @pc: the destination pc the caller passed at translation time + * @cs_base: the cs_base the dispatching block was translated with + * @flags: the flags the dispatching block was translated with + * + * A goto_jc looks the destination up on the caller's @pc with the flags a= nd + * cs_base of the block doing the dispatching, so all three have to be what + * get_tb_cpu_state() reports by the time the dispatch runs. That is a + * property of the translator, not of the generated code, so check it here + * rather than leaving a target that gets it wrong to be debugged as a blo= ck + * running with someone else's flags. + */ +void HELPER(goto_jc_check)(CPUArchState *env, uint64_t pc, uint64_t cs_bas= e, + uint32_t flags) +{ + CPUState *cpu =3D env_cpu(env); + TCGTBCPUState s =3D cpu->cc->tcg_ops->get_tb_cpu_state(cpu); + + assert(s.pc =3D=3D pc); + assert(s.flags =3D=3D flags); + assert(s.cs_base =3D=3D cs_base); +} +#endif + /* Return the current PC from CPU, which may be cached in TB. */ static vaddr log_pc(CPUState *cpu, const TranslationBlock *tb) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index fced3811c2..4f3cd9f082 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1854,6 +1854,41 @@ void tcg_gen_lookup_and_goto_ptr(void) tcg_temp_free_ptr(ptr); } =20 +void tcg_gen_goto_jc3(TCGType type, TCGTemp *pc, + TCGTemp *cs_base, unsigned flags) +{ + /* + * Widen @pc to i64 because the jump cache is keyed on a vaddr; + * for a 32-bit guest PC that is its zero extension. + * Note that cs_base is target-specific, not a vaddr, and always 64-bi= t. + */ + if (type =3D=3D TCG_TYPE_I32) { + TCGTemp *pc64 =3D tcg_temp_new_internal(TCG_TYPE_I64, TEMP_EBB); + tcg_gen_extu(pc64, pc); + pc =3D pc64; + } + +#ifdef CONFIG_DEBUG_TCG + /* + * The caller has asserted that no flags-affecting cpu state changes + * happened between this TB and the destination. Check it. + */ + gen_helper_goto_jc_check(tcg_env, temp_tcgv_i64(pc), + temp_tcgv_i64(cs_base), + tcg_constant_i32(flags)); +#endif + + tcg_gen_lookup_and_goto_ptr(); +} + +void tcg_gen_goto_jc(TCGType type, TCGTemp *pc) +{ + const TranslationBlock *tb =3D tcg_ctx->gen_tb; + TCGTemp *cs_base =3D tcg_constant_internal(TCG_TYPE_I64, tb->cs_base); + + tcg_gen_goto_jc3(type, pc, cs_base, tb->flags); +} + /* Host pointer operations */ =20 void tcg_gen_add_ptr(TCGv_ptr r, TCGv_ptr a, TCGv_ptr b) --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386585; cv=none; d=zohomail.com; s=zohoarc; b=XtPHhOt6wbMaSxxGkcHekpVjtTs4Ijqad1vpwLgJWpaadTJGUiNpNrZUOjsUb3hAwd3JSMnRlSXVgAWp3XqF2E9NBv0DqZtzHxq3IM+Lx9C0jd8OhrKVvVS7uqpmaq51vMOwhWuaBMTXx7+gIx2yD9FQbquHoqosElH82LSwSPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386585; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EyjEAsI6aq4Z4MAsWw4dQNTOpngWoSWPLuZe2/6GC+E=; b=WY43J9WcUGqd53R2IiCQM/1HchOb+sSAooXBH9Rl8aNm3jzEvJBXW677OluFk5PBrLYHfVyqf+kZQpG6TUSD6z+jETs2I24KIXC0HqZ2en4wfTeNYfiOMqWhiyNEvxByKiAAH37hPGDsonCAi25tYew53TnORU55zd8RpCZTXFI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386585433621.1965151997911; Fri, 30 Oct 2026 11:56:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrlr-0006s5-DT; Fri, 30 Oct 2026 14:56:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrli-0006rO-Lh for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:03 -0400 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlg-0004nM-18 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:01 -0400 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-8b0e21048f8so10201097b3.0 for ; Fri, 30 Oct 2026 11:55:59 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386558; x=1793991358; darn=nongnu.org; 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:content-type; bh=EyjEAsI6aq4Z4MAsWw4dQNTOpngWoSWPLuZe2/6GC+E=; b=Aw5KofhM6oI/K7bOzsDpeP9sWEXIbRTxGYteE0YZLojD2xD/t7Qeqm+yt6IN/pt7TG PaGz5YE0NFeGs7CY3gqHh69gcaUv0+LGPCEuZfNxiR3n+S5HH3XCa63kIiP3MKOLz5ic Z5qDkwJnOThbew2cyrRzIseDfuLzTHtLdAF6Lli2EtZEgov02OzZBCwjWu/mfmirs28o JOhdhhmcA1uoyWZzMitRulnJ+U09sX02wPwoqH9/2+mWI4FpnZiHZMlHV9O2FUlimU0v G/8JYNbsZYuJlV3UbseTWxMh22r70ZGiucScbT0M8TQ5qo4IKqanrpgEUmo+iVyToetq dFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386558; x=1793991358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EyjEAsI6aq4Z4MAsWw4dQNTOpngWoSWPLuZe2/6GC+E=; b=yqFfpaqUkjoPl+qXL/1eyLqN54ulKBl41mhlsGO7X75LsbmXt890bGKTp97yRl9Jic L3xaMD7KK5oZZ45hbzL+c0lc2KKN+msEtlbkmbNnQv3RzKGG/rRRukQ0fe+/2uS3PbsR 8CLNxyr26QeWbVV0blI5QvPnzo0wDFWrLN6o/vLnoG/NSnGdAVr+I+i/AcE9vz+rlCqx PoIaOmQ3qK+HOsb/KpULdPdq8tVkbcIJc2BwWylH9JAhI/Z6d3XmigEc+D18rIiF4ECy tPVf0lIXPMYAbVvlvy5KNXOJNlMRjx6inShHSIOVSYNJ/r0b9dRRsby8UrxlpqoNKoea s12Q== X-Gm-Message-State: AFq9FYJaPAXha8LaBiCBv7mA5Fh0o6h8Wt8m5LiwgAxGgij5wT+/e2NV sP+U1n8WCoc62n9ybU8DP0qZX3zf/ibXAjNGne0AI88SDWBuJmviIihtXN4iZXIEqBqPl1DwR6w YlpTK X-Gm-Gg: AYBFou2Qe7EUCy0JSnRI+hIjfrv6b2efKx6t12GAQFHQZNlPlNLSs4SReHHB3czFaJg sy1hTvIEyFxg1e6T24NaPqiN7oPZwqxbegljVHOmgaIBKRMuO6PXHhy/2kTGvnfXflfuD5I34/+ wnUIcjs9gz+TCIdC5hsJQE1zieJd4ugHvb9HtClmWyTigawKztTWqPUnRVioWIpyvdh5d36Qw6j Yt+p7Rw4wPGBVXhRqdUmlf1zEjBb39dM+E46H0Nze8M0acNPEbYrluCS/aqKip1dv/dV2BDjpbj 2nagsro6gFHQApN7Mft3LfUOSAwlRhdsH2TkIZC72/n0Wn2zdrx93FRJzihgttDXugMIAgOB79w cLPGxBGaJn/dSIecBL9dv/pu+HHldD3q+XsRcwdIFOzpQ+KnbcZjwmkURPttkzi2Xnn2WiYwleo 3+5coo8dTxeDKyaMdnRRPlcxyiJ93O4KX/+8Eojd9NCn2SPbosbDVzFHzhTf9Mv0l6iDiZXak5h J/RiReB7b+xyaBzMu1VKF3lX89hF91x9a+PsvgSjIl/cjXTcKu4U5X0Clui2Q2V5I+nitZuOFMc zkO6HBkt7nR7+YjNi4P9ZcCf9VYXN9YsnBZc X-Received: by 2002:a05:690c:e64c:20b0:8b0:7e6e:3dab with SMTP id 00721157ae682-8b2b6710f0amr16171397b3.14.1793386558289; Fri, 30 Oct 2026 11:55:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 02/14] target/alpha: Use tcg_gen_goto_jc{3}_i64 Date: Fri, 30 Oct 2026 13:55:39 -0500 Message-ID: <20261030185551.193092-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112c; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112c.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: qemu development 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: 1793386587966154100 Content-Type: text/plain; charset="utf-8" We can use tcg_gen_goto_jc_i64 for direct or indirect branches, where flags are known to not change. We can use tcg_gen_goto_jc3_i64 in gen_call_pal where flags are known to change in a very specific way. Introduce DISAS_PC_STALE_NOJC as a case where flags are changing in an unpredictable way and must therefore use the runtime lookup. Introduce DISAS_PC_STALE_NOCHAIN as a case where we must return to the main loop. Remove DISAS_PC_STALE and use DISAS_TOO_MANY instead, as they wind up having the same semantics. End the translation block when setting PS or FEN, as they represent changes in tbflags. This avoids a subsequent insn incorrectly chaining via the jump cache and failing the assert. Signed-off-by: Richard Henderson --- target/alpha/translate.c | 60 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 6f18b8d1af..ecb4ac4b02 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -80,9 +80,10 @@ struct DisasContext { /* Target-specific return values from translate_one, indicating the state of the TB. Note that DISAS_NEXT indicates that we are not exiting the TB. */ -#define DISAS_PC_UPDATED_NOCHAIN DISAS_TARGET_0 -#define DISAS_PC_UPDATED DISAS_TARGET_1 -#define DISAS_PC_STALE DISAS_TARGET_2 +#define DISAS_PC_UPDATED DISAS_TARGET_0 +#define DISAS_PC_STALE_NOJC DISAS_TARGET_1 +#define DISAS_PC_STALE_NOCHAIN DISAS_TARGET_2 +#define DISAS_PC_UPDATED_NOCHAIN DISAS_TARGET_3 =20 /* global register indexes */ static TCGv_i64 cpu_std_ir[31]; @@ -449,7 +450,7 @@ static void gen_goto_tb(DisasContext *ctx, unsigned tb_= slot_idx, int32_t disp) tcg_gen_exit_tb(ctx->base.tb, tb_slot_idx); } else { gen_pc_disp(ctx, cpu_pc, disp); - tcg_gen_lookup_and_goto_ptr(); + tcg_gen_goto_jc_i64(cpu_pc); } } =20 @@ -1096,8 +1097,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, = int palcode) } =20 /* Allow interrupts to be recognized right away. */ - gen_pc_disp(ctx, cpu_pc, 0); - return DISAS_PC_UPDATED_NOCHAIN; + return DISAS_PC_STALE_NOCHAIN; =20 case 0x36: /* RDPS */ @@ -1148,6 +1148,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, = int palcode) tcg_gen_ori_i64(tmp, tmp, 1); } else { st_flag_byte(tcg_constant_i64(1), ENV_FLAG_PAL_SHIFT); + ctx->tbflags =3D deposit32(ctx->tbflags, ENV_FLAG_PAL_SHIFT, 8= , 1); } tcg_gen_st_i64(tmp, tcg_env, offsetof(CPUAlphaState, exc_addr)); =20 @@ -1156,7 +1157,9 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, = int palcode) palcode & 0x80 ? 0x2000 + (palcode - 0x80) * 64 : 0x1000 + palcode * 64); - return DISAS_PC_UPDATED; + + tcg_gen_goto_jc3_i64(cpu_pc, load_zero(ctx), ctx->tbflags); + return DISAS_NORETURN; } #endif } @@ -1191,8 +1194,7 @@ static int cpu_pr_data(int pr) =20 static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv_i64 va, int regno) { - void (*helper)(TCGv_i64); - int data; + int data, ret =3D DISAS_NEXT; =20 switch (regno) { case 32 ... 39: @@ -1202,17 +1204,16 @@ static DisasJumpType gen_mfpr(DisasContext *ctx, TC= Gv_i64 va, int regno) break; =20 case 250: /* WALLTIME */ - helper =3D gen_helper_get_walltime; - goto do_helper; - case 249: /* VMTIME */ - helper =3D gen_helper_get_vmtime; - do_helper: if (translator_io_start(&ctx->base)) { - helper(va); - return DISAS_PC_STALE; - } else { - helper(va); + ret =3D DISAS_TOO_MANY; /* i/o insns must be last in tb */ } + gen_helper_get_walltime(va); + break; + case 249: /* VMTIME */ + if (translator_io_start(&ctx->base)) { + ret =3D DISAS_TOO_MANY; /* i/o insns must be last in tb */ + } + gen_helper_get_vmtime(va); break; =20 case 0: /* PS */ @@ -1236,7 +1237,7 @@ static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv= _i64 va, int regno) break; } =20 - return DISAS_NEXT; + return ret; } =20 static DisasJumpType gen_mtpr(DisasContext *ctx, TCGv_i64 vb, int regno) @@ -1264,12 +1265,12 @@ static DisasJumpType gen_mtpr(DisasContext *ctx, TC= Gv_i64 vb, int regno) case 252: /* HALT */ gen_helper_halt(vb); - return DISAS_PC_STALE; + return DISAS_PC_STALE_NOCHAIN; =20 case 251: /* ALARM */ if (translator_io_start(&ctx->base)) { - ret =3D DISAS_PC_STALE; + ret =3D DISAS_TOO_MANY; /* i/o insns must be last in tb */ } gen_helper_set_alarm(tcg_env, vb); break; @@ -1287,10 +1288,11 @@ static DisasJumpType gen_mtpr(DisasContext *ctx, TC= Gv_i64 vb, int regno) =20 case 0: /* PS */ st_flag_byte(vb, ENV_FLAG_PS_SHIFT); - break; + return DISAS_PC_STALE_NOJC; /* flags updated */ + case 1: /* FEN */ st_flag_byte(vb, ENV_FLAG_FEN_SHIFT); - break; + return DISAS_PC_STALE_NOJC; /* flags updated */ =20 default: /* The basic registers are data only, and unknown registers @@ -2289,7 +2291,7 @@ static DisasJumpType translate_one(DisasContext *ctx,= uint32_t insn) /* RPCC */ va =3D dest_gpr(ctx, ra); if (translator_io_start(&ctx->base)) { - ret =3D DISAS_PC_STALE; + ret =3D DISAS_TOO_MANY; /* i/o insns must be last in tb */ } gen_helper_load_pcc(va, tcg_env); break; @@ -2905,12 +2907,16 @@ static void alpha_tr_tb_stop(DisasContextBase *dcba= se, CPUState *cpu) case DISAS_TOO_MANY: gen_goto_tb(ctx, 0, 0); break; - case DISAS_PC_STALE: - gen_pc_disp(ctx, cpu_pc, 0); - /* FALLTHRU */ case DISAS_PC_UPDATED: + tcg_gen_goto_jc_i64(cpu_pc); + break; + case DISAS_PC_STALE_NOJC: + gen_pc_disp(ctx, cpu_pc, 0); tcg_gen_lookup_and_goto_ptr(); break; + case DISAS_PC_STALE_NOCHAIN: + gen_pc_disp(ctx, cpu_pc, 0); + /* fallthru */ case DISAS_PC_UPDATED_NOCHAIN: tcg_gen_exit_tb(NULL, 0); break; --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386706; cv=none; d=zohomail.com; s=zohoarc; b=PK5ty4nk15btFPjKv1P6i29QsAbkdO/+R+uVqOJ/Q2C9OUSczv98ocweT7V+xW9YKjwkzNGJ6lLu2gpllZIl+VdntaVKMoXBleZXplk/wM6id+z9N9BF4p2mlj4bpZhCfEl/+0+unNntPbnQr3jpUaO0PyCoetWttBqbx2acKdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386706; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iVMFpH/aq+G7a/y6geHD1weiXzxXQjxEl9EYUq2K0ZI=; b=NLhhhYigsH5svJxtHCrwCq8Qcr3aLwKhy/qgVVO9pxsPdo0bHNES75fe4nLHgTbxD40poTsu537TIWC/qXJuxmkQ3fiwGaxjWKsuOrdC21Z4Vqn7LOAXTEd78HxCJY0xlWXL8PRNdD35rssarG1fxKoJzEmIHij9OCTfke/FJv8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386706832361.00982888805527; Fri, 30 Oct 2026 11:58:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrm6-0006uv-HF; Fri, 30 Oct 2026 14:56:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrli-0006rV-PG for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:04 -0400 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlh-0004nZ-9m for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:02 -0400 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-8ab43af5e97so13182647b3.1 for ; Fri, 30 Oct 2026 11:56:00 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386560; x=1793991360; darn=nongnu.org; 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:content-type; bh=iVMFpH/aq+G7a/y6geHD1weiXzxXQjxEl9EYUq2K0ZI=; b=zmET4IIQlKmZT8vOBDebmAV7BZ1hRR4NVX6fN8WjSsurgrzgZNhrQS9A1AJCZOIXuO /P3Zmls8K2MF5wC2j8dghfM5tToFitqN/M5GauyHRzXPJ7dj4gay6SwpULlJfBcU5Dgw rP38cwAdUf+9njHhhVl81TyfPHa9zWFsXavhvIvc8Hh0kP4I81/qpTxgOjmRpwFs82cK rcMjyy91BwMSGXB5DbqU6HJxYbtZ4LNNy/ywQqkNDpoM73itzRumNuH/7HuttQgEmXvO +IsGHwk82JYl+3aeYcHU+Mipf8AZ0NL/UtHTbCavBCVnyh7tiv+SKDGOueUUmOjQgVF5 hTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386560; x=1793991360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iVMFpH/aq+G7a/y6geHD1weiXzxXQjxEl9EYUq2K0ZI=; b=OeTO85SIg/2lz/uf4noxh0fL3mHwEMkLUCdHDbVXK9oVP586DJtqX/6rLbWZsNChym H4KquU4Mf++XnEAIpC0c7C0Se3rhdvUtCySWYVgrbqkedfeusYE+jgRVi38AttWBciQq ypeX+CalU5a6FXYzpn8k2/xn4zxrr4a8sfhS6tePOc6Qh076lTuB/CewLzcdhmi7ebYj QHCStNcYVV7x0eScvd2YTdGvKBx7za4niic1MecsPF2nNKTzcXsO79NpgUy2KUTvsZLh fwe+apVunVuQBWLsDu8xcLy3x7LS6CvHQRiiHqziVxwpcZQ2pcvHKrptUy+vto+jEZm7 kFBQ== X-Gm-Message-State: AFq9FYIQmBciZ2yGFb3Xf26XEo/rOxdudoNC9wGy3eIBNvSNp19Bzx9t OFeyWCRI18XDCNQe9R5kGTrBCd6NTVlNrz3o5POKWaeLT/sjChx0UJ/eSsizlabjSEc5KxZCeQG 8m2fX X-Gm-Gg: AYBFou0Depu8jloXFjZX7xgHPe18eUlHYCXix7MYoPBs5ZCN/gCBp1ibL8eoVThytWd p1ge4HXyyPsFsMYPptIRMJ9NRpJyLkrVxqqDbDXyWXcSnLCsagSNrapB1fEIiinNcoHERmYQxJh fagWUnmpHV1V3dlYUgngLbW0aehebGY99e5SY98wLHo7gWNxA/rC5Xheee+Lpv+PerPyR/OSUnk hZNr8+8yAXuEjvMAB1WVnaLTEKwb+TIjDl47UCqBu77ReK8oOFf6jYhoZK+sgmnVeJS3DEtVrTo JukSkWDAKukV3kMkJIf7+LqnlJZNOIdgceBS2rNPiweujyVwpDluQ0IoOMSd7lOxG6eKl+GOllv 17t0YfhIZ3348kVbzLzpuuYt1XPNXRCbWb3xmoNUprMa0WPJcYMIBp+yoHIMUS+k3jOKMMjL4QN 6n76lHGqG5bvP9agq1y7OpwAV5QrLxHAoUK+1yKJZ8VATDYdEfHlw0fQ/r/SVdQobeULtT2suM2 7cT5A8ytDuoJvsYUODrcBMKYo7fQjVmGwSYxwaMSQ5aGpqaL/px2SypotRcVzTvTbLu+icU6zSa 3qqFOt8P8idndi74/FmBIzKrOyjgSJ44AaU= X-Received: by 2002:a05:690c:6609:b0:8b0:bc8e:9d75 with SMTP id 00721157ae682-8b2b6756fb4mr20448277b3.22.1793386560051; Fri, 30 Oct 2026 11:56:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 03/14] target/loongarch: Use tcg_gen_goto_jc_tl for JIRL Date: Fri, 30 Oct 2026 13:55:40 -0500 Message-ID: <20261030185551.193092-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1130; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1130.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: qemu development 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: 1793386709522154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner Allow direct use of the jump cache for direct and indirect branches. Signed-off-by: Matt Turner [rth: Drop the change to DISAS_STOP for now. I suspect both uses should simply use DISAS_TOO_MANY.] Signed-off-by: Richard Henderson --- target/loongarch/tcg/translate.c | 2 +- target/loongarch/tcg/insn_trans/trans_branch.c.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tcg/translate.c b/target/loongarch/tcg/transl= ate.c index 124dce6269..b0ff1f7dff 100644 --- a/target/loongarch/tcg/translate.c +++ b/target/loongarch/tcg/translate.c @@ -111,7 +111,7 @@ static void gen_goto_tb(DisasContext *ctx, unsigned tb_= slot_idx, vaddr dest) tcg_gen_exit_tb(ctx->base.tb, tb_slot_idx); } else { tcg_gen_movi_tl(cpu_pc, dest); - tcg_gen_lookup_and_goto_ptr(); + tcg_gen_goto_jc_tl(cpu_pc); } } =20 diff --git a/target/loongarch/tcg/insn_trans/trans_branch.c.inc b/target/lo= ongarch/tcg/insn_trans/trans_branch.c.inc index da07778658..d4318dfa43 100644 --- a/target/loongarch/tcg/insn_trans/trans_branch.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_branch.c.inc @@ -27,7 +27,7 @@ static bool trans_jirl(DisasContext *ctx, arg_jirl *a) tcg_gen_mov_tl(cpu_pc, addr); tcg_gen_movi_tl(dest, make_address_pc(ctx, ctx->base.pc_next + 4)); gen_set_gpr(a->rd, dest, EXT_NONE); - tcg_gen_lookup_and_goto_ptr(); + tcg_gen_goto_jc_tl(cpu_pc); ctx->base.is_jmp =3D DISAS_NORETURN; return true; } --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386636; cv=none; d=zohomail.com; s=zohoarc; b=cqowDXXDiXcLVrHOd8PjuxL7Z2wPnARV3xgrQUgn8LTO44ESZhnJLi/lMVfTsk+BlErJLFUhgEr6c42mLPpOLRskiRnF0lOARsNWElTOneqG2xtrnZ/LL3ED8EdWfr3uDwB1utlK4TYwUZMS6JQwNjmssL9suuW9DtB6LBF0VZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386636; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pQAgIw/VpjhY7UIgTqdO5KMEmGk/zD26S1wrBERgqQY=; b=Z4ffzY0+Y0HcHjk52hHzu3+G3I2I07fGFudJ8anOfGNshXvGWZHky6YgNR5beRHi8Kl9AIgUofE5Zg97rYd9+3YdRvmFR2966I0fWUlmomTU8SwytOnX8bqr41BFCEAs08D120X+g3rdRWqdJSNMYrkCXBgVPvbrAbmGJQchuyc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386636891417.4482727073256; Fri, 30 Oct 2026 11:57:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrm0-0006tX-Pp; Fri, 30 Oct 2026 14:56:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlk-0006rZ-KB for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:05 -0400 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlj-0004nm-8N for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:04 -0400 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-8b118bea471so6253277b3.0 for ; Fri, 30 Oct 2026 11:56:02 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386562; x=1793991362; darn=nongnu.org; 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:content-type; bh=pQAgIw/VpjhY7UIgTqdO5KMEmGk/zD26S1wrBERgqQY=; b=JygeUbFaITHs4lb4jBl3QP4Mi3cgQlcz3HLYUQMSYny66Xqh7ntTFyW5v7IYrluY/L JnF5HabnhOU+y2HFCBp13REyClyvkyXW179B+v8i1ZjEajoIb/+pX9lCWmKH+TxnOSSQ xKUNYNwUTaZElXqXeOcA2qaVUCfoDPCSZw4GKM+Inswnui0ESdyUeXMbwYKyKYg8BeoW 1la209dT7Vza6Mis5QTUHm6gfDdGFtmD+44L7kK8/+PcNd1RZzYbLLmQCKPApN4ZORT2 XKY91Dtn3hcARhymBm6NxlqWI39hj9xAYzZIQ6uUZq0tvEYTTKhemxHTT1muw2x6LmXw GE4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386562; x=1793991362; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pQAgIw/VpjhY7UIgTqdO5KMEmGk/zD26S1wrBERgqQY=; b=OKaZ3cuNym9KNglbwkO6iSgi3jd9pBIk0/n5prddrWhx/j2ce9B7Kv/+Ykd2fba1xj AJDRBLSD0h5V2L2Wwc3ts6uJinHnIf7bURd/SCQvkYq0dA6CwincSKE4gbgUYctgVqzz pN1LD6UwobUjqRi7Xi+0ho1JnKar/x8mZHOhEbJMYoWAKXDV01LPb/D8MtOyZeMJNB4p ATP0aOk+jgnvsUA3RoeWN3FbDynwYUrhO95GvBK+xkKyfPVtrzoEQKyLB33ZhGomLFE/ axkKUCduHSWM888knAHosw+vc3iLRXsVBbWrxaQ1UVtTLwn7YtV0Na/i14PnmwGbCycf KlsQ== X-Gm-Message-State: AFq9FYJXpygPRhVch4Tbcw5Ia510260qYV3LJF3jZgtXy6F9qBPBn0Qx AUnnOhages4k4oJU8Nfi3aQuhZRcs1+ky/Tv27VPmTeUFm4en8AK3u4NM01nik3fzWH9Sc6q4LL OV3Z1 X-Gm-Gg: AYBFou1r2aAqLxVRmJ4rk1gKN2F3Y4ftshdZWIcRiCZ86xJ75FqELnXdeFMeN85Wgoy pqPk0wbcKNJpSkPzwdvt6+Ujvq+U2KxA4WoklKzyQMHpDbLT7Vaxid52Lae4ETdCaKmGkWJjmej 9B2RiOyzk4btgp8t7z2eKj4hFCi4JGf8GGPToL1xK8zu37wtKSXGGDTNXDcGZoUqjWPcuQn+V45 8pUfPIraLtuB+YbRfuvZH+yrZvztRtA9aSaR/T730iL3ZgqrJcdWt2Rr7lWuRY5+nE21LkKhHVq U1msQmFMj3LSkXusktnKEhPM7F11juVgzpMmeiUX2Kc7EFOUqCQhPhj1dD0LgTnmBJ5ohMk2dqm NUFQIgKSrSqLO9mTE29Az2BSS3GOadOVC1RyuMnAAggi2NGLxBtIbit14gJphBGnaVNlLQN7uMf ktELOdiNOierPU0NBdf5KyhoRr7IckyZ23v0th5VFBv8vUr6eHX9Vknsr9b62tZ2NYx/BcQDF5D kDsSrJDZ/Nr30Y8V8tNaWejVD51je1CupmiPxQoQlmfszGi5EwZ+zO1w0M/hz3jzOaW+HrBnfvm nzQL9bHro1raVQ9nARQl8Pm8ACwPHQz+AX4= X-Received: by 2002:a05:690c:fd3:b0:8ae:dfee:cd0d with SMTP id 00721157ae682-8b2b6723edamr21218807b3.35.1793386561644; Fri, 30 Oct 2026 11:56:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 04/14] target/ppc: Use tcg_gen_goto_jc_tl Date: Fri, 30 Oct 2026 13:55:41 -0500 Message-ID: <20261030185551.193092-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1134; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1134.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: qemu development 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: 1793386638474154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner The only instance of mid-tb flags change occurs with spr_write_40x_dbcr0, which already uses DISAS_EXIT_UPDATE. Therefore we can always use tcg_gen_goto_jc_tl in preference to tcg_gen_lookup_and_goto_ptr. Signed-off-by: Matt Turner Signed-off-by: Richard Henderson --- target/ppc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 467b8f3d4e..a99ab018b8 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2649,7 +2649,7 @@ static void gen_lookup_and_goto_ptr(DisasContext *ctx) pmu_count_insns(ctx); } =20 - tcg_gen_lookup_and_goto_ptr(); + tcg_gen_goto_jc_tl(cpu_nip); } } =20 @@ -5164,7 +5164,7 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase, = CPUState *cs) pmu_count_insns(ctx); } =20 - tcg_gen_lookup_and_goto_ptr(); + tcg_gen_goto_jc_tl(cpu_nip); break; =20 case DISAS_EXIT_UPDATE: --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386673; cv=none; d=zohomail.com; s=zohoarc; b=mmCInHiAPw/QXM99Hs1nuXjKdmSxDD73T/pW3nsYL629SFSeJY3U+8Oym/FIJlGGTEWchdji9nLvESeDwOKgzavH/0MXfprWnvxwFPxP0pstdcTF5bNI6R6tu8RvFK1hTNdDZyojuNpMPdkZvBHtVaDO+ucHSHlcPoxlnNY37VU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386673; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5vcJ8YC/IHF2rwvCfFaTnD7lBd6nhIEwffs2J1zl4ps=; b=eaLw3earYZy6ni3A0FS1KdoFsufX3cuKyBANelOUUowweqk0QVb6HmHxdsT1W7wfRwL5J2XeCji52affqo5WI02kHNtvHeo8X2fUBKUJlm0LGOHQ1foWqXJRx3tTiXopLfMqN7oOEj1cDXoPH4vk95m9GZg+Bz6mflU3W0yiAAg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386673966546.9044115456425; Fri, 30 Oct 2026 11:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrnN-00084x-8y; Fri, 30 Oct 2026 14:57:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrll-0006rv-W5 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:06 -0400 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlk-0004o7-BH for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:05 -0400 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-8a83d2706fdso9777187b3.0 for ; Fri, 30 Oct 2026 11:56:03 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386563; x=1793991363; darn=nongnu.org; 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:content-type; bh=5vcJ8YC/IHF2rwvCfFaTnD7lBd6nhIEwffs2J1zl4ps=; b=PMJ54SHVlLZJu44ynjukrmkmFk7/0ihVMQfEmjOOGWZ1PBeSx23XXXYiPPZgoBcJrb rDiuv2cl4OfE9tWc+IX0TfmvK01S7aKPRx612qRVZ/ISnUdYu2oIA8n9/YPw7XVeE0kv Zoy9DU85X/MaAZuy8oD70bxF2RTg7co1K6naYpmCbAuO5FjUlxJeOzpKgu3nIzbw9dqB TNWFXDF+WaF+fn8/bw//6DzaoXusUVk6ZXqKpyPioCnDEYFdD6hEipsYcMpopD0AupSu fx8LJVdV/VpzHa2qWgAGObjHkLUBcCZhVeuq6jhE23G+xPAwl88RgiTLbUskjMdEr6KG xIlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386563; x=1793991363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5vcJ8YC/IHF2rwvCfFaTnD7lBd6nhIEwffs2J1zl4ps=; b=2Cw6gRdcqQbG4me4WilyQWH/Q84/FpLRPHxTZZk58PmB2d13Lez4hj4vrhgmFJUAQD xhzIpexdAWIIvi0sSTVGhGh3/FfAgj2tb+optOB5OqdETdt6MC7DyHAkp2vUeed+/C5s d4u6k73s1ai4QidH/LmrSCjc/72S7AwaDjOFVzAEQc3DUGj8xbaHosCWHT78P95seiZy CZiB/05u5A1+Dt9jP0WxT1y2jQVua0GKrcbjK7zz1RqvrPsX+oDIjDjcSAGFECtamKNh cmt68SCV9GUUlW/T0vysm88JzLDyv0+Y1DjyKeZD7Oadw5flsyGRK9i+TY4ggoaf0LSF zJ9Q== X-Gm-Message-State: AFq9FYKmhMV+yY5VszafQtgI7eO78GaJqWxhX2qaDZFfU2b/uP5iwdeb IsESdlvai332UAejyuaw4A+eDIHaPa8cFbdFlQ+88Bu9YoC54C3PrwBNP3aqF1UAV2s8VYeP0EN s0vqI X-Gm-Gg: AYBFou0R5azhVSa1gpP9pAliVTHuWzS4hxgks5Na3z11HXdRdQVbMeHUCK4rrhZ+aSJ glVAw4nLewy6tNVLqPyLxTqeK3I32RAT/NUwNqJp6oC9KMJWDiYWUjaQVeJTMhykY7h76M34Ktk g3rxX2THOhVfDIoNQt1v6kohDkZqMcnonjEjEDDNCdfu1dlseRJWxb0NFOEknn8qA50U0eFFbuY 6kzqt7B9U1r2sMbdympWgwmPa5eO44r1EaBnYAK6pqrD//qBfN5k+SFYgjm+fo0bm4Tdw4rXtqp zdC26D01fibJW2u5XAW3a4nPT9CQ71UBjRVxfKcrFP6BQc+IuZ6XoyeAQEdxYh+RKohVTG10AhL rVUY/dcuG2LOBDjY5QQhlnCdfWmzBF+r0jjKHYM4c/YCOZK6dMWkiigZNI7v1ZK3rPxzehEGgQl /XXEEtBnaJTYjKpwwKU/CGJFrAZbEI4SwnnizW4Nw/oUlGCuJ953qYdF4WMJsKoxvrw1P+RBlPV dIWxPYHCb5d02bdb/4UBi4sPkXdeghyAYAfQCkL3bzjBY0LG5xu2GSNrWx6BJv+kK9QJP1XHzVn effY2Hxi+Fsj+bQp+lgVlSMFAMRNYx4fl70= X-Received: by 2002:a05:690c:e0d4:10b0:8b1:691f:ab4d with SMTP id 00721157ae682-8b2b66e9a38mr11817957b3.35.1793386563044; Fri, 30 Oct 2026 11:56:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 05/14] target/s390x/tcg: Remove DISAS_PC_UPDATED Date: Fri, 30 Oct 2026 13:55:42 -0500 Message-ID: <20261030185551.193092-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1136; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1136.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: qemu development 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: 1793386677083154100 Content-Type: text/plain; charset="utf-8" This value is unused. Signed-off-by: Richard Henderson --- target/s390x/tcg/translate.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index ce55edb93a..3a29555605 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -1025,11 +1025,6 @@ typedef struct { =20 /* Return values from translate_one, indicating the state of the TB. */ =20 -/* We are not using a goto_tb (for whatever reason), but have updated - the PC (for whatever reason), so there's no need to do it again on - exiting the TB. */ -#define DISAS_PC_UPDATED DISAS_TARGET_0 - /* We have updated the PC and CC values. */ #define DISAS_PC_CC_UPDATED DISAS_TARGET_2 =20 @@ -6397,10 +6392,6 @@ static void s390x_tr_tb_stop(DisasContextBase *dcbas= e, CPUState *cs) break; case DISAS_TOO_MANY: update_psw_addr(dc); - /* FALLTHRU */ - case DISAS_PC_UPDATED: - /* Next TB starts off with CC_OP_DYNAMIC, so make sure the - cc op type is in env */ update_cc_op(dc); /* FALLTHRU */ case DISAS_PC_CC_UPDATED: --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386697; cv=none; d=zohomail.com; s=zohoarc; b=QI/8YlshE1Fp5xt81SiH6fTwtrSswRyFAlfbv8Q4gpVadcUjGugOIzotZDqnrh8uHRc+bDyjYyfoSAyMwVjR5kKpX8evKh7rNZYFAfLJoMiDZE0YlssaEMpQ5NVnWm1pCib9rtkQvumRHUrqlqyb47LJcT5sFNGmCYmvfj+HfHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386697; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=snPje9eTvXO8WBl9g3A/YZtenSR0D0gyFjZLY0cCXkA=; b=hUYX3nWmgVpPpDEaPjinm1l9amwz1e0aosFdNBfT0HppHD6gYPEiD6Hrz2TUbuDj5NTf7mUgjkUrrJdVh9Uwxa67wbT7pTV3vCSr5zvKrbVtmZ4hEG2uoP8UUMmt/RkC4bvUIN9VsGJ8M65vYc+WCDv8pWQbrGumOovHsIrolzg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386697914856.7337418498495; Fri, 30 Oct 2026 11:58:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrm6-0006xw-KM; Fri, 30 Oct 2026 14:56:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrln-0006s9-5l for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:09 -0400 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrll-0004oJ-O3 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:06 -0400 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-8ae8607e8afso8576697b3.3 for ; Fri, 30 Oct 2026 11:56:05 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386564; x=1793991364; darn=nongnu.org; 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:content-type; bh=snPje9eTvXO8WBl9g3A/YZtenSR0D0gyFjZLY0cCXkA=; b=iacgTs0lnxo0ClmV0QWQ/QeVxa3zvHS8pIUjKT+46noTDd7D/qlsOFiYx6fi6UXTqy M7/xFQycRwgA7ySMKQ87PP2itsXZj0zKI4PPHN1rJ5L3I/UH8D0pVE2DKdV0O6q/BFkR QTbfI1v/q/qKTyii+4F2GwPOz+kbuwIfb3qapYiQ8U7PkYQj36sSH7dmLMEMwdlLCeai mhNizt8EOtk7c/Exgdgc3IOtJjormsUg3EYo4lGmcfV1CPa6dfgMsE6SzrQaEZH9khS0 kkyMKiuvo4kcQobOraNC3M32AE49n52ytJTcsmRer5aYH5HMI+vxCmlY4fP+Am2F6xAb afIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386564; x=1793991364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=snPje9eTvXO8WBl9g3A/YZtenSR0D0gyFjZLY0cCXkA=; b=AMfDTvMlWqRpnIvdeWc96+LqadpPda4bASmjXffuSP2e/hK7iiwLLtyzI4e71oyjN+ xzXfbYpOZ6vzy17dt12sC2raeIizRc0lqt+zvVZzzX3jIcG5O/gHepJaqBDyRkdiUjRa qmRnKZP7RJ9UHe2SAzrR9S8INtj2FAig0/A2AaBJLT8IT8jRdQ0AUPV//8ni2A6s0ISK Np+JxBAk/ArjO1dtxp0H5zmh80mXFus7ELqbf867E2ud3athbT52J65veBhFBRrJ/FXD BWKQkLIIN3nABzzF76gUE0wYsogZLIZOt1oJ9KZA9iY+sufCInr3Whr9zqK5QHZ6nnOq 0DIQ== X-Gm-Message-State: AFq9FYKBY5fwSK9cqHGoDWoqBW7oiakb8nC2vzYVPv2qXAnKjTq/Xrj4 QvIkwnSAn82kv43ec9KUyiPFSg4HQCIgzL461bIsEv5tf4PPwz0GIDE3mokEcUvG6YPmN0XwNxu JQkug X-Gm-Gg: AYBFou1/8mm1TwDyx2GgcXJw1irKqOSx84E1/DsoQmOvSgeMOoMpy0bRZSXAvYhpqW+ nrNGp6bNQxoCIFoZqdolBCbunwwG3fHT6Bn1lYJ973K51Q8QE8NerM+w/UXSwz4qjWrDfudOAVn roeZ977t/Vq9uivq2GvLztHTPxk+ISs7JqDqkOSqX1fpF8epjd+xZfFomwbdJnvzn+MWQx1pWT+ hdBB+bIH8i7qMycdzvTdwSb2fyvl/s5Zy+hnR3+YV/485yMBdBseOhVlmYVyOON5qlA3eBV/Vss giUP5jxQ/koDmXugfOjJ0lyExmMvJrTAzAp7ybH7LOOm3HqKrKDNA+1UKkOAmWiroDvXcne36hA 7yWWH/npi9C6INAGmG1Qnp4XRHef2/WOzfHkML4m0W5ssMYy0/rlVVYwd9gO6hpX8esOLYXztJ9 5z8phGNQ09i8BjtyQ+IEY1ABnfCt0Bo4haJHt2xLHdOoOzYT5T2T57gznIizqpp6oW2cU8jNTg2 wy4x1D+0T1LImEKxNeWoZadKz840XQyZSJlu7ryD23vj3czKbd5AagmeZ6A2y053k9z8Vtp6dCx YUecCgqzbxzAWggt4KbTh85mZV0AIYzf/34= X-Received: by 2002:a05:690c:289:b0:871:bc3:9856 with SMTP id 00721157ae682-8b2b672fd3bmr15544327b3.33.1793386564590; Fri, 30 Oct 2026 11:56:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 06/14] target/s390x/tcg: Use tcg_gen_goto_jc3_i64 for branches Date: Fri, 30 Oct 2026 13:55:43 -0500 Message-ID: <20261030185551.193092-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1136; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1136.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: qemu development 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: 1793386699395154100 Content-Type: text/plain; charset="utf-8" Introduce gen_goto_jc as a helper. Use it instead of DISAS_PC_CC_UPDATED or tcg_gen_lookup_and_goto_ptr within help_goto_direct, help_goto_indirect, and help_branch. Always return DISAS_NORETURN from those functions. Do not use goto_jc elsewhere as yet. At least op_ex, op_sacf, op_sam require other updates; icount and PER_IFETCH want to use goto_tb not goto_jc. and PER_IFETCH needs some TLC. Signed-off-by: Richard Henderson --- target/s390x/tcg/translate.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 3a29555605..685628789f 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -638,6 +638,15 @@ static bool use_goto_tb(DisasContext *s, uint64_t dest) return translator_use_goto_tb(&s->base, dest); } =20 +static void gen_goto_jc(DisasContext *s) +{ + /* + * ex_value, aka cs_base, is only ever live at the start of a TB + * and is immediately cleared. It is only ever set by op_ex(). + */ + tcg_gen_goto_jc3_i64(psw_addr, tcg_constant_i64(0), s->base.tb->flags); +} + static void account_noninline_branch(DisasContext *s, int cc_op) { #ifdef DEBUG_INLINE_BRANCHES @@ -1082,11 +1091,11 @@ static DisasJumpType help_goto_direct(DisasContext = *s, uint64_t dest) tcg_gen_goto_tb(0); tcg_gen_movi_i64(psw_addr, dest); tcg_gen_exit_tb(s->base.tb, 0); - return DISAS_NORETURN; } else { tcg_gen_movi_i64(psw_addr, dest); - return DISAS_PC_CC_UPDATED; + gen_goto_jc(s); } + return DISAS_NORETURN; } =20 static DisasJumpType help_goto_indirect(DisasContext *s, TCGv_i64 dest) @@ -1095,7 +1104,8 @@ static DisasJumpType help_goto_indirect(DisasContext = *s, TCGv_i64 dest) per_breaking_event(s); tcg_gen_mov_i64(psw_addr, dest); per_branch(s, psw_addr); - return DISAS_PC_CC_UPDATED; + gen_goto_jc(s); + return DISAS_NORETURN; } =20 static DisasJumpType help_branch(DisasContext *s, DisasCompare *c, @@ -1157,7 +1167,7 @@ static DisasJumpType help_branch(DisasContext *s, Dis= asCompare *c, tcg_gen_goto_tb(0); tcg_gen_exit_tb(s->base.tb, 0); } else { - tcg_gen_lookup_and_goto_ptr(); + gen_goto_jc(s); } =20 gen_set_label(lab); @@ -1167,9 +1177,10 @@ static DisasJumpType help_branch(DisasContext *s, Di= sasCompare *c, if (use_goto_tb(s, s->pc_tmp)) { tcg_gen_goto_tb(1); tcg_gen_exit_tb(s->base.tb, 1); - return DISAS_NORETURN; + } else { + gen_goto_jc(s); } - return DISAS_PC_CC_UPDATED; + return DISAS_NORETURN; } =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386639; cv=none; d=zohomail.com; s=zohoarc; b=NlDVbi0KDd4PxKt2fTamKn4kx3AClUOsPcss/JOPk5V9eiaEzMBrl39SuV5ZYrh7eq7tBNxJp0V3S0+f4ZJfugA+mCUkyZZlSa703lZ2ynshtrFNwONmur9vw9RupdtIy5eX+rKOJTk9IN+g7TLqPWNj+clQNVr1BwWLXecxHh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386639; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q7yVmOjDkEbe0BVZGoC/5nOMtAyC/kW47+ufduY/aMM=; b=OggU/UAVCvIq70xI/Nt21bcJagjPGE4uB/qxMIvwDF/t0EiwmWlahvDfok8Sd9j1qW0rx0GvVrCwgcDefX7HH836ORO7UcQJnqNQIE7SoXwe8H69xuTh+hDrX6pDObteJ08J+H6+d/E3Ge5ZEAAw78yiIIDu/ovo0Njar3eV928= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386639322132.19808890937998; Fri, 30 Oct 2026 11:57:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrmH-00070o-Ec; Fri, 30 Oct 2026 14:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlp-0006sL-C2 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:09 -0400 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrln-0004oa-6o for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:08 -0400 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-8b0f59a5fdeso9413537b3.1 for ; Fri, 30 Oct 2026 11:56:06 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386566; x=1793991366; darn=nongnu.org; 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:content-type; bh=q7yVmOjDkEbe0BVZGoC/5nOMtAyC/kW47+ufduY/aMM=; b=ysIc9DpuAUX8XtE+nB4aZ8Dp1uYjKsPiQqBzljl43VP7QH8GNG/qjZfr6MPvQHapOQ f1biuTkyb2RIpH7v1F7MProelc7nmEuDr+wzGa8aD83KanDrE6YclxleOhRQymc/0ijY LnPYhEUNWAGM5iZK7rq0Pc55SucTO4B2PeLb14cxyKhtEp3Oeo7WPjePVqAzZg48sLLc 1DmlEHt8nFREk7ks5fMdnwEt/CbkefdPpCCae3FozkEgJWLXJOHgsKC/jr71JMiQhXus vJjXR8qp0XWuRqMp2lq0Lk4xMyh/NwGN4wMJ4MqUE9y0EULHRUZ1cWqTYVl5ApVgyNEe A7Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386566; x=1793991366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=q7yVmOjDkEbe0BVZGoC/5nOMtAyC/kW47+ufduY/aMM=; b=QYtQnlIMxw3Rg8XkhIT4jpxRRfQXmiTSFLyYn4SdhZQ/ECM6Z7Ioy7ZoGUBKXAk/G+ Lrlfrs9TSy9ukR9KCNS3mvkblVOzPQrokJcL8sPGc1LbRQpeRUaIyPhbAPK27gJ7BAjN bJZW/VGg66FLT/RtWq2JbssU6pVj9RXbbjCtz2RWDRs2VP+7MCesi1oe77N6isXEWVc4 5kMMEv43LQ1CmL72+zD63x3RamJ909b/fRYL5QY67hSyV/K9tQGlgCwQiLsNxLkhZCZV oWR98UhrL+aYkPXy+magk8D7rgiKpz46WBPP/Ub8gFODK3Uj4L56JHfkx79exvXXN+eg LrDQ== X-Gm-Message-State: AFq9FYJH1Y0mzJ+XcqcSmkHOrr7SUhCeZJqjn1CXgS+3oYVSowp6cLpT veLlZFlnMAnUZIz1fZu51meYbsOvsCdq8R/Vsnk7MgHt+NEVyPP879Rzf4ECRCwgtY30hTgZhM8 08nRh X-Gm-Gg: AYBFou07GEKZgfOk3xH51wQtej2X4tsfoZrYZoTzRecBtG+p/iM2LsPEaKnHFO3Zc6M GZlu79VKACqxpDp6jq1yTqp8Vmz2TPOY9vnXs7jLVMs/vbXUkvWoxa2FcDwYw0LcqWDAHG+fmPR 86tv6vZq+ZHiSvXRq2y6Y2iEPIVFZ17wZwkq3hu3Jeu0KGi7irF2YYlGRsazb3hJ3iRGT0arrs+ Ci+rttPfB9ynH/t2bupqTvxwjliwSgTRni91kKU868Ha9Tk1NOgcQE31G5PW7YbFfhXZ1mAnbQe xPhT8Af8mDadEdeRWNNZLAW58Cw8tRLK0pZJ4YVpHzeGYAB5l3xopWi5RAErofZfoLDp6/V7x/S 31k6dqe7YxXq9lxb99HIZ7FCzxkCRXar8fT0a4wBrHppvJbwzxbjtNbqEGFJBeSGAYX8zEUNUfm Lq3rV5ldVnBz9+szCvbUznqEoh/5bfCQmOpyplE5LEkNNwAbwajPfzF6Sp9BQN94fAKhJPFQzy8 nAEK21y7IJ+R6JT3ZGalsO8NOOECkfqEIGj6z3Q3K4tCj3j/MJqpSLZ7El7TiV/9X9YipIBP2eJ DUpbjLQDyINZEcaX5E9PCZKLRLlJXqjnLsg= X-Received: by 2002:a05:690c:348a:b0:88f:df4:1c8e with SMTP id 00721157ae682-8b2b66c5d61mr19291407b3.22.1793386565880; Fri, 30 Oct 2026 11:56:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 07/14] accel/tcg: add CF_NO_GOTO_JC, set while a breakpoint is present Date: Fri, 30 Oct 2026 13:55:44 -0500 Message-ID: <20261030185551.193092-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1131; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1131.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: qemu development 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: 1793386639868158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner The next patch dispatches a goto_jc by probing the TB jump cache from generated code. That probe cannot check everything helper_lookup_tb_ptr() checks, and the one that matters is breakpoints: check_for_breakpoints() raises EXCP_DEBUG on an exact pc match and selects CF_BP_PAGE cflags for the rest of the page, and inserting a breakpoint deliberately invalidates no TB. The probe compares the destination's cflags against the cflags of the block doing the dispatching, and only takes the destination when they are equal. So a cflag is all that is needed. Add CF_NO_GOTO_JC, set it in CPUState::tcg_cflags while cpu->breakpoints is non-empty, and blocks translated from then on both decline to dispatch inline themselves -- the next patch makes them emit the plain helper call -- and are unreachable from blocks that do, because their cflags no longer match. The two ends of the flag are cpu_breakpoint_insert() and cpu_breakpoint_remove_by_ref(), which are the only places the list changes. Both already run either on the CPU's own thread or with it stopped, or reach another CPU exactly as cpu_single_step() does, which is where the previous patch put the same kind of update. That leaves blocks translated before the breakpoint was inserted, which are still live and still chain to each other. They do so on the old cflags, so inline dispatch among them keeps working until the vCPU reaches its main loop, which then looks up with the new cflags and translates afresh. In system mode gdb inserts breakpoints with the vCPUs stopped, so there is no window at all. In user mode the window is the one goto_tb chaining already has: a chained direct jump consults nothing either, and is not broken by inserting a breakpoint. Nothing reads CF_NO_GOTO_JC yet; the next patch does. Signed-off-by: Matt Turner Signed-off-by: Richard Henderson Message-ID: <20260901034808.3524945-6-mattst88@gmail.com> --- include/exec/translation-block.h | 5 +++-- accel/tcg/cpu-exec-common.c | 13 ++++++++++++- accel/tcg/cpu-exec.c | 2 +- cpu-common.c | 27 +++++++++++++++++++++++++-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/exec/translation-block.h b/include/exec/translation-bl= ock.h index 5a7a638b08..4406db5ab2 100644 --- a/include/exec/translation-block.h +++ b/include/exec/translation-block.h @@ -76,8 +76,8 @@ struct TranslationBlock { #define CF_COUNT_MASK 0x000001ff #define CF_NO_GOTO_TB 0x00000200 /* Do not chain with goto_tb */ #define CF_NO_GOTO_PTR 0x00000400 /* Do not chain with goto_ptr */ -#define CF_SINGLE_STEP 0x00000800 /* gdbstub single-step in effect */ -#define CF_MEMI_ONLY 0x00001000 /* Only instrument memory ops */ +#define CF_NO_GOTO_JC 0x00000800 /* Do not dispatch via the inline prob= e */ +#define CF_SINGLE_STEP 0x00001000 /* gdbstub single-step in effect */ #define CF_USE_ICOUNT 0x00002000 #define CF_INVALID 0x00004000 /* TB is stale. Set with @jmp_lock hel= d */ #define CF_PARALLEL 0x00008000 /* Generate code for a parallel contex= t */ @@ -85,6 +85,7 @@ struct TranslationBlock { #define CF_PCREL 0x00020000 /* Opcodes in TB are PC-relative */ #define CF_BP_PAGE 0x00040000 /* Breakpoint present in code page */ #define CF_STEP_ATOMIC 0x00080000 /* Running in cpu_exec_step_atomic */ +#define CF_MEMI_ONLY 0x00100000 /* Only instrument memory ops */ #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 =20 diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index 4e5e69649a..32e76d5f41 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -33,7 +33,7 @@ bool tcg_allowed; * they are derived from gdb single-step, one-insn-per-tb and -d nochain. */ #define CF_DERIVED (CF_COUNT_MASK | CF_NO_GOTO_TB | CF_NO_GOTO_PTR | \ - CF_SINGLE_STEP) + CF_NO_GOTO_JC | CF_SINGLE_STEP) =20 bool tcg_cflags_has(CPUState *cpu, uint32_t flags) { @@ -65,6 +65,17 @@ void tcg_update_cflags(CPUState *cpu) cflags |=3D CF_NO_GOTO_TB; } =20 + /* + * A block that dispatches through the jump cache inline does not cons= ult + * cpu->breakpoints, and inserting a breakpoint deliberately invalidat= es + * nothing. Give blocks translated while one is set a distinct cflags= , so + * that they neither dispatch inline themselves nor are reached by a b= lock + * that does, and check_for_breakpoints() gets to run on every dispatc= h. + */ + if (unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) { + cflags |=3D CF_NO_GOTO_JC; + } + cpu->tcg_cflags =3D cflags; } =20 diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index cf690e0e11..4c20091ef5 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -593,7 +593,7 @@ void cpu_exec_step_atomic(CPUState *cpu) /* Execute in a serial context. */ s.cflags &=3D ~CF_PARALLEL; /* After 1 insn, return and release the exclusive lock. */ - s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | + s.cflags |=3D CF_NO_GOTO_TB | CF_NO_GOTO_PTR | CF_NO_GOTO_JC | CF_NOIRQ | CF_STEP_ATOMIC | 1; =20 /* diff --git a/cpu-common.c b/cpu-common.c index adb76b3a78..81a302ace9 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -22,6 +22,7 @@ #include "exec/cpu-common.h" #include "hw/core/cpu.h" #include "qemu/lockable.h" +#include "system/tcg.h" #include "trace/trace-root.h" =20 QemuMutex qemu_cpu_list_lock; @@ -429,6 +430,11 @@ int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int= flags, *breakpoint =3D bp; } =20 + /* The first breakpoint takes the CPU off the inline dispatch path. */ + if (tcg_enabled()) { + tcg_update_cflags(cpu); + } + trace_breakpoint_insert(cpu->cpu_index, pc, flags); return 0; } @@ -452,7 +458,7 @@ int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int = flags) } =20 /* Remove a specific breakpoint by reference. */ -void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *bp) +static void cpu_breakpoint_remove_by_ref_int(CPUState *cpu, CPUBreakpoint = *bp) { QTAILQ_REMOVE(&cpu->breakpoints, bp, entry); =20 @@ -460,14 +466,31 @@ void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUB= reakpoint *bp) g_free(bp); } =20 +void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *bp) +{ + cpu_breakpoint_remove_by_ref_int(cpu, bp); + + /* The last breakpoint puts the CPU back on the inline dispatch path. = */ + if (tcg_enabled()) { + tcg_update_cflags(cpu); + } +} + /* Remove all matching breakpoints. */ void cpu_breakpoint_remove_all(CPUState *cpu, int mask) { CPUBreakpoint *bp, *next; + bool removed =3D false; =20 QTAILQ_FOREACH_SAFE(bp, &cpu->breakpoints, entry, next) { if (bp->flags & mask) { - cpu_breakpoint_remove_by_ref(cpu, bp); + cpu_breakpoint_remove_by_ref_int(cpu, bp); + removed =3D true; } } + + /* The last breakpoint puts the CPU back on the inline dispatch path. = */ + if (tcg_enabled() && removed) { + tcg_update_cflags(cpu); + } } --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386673; cv=none; d=zohomail.com; s=zohoarc; b=cmjWeVAE/43N7AyQdW7Oud8oYPncYeVw0L7Gxwk2QWnyDfY/lK1TUzO/jkJxudaPm/y3KKQKOpGTPX9irBDtHlpVaDJzxyRRMG/oLBXlkxIej0pkxSHS/3d9rQI6FeawCNdwtevr7juqRaKNnz69/F779kOcbRSow33kzFJ3Wjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386673; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AiG69fVg0vTrsRYUt3PicmCOLEYjh1xeu/BruZIA7DM=; b=Cg7aX9SUmJR55HvkbzGSWZMGU4CIBXlxzpo2lifqIBFiJPIVX/PpDVFFRiOXWMbQKMuw9Xu0+S2Tf/4L3rmu6i5DuyQreYxcIrXcnhM5fyZQL6ZNYMgiSV5jOwgFPaa/BywWTbVLhBVy7boeAZ3JD0jCx6ghw2T9uIVoUEOiviw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386673859918.301112256462; Fri, 30 Oct 2026 11:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrm1-0006uJ-4I; Fri, 30 Oct 2026 14:56:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlp-0006sM-Ss for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:11 -0400 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlo-0004oj-GQ for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:09 -0400 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-8ab43af5e97so13184217b3.1 for ; Fri, 30 Oct 2026 11:56:08 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386567; x=1793991367; darn=nongnu.org; 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:content-type; bh=AiG69fVg0vTrsRYUt3PicmCOLEYjh1xeu/BruZIA7DM=; b=JewtPqdAImtEGCbv6IBXPpwEjp5+8zlGRHDfod2RIFktJc3Zm0PApLKon6OeJSuqqk qYiQ/WB2ms21vXyE0d31CnqTblpTHbDiahERIinXPe445Z6zPRKOY/T6wBcuhl4WzwzB nB4+aPkog1qkRYemAOXRhki64pzxdfnx3CkSTZielNEx8VtZd/+oMdzCpogoruULrSHA tpTwSnd+oRevj6aOqlsAWR59W9c9WStFRq9T/RIu+lDEHEPdBZFDnaEB4KeTNSelxUXt NaGKz7/P1yOR1jH8JaRK4ZZagDndsUXmax7BWT837I1Vl1uw4/1JxcsldIWh+pFEPC6B 7mKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386567; x=1793991367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AiG69fVg0vTrsRYUt3PicmCOLEYjh1xeu/BruZIA7DM=; b=kjgIS5FBWJORfJIqLvM82qiy08OVjztrOU0zUIqJ3eJtTWhTdmHxRyX+5nXqjY7EDY sURn3c5q/FIhAU/DOSfh0khiw7JfPI3bl9UNc36SmOtC+jawRpRAivKVM1dBKagR5JM0 wuz1q88vhzmPJiBefGCnTrClpLsb6gslkcNi0EzD1+jSEnIoAb0uo3teT/XIL2vk551Y Ur2mq8pWZrPtFzc6WhF3XYKZqGFUUPyWgeWKHNjJdc/C/wVPoMmoiiowEwiD368QEmS/ aVj7KttQSWssm5forvHpZlZHJXDCvzUKjoXDs83OBC1BD4tLPsZvAv4TthlXTr4OoFXA YGVg== X-Gm-Message-State: AFq9FYJzhH9byUWS1FoejLM2LRoW8jRcziVgsaIstmdbT0o8P12TbUos lV2n8PauSpNo2or1VqR2qYl1erS8RB0Lb6981Ph0JEPqk8ul8FxUko9U3ru0HY5BdqXdVnjx41w +zcht X-Gm-Gg: AYBFou2Q+P9TD2+fdG89Bx3ujvtkW3Uo/ou3CkuEqRRHw9ZP1JBMcASK9MutNfCBtrG 7DoVunowM0cUeDaJZJLSKC+Ll89A/Iw0QA3RDbplugJMcpGoMHe3IrFm5xrcu/3HTLZbsykLSDr QeJjWVv5nH3vvf0L9BNhg7Jp41rhW+AtyLpy4tR7RggtJwyl3awQEKVjYXG9teMubQKQzGq8AO0 daxn/KADv66+jWYn2GqxxxEQ5+GsncTfZdKI/9HZN7IzDjMJPQFVmxi9norGvsT1tLXnKGxC/wh HZeQnv64g4aKBNMAXZUSaw/TxBFKoIt4m8uDr0BRCHIPu5oorlGNA8I2DakFlJ8HfZ22r4OKagE B9/qad3QFtQNhWg5FFyXsmUQ0OH8iaq8N3vLGT3WyxalHqdNI7DO13MypEGjN/DH8BgdpQw8keZ GLXXdqk7htAWo2sOw+KEK8VBPZbgES+Yw3paZc7o/j9jxzmGwt7ndkOwOLZE5p0Cee0WGvsTz1W M7RdTk31ObCdIAIA9Ulm1lPnGrjH6Ggt2tt+bF9uqQKp26hPTmSJnwRDYaXzXuXVJuJNYM+UzKv EAwonsSDvWG8l9IA8TPU1BMhRy3zKA8n5JQ= X-Received: by 2002:a05:690c:800c:20b0:8b1:60a0:c311 with SMTP id 00721157ae682-8b2b67c6b9fmr14770667b3.33.1793386567140; Fri, 30 Oct 2026 11:56:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 08/14] include/exec: Move tc within TranslationBlock Date: Fri, 30 Oct 2026 13:55:45 -0500 Message-ID: <20261030185551.193092-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112b; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112b.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: qemu development 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: 1793386674502158500 Content-Type: text/plain; charset="utf-8" Move tc so that it is adjacent to cs_base, flags, cflags. This will allow the s390x backend to load them all at once. Signed-off-by: Richard Henderson --- include/exec/translation-block.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/translation-block.h b/include/exec/translation-bl= ock.h index 4406db5ab2..a675b5038b 100644 --- a/include/exec/translation-block.h +++ b/include/exec/translation-block.h @@ -93,12 +93,12 @@ struct TranslationBlock { * Above fields used for comparing */ =20 + struct tb_tc tc; + /* size of target code for this block (1 <=3D size <=3D TARGET_PAGE_SI= ZE) */ uint16_t size; uint16_t icount; =20 - struct tb_tc tc; - /* * Track tb_page_addr_t intervals that intersect this TB. * For user-only, the virtual addresses are always contiguous, --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386629; cv=none; d=zohomail.com; s=zohoarc; b=VCVeL1YbnSsAczkNcgiec1nGbPDZy/sBE27PMLJPkZ0x/x1/a1OlBLH22/XEcIxv0eQbOnqv1hsHM3Doj7+Ahp1YZMR140XTmd0pbe2grTQtZMmacsMOlCrrsuh3cQx/84XMYmXkz0yuotz0NXPmnd4CeKqs55cQWJCIwOxiNBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386629; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C7dxaNAfjYUQrUyCWYAr9IXCKFQL6v6JyafIchcWzKU=; b=MYswccaLt/U22poK2etbLtuGMU4hIFPPXdhVmDcBIx43aQdz3KJLU9waG6xAMPPoND1UNOvvvzoemV78ZCYevhn/MM4wHF0woxRTEFl3N7Gk6WdWZCIq+nzM/VJLm9ko7hgDGloSvR6JHAaNgt+xKPN6YOwRWIH1Qcqrs6qKVbY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386629360753.7816718844451; Fri, 30 Oct 2026 11:57:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrmb-0007Ih-KU; Fri, 30 Oct 2026 14:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlv-0006tC-8g for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:18 -0400 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlp-0004oo-Kq for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:13 -0400 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-8b10d24345dso10233567b3.3 for ; Fri, 30 Oct 2026 11:56:09 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386568; x=1793991368; darn=nongnu.org; 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:content-type; bh=C7dxaNAfjYUQrUyCWYAr9IXCKFQL6v6JyafIchcWzKU=; b=P9r4q/EBwjApUSpSEgYKFr5sLk/ojHTn2WUU3uLoNrxWxGxQIRwzX7jRWwyZHe9T4Q iPB5jn43OEaQbYmmIaB8WEpQ11HCRCx1rW2pSq0NrV1JOL3O6gCEpSRlGnLjR0dZUYsl TVykgWDq31myRa3MC2pL1OTVLDgobARE4I8ZIC/BhoF/ZPvr/d9p6DJD5Jz94aKpol65 yaFrPIn6Xm4qRbxjIpk8Q5dAw89NefraHv9WHDijRsXP/j9BkIaMMAO/nan2xZrt+BKi TY+X5pduOJ2gXNpaynbEfH6OBWo+YKTc89//wgo3H/Htb9wP4rDyOYmOFqGB1dIJx+q2 ukaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386568; x=1793991368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=C7dxaNAfjYUQrUyCWYAr9IXCKFQL6v6JyafIchcWzKU=; b=SUp9Z4EbXvqXEXGRRq32eUlRNEYVhEyvsEhX+B7n93APnFA/eKRQT+rZfoIW7jhN43 W/nhV+tFIqBqBDzGy12DoHKDF4HRy22eKkCZJJstlxwYKEodJX2BYhMOeDFN1vHQPV5l FtPp4gPX+JrCWvzepj3mRHrq083zH0DfonbMqvtrCeU5fwhkrdbvU+0fOJOuHAHriYiF EUFyw4HCVc508SMNSEQhyDQhNu9B9KhNStCIc+e+TIa/PNhva+9W6Gs/YrMbwkAN24BW Wrcr9w6yKpotOOIE48IQrbuwBVAmB4wIms88HxZ34XxzZFOKVc1ym+j7t/A7ys8MUkme sEEA== X-Gm-Message-State: AFq9FYIdWR7FoApCD/L5PcDZjK024vi6Pu13gm4Vdy6mOlYOiu++j6tY 5pScl0FobGmP4XZiP+ZQ9ngrgIvUKU8e7herTk33uGZ5IGHD+i1I2CqR5xznuYYR3VYua7bUGM0 A1XMc X-Gm-Gg: AYBFou0WZPDo+XUf/kBbY/f5/e8gvB3ehakAqXQZDIWP9/em0HPG6DDrLgbeqWzWpmR SPfiM1RDCiCfKjdmu3ral/U87f/wV1L2NlI6pr+mEMOtBX2CuY6Wad3b+pJjATmazI8S1Pmvan/ o1k3PKeaI4/Z6p9TBvCd0leo8dczh2bdmODqcEubsYZozT//heOkYfm90e3rmNmvWC5hvl8l7AW QUPbZO/L5XgYJljOF7NzljJV3DzcsmlOyzrjTQ4M03IGKXO/2KF0EacqIHQnZBM7pOhFWAY49i/ 95akU3+l+XA4gKl+VohaIzC0KBZQ0DQbI6J32CXKxzxiPaXI3yWp9S+oH42VNRYbFyELcEOy8LG nRJPLWSu3z9qgIv0V5d+UaO4ohdRuc4FtW2ib5sZ9CGiGtI8hYqpMjh0nooWVVbVSJeS5EOCU4X saEqbT4r0+UqClQKAmiGY7A7H4NNFACzQjvXsdI0+DWDD2zacj5HKnPXYRKoV56YkbYMU+bCv9C WAmlZOJixJf5G9oq3ReKS6LCA2c6KsPmq4dLGxrffkkTWKuKGih7w7bIns5GzWA6vjdjNb/DwO4 eB6g0ITKIseoxoPbf7PRm3He/2pm+5eXVbE= X-Received: by 2002:a05:690c:f05:b0:8b0:e238:271b with SMTP id 00721157ae682-8b2b65d4897mr20749857b3.2.1793386568323; Fri, 30 Oct 2026 11:56:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 09/14] tcg: Probe the TB jump cache inline instead of calling a helper Date: Fri, 30 Oct 2026 13:55:46 -0500 Message-ID: <20261030185551.193092-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1133.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: qemu development 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: 1793386632558154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner Every indirect branch that cannot use goto_tb ends in a dispatch that calls helper_lookup_tb_ptr(). For an emulated compiler that is 8.4 billion helper calls in a single translation unit: 24.6% of all TB exits take this path, because jsr/ret/jmp have a register destination and because goto_tb is restricted to same-page targets. The helper itself is already tight, but each call pays for a call frame, the can_do_io store, the get_tb_cpu_state() indirect call through TCGCPUOps, curr_cflags(), and a breakpoint check, before it gets to the jump cache probe that almost always hits (95.8% for this workload). Emit the probe inline instead, for the callers that have migrated to tcg_gen_goto_jc_*(). Those supply what it needs: the destination PC is in a TCG temp, and the flags, cflags and cs_base the destination must match are constants at translation time. The fast path is therefore a hash, four guarded loads and a goto_ptr. Only a miss calls the helper, which still owns filling the cache. Two details matter for the generated code. The flags and cflags guards are folded into a single aligned 64-bit load and compare, since the fields are adjacent. And each path emits its own goto_ptr rather than branching to a shared one: a temp live across the label is spilled and reloaded on every dispatch, which cost 6.3% on its own. The flags and cflags constants are safe against the other things that can change them. CF_PARALLEL is only ever set by begin_parallel_context(), which flushes first, so no block predating it survives to dispatch. gdb single-step is only turned on with the CPU stopped, and a block translated without CF_SINGLE_STEP can only be re-entered through tb_lookup(), which from then on demands the new cflags -- so a stale-cflags block is never the one running. Breakpoints are handled by CF_NO_GOTO_JC, added by the previous patch: while one is set, blocks are translated with a cflags that both keeps them off the inline path and keeps them unreachable from blocks already on it. What is left is one_insn_per_tb and -d nochain; see below. Measured with qemu-alpha running an emulated alpha gcc 16.2.0 compiling the SQLite 3.45.1 amalgamation (255k lines, -O2) on an x86-64 host, LTO build, on top of the preceding patches: before: 1,402,667,803,616 instructions after: 916,415,123,244 instructions -34.67% before: 115.56s wall clock after: 85.59s wall clock -25.94% The gap between the two is the point at which this stops being a straight-line win: the helper call was highly predictable work that the host pipelined well, so removing it retires far fewer instructions than it saves time. IPC falls from 2.48 to 2.17 across this patch for that reason. Despite emitting more code, this also reduces instruction cache pressure, because a dispatch no longer jumps into qemu's .text and evicts translated code: before: 11,735,141,703 L1-icache-load-misses after: 7,154,863,292 L1-icache-load-misses -39.0% The mechanism is visible directly in a profile: helper_lookup_tb_ptr() falls from 31.01% of samples to 0.35%, and qemu's own .text falls from 38.8% to 5.3%, with the balance moving into generated code. Combined with the preceding patches, against an unmodified LTO build, 1,646,994,254,249 instructions fall to 916,415,123,244, or -44.36%. The emulated compiler produces byte-identical output throughout. A follow-up worth having: the probe is emitted entirely out of generic TCG ops, and several backends can do much better than the result. x86_64 and s390x have memory-operand comparisons; aarch64 can form env + off + h * 16 with a shift-add, load (tb, pc) and (cs_base, flags) with two ldp, and halve the branches with ccmp. That wants a backend expansion of a dedicated opcode, which is a separate series. Signed-off-by: Matt Turner Signed-off-by: Richard Henderson Message-ID: <20260901034808.3524945-7-mattst88@gmail.com> --- tcg/tcg-op.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 9 deletions(-) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 4f3cd9f082..1b4ee6d3d9 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -28,6 +28,8 @@ #include "tcg/tcg-op-common.h" #include "exec/translation-block.h" #include "exec/plugin-gen.h" +#include "hw/core/cpu.h" +#include "../accel/tcg/tb-hash.h" #include "tcg-internal.h" #include "tcg-has.h" =20 @@ -1838,20 +1840,115 @@ void tcg_gen_goto_tb(unsigned idx) tcg_gen_op1i(INDEX_op_goto_tb, 0, idx); } =20 +static void gen_goto_ptr(TCGTemp *ptr) +{ + tcg_gen_op1(INDEX_op_goto_ptr, TCG_TYPE_PTR, temp_arg(ptr)); +} + +static void gen_lookup_tb_ptr_and_goto(void) +{ + TCGv_ptr ptr =3D tcg_temp_ebb_new_ptr(); + + gen_helper_lookup_tb_ptr(ptr, tcg_env); + gen_goto_ptr(tcgv_ptr_temp(ptr)); + tcg_temp_free_ptr(ptr); +} + void tcg_gen_lookup_and_goto_ptr(void) { - TCGv_ptr ptr; - if (tcg_ctx->gen_tb->cflags & CF_NO_GOTO_PTR) { tcg_gen_exit_tb(NULL, 0); - return; + } else { + plugin_gen_disable_mem_helpers(); + gen_lookup_tb_ptr_and_goto(); } +} =20 - plugin_gen_disable_mem_helpers(); - ptr =3D tcg_temp_ebb_new_ptr(); - gen_helper_lookup_tb_ptr(ptr, tcg_env); - tcg_gen_op1i(INDEX_op_goto_ptr, TCG_TYPE_PTR, tcgv_ptr_arg(ptr)); - tcg_temp_free_ptr(ptr); +static void gen_jc_hash(TCGTemp *h, TCGTemp *t, TCGTemp *pc) +{ +#ifdef CONFIG_SOFTMMU + /* + * tb_jmp_cache_hash_func(), softmmu form. TARGET_PAGE_BITS is a load + * from target_page in this translation unit, but it is decided long + * before any translation happens, so it is a constant here. + */ + int shift =3D TARGET_PAGE_BITS - TB_JMP_PAGE_BITS; + + tcg_gen_shri(TCG_TYPE_I64, t, pc, shift); + tcg_gen_xor(TCG_TYPE_I64, t, t, pc); + tcg_gen_shri(TCG_TYPE_I64, h, t, shift); + tcg_gen_andi(TCG_TYPE_I64, h, h, TB_JMP_PAGE_MASK); + tcg_gen_andi(TCG_TYPE_I64, t, t, TB_JMP_ADDR_MASK); + tcg_gen_or(TCG_TYPE_I64, h, h, t); +#else + /* tb_jmp_cache_hash_func(), user-only form. */ + tcg_gen_shri(TCG_TYPE_I64, h, pc, TB_JMP_CACHE_BITS); + tcg_gen_xor(TCG_TYPE_I64, h, h, pc); + tcg_gen_andi(TCG_TYPE_I64, h, h, TB_JMP_CACHE_SIZE - 1); +#endif +} + +static void gen_jc_probe(TCGTemp *pc, TCGTemp *cs_base, uint32_t flags) +{ + const TranslationBlock *tb =3D tcg_ctx->gen_tb; + g_autoptr(TCGTemp) t =3D tcg_temp_new_ebb(TCG_TYPE_I64); + g_autoptr(TCGTemp) h =3D tcg_temp_new_ebb(TCG_TYPE_I64); + g_autoptr(TCGTemp) p =3D tcg_temp_new_ebb(TCG_TYPE_PTR); + TCGLabel *slow =3D gen_new_label(); + uint64_t fpair; + + QEMU_BUILD_BUG_ON(sizeof_field(CPUJumpCache, array[0]) !=3D 16); + QEMU_BUILD_BUG_ON(offsetof(CPUJumpCache, array[0].pc) % 8 !=3D 0); + /* One 64-bit load has to cover both, so they must be adjacent... */ + QEMU_BUILD_BUG_ON(offsetof(TranslationBlock, cflags) !=3D + offsetof(TranslationBlock, flags) + 4); + /* ...and aligned, which nothing else currently relies on. */ + QEMU_BUILD_BUG_ON(offsetof(TranslationBlock, flags) % 8 !=3D 0); + + /* p =3D &jc->array[tb_jmp_cache_hash_func(pc)] */ + gen_jc_hash(h, t, pc); + tcg_gen_ld(TCG_TYPE_I64, t, tcgv_ptr_temp(tcg_env), + offsetof(CPUState, tb_jmp_cache) - sizeof(CPUState)); + tcg_gen_lea(TCG_TYPE_I64, p, t, h, 4, 0); + + /* + * The pc first: on a hash miss it is the field most likely to differ, + * and an entry whose tb is NULL has a zero pc that only pc 0 matches. + */ + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(CPUJumpCache, array[0].pc)); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, pc, slow); + + tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(CPUJumpCache, array[0].tb)); + tcg_gen_brcond(TCG_TYPE_PTR, TCG_COND_EQ, + p, tcg_constant_internal(TCG_TYPE_PTR, 0), slow); + + /* + * flags and cflags are adjacent uint32_t, so one aligned 64-bit load + * and compare covers both. + */ + fpair =3D (HOST_BIG_ENDIAN + ? deposit64(tb->cflags, 32, 32, flags) + : deposit64(flags, 32, 32, tb->cflags)); + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, flags)); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, + t, tcg_constant_internal(TCG_TYPE_I64, fpair), slow); + + /* + * cs_base is a second word of target-specific flags despite the name, + * and the pc alone does not imply it on a target that uses it. + */ + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, cs_base)); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, cs_base, slow); + + tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(TranslationBlock, tc.ptr)); + gen_goto_ptr(p); + + /* + * Emit a second goto_ptr rather than branching to a shared one: a temp + * live across the label would be spilled and reloaded on every dispat= ch. + */ + gen_set_label(slow); + gen_lookup_tb_ptr_and_goto(); } =20 void tcg_gen_goto_jc3(TCGType type, TCGTemp *pc, @@ -1878,7 +1975,17 @@ void tcg_gen_goto_jc3(TCGType type, TCGTemp *pc, tcg_constant_i32(flags)); #endif =20 - tcg_gen_lookup_and_goto_ptr(); + /* + * A breakpoint is the one thing the probe cannot check for itself, so + * while one is set the flag is set too and every dispatch takes the + * helper, which does check. See tcg_update_cflags(). + */ + if (tcg_ctx->gen_tb->cflags & CF_NO_GOTO_JC) { + tcg_gen_lookup_and_goto_ptr(); + } else { + plugin_gen_disable_mem_helpers(); + gen_jc_probe(pc, cs_base, flags); + } } =20 void tcg_gen_goto_jc(TCGType type, TCGTemp *pc) --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386673; cv=none; d=zohomail.com; s=zohoarc; b=cQR4+snNkksJVUWe/jJvYBtHz8Q9j4gvSpUpd84Gf7LUdbhMjc113ycSMemip++dtK3HyC4PwU0UnVOTXRap4iiaD3Yskyn2hvUJx91X6qZdCX7400GqhXjUN6Uzgl0JuW9kErE4iijnIX39wOBzt5MDfSU6aIkN4Mrb9bfLZ1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386673; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1YZySs8MIn4PwSvFcs6OR/idr1m7L2c0nPNHdhNTkgs=; b=ephT9ZebcmhvgoYERvGQi7vaSnDI3m43qbTR0Hor0JZz8kK9+PccVh8+O37HEj7eYuy2cc/HCZDvXJMlFat54UTMpJZ1IMyDDRljb8hyOxxWyf7Y7tbGgFKXflV6Aq0CMtOKo/4B8iwf+x2u/ypkDBhugentWLqzvE8kU51VNfE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386673784655.0787012111459; Fri, 30 Oct 2026 11:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrmc-0007Kj-IE; Fri, 30 Oct 2026 14:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlv-0006tB-8P for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:18 -0400 Received: from mail-yx1-xb133.google.com ([2607:f8b0:4864:20::b133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlr-0004p3-Bs for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:13 -0400 Received: by mail-yx1-xb133.google.com with SMTP id 956f58d0204a3-6790844c9b0so803334d50.2 for ; Fri, 30 Oct 2026 11:56:10 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386570; x=1793991370; darn=nongnu.org; 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:content-type; bh=1YZySs8MIn4PwSvFcs6OR/idr1m7L2c0nPNHdhNTkgs=; b=NKoyVDV+hYlEk+bHwrjflFZOo3N1J808+u4Sr+macFr+1wJ6ZHUA2FkemhHBYHHArW MX6Kfuy2EVbHDfbzIIidFKWcN1L3JCE7fOIza8RZitS99b/rZR3EVHmUkyjY6ZcfuM/A hXLyhnLYJV05fToEofWLN8Tsp7z5bXMYWkXPOP3CTgAXyl8FX71wI37xf3pJzEdx87DF bu3B7sjXX9FL8K4opmDFh7O4HzkDPoiholPNOwBGHAkPqpH+HuYdwnxaR9rQ7i9aROh1 PsKGkrHXmL4UxO9Japz1t9/7vpqUt4MQA/sfWExjFqcW0xeF1g5K/YPOQ4XxrF+jNTH+ j4LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386570; x=1793991370; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1YZySs8MIn4PwSvFcs6OR/idr1m7L2c0nPNHdhNTkgs=; b=nGqamO6t5NMp/vHZrkG6eKQT97FS2hpAmgv2oCNhJFbiqtP7imZPh8reEqtzoIgCpR ZI/87AICabhOKoHGf2E7HOSGSxJPhsSA9ML10VBJJKUA6rS9T/ar9wRuEQ/laO30NerF h5VPo7r6jg39SdusPQC3Dka1kfv+/CXC7w5Wn/SYe6knPqK/IEsNgwUclGbf6c0L/i8v w5hURYeL6w79h0dWHCrhwJz63bd4WCfn0x5WETASbEZnejGgEsdAv6rLkkCeguf18EA1 8MS9cAdC/aTH/lth066KG8vaKINw9BgXUIBABNuu86BqKlZ8nYhk7rx58vSRCIGLol26 +Bew== X-Gm-Message-State: AFq9FYJbTMaV8yg/XzKf3IuGErjjIrkD5uW7hyX9qFOja43SNu6Fcfse +qm7aMz9eclzA0X0Zh4MFvIiHbbKEmmwzsoGSNePOSfKpGnX5HhFDKDjuuS7j+7O7VUtmcJINPv BhY3x X-Gm-Gg: AYBFou3ZC6r6wpbXLp/nZxze7ZBhX5FD9UG02tYTjZyd+2P/L/01IBBPwkqM2yoTGqt VpkhC6qzbO22B94XqRqnT3fhtgsPNhZCAzF9BX2b7Zqj449Zk4WxKv48WnVirnYDlr/f+YpnCM3 oGJRhYS3o2ppqtRI1aIymbdYpJ1bWpau1ywfAbe2TeWxfkLUgwzcdrNOL5iFRh+hMXLN7C92sUB kXpUOhTwRrAuvBuwQHzc39ALrisJMIzkdmGbKpj5YhWVkP/RxBVH9ju/FF9OP7pmUERXo/69CNM oj/ewUO8U6GtGgsUpWFeHYT/sBOL8fk9rvIOfBso2pfCbPPl0EVCzbOqcIDD+CcZ5jpq7XhPnuG IRvAqRbD7IsahybvgU0kys3b5+d7ynvkf2VzMQfCkikMwhtcxS3pq3Q68y8QuOFbLgY7oloHZNc uRnyBuguWuh4ZHx3toGk9qKTV1/1B+U04vS4RFd/CrW+5daLAojufKLOeYmryq6KCeMHdHodAvy /ybCGudzr++TUkDYKFYBiwJ/C3+6ri+opVAUhWOP69cRhan3qSOP47Sdv6B1Vba53/KFImBX05S 9N9+mIEX4tN7mgE6k8XZB+TIZLkapZDPHNo= X-Received: by 2002:a05:690e:e89:b0:675:41a6:7971 with SMTP id 956f58d0204a3-67ba5057a6amr2392760d50.98.1793386569668; Fri, 30 Oct 2026 11:56:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 10/14] tcg: Add INDEX_op_goto_jc Date: Fri, 30 Oct 2026 13:55:47 -0500 Message-ID: <20261030185551.193092-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b133; envelope-from=richard.henderson@linaro.org; helo=mail-yx1-xb133.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: qemu development 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: 1793386674593158500 Content-Type: text/plain; charset="utf-8" Allow goto_jc to be implemented in the backend. Signed-off-by: Richard Henderson --- docs/devel/tcg-ops.rst | 11 ++++++ include/tcg/tcg-opc.h | 1 + tcg/tcg-internal.h | 8 ++++ tcg/tcg-op.c | 65 ++++++++++++++++++-------------- tcg/tcg.c | 22 +++++++++++ tcg/aarch64/tcg-target.c.inc | 4 ++ tcg/loongarch64/tcg-target.c.inc | 4 ++ tcg/ppc64/tcg-target.c.inc | 4 ++ tcg/riscv64/tcg-target.c.inc | 4 ++ tcg/s390x/tcg-target.c.inc | 4 ++ tcg/sparc64/tcg-target.c.inc | 4 ++ tcg/tci/tcg-target.c.inc | 4 ++ tcg/x86_64/tcg-target.c.inc | 4 ++ 13 files changed, 111 insertions(+), 28 deletions(-) diff --git a/docs/devel/tcg-ops.rst b/docs/devel/tcg-ops.rst index 51fa183e91..ca640610b4 100644 --- a/docs/devel/tcg-ops.rst +++ b/docs/devel/tcg-ops.rst @@ -752,6 +752,17 @@ QEMU specific operations | This operation is optional. If the TCG backend does not implement= the goto_ptr opcode, emitting this op is equivalent to emitting exit_= tb(0). =20 + * - goto_jc *jc*, *pc*, *cs_base*, *flags*, *label* + + - | *jc* is a CPUJumpCache pointer. Generate code for: + | + | if (jc->pc !=3D pc) goto label; + | tb =3D jc->tb; + | if (tb =3D=3D NULL) goto label; + | if (tb->flags !=3D flags) goto label; + | if (tb->cs_base !=3D cs_base) goto label; + | goto tb->tc.ptr; + * - qemu_ld_i32/i64/i128 *t0*, *t1*, *flags*, *memidx* =20 qemu_st_i32/i64/i128 *t0*, *t1*, *flags*, *memidx* diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index 884345afe5..ce7703d583 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -122,6 +122,7 @@ DEF(insn_start, 0, 0, INSN_START_WORDS, TCG_OPF_NOT_PRE= SENT) DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | TCG_OPF_NOT_PRESE= NT) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END | TCG_OPF_NOT_PRESE= NT) DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) +DEF(goto_jc, 0, 4, 1, TCG_OPF_BB_EXIT | TCG_OPF_BB_END) =20 DEF(plugin_cb, 0, 0, 1, TCG_OPF_NOT_PRESENT) DEF(plugin_mem_cb, 0, 1, 1, TCG_OPF_NOT_PRESENT) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index ae0a19a2f7..9f1fb91006 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -139,6 +139,14 @@ static inline void tcg_gen_op_tttt(TCGOpcode opc, TCGT= ype type, TCGTemp *t0, temp_arg(t2), temp_arg(t3)); } =20 +static inline TCGOp *tcg_gen_op_tttti(TCGOpcode opc, TCGType type, TCGTemp= *t0, + TCGTemp *t1, TCGTemp *t2, + TCGTemp *t3, TCGArg a4) +{ + return tcg_gen_op5(opc, type, temp_arg(t0), temp_arg(t1), + temp_arg(t2), temp_arg(t3), a4); +} + static inline void tcg_gen_op_tttii(TCGOpcode opc, TCGType type, TCGTemp *t0, TCGTemp *t1, TCGTemp *t2, TCGArg a3, TCGArg a4) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 1b4ee6d3d9..0040d149e0 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1895,7 +1895,13 @@ static void gen_jc_probe(TCGTemp *pc, TCGTemp *cs_ba= se, uint32_t flags) g_autoptr(TCGTemp) h =3D tcg_temp_new_ebb(TCG_TYPE_I64); g_autoptr(TCGTemp) p =3D tcg_temp_new_ebb(TCG_TYPE_PTR); TCGLabel *slow =3D gen_new_label(); - uint64_t fpair; + /* + * flags and cflags are adjacent uint32_t, so one aligned 64-bit load + * and compare covers both. + */ + uint64_t fpair =3D (HOST_BIG_ENDIAN + ? deposit64(tb->cflags, 32, 32, flags) + : deposit64(flags, 32, 32, tb->cflags)); =20 QEMU_BUILD_BUG_ON(sizeof_field(CPUJumpCache, array[0]) !=3D 16); QEMU_BUILD_BUG_ON(offsetof(CPUJumpCache, array[0].pc) % 8 !=3D 0); @@ -1911,37 +1917,40 @@ static void gen_jc_probe(TCGTemp *pc, TCGTemp *cs_b= ase, uint32_t flags) offsetof(CPUState, tb_jmp_cache) - sizeof(CPUState)); tcg_gen_lea(TCG_TYPE_I64, p, t, h, 4, 0); =20 - /* - * The pc first: on a hash miss it is the field most likely to differ, - * and an entry whose tb is NULL has a zero pc that only pc 0 matches. - */ - tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(CPUJumpCache, array[0].pc)); - tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, pc, slow); + if (tcg_op_supported(INDEX_op_goto_jc, TCG_TYPE_PTR, 0)) { + TCGOp *op =3D tcg_gen_op_tttti(INDEX_op_goto_jc, TCG_TYPE_PTR, + p, pc, cs_base, + tcg_constant_internal(TCG_TYPE_I64, f= pair), + label_arg(slow)); + add_as_label_use(slow, op); + } else { + /* + * The pc first: on a hash miss it is the field most likely + * to differ, and an entry whose tb is NULL has a zero pc + * that only pc 0 matches. + */ + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(CPUJumpCache, array[0].pc)= ); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, pc, slow); =20 - tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(CPUJumpCache, array[0].tb)); - tcg_gen_brcond(TCG_TYPE_PTR, TCG_COND_EQ, - p, tcg_constant_internal(TCG_TYPE_PTR, 0), slow); + tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(CPUJumpCache, array[0].tb)= ); + tcg_gen_brcond(TCG_TYPE_PTR, TCG_COND_EQ, + p, tcg_constant_internal(TCG_TYPE_PTR, 0), slow); =20 - /* - * flags and cflags are adjacent uint32_t, so one aligned 64-bit load - * and compare covers both. - */ - fpair =3D (HOST_BIG_ENDIAN - ? deposit64(tb->cflags, 32, 32, flags) - : deposit64(flags, 32, 32, tb->cflags)); - tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, flags)); - tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, - t, tcg_constant_internal(TCG_TYPE_I64, fpair), slow); + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, flags)); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, + t, tcg_constant_internal(TCG_TYPE_I64, fpair), slow= ); =20 - /* - * cs_base is a second word of target-specific flags despite the name, - * and the pc alone does not imply it on a target that uses it. - */ - tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, cs_base)); - tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, cs_base, slow); + /* + * cs_base is a second word of target-specific flags despite + * the name, and the pc alone does not imply it on a target + * that uses it. + */ + tcg_gen_ld(TCG_TYPE_I64, t, p, offsetof(TranslationBlock, cs_base)= ); + tcg_gen_brcond(TCG_TYPE_I64, TCG_COND_NE, t, cs_base, slow); =20 - tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(TranslationBlock, tc.ptr)); - gen_goto_ptr(p); + tcg_gen_ld(TCG_TYPE_PTR, p, p, offsetof(TranslationBlock, tc.ptr)); + gen_goto_ptr(p); + } =20 /* * Emit a second goto_ptr rather than branching to a shared one: a temp diff --git a/tcg/tcg.c b/tcg/tcg.c index d19c3fb857..671cf8fd0e 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1101,6 +1101,12 @@ typedef struct TCGOutOpLea { TCGReg a2, unsigned sh, tcg_target_long imm); } TCGOutOpLea; =20 +typedef struct TCGOutOpGotoJC { + TCGOutOp base; + void (*out)(TCGContext *s, TCGReg jc, TCGReg pc, TCGArg cs, bool const= _cs, + TCGArg fl, bool const_fl, TCGLabel *l); +} TCGOutOpGotoJC; + #include "tcg-target.c.inc" =20 #ifndef CONFIG_TCG_INTERPRETER @@ -1190,6 +1196,7 @@ static const TCGOutOp * const all_outop[NB_OPS] =3D { OUTOP(INDEX_op_extrh_i64_i32, TCGOutOpUnary, outop_extrh_i64_i32), OUTOP(INDEX_op_extrl_i64_i32, TCGOutOpUnary, outop_extrl_i64_i32), OUTOP(INDEX_op_extu_i32_i64, TCGOutOpUnary, outop_extu_i32_i64), + OUTOP(INDEX_op_goto_jc, TCGOutOpGotoJC, outop_goto_jc), OUTOP(INDEX_op_ld, TCGOutOpLoad, outop_ld), OUTOP(INDEX_op_ld8s, TCGOutOpLoad, outop_ld8s), OUTOP(INDEX_op_ld8u, TCGOutOpLoad, outop_ld8u), @@ -3013,6 +3020,7 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have_p= refs) case INDEX_op_set_label: case INDEX_op_br: case INDEX_op_brcond: + case INDEX_op_goto_jc: col +=3D ne_fprintf(f, "%s$L%d", k ? "," : "", arg_label(op->args[k])->id); i++, k++; @@ -3482,6 +3490,9 @@ void tcg_op_remove(TCGContext *s, TCGOp *op) case INDEX_op_brcond: remove_label_use(op, 3); break; + case INDEX_op_goto_jc: + remove_label_use(op, 4); + break; default: break; } @@ -3580,6 +3591,9 @@ static void move_label_uses(TCGLabel *to, TCGLabel *f= rom) case INDEX_op_brcond: op->args[3] =3D label_arg(to); break; + case INDEX_op_goto_jc: + op->args[4] =3D label_arg(to); + break; default: g_assert_not_reached(); } @@ -3654,6 +3668,7 @@ reachable_code_pass(TCGContext *s) case INDEX_op_br: case INDEX_op_exit_tb: case INDEX_op_goto_ptr: + case INDEX_op_goto_jc: /* Unconditional branches; everything following is dead. */ dead =3D true; break; @@ -5823,6 +5838,13 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) tcg_out_goto_ptr(s, new_args[0]); break; =20 + case INDEX_op_goto_jc: + tcg_debug_assert(!const_args[0]); + tcg_debug_assert(!const_args[1]); + outop_goto_jc.out(s, new_args[0], new_args[1], new_args[2], const_= args[2], + new_args[3], const_args[3], arg_label(new_args[4= ])); + break; + default: tcg_debug_assert(def->flags & TCG_OPF_VECTOR); tcg_out_vec_op(s, op->opc, type - TCG_TYPE_V64, diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 5c186156c0..1c3cf835e2 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -2008,6 +2008,10 @@ static const TCGOutOpQemuLdSt2 outop_qemu_st2 =3D { .out =3D tgen_qemu_st2, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static const tcg_insn_unit *tb_ret_addr; =20 static void tcg_out_exit_tb(TCGContext *s, uintptr_t a0) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index 377cd9ec08..733cce516e 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -2113,6 +2113,10 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg rd, TCGReg rs) { diff --git a/tcg/ppc64/tcg-target.c.inc b/tcg/ppc64/tcg-target.c.inc index 99f4469f4b..466ae836d5 100644 --- a/tcg/ppc64/tcg-target.c.inc +++ b/tcg/ppc64/tcg-target.c.inc @@ -3637,6 +3637,10 @@ static const TCGOutOpLea outop_lea =3D { .base.static_constraint =3D C_NotImplemented, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) { switch (opc) { diff --git a/tcg/riscv64/tcg-target.c.inc b/tcg/riscv64/tcg-target.c.inc index 6da52929a4..8c4ce59935 100644 --- a/tcg/riscv64/tcg-target.c.inc +++ b/tcg/riscv64/tcg-target.c.inc @@ -2758,6 +2758,10 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, unsigned vecl, unsigned vece, const TCGArg args[TCG_MAX_OP_ARGS], diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index db3b2fc3c9..3b63383315 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -3202,6 +3202,10 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src) { diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index cb457453ff..0582dc8bdd 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -2124,6 +2124,10 @@ static const TCGOutOpLea outop_lea =3D { .base.static_constraint =3D C_NotImplemented, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags) { diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 6942fdbb4e..5d8892abc4 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -1224,6 +1224,10 @@ static const TCGOutOpLea outop_lea =3D { .base.static_constraint =3D C_NotImplemented, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + /* Test if a constant matches the constraint. */ static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) diff --git a/tcg/x86_64/tcg-target.c.inc b/tcg/x86_64/tcg-target.c.inc index 3fca0693e2..04c83fbe6b 100644 --- a/tcg/x86_64/tcg-target.c.inc +++ b/tcg/x86_64/tcg-target.c.inc @@ -3374,6 +3374,10 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static const TCGOutOpGotoJC outop_goto_jc =3D { + .base.static_constraint =3D C_NotImplemented, +}; + static int const umin_insn[4] =3D { OPC_PMINUB, OPC_PMINUW, OPC_PMINUD, OPC_VPMINUQ }; --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386673; cv=none; d=zohomail.com; s=zohoarc; b=jNrPY1Xv6AdPZlCouqDIRKf9uqT4hqSDNm3IfzoGJp9GY4aU6rNOFJFGGUm3XVW9XWZji132eI5OpYVJHXfhjq3p0PNs3sKAchb/bjSXP14sVsXNmQD663f1qDGdPmDsyWHVjGmAz9VZtVR/Xh/PTVhNjklIv9pCeOZoljn3XPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386673; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BSf4yzgKqdfUtkbrvtphNnKJMg2rwq5r2CRGhdXxOZc=; b=PTUpqVDgspvIXML9Dv+7OZr/GlvOO/xGkhesVIyjE0nZCSFxX67bKHLOd1a2+O3FkWuvfD+FuLVI6yowQWeP9Lz1cCrmsehskh3zbfQXtlnuAo7PVDJRaUCcfTJ/3gI4XwIB1k2tXSw8TZfItNqZgWJSFA+xYB304PoGsN3Gwmk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179338667378224.04750609689063; Fri, 30 Oct 2026 11:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrmY-00071X-2R; Fri, 30 Oct 2026 14:56:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlx-0006tI-9a for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:19 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlt-0004p9-74 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:16 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-8b0d63f60bcso9408557b3.3 for ; Fri, 30 Oct 2026 11:56:12 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386571; x=1793991371; darn=nongnu.org; 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:content-type; bh=BSf4yzgKqdfUtkbrvtphNnKJMg2rwq5r2CRGhdXxOZc=; b=PMybKzayJqHOK3Mu02+iSdJO0NITScXcfv+M/r2yk/9Rcxt5yx/3rGbnHOF45Fp/4w Oh6jSQXwABFDcbhV6hTWYQENODC+kl8c819E73roLFYG5Mk464et6FaUvy6muptnvoSC HUT2U7ZjRmswPjZbmMNo6vYo9I6ZBSK+9YBs/Lo8WBYU5m+nMqy0o5t55eFhB2nmaMb4 f6glBnKud9fRUw7ly38KlkNpMrLgoF/j0jArQyfMIAP3Khut/QJEojayyc0lJVmRr5Kd C0mC1oNH/UgGl7C4O2eptX5z+a9jGZo5RBNCxTOYQ08DNbUHVOcRPeWujpYhsHDGDZ65 cMbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386571; x=1793991371; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=BSf4yzgKqdfUtkbrvtphNnKJMg2rwq5r2CRGhdXxOZc=; b=Kw5j6+8ouMyUr8T4l9inBHD8R4/h0RMvGi4R3I19M7OR8pzh7NkD5nOHPBN7Ya2mWY wxg+QmPcok49PjUw00CRq5hefmzMkNQquP90I4lysMWHYGKewS2JE7+cMA5BIZSZmmrZ uiBm00C2KVcID8VmyecQYvpXLpVT+eicH3BTcqy1x1FlgnoVWTUv8aQy5YoVAYkz0GJg QHfI/n2rUPwPxxeMGB59VeE6ULP8zhKLFWxnCtXDJ6yg4539bvSrh15aa20TDsZHDQlc gyLWuVwXUUUQN6SGXqVy69B1p+bLPSxItlxevhj45ke5wkaxL/WFmj7JuZG5EZZzLvbb l9Ag== X-Gm-Message-State: AFq9FYIcStZ7oYpxPZLYVJ0QyHDe767qlUL16e72SM6YCrz3B0AAWkz3 pHiUum4YWU/JiHtZfmn8PVdLnyBiKjF12q3GnSbKr6fvAC0eN8dmGA44/pq9ZJ31AMAmwwNhxPu oMK2q X-Gm-Gg: AYBFou2FjiDMylpwAewfwP4vw/kr6LqCIAsYZB+UtMYvlvXeHEOHg7rjJEzvzNsCVYx zcDBIensLe4woDZmB5OcoLWCua5IDXCfXKdV/1qIpr2Iv3kY2S47rjvKi+0PxHy9om0FodyFyrA bL8M6mgk68SfdB5adWAUp3Dlha+fl3odezCZocuzsNH4OvBkP83nYSBZlePvr/IqiFsuQYKsVs8 5ntcMdQb3uL/ST6Errn5a7QHnzDh+f9t6puRqQ4qcvVEbGse2HAzP+7+r3kPDTpYYWoJcInh95q 13cRbd144h0DbYpe6RhB7tyj7DuKC191tNk6YXUevOtJkwM3p4ZoBOfrGw9mi7l5yVrJnh5Wbue XJLaZIAJFcbO4OAhY3mZ8ZG0D2rGynZPl9u4zjR6SAzziBN/EpzFg1czt0XXWVyKz/ekf4gcjNb xPHeOZyQfwDyVC1l9Ld3ojxOZdmU1TSu/lyAaI57YsESmnTAauR6xCX/nT4M6gw605/k0qjzwug 40EurmqxWZ1IByZkCyn8yDSyC95JZn36ogtq2p+lr9FEgWP0opRtTm/LOIcHEncsvTKWlDgjjfl epD4MMK9kkjs1je861aWXOE77SL3UmIu9hU= X-Received: by 2002:a05:690c:4003:b0:8b0:ad62:19aa with SMTP id 00721157ae682-8b2b671babcmr16965717b3.33.1793386571087; Fri, 30 Oct 2026 11:56:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 11/14] tcg/x86_64: Implement INDEX_op_goto_jc Date: Fri, 30 Oct 2026 13:55:48 -0500 Message-ID: <20261030185551.193092-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1132; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1132.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: qemu development 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: 1793386674537158500 Content-Type: text/plain; charset="utf-8" Use comparisons vs memory, short branches, and an indirect memory jump. Signed-off-by: Richard Henderson --- tcg/tcg.c | 1 + tcg/x86_64/tcg-target.c.inc | 77 ++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 671cf8fd0e..24eee302eb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -61,6 +61,7 @@ #ifdef CONFIG_USER_ONLY #include "user/guest-base.h" #endif +#include "../accel/tcg/tb-hash.h" =20 /* Forward declarations for functions declared in tcg-target.c.inc and used here. */ diff --git a/tcg/x86_64/tcg-target.c.inc b/tcg/x86_64/tcg-target.c.inc index 04c83fbe6b..d21fc2e9c7 100644 --- a/tcg/x86_64/tcg-target.c.inc +++ b/tcg/x86_64/tcg-target.c.inc @@ -1532,6 +1532,12 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, = TCGArg arg1, return jz; } =20 +static void tgen_cmp_mem_reg(TCGContext *s, int rexw, TCGReg reg, + TCGReg base, intptr_t ofs) +{ + tcg_out_modrm_offset(s, OPC_CMP_GvEv | rexw, reg, base, ofs); +} + static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *label, bool small) @@ -3374,8 +3380,77 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static void tgen_goto_jc_cmp_part(TCGContext *s, TCGArg val, bool const_va= l, + TCGReg scratch, const TranslationBlock *= tb, + TCGReg base, ptrdiff_t ofs) +{ + if (!const_val) { + /* cmpq ofs(base), %val */ + tgen_cmp_mem_reg(s, P_REXW, val, base, ofs); + } else if (val =3D=3D (int8_t)val) { + tcg_out_modrm_offset(s, OPC_ARITH_EvIb | P_REXW, ARITH_CMP, base, = ofs); + tcg_out8(s, val); + } else if (val =3D=3D (int32_t)val) { + tcg_out_modrm_offset(s, OPC_ARITH_EvIz | P_REXW, ARITH_CMP, base, = ofs); + tcg_out32(s, val); + } else { + uintptr_t tb_slot =3D (uintptr_t)tb + ofs; + + tcg_out_ld(s, TCG_TYPE_I64, scratch, base, ofs); + /* + * Compare the value vs a rip-relative reference. + * If the value is unchanged from the current TB, + * we can reuse that. Otherwise drop it in the pool. + */ + if (val =3D=3D *(uint64_t *)tb_slot) { + tcg_out_modrm_sib_offset(s, OPC_CMP_GvEv | P_REXW, scratch, + TCG_REG_NONE, TCG_REG_NONE, 0, tb_slo= t); + } else { + tcg_out_modrm_pool(s, OPC_CMP_GvEv | P_REXW, scratch); + new_pool_label(s, val, R_386_PC32, s->code_ptr - 4, -4); + } + } +} + +static void tgen_goto_jc(TCGContext *s, TCGReg ptr, TCGReg pc, + TCGArg cs, bool const_cs, TCGArg fl, bool const_f= l, + TCGLabel *label) +{ + const TranslationBlock *tb =3D s->gen_tb; + unsigned free =3D (ALL_GENERAL_REGS & ~s->reserved_regs & ~(1 << ptr) + & ~(const_fl ? 0 : 1 << fl)); + TCGReg scratch =3D ctz32(free); + + /* ptr is CPUJumpCache */ + + /* Validate pc match */ + tgen_cmp_mem_reg(s, P_REXW, pc, ptr, offsetof(CPUJumpCache, array[0].p= c)); + tcg_out_jxx(s, JCC_JNE, label, true); + + /* Load and validate tb non-null */ + tcg_out_ld(s, TCG_TYPE_PTR, ptr, ptr, offsetof(CPUJumpCache, array[0].= tb)); + tcg_out_brcond(s, P_REXW, TCG_COND_EQ, ptr, 0, true, label, true); + + /* ptr is now TranslationBlock */ + + /* Validate cs_base match */ + tgen_goto_jc_cmp_part(s, cs, const_cs, scratch, tb, ptr, + offsetof(TranslationBlock, cs_base)); + tcg_out_jxx(s, JCC_JNE, label, true); + + /* Validate cflags:flags match */ + tgen_goto_jc_cmp_part(s, fl, const_fl, scratch, tb, ptr, + offsetof(TranslationBlock, flags)); + tcg_out_jxx(s, JCC_JNE, label, true); + + /* Jump to tb */ + tcg_out_modrm_offset(s, OPC_GRP5, EXT5_JMPN_Ev, + ptr, offsetof(TranslationBlock, tc.ptr)); +} + static const TCGOutOpGotoJC outop_goto_jc =3D { - .base.static_constraint =3D C_NotImplemented, + .base.static_constraint =3D C_O0_I4(r, r, ri, ri), + .out =3D tgen_goto_jc, }; =20 static int const umin_insn[4] =3D { --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386674; cv=none; d=zohomail.com; s=zohoarc; b=nW8rSmCxPxeSS2tPy3i9GliuHLrVmPPzLuAWdJ4MDp+eiTmPx+1NGYYTJpUvhK8nDn6L7rgylDhv5qAR+kAr/rGtmiq2UcLB+t0mZjciFw176wxYaZDGxAjL2lCcu1EDCRT5FtzCBOV7eegAjXBmQ2dNCHB7dURXGHBXpXXad9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386674; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=huYcXpcvi0CcacnVUoggrHLfJkueTbDQs53OqkTKktQ=; b=caM/IUFQ1PglOgO1IZ21E3NRrcYLNrB8Pmk3aGLnJma1TVxxen3+LG5CvJMUWDia7G/gynTupRNjGngI8DNyf8Gju1RWoU5deYvaQCqe8At7wfLSyt15W57sFhaWWbynZghzsUQtgoYQhKv6cyY99F2v2ofrbdW8cxsgQaX1TdU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179338667433098.05059678454597; Fri, 30 Oct 2026 11:57:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrmy-0007YC-4l; Fri, 30 Oct 2026 14:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrlz-0006tv-6U for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:20 -0400 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlv-0004pJ-12 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:16 -0400 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-8726acc5eadso9309247b3.0 for ; Fri, 30 Oct 2026 11:56:13 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386573; x=1793991373; darn=nongnu.org; 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:content-type; bh=huYcXpcvi0CcacnVUoggrHLfJkueTbDQs53OqkTKktQ=; b=AxEDrBaE0nh93LFlsFya8yWNBVdRmCfw4vEGzidPaHg6Ew/V53yovI23f4Bk3A8CtO HY4j6Dmzz/vablASOMSqDPRLE+AIhT5GN+bGoyssCS1OPIursldbVzcJYvCKMOh26art YxzipeaxW2TsGduDRtzCfcHMypjJkwjzc44fYoUGwLOqUtqcQ+292dJki5y3nveq/zWL 6jhD1TNib9J4dQXmdRsWwCPgcLjDFlQ/XR2S/8rJRenFaA6UhXUFHWLeBmR8dAYvfnJ0 oMDfOm3ShtkzP+i3uorR64wz+tMpZ0qGK+D01YJySJ+lMJ3CF51skf5b3tQY5M41fASK Nv7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386573; x=1793991373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=huYcXpcvi0CcacnVUoggrHLfJkueTbDQs53OqkTKktQ=; b=xM8yvV81sei9AQfvTokFdeJjiO6BBkyj58a+HVNnKfrQlc+QOdyPykAqy9jtRWTlOC IVn0+JZpWxKR6vwq5wr84u2oR7BOVE3Ehkh/oPiMj5gvcIxIm+lBHJDJlimRlVQkIEXu VzN/Hu6r25UkTGH3Bx25J5dCPEtdxq4w4Q8GleIlrEi3fHt4V5gPW9HV2mAtZwxt7/9J X7MZjTTvPbLe64ThGhxXz9C8M2W7vdMTfwPOQY0C4oqoHrq834O5Pk1t0sdHYpvt5Hxf U/G5WYEK8unjc1Zz4l2IDGqPbLQFMovrEHBMwPD5SeGqzKnCs1HgnT4CI5Hfo1attsgV XSkQ== X-Gm-Message-State: AFq9FYLFPA/9Z+6eY7wvW5PZnLNQ5x/UfPsAKPlWgnNBJsE/v0pG4qtR Y7SrGiYvJnBRjetZw/0L4i8AuLOzTj/VlE6kausZfxJolO3veRUkUIw4YaSXVjYTE+sD93SgCKw d0nOU X-Gm-Gg: AYBFou3HKAnzKCwbpgMkSkzCU8aNgbTxCGhqgxJevCesH9K7R6VzkAm9OWplW5H0kuT 8DLbCu3RbLwa+/J77YWQW12eE9+9L5EpqjUL8B5K9NhpUbjuSixBXWoHiPttrfWYwbOvb+YbXgQ txA8GWrJYXi/qZhH5MEv/QRaqSeNSrcfjSBDva/N+tcWp77oE/LmAxcUbMMvF4m0Jcuq+kXAWNG SbM//oRI5HbqUamrarEKdbDri6O9mfRdZSKJm0EZWKBSt4AluElgx3l9DEJvt1mZXnStAFgQLbo Bqpc+0LoRRiweiJQRQUzI44qjSwClGxv8/yypbSlYknTzDSxeE8IKTFbT5j/eq5MxDCqC00K1SK tmna9+jtRBNkweWIcmiOP2byUlnCIAoFGO8E/HUeLRtzN2Vn4UJph4YFAjOQM1/aTHPmV2NbGpO YNUGsgXivPMdpHNT791azg1bEE9LAcbwEj3vU7beonD4z4176fC1b+t7I+VWLGDktpUga8dcX/J c7lB6c1Qp92P03YQta7LW30Um2MAGve06CDETRGxu/w9XptVJK/TcEZjk21Kb3s/M3cdo/IIN8Q N45DmBuEFckkd2nKWkI8bfC+h7cxvkS3Bn4= X-Received: by 2002:a05:690c:6609:b0:8ae:b617:7138 with SMTP id 00721157ae682-8b2b6769adamr22092217b3.49.1793386572679; Fri, 30 Oct 2026 11:56:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 12/14] tcg/aarch64: Implement INDEX_op_goto_jc Date: Fri, 30 Oct 2026 13:55:49 -0500 Message-ID: <20261030185551.193092-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112c; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112c.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: qemu development 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: 1793386676551158500 Content-Type: text/plain; charset="utf-8" Use ldp to load multiple values at once. Use ccmp to reduce the number of branhes. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target-con-set.h | 1 + tcg/aarch64/tcg-target.c.inc | 129 +++++++++++++++++++++++++++++-- 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/tcg/aarch64/tcg-target-con-set.h b/tcg/aarch64/tcg-target-con-= set.h index dd84a9af58..9d13aef4a3 100644 --- a/tcg/aarch64/tcg-target-con-set.h +++ b/tcg/aarch64/tcg-target-con-set.h @@ -14,6 +14,7 @@ C_O0_I2(r, rC) C_O0_I2(rz, r) C_O0_I2(w, r) C_O0_I3(rz, rz, r) +C_O0_I4(r, rz, ri, ri) C_O1_I1(r, r) C_O1_I1(w, r) C_O1_I1(w, w) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 1c3cf835e2..f3264545a3 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -570,6 +570,10 @@ typedef enum { /* Logical shifted register instructions (with a shift). */ Iaddsub_realshift_AND_LSR =3D Ilogic_shift_AND | (1 << 22), =20 + /* Conditional compare. */ + Iccmp_reg_CCMP =3D 0x7a400000, + Iccmp_imm_CCMP =3D 0x7a400800, + /* AdvSIMD copy */ Isimd_copy_DUP =3D 0x0e000400, Isimd_copy_INS =3D 0x4e001c00, @@ -712,6 +716,16 @@ static void tcg_out_insn_bcond_imm(TCGContext *s, AArc= h64Insn insn, tcg_out32(s, insn | tcg_cond_to_aarch64[c] | (imm19 & 0x7ffff) << 5); } =20 +static void tcg_out_insn_ccmp_reg(TCGContext *s, AArch64Insn insn, + TCGType ext, TCGCond c, TCGReg rn, + TCGReg rm, unsigned nzcv) +{ + tcg_out32(s, insn | ext << 31 | tcg_cond_to_aarch64[c] << 12 + | rm << 16 | rn << 5 | nzcv); +} + +#define tcg_out_insn_ccmp_imm tcg_out_insn_ccmp_reg + static void tcg_out_insn_tbz(TCGContext *s, AArch64Insn insn, TCGReg rt, int imm6, int imm14) { @@ -1450,12 +1464,17 @@ static void tcg_out_br(TCGContext *s, TCGLabel *l) } } =20 +static void tgen_b_c(TCGContext *s, TCGCond c, TCGLabel *l) +{ + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); + tcg_out_insn(s, bcond_imm, B_C, c, 0); +} + static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, TCGReg a, TCGReg b, TCGLabel *l) { tgen_cmp(s, type, c, a, b); - tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); - tcg_out_insn(s, bcond_imm, B_C, c, 0); + tgen_b_c(s, c, l); } =20 static void tgen_brcondi(TCGContext *s, TCGType ext, TCGCond c, @@ -1502,8 +1521,7 @@ static void tgen_brcondi(TCGContext *s, TCGType ext, = TCGCond c, =20 if (need_cmp) { tgen_cmpi(s, ext, c, a, b); - tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); - tcg_out_insn(s, bcond_imm, B_C, c, 0); + tgen_b_c(s, c, l); return; } =20 @@ -2008,8 +2026,109 @@ static const TCGOutOpQemuLdSt2 outop_qemu_st2 =3D { .out =3D tgen_qemu_st2, }; =20 +static void tgen_goto_jc_cmp_ccmp(TCGContext *s, + TCGReg reg1, TCGArg ref1, bool const_ref= 1, + const uint64_t *tb_slot1, + TCGReg reg2, TCGArg ref2, bool const_ref= 2, + const uint64_t *tb_slot2, + TCGCond ccmp_cond, unsigned ccmp_nzcv) +{ + if (!const_ref1) { + tgen_cmp(s, TCG_TYPE_I64, TCG_COND_NE, reg1, ref1); + } else if (tcg_target_const_match(ref1, TCG_CT_CONST_CMP, + TCG_TYPE_I64, TCG_COND_NE, 0)) { + tgen_cmpi(s, TCG_TYPE_I64, TCG_COND_NE, reg1, ref1); + } else { + if (tb_slot1 && ref1 =3D=3D *tb_slot1) { + tcg_out_insn(s, ldlit, LDR, tcg_pcrel_diff(s, tb_slot1) >> 2, + TCG_REG_TMP2); + } else { + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP2, ref1); + } + tgen_cmp(s, TCG_TYPE_I64, TCG_COND_NE, reg1, TCG_REG_TMP2); + } + + if (!const_ref2) { + tcg_out_insn(s, ccmp_reg, CCMP, TCG_TYPE_I64, ccmp_cond, + reg2, ref2, ccmp_nzcv); + } else if (ref2 <=3D 0x1f) { + tcg_out_insn(s, ccmp_imm, CCMP, TCG_TYPE_I64, ccmp_cond, + reg2, ref2, ccmp_nzcv); + } else { + if (!is_aimm(ref2) && tb_slot2 && ref2 =3D=3D *tb_slot2) { + tcg_out_insn(s, ldlit, LDR, tcg_pcrel_diff(s, tb_slot2) >> 2, + TCG_REG_TMP2); + } else { + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP2, ref2); + } + tcg_out_insn(s, ccmp_reg, CCMP, TCG_TYPE_I64, ccmp_cond, + reg2, TCG_REG_TMP2, ccmp_nzcv); + } +} + +static void tgen_goto_jc(TCGContext *s, TCGReg ptr, TCGReg pc, + TCGArg cs, bool const_cs, + TCGArg fl, bool const_fl, TCGLabel *label) +{ + const TranslationBlock *tb =3D tcg_splitwx_to_rx(s->gen_tb); + + /* ptr is CPUJumpCache */ + + QEMU_BUILD_BUG_ON(offsetof(CPUJumpCache, array[0].pc) !=3D + offsetof(CPUJumpCache, array[0].tb) + 8); + tcg_out_insn(s, ldstpair, LDP, ptr, TCG_REG_TMP0, ptr, + offsetof(CPUJumpCache, array[0].tb), 1, 0); + + /* + * if (ptr =3D=3D 0 || pc !=3D tmp) goto label; + * + * z=3Dcmp(ptr,0) + * if !z, z=3Dcmp(pc,tmp), else z=3D0 + * if !z, goto label + */ + tgen_goto_jc_cmp_ccmp(s, ptr, 0, true, NULL, + TCG_REG_TMP0, pc, false, NULL, + TCG_COND_NE, 0b0000); + tgen_b_c(s, TCG_COND_NE, label); + + /* ptr is now TranslationBlock */ + + QEMU_BUILD_BUG_ON(offsetof(TranslationBlock, flags) !=3D + offsetof(TranslationBlock, cs_base) + 8); + tcg_out_insn(s, ldstpair, LDP, TCG_REG_TMP0, TCG_REG_TMP1, + ptr, offsetof(TranslationBlock, cs_base), 1, 0); + tcg_out_ld(s, TCG_TYPE_PTR, ptr, ptr, offsetof(TranslationBlock, tc.pt= r)); + + /* + * if (cs !=3D tmp0 || fl !=3D tmp1) goto label; + * + * z=3Dcmp(cs,tmp0) + * if z, z=3Dcmp(fl,tmp1), else z=3D0 + * if !z, goto label + * + * Since both comparisons are logically NE, sort the register or + * smaller immediate value second, where it is slightly more likely + * to be able to use CCMP (immediate). + */ + if (!const_fl || (const_cs && fl < cs)) { + tgen_goto_jc_cmp_ccmp(s, TCG_REG_TMP0, cs, const_cs, &tb->cs_base, + TCG_REG_TMP1, fl, const_fl, + (const uint64_t *)&tb->flags, + TCG_COND_EQ, 0b0000); + } else { + tgen_goto_jc_cmp_ccmp(s, TCG_REG_TMP1, fl, const_fl, + (const uint64_t *)&tb->flags, + TCG_REG_TMP0, cs, const_cs, &tb->cs_base, + TCG_COND_EQ, 0b0000); + } + tgen_b_c(s, TCG_COND_NE, label); + + tcg_out_goto_ptr(s, ptr); +} + static const TCGOutOpGotoJC outop_goto_jc =3D { - .base.static_constraint =3D C_NotImplemented, + .base.static_constraint =3D C_O0_I4(r, rz, ri, ri), + .out =3D tgen_goto_jc, }; =20 static const tcg_insn_unit *tb_ret_addr; --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386705; cv=none; d=zohomail.com; s=zohoarc; b=a2VP7WYLA/+qCFbB+ckPLjDj+PDWOm9MRjy1qaFfEFKME5NACq9Khoy34gDCN4hQS9ve0+15K0ArspGobYoB5vUF8prthluzJxV8wiolEcw15Qi5B8bBiyG+vhyzcWxmRaXXH69fo3pDmqjcZvHSC2Npmj7HECAYO6Zx7/hDSUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386705; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PKaovmZvoy42vyhXFWLgIndq++j7MuMZxApm2MP9S5U=; b=fdVrPUmruQxLbbwFTBR5wxp+W5IzR1AiqIunZMnzV9cBj2hm4KIKh8rb3uwDATm5iu+0WDcEQ3NyotS9hBdXv3cwUvc9mL8gA9ALZr1hYguFH1pYa3bXK0uK89WCdjb7WGfqAjcracmPHxMlCso4c3BcxGAPL/A3e0+OazzvYbs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386705007716.3795246874832; Fri, 30 Oct 2026 11:58:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrnR-0008Id-Ii; Fri, 30 Oct 2026 14:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrm0-0006uN-UK for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:21 -0400 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlw-0004pR-R5 for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:20 -0400 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-8b05bf699easo11198277b3.2 for ; Fri, 30 Oct 2026 11:56:14 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386574; x=1793991374; darn=nongnu.org; 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:content-type; bh=PKaovmZvoy42vyhXFWLgIndq++j7MuMZxApm2MP9S5U=; b=fk3LcVEO3UhyCTtpJdlVsO9AdPIB7eCaj28YUU5XN6dj2A4yTb3KwP+hb69EQvqSyw KMCKGEdo0Ji9Ures5dxvAGinOWb3Nx4qYuVDSAQJzvYHYotUHlPf1+w4CKQRM/OLpZrt curSeJ6hB9kObJSscdNNZOAfKXZ5m6jss6TqhXnr50x9m9CAGKb9LPsKck0UFtGA7KHJ YMeAOojxIss391JpjZAhD+Ve0HqS7xSP7Qc51shxQufWLWDOU7xAnAeWQ/OFO2t1o2pD Ehky8Rsm3JphBLEfqPjBexfixhc1GQU+zypMBd4hZqodort/vtHmqahg3QWDGh01j0DY HRvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386574; x=1793991374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PKaovmZvoy42vyhXFWLgIndq++j7MuMZxApm2MP9S5U=; b=bfDJU8ZqJrTOERnH33C6H75ubBF4Z1PyvIyuBVSoTqR1DX23SIxwmCchIZuDROpKeG otvh1hNLBugouijbM3LVqm8iL79AkvmdwkWBhxOsRyLdBvlM9TZ12+8b1t34tm6dpwY+ xMCdfEMpt9pOCYBGTG1M/m/77gCoYOWMX4kI2NNNT9vfsfzY6NFTzn0x2b0gxt5vUy+A a7NEExplYL79LpIkQTDB1UgTWw29ruSibl8msTKO1Dix1ckdqNbX7A408hrWtKpls0VM hwrrUcYE4L56WD7qqsj3ltgpaqn5d6SreIu8tRb84otFQqhGT5cqbCk3M6o4X88rEM/E kMaQ== X-Gm-Message-State: AFq9FYKN1virF9ElerePYfIyvjMnzx57ezU18XAIyReJh1kyyjvXLqy2 YF+DqDmMXjPjgZY1yO4j3QPcYMWscrfSq8/b7JHkDStvRVM85guvKsm6yr8YCGvnY6fPEOVtLnp 9OJIe X-Gm-Gg: AYBFou2cebS8a8upmylRUbi2RnE1GgxM05koC9mRvO0pKkz615MLU314UNP/szcuaI4 r9vKjTVMNjlHMAeoK2RwXI066UU4W5BYIzxFHZx+kwoXa0g7GDqAKeEVCK0J5VLepni8J6Q0CsX rSj0muWn+NiRCojTTGUY7O6VUrFfFV3mMxoGR8qu6NI1c6svIT4A8eL+NlIu3xcI/KfkrY2Sn10 kzm9XlD29tNapEuAZOmwWUEqATbFsWKhRi3g5h2jmliBJclgN2w8noXJ25G3bbdjLR5AJPcCHhA n5lJSJp8euGLzMLU02KnS0iNghB0iOACUoMgAhoFByVkup0hvThATvF2lq8+gVsA1EDcLj6Lxuj mYcS2OsMGC/vlAV9a1brlwJjKzEcyEL3M598jiQqEnwEAz1JtdrX+SipSqs/veVADWCQbRjRSJs 3J+xyTlhZBRSmmjsBi6uJuCNiEo+gSLkIghkK7hYss9LAHCDMZhqm4AVPeQU+VCyM/n1Jm/q9L6 UsI6iz9EhFvhcFo73CuoIbzuQgDQgRVNVud6gCMGzNPgbpoJBAuMh6zKcqjM2wxGJ5fez64RT+m 7KOxgyx/P4qiZbpBP1/xfAYeP49UBNdeCF4= X-Received: by 2002:a05:690c:ec3:b0:8ae:8607:e6cc with SMTP id 00721157ae682-8b2b65b261bmr19140547b3.2.1793386574006; Fri, 30 Oct 2026 11:56:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 13/14] tcg/s390x: Implement INDEX_op_goto_jc Date: Fri, 30 Oct 2026 13:55:50 -0500 Message-ID: <20261030185551.193092-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1135; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1135.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: qemu development 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: 1793386707135158500 Content-Type: text/plain; charset="utf-8" Use LGM to load multiple values at once. Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target-con-set.h | 1 + tcg/s390x/tcg-target-con-str.h | 1 + tcg/s390x/tcg-target.c.inc | 60 +++++++++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/tcg/s390x/tcg-target-con-set.h b/tcg/s390x/tcg-target-con-set.h index f67fd7898e..b22614d718 100644 --- a/tcg/s390x/tcg-target-con-set.h +++ b/tcg/s390x/tcg-target-con-set.h @@ -18,6 +18,7 @@ C_O0_I2(r, ri) C_O0_I2(r, rC) C_O0_I2(v, r) C_O0_I3(o, m, r) +C_O0_I4(r, h, hi, hi) C_O1_I1(r, r) C_O1_I1(v, r) C_O1_I1(v, v) diff --git a/tcg/s390x/tcg-target-con-str.h b/tcg/s390x/tcg-target-con-str.h index 636a38a168..e44b2a92d5 100644 --- a/tcg/s390x/tcg-target-con-str.h +++ b/tcg/s390x/tcg-target-con-str.h @@ -9,6 +9,7 @@ * REGS(letter, register_mask) */ REGS('r', ALL_GENERAL_REGS) +REGS('h', 0xfff8) /* general regs other than r0-r2 */ REGS('v', ALL_VECTOR_REGS) REGS('o', 0xaaaa) /* odd numbered general regs */ =20 diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 3b63383315..f31835da2b 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -3202,8 +3202,66 @@ static const TCGOutOpLea outop_lea =3D { .out =3D tgen_lea, }; =20 +static void tgen_goto_jc_cmp_part(TCGContext *s, TCGReg reg, + TCGArg ref, bool const_ref, + const uint64_t *tb_slot, TCGLabel *l) +{ + if (!const_ref || ref =3D=3D (int32_t)ref || ref =3D=3D (uint32_t)ref)= { + tgen_brcond(s, TCG_TYPE_I64, TCG_COND_NE, reg, ref, const_ref, l); + } else { + if (ref =3D=3D *tb_slot) { + tcg_out_insn(s, RIL, CGRL, reg, tcg_pcrel_diff(s, tb_slot) >> = 1); + } else { + tcg_out_insn(s, RIL, CGRL, reg, 0); + new_pool_label(s, ref, R_390_PC32DBL, s->code_ptr - 2, 2); + } + tgen_branch(s, S390_CC_NE, l); + } +} + +static void tgen_goto_jc(TCGContext *s, TCGReg ptr, TCGReg pc, + TCGArg cs, bool const_cs, + TCGArg fl, bool const_fl, TCGLabel *label) +{ + const TranslationBlock *tb =3D tcg_splitwx_to_rx(s->gen_tb); + + /* + * Note that pc, cs, fl are constrained to r3 or higher, r0 and r1 + * are always reserved as scratch, this is the end of the translation + * block so r2 may now be clobbered, and the input ptr * is dead + * after the initial LMG. + */ + + /* ptr is CPUJumpCache */ + + QEMU_BUILD_BUG_ON(offsetof(CPUJumpCache, array[0].pc) !=3D + offsetof(CPUJumpCache, array[0].tb) + 8); + /* lmg r1,r2,tb(ptr) */ + tcg_out_insn(s, RXY, LMG, TCG_REG_R1, ptr, TCG_REG_R2, + offsetof(CPUJumpCache, array[0].tb)); + + tgen_brcond(s, TCG_TYPE_I64, TCG_COND_NE, TCG_REG_R2, pc, false, label= ); + tgen_brcond(s, TCG_TYPE_PTR, TCG_COND_EQ, TCG_REG_R1, 0, true, label); + + /* R1 is now TranslationBlock */ + + QEMU_BUILD_BUG_ON(offsetof(TranslationBlock, flags) !=3D + offsetof(TranslationBlock, cs_base) + 8); + QEMU_BUILD_BUG_ON(offsetof(TranslationBlock, tc.ptr) !=3D + offsetof(TranslationBlock, cs_base) + 16); + /* lmg r0,r2,cs(r1) */ + tcg_out_insn(s, RXY, LMG, TCG_REG_R0, TCG_REG_R1, TCG_REG_R2, + offsetof(TranslationBlock, cs_base)); + + tgen_goto_jc_cmp_part(s, TCG_REG_R0, cs, const_cs, &tb->cs_base, label= ); + tgen_goto_jc_cmp_part(s, TCG_REG_R1, fl, const_fl, + (const uint64_t *)&tb->flags, label); + tcg_out_goto_ptr(s, TCG_REG_R2); +} + static const TCGOutOpGotoJC outop_goto_jc =3D { - .base.static_constraint =3D C_NotImplemented, + .base.static_constraint =3D C_O0_I4(r, h, hi, hi), + .out =3D tgen_goto_jc, }; =20 static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, --=20 2.53.0 From nobody Mon Nov 23 04:30:03 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=1793386664; cv=none; d=zohomail.com; s=zohoarc; b=FQLU26Y00ULWExFN/pXvCFY13DJEJU4KnQBgwlyD28t1Vb4OXLPnuV8fAI1W2efmtq5T09N4bkUbu7PWwD5VyjG8qYKd6tzlP53UC/HeaUMvO7zbtsMCM/zcS0n9Hg0EBT1ntSG2dwJU0yg/W2/3u5M4kqAwBAiYbNFBhBLs39Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793386664; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RB/sKLvvfUB0Wfzn/1ltw/gBKjTDiPFiEr9fRa8ubkg=; b=fKCg185m7UJ4Mz8w5G54jSInIe4VyLIkmBszqV54UB67LPK0fqS69CByjokjMc9hTbvdN99T6oLK4FpZR4b7hFgYAsDXqUzIIpo4QGQHi53MEu7wgy1G+tkOt1xZOWgLrUNM0KT1dY+ja+eGvu7KFH0z0QiS4uJl6aVrwbzxZkE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793386664380466.35387808502765; Fri, 30 Oct 2026 11:57:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMrn4-0007eb-Hg; Fri, 30 Oct 2026 14:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xMrm0-0006uP-UI for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:21 -0400 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xMrlw-0004pk-Ra for qemu-devel@nongnu.org; Fri, 30 Oct 2026 14:56:20 -0400 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-8b0d91601bdso18475357b3.1 for ; Fri, 30 Oct 2026 11:56:16 -0700 (PDT) Received: from stoup ([2607:fb90:5e62:412b:1381:b0c1:1339:9c82]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b2b71a13b1sm13209657b3.39.2026.10.30.11.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2026 11:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1793386575; x=1793991375; darn=nongnu.org; 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:content-type; bh=RB/sKLvvfUB0Wfzn/1ltw/gBKjTDiPFiEr9fRa8ubkg=; b=TY002fMwfqlP8ygxjKy2QCXQjTvu6ZymNUGI2NpyggT2lPSt5TqwFziO2/D1PsT4vC ClU8tlQGxCVjWPNLsZHAPsxIemxG7vx79KOEGhHsBBrhSVa38SRTgyGBx7XPWr98PObD YGhTI0SCvvpCkJBZ/jAcaP9Q8Hbkr9xphmAWWudyG9yUa869ly8KXJ151JSSIYNXzHyG tsxI+TPg3RgOS1tB3RQQeeQNqcj8hNAkhOrM3uzcKNIi7DxnSih1aW4Gd4Q3Uc4N7BhX ngMwTAaFQiCqnFqs+25hLaZ0sop7/QuT0JhpOGFTDqp+FXb+finXKiZh24b/oqWGLZHp AdkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793386575; x=1793991375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RB/sKLvvfUB0Wfzn/1ltw/gBKjTDiPFiEr9fRa8ubkg=; b=O/0jOMVcYxOkQEgiAuAT0+cQvXd7T2OExy2m5CfBe/dFdxfke1Ma0/yWru1CLazVAY jea7hq+FUmgHkgeoGLNP+Qt2XQpz1+ePE9pQJkEch3u7+yUtQlwGhoek0vEjpi/8rAOV ed5hqZN3Q+ZAvj+HbiJdQpXTMKL3AJK0ZYKl9dc64g22IIBnTfwY4oQJGuPDoMqBDL1o eg2TOXtpubv5hLlkhHtC8GEMfsWpOcwGGcAGxAp+s0nJQb+0a/bdGPGHlIUb29U8n03j 5i5Zyq2b2bgqdLkU6QZrP+nVVGmVWRYFTFZ0A5ZMWPZXisrOCkFYGhWd4A7iwKHmwYC8 zvYA== X-Gm-Message-State: AFq9FYJ394g1pzTLpiLVPrvROMsI0ZG9Te58Nr0Fgga+AL9Ba8046qrQ l7dUztuDDTazDFD+qDiOjd1dGQ38GrH1JCyCIJxccR/B3MELdAxfALHhCEERXzeM0iimr4dwlFr YeRPd X-Gm-Gg: AYBFou28iQo0W52axBITz3d3L6w5gdLtXNzE3g0dUsYooHNefiSDMlPsVvKvxNEyBi/ feBHQ01wLudomNnRLhcMrpWVrqrY+9dFA5X8BAu9JinYXGIeONaBKFAJxq4mWmczuOxQK4VjvU9 ufo6UguYWDViRGRyMXGdzdE7O6ARRAnOlIYp9FDTQz9Cxs1KjEHryUcnSzTqF8qS7p/T4CaaxAP 0n58J8GhFzJU3zRIVxAUO76KHfYu4Pr/din2qv7VlkkMsQJ4UjIEWjZXxKDtaeNRiczoaE39KUJ rHHiS55rB7QCil4SAAV2UX67WEOHSEXd7/yHf3CG0kiqjVM9SRi7KmymiXCF+ZkuNgAz2tQMIst BBF9gMB1rV68RdXfsv8tkEtFGbHmb9nqiUf8Jhrgii92ytLDRvMmSfPp1HLOK/A9yxenG+BgInx LBB3/FCM9HJhFzps5CJ6hVFmFbQtVr1RVio5XnAjO0wbCoNooGaE5jxt9Tw8aaI1a2LvelZAiU2 K6y9TiB4JPdVj/v/66K4jMkKCG3YeJnKzVKse7eIDsUNna6qpw0V6kmYO51dgr+vtWGemDyQptN sLa9wIqahf78VTbL46Vf+bujuW2/koQ+mEw= X-Received: by 2002:a05:690c:a906:10b0:8b0:cc88:cbe3 with SMTP id 00721157ae682-8b1c6691f71mr38533737b3.11.1793386575200; Fri, 30 Oct 2026 11:56:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: iii@linux.ibm.com, mattst88@gmail.com Subject: [PATCH v7 14/14] accel/tcg: Move tb_jmp_cache to CPUNegativeOffsetState Date: Fri, 30 Oct 2026 13:55:51 -0500 Message-ID: <20261030185551.193092-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261030185551.193092-1-richard.henderson@linaro.org> References: <20261030185551.193092-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1131; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1131.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: qemu development 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: 1793386667163154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 4 ++-- accel/tcg/cpu-exec.c | 8 ++++---- accel/tcg/cputlb.c | 2 +- accel/tcg/tb-maint.c | 2 +- accel/tcg/translate-all.c | 2 +- tcg/tcg-op.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5b7c330047..5d1b624e6c 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -369,9 +369,11 @@ typedef union IcountDecr { * @plugin_mem_cbs: active plugin memory callbacks * @plugin_mem_value_low: 64 lower bits of latest accessed mem value. * @plugin_mem_value_high: 64 higher bits of latest accessed mem value. + * @tb_jmp_cache: Hash table of recently accessed TranslationBlocks. */ typedef struct CPUNegativeOffsetState { CPUTLB tlb; + struct CPUJumpCache *tb_jmp_cache; #ifdef CONFIG_PLUGIN /* * The callback pointer are accessed via TCG (see gen_empty_mem_helper= ). @@ -528,8 +530,6 @@ struct CPUState { AddressSpace *as; MemoryRegion *memory; =20 - struct CPUJumpCache *tb_jmp_cache; - GArray *gdb_regs; int gdb_num_regs; int gdb_num_g_regs; diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 4c20091ef5..2ed8f7c251 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -237,7 +237,7 @@ static inline TranslationBlock *tb_lookup(CPUState *cpu= , TCGTBCPUState s) tcg_debug_assert(!(s.cflags & CF_INVALID)); =20 hash =3D tb_jmp_cache_hash_func(s.pc); - jc =3D cpu->tb_jmp_cache; + jc =3D cpu->neg.tb_jmp_cache; =20 tb =3D qatomic_read(&jc->array[hash].tb); if (likely(tb && @@ -1012,7 +1012,7 @@ cpu_exec_loop(CPUState *cpu, SyncClocks *sc) * for the fast lookup */ h =3D tb_jmp_cache_hash_func(s.pc); - jc =3D cpu->tb_jmp_cache; + jc =3D cpu->neg.tb_jmp_cache; jc->array[h].pc =3D s.pc; qatomic_set(&jc->array[h].tb, tb); } @@ -1109,7 +1109,7 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp) /* Pick up one-insn-per-tb and -d nochain from the command line. */ tcg_update_cflags(cpu); =20 - cpu->tb_jmp_cache =3D g_new0(CPUJumpCache, 1); + cpu->neg.tb_jmp_cache =3D g_new0(CPUJumpCache, 1); tlb_init(cpu); #ifndef CONFIG_USER_ONLY tcg_iommu_init_notifier_list(cpu); @@ -1127,5 +1127,5 @@ void tcg_exec_unrealizefn(CPUState *cpu) #endif /* !CONFIG_USER_ONLY */ =20 tlb_destroy(cpu); - g_free_rcu(cpu->tb_jmp_cache, rcu); + g_free_rcu(cpu->neg.tb_jmp_cache, rcu); } diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index dc83f3bad8..c777f5ac3f 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -149,7 +149,7 @@ static void tlb_window_reset(CPUTLBDesc *desc, int64_t = ns, =20 static void tb_jmp_cache_clear_page(CPUState *cpu, vaddr page_addr) { - CPUJumpCache *jc =3D cpu->tb_jmp_cache; + CPUJumpCache *jc =3D cpu->neg.tb_jmp_cache; int i, i0; =20 if (unlikely(!jc)) { diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 4313864d2c..ca1b0089fc 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -905,7 +905,7 @@ static void tb_jmp_cache_inval_tb(TranslationBlock *tb) uint32_t h =3D tb_jmp_cache_hash_func(tb->pc); =20 CPU_FOREACH(cpu) { - CPUJumpCache *jc =3D cpu->tb_jmp_cache; + CPUJumpCache *jc =3D cpu->neg.tb_jmp_cache; =20 if (qatomic_read(&jc->array[h].tb) =3D=3D tb) { qatomic_set(&jc->array[h].tb, NULL); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ea8257935e..3dd1714414 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -624,7 +624,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) */ void tcg_flush_jmp_cache(CPUState *cpu) { - CPUJumpCache *jc =3D cpu->tb_jmp_cache; + CPUJumpCache *jc =3D cpu->neg.tb_jmp_cache; =20 /* During early initialization, the cache may not yet be allocated. */ if (unlikely(jc =3D=3D NULL)) { diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 0040d149e0..7969875d20 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1914,7 +1914,7 @@ static void gen_jc_probe(TCGTemp *pc, TCGTemp *cs_bas= e, uint32_t flags) /* p =3D &jc->array[tb_jmp_cache_hash_func(pc)] */ gen_jc_hash(h, t, pc); tcg_gen_ld(TCG_TYPE_I64, t, tcgv_ptr_temp(tcg_env), - offsetof(CPUState, tb_jmp_cache) - sizeof(CPUState)); + offsetof(CPUState, neg.tb_jmp_cache) - sizeof(CPUState)); tcg_gen_lea(TCG_TYPE_I64, p, t, h, 4, 0); =20 if (tcg_op_supported(INDEX_op_goto_jc, TCG_TYPE_PTR, 0)) { --=20 2.53.0