From nobody Mon Feb 9 05:43:06 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 ARC-Seal: i=1; a=rsa-sha256; t=1673196518; cv=none; d=zohomail.com; s=zohoarc; b=NIWGGM6+kbIqnuO3WQBBKFSzKNkWWIfjJc5jXwBw+x5IFBtwWq6LRMcn9Egi2xuqGnzpfYaMuI6Z17hUc8vAqgy/T0eu4MbZRRZzmguIkQCTRlnAPIndALLctj3AdRom+TlfYJ9bgFBYYj9dTbkRvZzYii55UrxlGsWM6hLYiAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673196518; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d92HqZO3HGiFOo1ukeBZZ1sHajJw5wbqCOY5xB+iG3Y=; b=TS15nfnlzGm447umr+VyIQrHb3XljvsHnagS8YdOeXf+C5BpNy6JX6qkedfNr36BOCWKIOe5EqcGpDNaXqmAX7ZzluNg2SZGIjIjp3Cmvi5by74Ckx+3/eTcJZD3xIJiP7Bf783m9793/oRY44+y691hMz0Y3KKGBx/bx0x0gA4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673196518018811.8658158738202; Sun, 8 Jan 2023 08:48:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEYqG-0006jB-Vp; Sun, 08 Jan 2023 11:48:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEYqC-0006ed-Lk for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:13 -0500 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEYqB-0000OX-0G for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:12 -0500 Received: by mail-qt1-x834.google.com with SMTP id h26so6187094qtu.2 for ; Sun, 08 Jan 2023 08:48:08 -0800 (PST) Received: from localhost ([185.156.46.146]) by smtp.gmail.com with ESMTPSA id y19-20020a05620a44d300b006fba44843a5sm3944808qkp.52.2023.01.08.08.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 08:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d92HqZO3HGiFOo1ukeBZZ1sHajJw5wbqCOY5xB+iG3Y=; b=i1T1hhedKv82+w3CXqbSpjPXjY44utNEg38vZv2h1443abOjQYcSJlSbwRADz5RxzL DtqnFau3spj+1JbhD6HY7j+e0sX+fHTl+YGuaXKAcCmCY8Y8hknN00ufrpORWRv0TKg/ lQEqGA/o9B6QDL8/RDBYpjxaOh0oGbQx+pRYydew8PQFjUVf4kGN+7g9k/0lOeGLhKWz cNYLMcecep8SVJpAJkw7GlwC/kDc1xnQ+RWupehaGN/3vDR7tcCyCqjPIGEo5L9S9kGk H1k+kfo9fY8nHX2/2b4ptDF+jJf7AMkinDhD9JBU07QXnQsMe1ydizgbvEpCGQQHGgID 4FEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d92HqZO3HGiFOo1ukeBZZ1sHajJw5wbqCOY5xB+iG3Y=; b=qVz2DxuJ1MQeRfp102jHReK1ge0tKFtU2dqb4MV/EU4+Wt7RK5u7E3eoyulePWfih8 MFdrIfOtu21pBHszsiGbb+tZ6I+YHuH6rVB/EETCxVlTW+keoyrmVVJtWcgENvgU+Ag/ 09dcrbyA0bdeyuNKB/VXC+ZuaQA33iVRQShIb5HPJUplBmr/ou1OcjyEyxyQlikoZY74 ZYQ5tvGEaN55ntVQtHy5xI3jBPeF2Zu5sanQR2VsDjmllltz1XeL4ar9CwIFPirn04jz pc5SOVfUy4au2rxU6Rryhuuyq8Sk1XLHcspRZEdMOB7iGhpC2QWYYgiXFtdqNApp4qLn kW2A== X-Gm-Message-State: AFqh2ko0QuldFS2OUOoX9b1YfBQZwvBo3WIrUAHzLMCbpawkgaNhOp9j fgmWc3NBbVW4k6pAlc4IdkIqHYUeyI4kTRIYWm4G/g== X-Google-Smtp-Source: AMrXdXtKIFpPDvDySKVHQC06IzxOpADUPEQv9FxYQ9uwIrUoiFCfO6cUF3HalYRlklke9wKRN+ONYw== X-Received: by 2002:a05:622a:4d06:b0:3a9:9217:9e6c with SMTP id fd6-20020a05622a4d0600b003a992179e6cmr97761509qtb.55.1673196487264; Sun, 08 Jan 2023 08:48:07 -0800 (PST) From: Emilio Cota To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Aaron Lindsay , Emilio Cota Subject: [PATCH 1/4] plugins: fix optimization in plugin_gen_disable_mem_helpers Date: Sun, 8 Jan 2023 11:47:28 -0500 Message-Id: <20230108164731.61469-2-cota@braap.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108164731.61469-1-cota@braap.org> References: <20230108164731.61469-1-cota@braap.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=2607:f8b0:4864:20::834; envelope-from=cota@braap.org; helo=mail-qt1-x834.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @braap-org.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1673196519455100005 Content-Type: text/plain; charset="utf-8" We were mistakenly checking tcg_ctx->plugin_insn as a canary to know whether the TB had emitted helpers that might have accessed memory. The problem is that tcg_ctx->plugin_insn gets updated on every instruction in the TB, which results in us wrongly performing the optimization (i.e. not clearing cpu->plugin_mem_cbs) way too often, since it's not rare that the last instruction in the TB doesn't use helpers. Fix it by tracking a per-TB canary. While at it, expand documentation. Related: #1381 Signed-off-by: Emilio Cota Tested-by: Aaron Lindsay --- accel/tcg/plugin-gen.c | 26 ++++++++++++++++++-------- include/qemu/plugin.h | 7 +++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c7d6514840..17a686bd9e 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -579,7 +579,8 @@ static void inject_mem_helper(TCGOp *begin_op, GArray *= arr) * is possible that the code we generate after the instruction is * dead, we also add checks before generating tb_exit etc. */ -static void inject_mem_enable_helper(struct qemu_plugin_insn *plugin_insn, +static void inject_mem_enable_helper(struct qemu_plugin_tb *ptb, + struct qemu_plugin_insn *plugin_insn, TCGOp *begin_op) { GArray *cbs[2]; @@ -599,6 +600,7 @@ static void inject_mem_enable_helper(struct qemu_plugin= _insn *plugin_insn, rm_ops(begin_op); return; } + ptb->mem_helper =3D true; =20 arr =3D g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), n_cbs); @@ -626,15 +628,22 @@ void plugin_gen_disable_mem_helpers(void) { TCGv_ptr ptr; =20 - if (likely(tcg_ctx->plugin_insn =3D=3D NULL || - !tcg_ctx->plugin_insn->mem_helper)) { + /* + * We could emit the clearing unconditionally and be done. However, th= is can + * be wasteful if for instance plugins don't track memory accesses, or= if + * most TBs don't use helpers. Instead, emit the clearing iff the TB c= alls + * helpers that might access guest memory. + * + * Note: we do not reset plugin_tb->mem_helper here; a TB might have s= everal + * exit points, and we want to emit the clearing from all of them. + */ + if (!tcg_ctx->plugin_tb->mem_helper) { return; } ptr =3D tcg_const_ptr(NULL); tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); tcg_temp_free_ptr(ptr); - tcg_ctx->plugin_insn->mem_helper =3D false; } =20 static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, @@ -682,14 +691,14 @@ static void plugin_gen_mem_inline(const struct qemu_p= lugin_tb *ptb, inject_inline_cb(cbs, begin_op, op_rw); } =20 -static void plugin_gen_enable_mem_helper(const struct qemu_plugin_tb *ptb, +static void plugin_gen_enable_mem_helper(struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { struct qemu_plugin_insn *insn =3D g_ptr_array_index(ptb->insns, insn_i= dx); - inject_mem_enable_helper(insn, begin_op); + inject_mem_enable_helper(ptb, insn, begin_op); } =20 -static void plugin_gen_disable_mem_helper(const struct qemu_plugin_tb *ptb, +static void plugin_gen_disable_mem_helper(struct qemu_plugin_tb *ptb, TCGOp *begin_op, int insn_idx) { struct qemu_plugin_insn *insn =3D g_ptr_array_index(ptb->insns, insn_i= dx); @@ -750,7 +759,7 @@ static void pr_ops(void) #endif } =20 -static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb) +static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb) { TCGOp *op; int insn_idx =3D -1; @@ -870,6 +879,7 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasCont= extBase *db, ptb->haddr1 =3D db->host_addr[0]; ptb->haddr2 =3D NULL; ptb->mem_only =3D mem_only; + ptb->mem_helper =3D false; =20 plugin_gen_empty_callback(PLUGIN_GEN_FROM_TB); } diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index a772e14193..e0ebedef84 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -118,7 +118,10 @@ struct qemu_plugin_insn { void *haddr; GArray *cbs[PLUGIN_N_CB_TYPES][PLUGIN_N_CB_SUBTYPES]; bool calls_helpers; + + /* if set, the instruction calls helpers that might access guest memor= y */ bool mem_helper; + bool mem_only; }; =20 @@ -158,6 +161,10 @@ struct qemu_plugin_tb { void *haddr1; void *haddr2; bool mem_only; + + /* if set, the TB calls helpers that might access guest memory */ + bool mem_helper; + GArray *cbs[PLUGIN_N_CB_SUBTYPES]; }; =20 --=20 2.34.1 From nobody Mon Feb 9 05:43:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673196518046983.6902720616492; Sun, 8 Jan 2023 08:48:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEYqG-0006in-OY; Sun, 08 Jan 2023 11:48:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEYqE-0006gA-J0 for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:14 -0500 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEYqD-0000Q9-40 for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:14 -0500 Received: by mail-qv1-xf33.google.com with SMTP id j9so4694794qvt.0 for ; Sun, 08 Jan 2023 08:48:12 -0800 (PST) Received: from localhost ([185.156.46.146]) by smtp.gmail.com with ESMTPSA id y10-20020a05620a25ca00b006fa4cac54a5sm3915882qko.72.2023.01.08.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 08:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bfHq7d6gEeqDcPDN5XCy/P/V1tIeaifeaACu/hJYYAI=; b=0kTMznWqh+avjIW3JXqlsnVR8vzd7KkcmsE6WgY1wVx9OqjeYaDq0YeJVZhlV5+3Rw jeG2wcF5pBd1gRONVdFO9e3X5gfjuAMJcxkDnontL028yo2/4RiCaBRL9iEdlqy6ZiiU kJ1mlhO0fQI84Kl5odNfsn/swEOsby9rQAJExODqhOH6kVI8QRFZqCC+H2wTVjcUcmIO W99oF5vLewauU8DtwSNZRvGkDtEopplI8vlxwGO+asXhj4lY/3IrHLyzEJagyrvsVBvY zt4qGcs7SAnq8/SPY9UyuVbu3FX9h9xUASFr+mHnryTNsHX5nQbe3Zm2W6p2jIsFKUAH BGMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bfHq7d6gEeqDcPDN5XCy/P/V1tIeaifeaACu/hJYYAI=; b=64mF/fDJuixUY1wv3qpjy+R+3fTBtLbT94/AmAWUQR+drLaztIH7MbGEjQXhf3A+qG wgjlm5AycUILGVw9o0FWS36s10qfb0+TlGxfpLAwnZAQgfliysdiQlCZZNqdrUhb/DiH jLVQYO82fl8qto8bsB3hADjYJTRsXGDIeAVmDUBGS5u3pYnc9Oqs0lW0onE220ktmrwN 7U3AhdxB+v9duhsBPHT7VgoQvNlLN4imU0KKk+qSehXlSB3DBAGGy/HINYOwI04O/hRV 7lOzqlj2c+237Xg8hDQAtU88y1Da9C1HON3JGgQtfEWDwEqObBVgGkn5YyCda18PavCk JJ1A== X-Gm-Message-State: AFqh2krvcflTh2DQlJmDlafm0v/z8miAeMMpdlmrlRXoF/L/uwXXHqe1 yPglJl0zbrxV8GeIP/yc2N1x/wVd+i5iOGWWS+Y5DA== X-Google-Smtp-Source: AMrXdXt3KLZnifqhYTxinAzAtqiiTLprsDw1jeoXfeiiY0aQBO/ez4Z5tDi71xQAG9JKGDagCuVZLg== X-Received: by 2002:a05:6214:5a07:b0:532:1ebe:84c8 with SMTP id lu7-20020a0562145a0700b005321ebe84c8mr11351759qvb.2.1673196491988; Sun, 08 Jan 2023 08:48:11 -0800 (PST) From: Emilio Cota To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Aaron Lindsay , Emilio Cota Subject: [PATCH 2/4] translator: always pair plugin_gen_insn_{start, end} calls Date: Sun, 8 Jan 2023 11:47:29 -0500 Message-Id: <20230108164731.61469-3-cota@braap.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108164731.61469-1-cota@braap.org> References: <20230108164731.61469-1-cota@braap.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=2607:f8b0:4864:20::f33; envelope-from=cota@braap.org; helo=mail-qv1-xf33.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1673196519310100002 Content-Type: text/plain; charset="utf-8" Related: #1381 Signed-off-by: Emilio Cota Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Aaron Lindsay --- accel/tcg/translator.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 061519691f..ef5193c67e 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -100,19 +100,24 @@ void translator_loop(CPUState *cpu, TranslationBlock = *tb, int max_insns, ops->translate_insn(db, cpu); } =20 - /* Stop translation if translate_insn so indicated. */ - if (db->is_jmp !=3D DISAS_NEXT) { - break; - } - /* * We can't instrument after instructions that change control * flow although this only really affects post-load operations. + * + * Calling plugin_gen_insn_end() before we possibly stop translati= on + * is important. Even if this ends up as dead code, plugin generat= ion + * needs to see a matching plugin_gen_insn_{start,end}() pair in o= rder + * to accurately track instrumented helpers that might access memo= ry. */ if (plugin_enabled) { plugin_gen_insn_end(); } =20 + /* Stop translation if translate_insn so indicated. */ + if (db->is_jmp !=3D DISAS_NEXT) { + break; + } + /* Stop translation if the output buffer is full, or we have executed all of the allowed instructions. */ if (tcg_op_buf_full() || db->num_insns >=3D db->max_insns) { --=20 2.34.1 From nobody Mon Feb 9 05:43:06 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 ARC-Seal: i=1; a=rsa-sha256; t=1673196526; cv=none; d=zohomail.com; s=zohoarc; b=kYVb588o8p2a0+xyFJpdWBZspewGna9WjLS93gLsEUfy8332v+LzG7eYfKvOCBObpV6953+JSSLH7KeqM9hiwkrATTkqMkaP2qeWFUq5ioB1QahWanTP3VOCHvC0AajXyv4becJ5pyW+YzIyTjta1e3mQ3f1DUunwwGs+qqHP+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673196526; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aaox4hWeUonfLH9h27CRl8dbbaN6wq8FriB4sD8Tzls=; b=ZsZM6sYT0/UrCp+NmcgcsDouzgmMkAfPfQ3C/SceyqjD3K28RbQddYICmHS64gZSe96q+FJhIpDuP/gCt62fslr/sU822/YyvjAn6O5pxr8DWunljdn35TtNfYfavTeeh5l+0broUIw+44D2YiYjNfu7n7axDaxp90sXXoeAKMU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673196526332873.8839345904521; Sun, 8 Jan 2023 08:48:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEYqI-0006md-E9; Sun, 08 Jan 2023 11:48:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEYqH-0006jk-5p for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:17 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEYqF-0000RF-Kc for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:48:16 -0500 Received: by mail-qt1-x835.google.com with SMTP id a16so6066010qtw.10 for ; Sun, 08 Jan 2023 08:48:15 -0800 (PST) Received: from localhost ([185.156.46.146]) by smtp.gmail.com with ESMTPSA id d8-20020ac84e28000000b0039c7b9522ecsm3423049qtw.35.2023.01.08.08.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 08:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aaox4hWeUonfLH9h27CRl8dbbaN6wq8FriB4sD8Tzls=; b=cs8ThutuSniVZr9lXiuMr2nxzejs1YJPLGfk+HJmL6t9qhUUdTAjOX2tg6AEqsNYKH 0xTjWBn9PmRwHWfdfnPLlLwUuPo5f30gPA+cGIi2M8bsSsKD6G3sy/QvIorKZuezZ2Si z1awLF/QNaz+p+e1PJO/ups7/zXSRwJvFlDznslzwAldP1Q8aSs6Fs+AmteM+atq0xt4 O+zRT6jW8F6XzhMVN95tKM8BSmrEbYiaspxDqBN813IgK4cA4AAA7k48iGrum8+BF1d8 /m0KYLv5ssn+HuuBc+9GDD/xtCUXdcA57uT/vRBHUyiLakBdxmeN4KqZnGsVBafzzFMX 5mKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aaox4hWeUonfLH9h27CRl8dbbaN6wq8FriB4sD8Tzls=; b=fShNzRmicXQT5+r6igJR8uh0FJXTYFvSkjnm/VqJnSCexiw5wpwNndHsjZp2VLSavy W3FmuQ3OPtHH/VU+q1ulfRp2E9vp72nYWOgKf8aqalTPYgQzXZOVLPq/HQ57WGDqYB5B /oBkyfEN72/fWrLBbhVAW7CX3VNn97RzxRd+yZuoiHOjJcZdI+sUoiA4CZTxvUk04KmH zH7dDY8VqSGERQiLG4g1s/nXTqF0/+Io6dnsIsnV8WcgwqOV3jiKsEAtzNT//5bzOTUv XZdVIJSus7VfCMHRpsDXHfB6HQztzSCLl2plFsBAWDkheLL00cd+8N+Pd0uoxjWvQq1H gBvg== X-Gm-Message-State: AFqh2kpt3OkdIiBagonitNde3ElHKSiXI09pEML1NSvm7GrwY/HQjX9Z T1JZCeyxNSl2HG6Rr6H2iY3wTeZo4mmRF6aBd9N08Q== X-Google-Smtp-Source: AMrXdXsKSaneRLjlZbHZ+fJdM1mwTrjxWbk5PMBpMBqTyf82ZPlERlEAn8LNuiWMSOOddKjpm4+i4A== X-Received: by 2002:ac8:4a93:0:b0:3a7:ec9b:e00b with SMTP id l19-20020ac84a93000000b003a7ec9be00bmr84094402qtq.68.1673196494520; Sun, 08 Jan 2023 08:48:14 -0800 (PST) From: Emilio Cota To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Aaron Lindsay , Emilio Cota Subject: [PATCH 3/4] tcg: exclude lookup_tb_ptr from helper instrumentation Date: Sun, 8 Jan 2023 11:47:30 -0500 Message-Id: <20230108164731.61469-4-cota@braap.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108164731.61469-1-cota@braap.org> References: <20230108164731.61469-1-cota@braap.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=2607:f8b0:4864:20::835; envelope-from=cota@braap.org; helo=mail-qt1-x835.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @braap-org.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1673196527120100001 Content-Type: text/plain; charset="utf-8" It is internal to TCG and therefore we know it does not access guest memory. Related: #1381 Signed-off-by: Emilio Cota --- tcg/tcg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index da91779890..ee67eefc0c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1652,8 +1652,10 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nar= gs, TCGTemp **args) op =3D tcg_op_alloc(INDEX_op_call, total_args); =20 #ifdef CONFIG_PLUGIN - /* detect non-plugin helpers */ - if (tcg_ctx->plugin_insn && unlikely(strncmp(info->name, "plugin_", 7)= )) { + /* flag helpers that are not internal to TCG */ + if (tcg_ctx->plugin_insn && + strncmp(info->name, "plugin_", 7) && + strcmp(info->name, "lookup_tb_ptr")) { tcg_ctx->plugin_insn->calls_helpers =3D true; } #endif --=20 2.34.1 From nobody Mon Feb 9 05:43:06 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 ARC-Seal: i=1; a=rsa-sha256; t=1673196702; cv=none; d=zohomail.com; s=zohoarc; b=koQsydsJh1A1JKiG3L9tDGKyFqCcIM7FIpr+CvkQvyU8rEzfM8950GiWOlHJGa3MuFkoZF5PpWPBXU5oDW88Na/ketcUNFApt02PxvPheYghTd8NZshiu2hOR3jzQbqO5my2S3W4B73Wi/b6z3vzXtEbYpStK1Ld3ShOn3Z3QMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673196702; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qdYBozkTmEnnxMe67YTmLz59tHO5RbfllBVv5dQ0Y3U=; b=hkzvWXCggjQf7pTkogk15+9LeCbgnqjEP1YqxogamPxe+n6jYS98qjbl2jeQGeEpZP3JtnzmNwwZQJ/nkRFIR/O98gmgjB0wkjuH5Zvaz94UbfhxteV4GBKzBE2XA2cGOKyWQhWNTWWmvSM0JSlF0kKp1sZCRis1Angm0X/gAoY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673196702727211.8190567328653; Sun, 8 Jan 2023 08:51:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEYtL-0001rf-SA; Sun, 08 Jan 2023 11:51:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pEYtI-0001rU-6t for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:51:24 -0500 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEYtE-0001NE-VR for qemu-devel@nongnu.org; Sun, 08 Jan 2023 11:51:23 -0500 Received: by mail-qv1-xf35.google.com with SMTP id t17so4641964qvw.6 for ; Sun, 08 Jan 2023 08:51:19 -0800 (PST) Received: from localhost ([185.156.46.146]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a430c00b006ee949b8051sm3912447qko.51.2023.01.08.08.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 08:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qdYBozkTmEnnxMe67YTmLz59tHO5RbfllBVv5dQ0Y3U=; b=4rt7y2byDKry2+p586uomYyFNjwAmFzcVrDWHeC4DA+tjQBH0bfYY/GNy5R/4LXWO0 vUPbaVLARibxnHjFaBFykHYash4kiN8cJWqnauAhivVj2IY2jVcj+BZ6dOV+MSuAXpRS oBsdpKDyWnOiFd2+bCaiOGae7gBm0Jukh8YgsYu0/O+Pw6Tf2KUMC38vf4Go0BI6fskJ MK0euWrsNM1xV395CYwehCYWgFEvQldJl/1ikPVdAzYdZg3FqxR01l4TDqy/fHpjGJo9 iy/VsNGWt66+7bCoUXSkKTZDRzxriggkjdzo0A/hsy+OD55zkLPiEWvByG00yp3mLGSO V5HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qdYBozkTmEnnxMe67YTmLz59tHO5RbfllBVv5dQ0Y3U=; b=W5xu6xANTj5LvFr8dd57L0EfxOsdUQAePDc/iJeV6wD5EeiOP6AjrQ1Mr1dNVco7Qh BDEfGbQgoJ/SBsEWeU9EmDKZVODXEg2fMCXH/SQUN2keZdV28o3nWK8X5RluixQA4nBQ 2/zjhFUhjPurTl2XhfpZXV8WDWMhYylaFjF9SPU2KNVbO94q40thnxih0YvpGKJyhoNe aVpze1dBwwEItrIyVKblYMrS1ekDyZ+wcuHbYq0Fhph2GVcC2DCWjPftBdS0ixMCg4CH QHCgXaKgPNv2YHEcFhMQLi67S0VWD7mZIaBflAnWy+UwIkeKLCFV2Kh0hU4aZj3OZsIH X0Vg== X-Gm-Message-State: AFqh2krEuKO0dU734MZe7ZrjAE1lCMfSWbMOhRQHGvtdUtodxmVfo1Wk eCQTYaNOpRFJth0Bp3edHc8tYYgAlIEO/cRpGjv8JQ== X-Google-Smtp-Source: AMrXdXvDW0olP9LtmWJ8A315j3/Q/IzEUFGybO59puD5PzbAn5d9EepFa2dFtgVk0BkW8ian7AfRhA== X-Received: by 2002:a05:6214:1383:b0:531:a8f3:e8db with SMTP id pp3-20020a056214138300b00531a8f3e8dbmr45231241qvb.47.1673196678952; Sun, 08 Jan 2023 08:51:18 -0800 (PST) From: Emilio Cota To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Aaron Lindsay , Emilio Cota Subject: [PATCH 4/4] cpu-exec: assert that plugin_mem_cbs is NULL after execution Date: Sun, 8 Jan 2023 11:51:07 -0500 Message-Id: <20230108165107.62488-1-cota@braap.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108164731.61469-1-cota@braap.org> References: <20230108164731.61469-1-cota@braap.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: softfail client-ip=2607:f8b0:4864:20::f35; envelope-from=cota@braap.org; helo=mail-qv1-xf35.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @braap-org.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1673196703851100001 Content-Type: text/plain; charset="utf-8" Fixes: #1381 Signed-off-by: Emilio Cota --- accel/tcg/cpu-exec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 356fe348de..de4ba6e23c 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -504,6 +504,7 @@ static void cpu_exec_exit(CPUState *cpu) if (cc->tcg_ops->cpu_exec_exit) { cc->tcg_ops->cpu_exec_exit(cpu); } + g_assert(cpu->plugin_mem_cbs =3D=3D NULL); } =20 void cpu_exec_step_atomic(CPUState *cpu) @@ -1031,6 +1032,7 @@ int cpu_exec(CPUState *cpu) =20 cpu_loop_exec_tb(cpu, tb, pc, &last_tb, &tb_exit); =20 + g_assert(cpu->plugin_mem_cbs =3D=3D NULL); /* Try to align the host and virtual clocks if the guest is in advance */ align_clocks(&sc, cpu); --=20 2.34.1