From nobody Sat Nov 23 22:59:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1729683889699171.2956646743438; Wed, 23 Oct 2024 04:44:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B05B6C85; Wed, 23 Oct 2024 07:44:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7D3001BA0; Wed, 23 Oct 2024 07:44:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 65F029EE; Wed, 23 Oct 2024 07:44:06 -0400 (EDT) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A7D04CA9 for ; Wed, 23 Oct 2024 07:44:05 -0400 (EDT) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5c9634c9160so7244929a12.2 for ; Wed, 23 Oct 2024 04:44:05 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a91571ed3sm463602366b.164.2024.10.23.04.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 04:44:03 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B34075FC34; Wed, 23 Oct 2024 12:34:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729683844; x=1730288644; darn=lists.libvirt.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; bh=0yP4SNsaEappmzZc/gnms0PRD/uAmEAQCRgu6RQMiI8=; b=Hq6tv9izDAAawtGrWn8JE1QTrglpbw73lWB91xT+kjt6NNINa4ElK+53fqjMJHpytY mnYDAun1pB0ZBgts7LBAJTepuyEEBnIkbb0tb9Rdgl7ayLqhuDyCxn/AleRhkqse9K9u DmyWYirD8F0GkxyDerI9aQViSNlMLFOB4kEjP98v9LyWZfyzN8w+CyhRCTMWRE0FElnC vxJywmcpr8b6hxQiN0tJNhquzq4Zp0CM5B+Up43wLhDJYUAYrUzFAaZzIc/yQ3rD48s3 OMi3wrC3PGgWVAd02D4cg4ny10QxDsvnvYa5c/u+saKrRD8XFgYDGlJCSe2Js925vJOg VWXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729683844; x=1730288644; 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=0yP4SNsaEappmzZc/gnms0PRD/uAmEAQCRgu6RQMiI8=; b=uAkH+4MzxJ5jNZpu9fF+ONIrNmrR48k2o6M4ZJr6UJ2ijrGLIHb50sxEQhiRTnSQs5 MXkg5nRSteI2yulF/bF12nsDsikgpIqcjcCFSo+MqjsQEb/uVAwUYs4gO6PyQ3zygWwm YktbfALokjnHuDIESATZ6s6hZbijv1FXorGjyxTOQLxwWIv0jLtEI9PlCGvW/jshDI7b /gA23nZOy1YigRa7NqKtMB4pQiTK1TRAmnan2iXdndtCTRzEOleS6bsJy04yGa8FAq2d T1aLplsjdutqokF5uohUWHXNsdtUNJvpswI8BqR1hthNF2VhqA+o5H+keQopyYtR9Jl0 SDBg== X-Forwarded-Encrypted: i=1; AJvYcCV1OdgSg/rq/PtymMj0JQYD58k8X/BrUu+fUXswBmgKQ2dpncwAqvOfgxT0MAN91ivXEhwTpQ==@lists.libvirt.org X-Gm-Message-State: AOJu0YxqqFNzFR30Y0d9H5GKNtGYU8mbw2ria8tRZCwWZB5+BOVbggFq Q+UJDpv/MQkpwWc9sehs7hd1fN57I0yJrKWq6oGQcwNJVyZ8dgICzrSw63cn8ww= X-Google-Smtp-Source: AGHT+IHMnbwSpFbIxFr8E05r4uLkxn6q0bmtEG4CkFZ2WZbJ45lEqJq6MM15OG/HAzJxk8Ota85Nkw== X-Received: by 2002:a17:907:a4c:b0:a9a:e9c:1d8d with SMTP id a640c23a62f3a-a9abf8664aamr189274166b.17.1729683844365; Wed, 23 Oct 2024 04:44:04 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 18/18] plugins: fix qemu_plugin_reset Date: Wed, 23 Oct 2024 12:34:06 +0100 Message-Id: <20241023113406.1284676-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241023113406.1284676-1-alex.bennee@linaro.org> References: <20241023113406.1284676-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PAHT4FELIZOJGLQA4QD4M2GFOYE5QGX4 X-Message-ID-Hash: PAHT4FELIZOJGLQA4QD4M2GFOYE5QGX4 X-MailFrom: alex.bennee@linaro.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: Zhao Liu , Eduardo Habkost , Pierrick Bouvier , Peter Maydell , Yanan Wang , John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , devel@lists.libvirt.org, Marcelo Tosatti , Riku Voipio , Wainer dos Santos Moschetta , Marcel Apfelbaum , Paolo Bonzini , Mahmoud Mandour , Laurent Vivier , Jiaxun Yang , "Edgar E. Iglesias" , Richard Henderson , Alexandre Iooss , qemu-arm@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Cleber Rosa , kvm@vger.kernel.org, Beraldo Leal , Thomas Huth , =?UTF-8?q?Al ex=20Benn=C3=A9e?= , Robbin Ehn X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1729683891075116600 Content-Type: text/plain; charset="utf-8" From: Pierrick Bouvier 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 Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Tested-by: Robbin Ehn Message-Id: <20241015003819.984601-1-pierrick.bouvier@linaro.org> [AJB: trim patch version details from commit msg] Signed-off-by: Alex Benn=C3=A9e --- accel/tcg/plugin-gen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 2ee4c22bef..0f47bfbb48 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -467,4 +467,8 @@ void plugin_gen_tb_end(CPUState *cpu, size_t num_insns) =20 /* inject the instrumentation at the appropriate places */ plugin_gen_inject(ptb); + + /* reset plugin translation state (plugin_tb is reused between blocks)= */ + tcg_ctx->plugin_db =3D NULL; + tcg_ctx->plugin_insn =3D NULL; } --=20 2.39.5