From patchwork Mon Oct 14 22:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 835181 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp2196215wrd; Mon, 14 Oct 2024 15:35:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVecetCLOpqG6HaMdR1a0+df/lnzbPdtYL1LCaQ5f5dPvGn/vuTrESmL6iPrZkbX0PIJJKxeg==@linaro.org X-Google-Smtp-Source: AGHT+IG6NsY7RPCow75nlVYfIH8PLG7iHrAiy7+sW9RLuukPtMgJr2Sv4pqRYVJV0NoFXokH/TUR X-Received: by 2002:a05:620a:1b95:b0:7b1:35f4:fe19 with SMTP id af79cd13be357-7b135f4ff20mr22694885a.58.1728945323430; Mon, 14 Oct 2024 15:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728945323; cv=none; d=google.com; s=arc-20240605; b=cDf25ouwSvbfVKy2tPm2e4soXyGLI2OZ3oCBGFnbbTqSseeKTy9K2Cqjp6w8hQiSFP 7LVAeMoXSd/Gq99ctbleAX+NuCTfy8n22ZqBYBvrRRfL3QQvBlk5/IKRMZkleZAYUX6N 2c1KqM8q/PstWg2y7+f0DYxH/ZNAX/4BvMmWK/tY0mKSK7U1g/3TtaFYXCSlzD1y3Wq6 +vmCn6C0jXp5p562zY04OjOpxY6GIAOcuhUJSLp3PdNcRxYlLMqmizoCG/mJas4xCeER 2b9UR5UgUXktIZ0rMHRvgT62zq57rORSlPgxQieiY5E7BbSFIGN7Yg11mm9ddXUahrQz Wjdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Xk75/hfGdWlL+1Mc1jz1GSd3w6HecYRikmmbqffemEs=; fh=xV67GGMQ5pU8J/gnORw13n24c/e5f/6nnXplYzSteKA=; b=HTak4saRG3wibfg+CURl2sCK++AaNhOj/rgn1ItAAENaWq4Axbg3vTMUhTXvqa9kX9 Wv9k2bz/LtT9BhwL9e4Ein0bI4KKVsr+y3IV6Dbon8TpVE2P+rqG40JBUckRHtv+d3LF 7HIpPAJJ3AsXS+6MtmYvIJHWbWbtToYvRlWwKhnzfMPLY750SnpDXx2upE4cPP1NL3dH hcjaUbws5MFypu00gr6G+/KEk4Dt0HYUTGiGKPs6vYd+uh8NIEz9eMfaT+r2/UQqffgc ASP5yXSukTQKoJqrIzOUDaDKq3Jb+f8n7ayisrrfawb97rv7YRxFchXSlejirYT1dCX+ /JEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J7e/Hp37"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b1363f0911si5143385a.604.2024.10.14.15.35.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2024 15:35:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J7e/Hp37"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0Te1-00030O-6h; Mon, 14 Oct 2024 18:34:29 -0400 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 1t0Tdv-000303-E1 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 18:34:25 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0Tde-0001rv-B7 for qemu-devel@nongnu.org; Mon, 14 Oct 2024 18:34:08 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-20ca388d242so23040515ad.2 for ; Mon, 14 Oct 2024 15:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728945243; x=1729550043; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xk75/hfGdWlL+1Mc1jz1GSd3w6HecYRikmmbqffemEs=; b=J7e/Hp376KUyq7crvHVvfOWxST9wu5VLJV2l6gNDXsg6a28Nyo2ooLXNv5xtL6mIpI TgIyIJeeh1iqfvAyo7IZe7Z2NyieDbliU2GujgBBzBlepKkPWhobnKmLj+WgwQ6FcOgb RtN1Cyram/a3//6TsNX4y7js9rz6U/f6WH7feP7C47YbmWGpgcTv1j4C/83+ykB7OpU/ iktKlE19p9egphtm6tVkxWQ71IZIQXH0rEWMalCqNDTIOoJJ49dDugzjhIbEFInwoUun 0NMAil4zVnX1eLOImrKlZxgptyfDScg4PIC5mOBpB2vsduvDDB5aZEIJQWiFPVNRdGwv XyfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728945243; x=1729550043; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xk75/hfGdWlL+1Mc1jz1GSd3w6HecYRikmmbqffemEs=; b=hjd+p4BYvCZaMXYAtrnBp/U8uv1+aaRreuxJLBAOJIfVNChDH2e0N/Dhq98nWM5Hwh Lpcc2Kq957FImkwLPeNUY/Jzs6dOYQK0zQP98hJxXkaJ1k+LWyqPdjTiBgPyp2xRIRn7 Y2geu1R7w3l5F8bsT+ih3LNtnCKdvrp0nMIFzcn+ns+TGik0vUl8IBm1PgT2+6LWL2MK rkFYIuLtwWLU5HFSNp+wrC8XWleBH+k9UO0Fo2oSD+skOBmfEfVmbczHFBxkTNWVkc7J w8G81pMFgxn5y2/Qc/Zq1rlUR7r9VQuhAWLYTNYZh4Cd0cme9eoMRb4vI3EC/4nClSWP hiRw== X-Gm-Message-State: AOJu0YwXfABH4TkEz5DBTnSAkbI6GILHL4l9bEfV4hop8w+1Yzj3QyB3 ypb7hFovWW0vpr3gVwH89RgCl5AzBJ+9U7wRACGB77TqTrGaFgM9DhUpMfRYC6bV81AFYtLT1Cu EVkuC+VBi X-Received: by 2002:a17:902:fc50:b0:20c:8c0f:f986 with SMTP id d9443c01a7336-20cbb1a91camr131945475ad.24.1728945242349; Mon, 14 Oct 2024 15:34:02 -0700 (PDT) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20d1806c1c0sm267985ad.301.2024.10.14.15.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 15:34:01 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , alex.bennee@linaro.org, Pierrick Bouvier Subject: [PATCH] plugins: fix qemu_plugin_reset Date: Mon, 14 Oct 2024 15:33:53 -0700 Message-Id: <20241014223353.900481-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 34e5e1 refactored the plugin context initialization. After this change, tcg_ctx->plugin_insn is not reset inconditionnally anymore, but only if one plugin at least is active. When uninstalling the last plugin active, we stopped reinitializing tcg_ctx->plugin_insn, which leads to memory callbacks being emitted. This results in an error as they don't appear in a plugin op sequence as expected. The correct fix is to make sure we reset plugin translation variables after current block translation ends. This way, we can catch any potential misuse of those after a given block, in more than fixing the current bug. Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2570 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- accel/tcg/plugin-gen.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 2ee4c22befd..2a8c8b2ad14 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -467,4 +467,9 @@ void plugin_gen_tb_end(CPUState *cpu, size_t num_insns) /* inject the instrumentation at the appropriate places */ plugin_gen_inject(ptb); + + /* reset plugin translation state */ + tcg_ctx->plugin_db = NULL; + tcg_ctx->plugin_insn = NULL; + tcg_ctx->plugin_tb = NULL; }