From nobody Mon Nov 25 05:44:05 2024 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=1717677669; cv=none; d=zohomail.com; s=zohoarc; b=jUVTmRjGRievK5KWPKtp1XB8XUJ1ZQf6CmdcYkl6a6RhDc+ALBR0PWf1H9dr7LGZ63i9SYAopNN2UfouULl3vP08fly9ADPBaNW6MQV5d6spL18FOoULW9detYQlJe71NNUzJsMwPseMkqPXfX04KG+k5CI+gEG/vmByoh1rjZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717677669; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YpuRJxgqfBz76ap36ezT/qPPBflhAp2VI9pF8aWCMBk=; b=PzRRxMU2/p/BAnsggLk8z+5pBzTWhY5o33vb5gAVhC7svi7ErMM9qo0UpHBcotyMMUxoWilheaH2/qm4sPYVxsbyDYyIS6jDAJ16aw7vBuPz+PB+2POWLwZTE7aMAJ3LljFU8LhxGknrNSxL3Yv5RIkXgLQQF8Tkb2Oq8xbCXLI= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717677669469322.26596583533467; Thu, 6 Jun 2024 05:41:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFCQ5-0001JW-E9; Thu, 06 Jun 2024 08:40:41 -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 1sFCPv-0001Ey-Lm for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:33 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFCPt-0002R0-Q3 for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:31 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3550134ef25so890087f8f.1 for ; Thu, 06 Jun 2024 05:40:29 -0700 (PDT) Received: from localhost.localdomain (94.red-88-29-105.staticip.rima-tde.net. [88.29.105.94]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5d6985csm1461911f8f.60.2024.06.06.05.40.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Jun 2024 05:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717677628; x=1718282428; 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=YpuRJxgqfBz76ap36ezT/qPPBflhAp2VI9pF8aWCMBk=; b=ZvszW2wq2cGkM0tF1CJvYA61pGIqaVQol2vGuTDTw2iSKCkbza3OtJSRKZM5gxMTVO XlYELAAykKP3LEacnDQGYIMdiIIzEKQ+0BBW1Ia5cL0yJsF6a6qpq3lmpVQHzRvKyBSn lUVEJMrk8ondOM7rwbOfuWZUZG42pmTSKXKvO7Z2pDH7VubF5/E/Nnl87SbVKRV85wBh wwBg4FuWo3tTlqe1u7KfDUoowdbHFFPm/ibSgB9SC/eDqDWonaEwLlR7drugsDDj2rTO PGlTa0ANXXBIaMYxyOdMVCxPQaO3O+JcERkni5day0nAkcjJ8j/kSvXx82b4+/7UmCV0 pIKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717677628; x=1718282428; 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=YpuRJxgqfBz76ap36ezT/qPPBflhAp2VI9pF8aWCMBk=; b=e4nj6BSignhZUvU5i7D6ks0heCCyp/EEF4jCbx4wUrtRey6VzlYsFSnuo/LOK4xD++ 7SS7Ka2BoYvzbWZmppRHHws8W/gB/LRE3bPTpYW3ZEZYwzblErzfVvZj0nZdM3UiJ1ix J/1fg//oR/iQ/6Hc17y6nWL5cQ8/N+O62jCQxuj14ehujNlkRPvnedM/2/rf3rMb6RNB 3BA99Gs0by7Q+KQXkhpKOuacnrnnp5EfSTB3lw33Q7flJtDsAnbAYM1aNh5eotQk9LeL GBWSnwb+kmvUaTOuU0o8XnFZ7ln+68kRifoqO1Imyc0dLWdVbGigs8StO03MZq9F/ERf W+OA== X-Gm-Message-State: AOJu0YxfKtONHH1UnAiEuVsTGj5u4CghvL8BRWOHDsu7e2ukw4EzHMIv HhX/ET7CNGzLfxtpC+0IZHzgjx8eksTaS4kNO4fqeuDD0ijmCaGGrOyy9PoLw5t6SB1VZlmjxPW m320= X-Google-Smtp-Source: AGHT+IFuHw7E1VkMs4wnApDm1Dka1VqP/g9NpKqGxAapHKxEoAHRhUuhso9yeNtfYqmoIEr4ttBqZw== X-Received: by 2002:a5d:59ad:0:b0:34d:990a:e4cb with SMTP id ffacd0b85a97d-35e8669bd34mr4615057f8f.36.1717677627792; Thu, 06 Jun 2024 05:40:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Marcel Apfelbaum , Eduardo Habkost , Pierrick Bouvier , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mahmoud Mandour Subject: [PATCH 2/3] plugins: Free CPUPluginState before destroying vCPU state Date: Thu, 6 Jun 2024 14:40:09 +0200 Message-ID: <20240606124010.2460-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240606124010.2460-1-philmd@linaro.org> References: <20240606124010.2460-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1717677671698100014 cpu::plugin_state is allocated in cpu_common_initfn() when the vCPU state is created. Release it in cpu_common_finalize() when we are done. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- include/qemu/plugin.h | 3 +++ hw/core/cpu-common.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bc5aef979e..af5f9db469 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -149,6 +149,9 @@ struct CPUPluginState { =20 /** * qemu_plugin_create_vcpu_state: allocate plugin state + * + * The returned data must be released with g_free() + * when no longer required. */ CPUPluginState *qemu_plugin_create_vcpu_state(void); =20 diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index bf1a7b8892..cd15402552 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -283,6 +283,11 @@ static void cpu_common_finalize(Object *obj) { CPUState *cpu =3D CPU(obj); =20 +#ifdef CONFIG_PLUGIN + if (tcg_enabled()) { + g_free(cpu->plugin_state); + } +#endif g_array_free(cpu->gdb_regs, TRUE); qemu_lockcnt_destroy(&cpu->in_ioctl_lock); qemu_mutex_destroy(&cpu->work_mutex); --=20 2.41.0