From patchwork Thu Oct 24 09:56:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 838105 Delivered-To: patch@linaro.org Received: by 2002:adf:a399:0:b0:37d:45d0:187 with SMTP id l25csp270740wrb; Thu, 24 Oct 2024 02:58:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUi0fRXmxp3okEMDcKmPA5Sd/48OssTf7PJSOwcK7tlJ7LitaEcQomix86jwuy1Fq1KgSajuA==@linaro.org X-Google-Smtp-Source: AGHT+IGBpcbEcZo2CmNxlUA40naKquLshF8u0GlE6AjzjAN0sBZQz9AbhnbEU7YK2het6GwNzJFk X-Received: by 2002:a05:620a:4088:b0:7b1:52a9:ae15 with SMTP id af79cd13be357-7b17e5404a9mr739129085a.9.1729763924812; Thu, 24 Oct 2024 02:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729763924; cv=none; d=google.com; s=arc-20240605; b=lN+xuQGEi5SiQMgUQghqSfhixWG+WdiEe0tDPmMlZKE12Cld+7OvJz22mX8DkLv0bR EB0HSSo8aL+5TNRDnDGfrVidkrkUgelk5E8EH9K235ZQB4EG/kZZ9d6jX8WU5JlWpKOL TGHKga7ZUueM+CEhSWcoJgVfOGNBjzF0fCu9lmyOLBM1ZLvsWcG315tdMx1Sty4vHquK syr4EWedyvb+hx8VD/h0Bj85Nz97dKGwBfnuuLdW355BsaT/wachAJcSPUB1UVqK8xbR DGwUg7uXhugcCCOsjEwWg4Hb4amgQNwGdgovyqRjRzL2eIRPg2i3o2PbP0ayKTFIMlC2 aG2A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WhyVCt5uiJi85ejZ/liwkfrDbqe1iEIJ3VaYNksmEf8=; fh=b12Xef+gDmLHQh0sHC6BUlQshkIlkgj0JtHe/4dS4PE=; b=acEZuRK4v6WOPala38V9YwZLNT67Oc0h104N0yIdWDz0HoAsctU8vtbsJyP9sOn52k s2HPdKbl+ccfTS/U8haKLaGPajfR0u2PXg3i8AcFl4kKoKKBUggAPrTaXHmueqakm0py jt923oqVqR6twH6Dyue0ImZxJZwf4oqk5BaX/Db7mRIcv/GodW2d3hlb9OmQ9m+kKHC0 eMF7U11iqwGiDKEwdHLxxYJAw+SXIxvZvxtluF2AtiDaFjmpk4HwhMupHJc1M119nUBe Oabq59jHpC6DUM9yVDuKJf6ID7cmXXs0nGRq8/ogUoWgkcXisEbDw3pBUD3nwMeHBzRa Gsag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KGCauwgx; 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-7b165ab84e2si1104164885a.786.2024.10.24.02.58.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2024 02:58:44 -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=KGCauwgx; 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 1t3ua3-0001Eh-BJ; Thu, 24 Oct 2024 05:56:35 -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 1t3uZo-0001AG-BQ for qemu-devel@nongnu.org; Thu, 24 Oct 2024 05:56:20 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3uZm-0003pc-Bg for qemu-devel@nongnu.org; Thu, 24 Oct 2024 05:56:19 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a9a1b71d7ffso104950366b.1 for ; Thu, 24 Oct 2024 02:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729763777; x=1730368577; 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; bh=WhyVCt5uiJi85ejZ/liwkfrDbqe1iEIJ3VaYNksmEf8=; b=KGCauwgxMeLcAMQpET/y7GQ3CRSX460Fykcw8GA6Ssl0eeTVh9ZZfj6Drwlqv8Wtjf yUz+Cp/jlxvFWtoMQ6PKL/kx158T6I/s5DwZHLQnYN/cDCLRCk59IVxpORtlvO6W7zJw Bmf7/4sKDV1XnFiACOSN1XGUwW6uc/j3SQvDzPwaIdoKvCvWSz6TntQcU8VPdkpgbCj1 dv2pVVzZDHkRuHaqaZPwPEgUxHwcoSdyYOVlXHXtTKZL3DRoFfO97ZkrDp78CoJNRMjZ yT0leupqxhICUNWUqTtRMKVgofoD+UgBA015tuJ2LnruubSjJxUVc8ShcSmmFXZoAfYL EPHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729763777; x=1730368577; 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=WhyVCt5uiJi85ejZ/liwkfrDbqe1iEIJ3VaYNksmEf8=; b=CkHT/8rVP6ihXnwCHowj/M8FC8Qpi32BuRIRmjaHQflwtyoesut1VX+r3jB6w58Twc aN42XS2CP4S/vKqjAvddLngJu/Vj8yvxOqNE24wOn3ww6gAdU0F2qaFwAkSXJU8EO1vP 3ncdNq+46h1hL4D7MDkO2r5NniCG/KzUZpHsKZlmYf+pJvxKgYO7bBLf2hP79YPdtDXQ vrl0rBamdkK25R+8801Tv9Y4mHsg2QrJ5V0b+qNe5zRda6SxJvBxLvOm4GBk+AETCSmF oJ3kYOiWpL/RgViS8vqt0Nnw0d4Z280KRor6M3PizaIRg5Vp33Tbc/8ulUflmyvyrDCp x4WQ== X-Gm-Message-State: AOJu0YzmzVChnpVN36eAXoXpV8YsdJTgoePnFg+NHSnXlvAdNHz6Vz5Y NXQEGHV/F0f92YMduSkd6UOEmHriaw9en2Umed/JNK7D/sz6sJEujhFVbquDKKg= X-Received: by 2002:a17:906:db02:b0:a9a:f53:a5c6 with SMTP id a640c23a62f3a-a9abf96b501mr572318266b.65.1729763776966; Thu, 24 Oct 2024 02:56:16 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a913706b2sm592190766b.121.2024.10.24.02.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 02:56:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7A0F45FC19; Thu, 24 Oct 2024 10:56:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Richard Henderson , Robbin Ehn , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 17/17] plugins: fix qemu_plugin_reset Date: Thu, 24 Oct 2024 10:56:03 +0100 Message-Id: <20241024095603.1813285-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241024095603.1813285-1-alex.bennee@linaro.org> References: <20241024095603.1813285-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.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 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ée Message-Id: <20241023113406.1284676-19-alex.bennee@linaro.org> 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) /* 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 = NULL; + tcg_ctx->plugin_insn = NULL; }