From patchwork Thu Jun 6 12:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 802001 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp277700wro; Thu, 6 Jun 2024 05:41:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVi/ufdwxfZK6PiKKVIbE2wqmhUx1ezfWTQO19ryGP5EbBgN/WldZMGwBIgJ6kh3iesit8mlZvfvVQLbhZ8JC+L X-Google-Smtp-Source: AGHT+IH4sQL7MnGvdvWpFV4esCGUeB7bn5TQnXQ6zaWUnnPI0BUpAq+7/A4JLtHm2SNb3MCx0gMD X-Received: by 2002:a81:ae16:0:b0:622:ccd5:3fa1 with SMTP id 00721157ae682-62cbb4c3acfmr57446727b3.12.1717677669280; Thu, 06 Jun 2024 05:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717677669; cv=none; d=google.com; s=arc-20160816; b=IyghtnYev+UBa8i6A6pgB0ohBZMAljm/bxpJBptBzCBBidaAW5RzHVCti0gxa4d8Z8 AMYQXYKy3PoXyZGxS5GUmuD3Hc2+Q7yP0vKzXC36pTYSkZ+P9DOr0hUm8krnsrGscN4z orD0miK6As4xJv1k8OXi9lOZE7paa7nzwOuNHRluz+ybdFLWY6gx/9H3IMw29viiQyHJ fbH5RSv8vaUU6YyCUxD91AG7W5lb7Elh+rAz5mapRe3tbrc5pCRBOWiRAfPMzUgQEyoA QcGnbyPyULqB82IEoLr4vRsf0lGi1/kIN12zJaUlhJnPlCW8tgETR56u6T+5Hn0CvkfT 68Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=1FuIkTOE+lXFH9ZydHNxhyvDKE3guv4TMSshNohbxYc=; fh=M9sf6J8EEPZfAH3nsXnBMU17qdsDd/zzle6ruDzcvDU=; b=ur4fKikh60zyQ/4z8pqNF0GS+dXj4eWPptalAG9CmZA/+pX4PaKsb/4Z91bf+/xdqU Tg37W+zI/7oeL033q/0bIiLfFZI3V1wDZZoyw8q94Xlrc6PsOVpfdq8jPcFVXLMn8uVY eMTUhKipOMb+LH7Eh8jKk1rIx3zTME+5ktwn1gV20Q4arbWkeezwhB36xbtS70jF/Tny 7SBclp0gsd83PhYZz2sdPex51T7S9cEPRKa7kY4fDAmMtvj2a7KLcEIhDiS04B8R5Ou5 xLpsoGX/beDwiyo1Q8IFE1+vIXSmqQRivhhbAkLIgtTtVlDvg1rlWmCrIEqTheu8vVve xUfQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZqVemX23; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44038b6167bsi14670291cf.583.2024.06.06.05.41.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jun 2024 05:41:09 -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=ZqVemX23; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFCPq-00019r-9n; Thu, 06 Jun 2024 08:40:26 -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 1sFCPo-00015D-NI for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:24 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFCPn-0002Ou-5W for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:24 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4215c65dca2so6555675e9.1 for ; Thu, 06 Jun 2024 05:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717677621; x=1718282421; 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=1FuIkTOE+lXFH9ZydHNxhyvDKE3guv4TMSshNohbxYc=; b=ZqVemX23wE05crTxwnmLpiptzQpdi8ObnGfoeoBE9CkF0xjJeHOFbth9MSPwhPhznT btYI6ArAnix2VgvWaAX2SJUws5TSSgTjwxMO4cXiB13CCzvCv5AZiRLj1aavw9GoV6pS w3QVwPXf41wjp7Pvn9Wyf50AL7dgLVy05I9iBTFE6MHi464gqvUoJF7FqMDyrCbfZexg k5DvV7SJDcdEmL9iFaCf5LIdQv9spNipF0FO6rgUOWB3cMihDWIEButXZqDg5b8EjT3O fc5YWSGoMQ+fVhebrezCCUrXI6McptJztEotOe9oii4zOvJ+XxYcRJKKq9d+RCGXVjfX XghQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717677621; x=1718282421; 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=1FuIkTOE+lXFH9ZydHNxhyvDKE3guv4TMSshNohbxYc=; b=Wz1dp3Loe5MJmtPg/JDG4wVDjUffNYMYOVIi99KEc133pPRvgSv8Sn89l7Etj9GwXs GeiIR+oeKaoxbgO2XKg2Ix3M2FBQgV69cZi6xtcLoktEc2U3RK9ATjNlm7FOWUrA31sK EjCtoXg0AEQXvA5lAosvQ0n2frXBO6BolPYE+VAzlcRvEJxu1Ne1VXnUvQG2Uf1saCvk hBMEHrHeftGe5W0VLWkHx52q5MFjYkEXApermSPSMQiVnI8fAaoStzX/ogmDS9ek9Cnt MYwZuF8oWAapRk24qcce/BBHljwo+mGGCfELlUVDDn/C8d24Unu1moNjZGpwtW3RipTC vlSQ== X-Gm-Message-State: AOJu0YyS6sqPbEYKFQUgOOiI/YXEATvVGo40CRBh28zgysVZO8Ei3APr Vb+D9KZsR3pSj0U6zPveT5JFELcO/7KxiYy6bpo6qqkilC27Ha/B/l3uKyAeIOhRlktIf/E7EkZ MMvQ= X-Received: by 2002:a05:600c:a01:b0:421:5927:e8cb with SMTP id 5b1f17b1804b1-4215927eb54mr34917445e9.18.1717677621165; Thu, 06 Jun 2024 05:40:21 -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 5b1f17b1804b1-4215814f141sm54305615e9.42.2024.06.06.05.40.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Jun 2024 05:40:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Marcel Apfelbaum , Eduardo Habkost , Pierrick Bouvier , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mahmoud Mandour Subject: [PATCH 1/3] plugins: Ensure vCPU index is assigned in init/exit hooks Date: Thu, 6 Jun 2024 14:40:08 +0200 Message-ID: <20240606124010.2460-2-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 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since vCPUs are hashed by their index, this index can't be uninitialized (UNASSIGNED_CPU_INDEX). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- plugins/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/core.c b/plugins/core.c index badede28cf..d339b3db4d 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -245,6 +245,7 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) { bool success; + assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX); qemu_rec_mutex_lock(&plugin.lock); plugin.num_vcpus = MAX(plugin.num_vcpus, cpu->cpu_index + 1); plugin_cpu_update__locked(&cpu->cpu_index, NULL, NULL); @@ -263,6 +264,7 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu) plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXIT); + assert(cpu->cpu_index != UNASSIGNED_CPU_INDEX); qemu_rec_mutex_lock(&plugin.lock); success = g_hash_table_remove(plugin.cpu_ht, &cpu->cpu_index); g_assert(success); From patchwork Thu Jun 6 12:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 802002 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp277698wro; Thu, 6 Jun 2024 05:41:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUm3rDpMC7fF3EDL0WpoVbrwu3o4qgwzSDjujOYsTxg1j+k7C7s3ZfxX2Q4h9F1Xr4AjPrMF6lHtoNt2oHricdP X-Google-Smtp-Source: AGHT+IGKDke0ukCVwzHLM1dvyimaWMi/LSOjzwdRuH904V8IPSFM1t6DpvuqVFItvrR7D9ctHyUk X-Received: by 2002:a05:620a:2190:b0:78d:766a:d695 with SMTP id af79cd13be357-79523fc4732mr589144985a.77.1717677669292; Thu, 06 Jun 2024 05:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717677669; cv=none; d=google.com; s=arc-20160816; b=p22uaEOUOwGZZrfuxmmkCeZmts7ct+KsklhHIsDgz/uT7HXYHMxSggIwigAMN709Hl AjPXNAtXDgx9r3tky2FBdc4783BxWIxTN7Ih1Gw0dKQr3XXUoymMLxRJqU2chkLOdye2 +zjlQMFoyeX1qIiCI7xVDBG2/IhY8S3SX/SxJ/1Eg7vaplbeBVExXm1IgEPbJr+/GJRu wN01kPgqpAUzjTLbuSYeosTvxWa/zkJKf7sjobz5a0HKOFYvCVeGwniT4VrRDlv9S083 Xb0lxQlMqqQfPsJOkd4A8sOxF2CIEIXYQUd1qlFp/B4ULPKmuCt91xl1FDgaY6aMfTs+ 3mbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=YpuRJxgqfBz76ap36ezT/qPPBflhAp2VI9pF8aWCMBk=; fh=M9sf6J8EEPZfAH3nsXnBMU17qdsDd/zzle6ruDzcvDU=; b=lHd2Zg6btlL38ok9OQCnR20Go5j2Qj0dbGUEy3J/+BrZ7TRni7lnVImsCDawQz6Voa KHWe/ek8q4mDlqkTBMPDf6mZu0HuQznhMkkF9s2pvPxXgMfkhEswAzvJlO6Rxvzpijga eib6gepZVDMywFH/3rvC+B4NQhyd+YGGln+IJ1Wn2Tb+0umB/odvwcPTu8EmHPiDvcHK /k/n4YnEFVOXG1xg8UMiwgiNtUMX2wjxS+GO5l/dslF0i/8QOissD2s2i3BD11AjXC7t AXd0vnRwQXpVOb8XOQ5XJa9trZqyL/REvKwmcFPToM13seu+tXBaWDL2Dnmmhj/KAUjp r1ow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZvszW2wq; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-795332ef094si141011285a.468.2024.06.06.05.41.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jun 2024 05:41:09 -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=ZvszW2wq; 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 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Marcel Apfelbaum , Eduardo Habkost , Pierrick Bouvier , Yanan Wang , =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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 { /** * 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); 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 = CPU(obj); +#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); From patchwork Thu Jun 6 12:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 802003 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp277694wro; Thu, 6 Jun 2024 05:41:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXJ53anHk9PI4q5ne02w4N/T6UVPrYTAM9FVAn1D3dx2TZGR1FifHbyCp1wr7XpdrFU/SOJYHLqZZZNUnPCGByk X-Google-Smtp-Source: AGHT+IG8CgLQ0LwRccSJrdZ0K28i7wp61o8OvNswjLXwqtQJJGaWK7dP9DoF8E6laZlN/ixM1jzR X-Received: by 2002:ae9:e019:0:b0:795:2110:7753 with SMTP id af79cd13be357-79523d35f48mr541389985a.27.1717677669343; Thu, 06 Jun 2024 05:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717677669; cv=none; d=google.com; s=arc-20160816; b=Rip20UTWovjzvTq8RGTJHT5vsXvOuH5l4/8guvQTudgwY+TQzruKl8rMHe7qlaokjW 976JxQor7DC6LMlejM1WSNMon9yVvR3tfb3ri2FYeMbRZ1yBkBSZRvIy4yvZYAUr/rCv adWvFFjnJhplYLYut6qHidkYPb3gVcjEk9XJ1bo+2FbkYwEBFAA9ynjQ1de8KmRQAHfz 7WBAB/uXZZFYTZv2E9zYsyhssjXs84Z4BxsEZT8vhp4VLvY2ncky/zDw424MIHVgUngm YCVB6bgLoaV8/EqsQ6XhcEIrFvx5vznF2CG7PHUnP6AOlrahhwH2E9BlNlTJJ42i27Hd JPvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=CRSz2yaOsEhwUEucQOXNUUVmWnoAQi/uTeMffq4fYCw=; fh=ckqfxOt4XSIcs2XcSsYpM90byaJ+O7qbAtzq8vWkWzw=; b=W25T5ihOQ7EVNL4SPR+Hxmz0qLd653wxgtYybz34K3QmcWkIVVQp6mJ4ybVnIXPeTb 4cvGTWJTLGYs7IPJUVcEFIxBYZrqwryLSucR8aM1oBSMKImDPicwM2VaVy9sugFRYZw4 Zyjhurxx77rDNnF85ul8njGnvBMDyhhXz0yuiC62hS1xSjCYwtjXUq7XsFtbPtm0RHWI OwbcXYOEg6sThi4XFp4COHdNgKUzsmGwgpLqYCIIIl7O7J+IOSzXR09U7jQBwyL6HAsM ow7rWDs+DCqpfIIMjtLEwZjR+y0VsJHHDLT3zK6CM1UKiaIKJdb5lZ9HinnZEh3LXOSl jf2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E8n01ZAL; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-795332f4ecbsi131684285a.491.2024.06.06.05.41.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jun 2024 05:41:09 -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=E8n01ZAL; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFCQA-0001Ny-Vd; Thu, 06 Jun 2024 08:40:47 -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 1sFCQ3-0001Jw-1R for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:41 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFCQ1-0002RU-42 for qemu-devel@nongnu.org; Thu, 06 Jun 2024 08:40:38 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42108856c33so12134175e9.1 for ; Thu, 06 Jun 2024 05:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717677634; x=1718282434; 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=CRSz2yaOsEhwUEucQOXNUUVmWnoAQi/uTeMffq4fYCw=; b=E8n01ZALd7ywVD71zre1scXUbMVv4hdpGKCzsxGxA5PhQ6RBstGqugkk8QUVpuUWhA oRSAAhCaj8kpfkliTDYYJo4dstnTQbnPBTY0Si1Peb6RTu7bT5Cbg6acLwGfMlrH7CHV b5tLxm+LVyzFfzhDWkoEfXTCNmiEw0XJm3hhqhusbTuWnxZetQrMX2aVSo3WSBnISRGc BF7ZftMKDL4s+dTuVo78sVFK9zxuU4e7VErHPa5rRHBrM2A3VtoDnorUKgglnYKosIbf cjfh1nMNK+Vk+NLSYhGm/jrlyFcFzdGVF2YyApqQL8E217Fm5wGudFPckLGQKmi1jApr U+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717677634; x=1718282434; 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=CRSz2yaOsEhwUEucQOXNUUVmWnoAQi/uTeMffq4fYCw=; b=CQL2ZS9q4FeHpZI80MGlQb+bTjZ2MWO7ZqjJTcmfqFP+Uxf1DOUXXRklk9+yb/nI7M w8hBtJ53dMPl060xBiP1Sy7ppFr4nDEMkIxukBqj/EA78S7VR2A0uSDh9xjSEL62Wnfl q2GpP2IYWBbKhaas7k/dEunicy1koH/sYw3K9r4h0keOqhJCKVWqB2SsSo47nCDzUoSl PNyBgVLUxg6XKVIBeH77se2OFVOEO27wo3QPleItO9zIQasUG8AnNM710ZI2e4TV3mY3 Mj0E4EAUKpZCg/gGSOKlB58FbpampMnfY8FByUiTdyvgqcpi0xAXiWkZBBxivoLN7Xas 5dsA== X-Gm-Message-State: AOJu0Yxq77CaaSjHvbboVwWfIGtiNE5EORt25JbJBDRBBAu0TDyy+f7i uHhEhX01l9CILWc/2vCTkrdnjBiBQzJ5dEXCeOUz4fCaipECWwfK8ygoWcxwxGJx3NiRx+OpaI9 0pbA= X-Received: by 2002:a5d:6a44:0:b0:357:16f6:71dc with SMTP id ffacd0b85a97d-35ef0d7a2e0mr2482270f8f.13.1717677634496; Thu, 06 Jun 2024 05:40:34 -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 5b1f17b1804b1-4215c2c6bedsm20432045e9.30.2024.06.06.05.40.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Jun 2024 05:40:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Marcel Apfelbaum , Eduardo Habkost , Pierrick Bouvier , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mahmoud Mandour , Richard Henderson Subject: [PATCH 3/3] accel/tcg: Move qemu_plugin_vcpu_init__async() to plugins/ Date: Thu, 6 Jun 2024 14:40:10 +0200 Message-ID: <20240606124010.2460-4-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 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Calling qemu_plugin_vcpu_init__async() on the vCPU thread is a detail of plugins, not relevant to TCG vCPU management. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- hw/core/cpu-common.c | 9 +-------- plugins/core.c | 8 +++++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index cd15402552..79fcc0b286 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -192,13 +192,6 @@ static void cpu_common_parse_features(const char *typename, char *features, } } -#ifdef CONFIG_PLUGIN -static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused) -{ - qemu_plugin_vcpu_init_hook(cpu); -} -#endif - static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); @@ -274,7 +267,7 @@ static void cpu_common_initfn(Object *obj) #ifdef CONFIG_PLUGIN if (tcg_enabled()) { cpu->plugin_state = qemu_plugin_create_vcpu_state(); - async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); + qemu_plugin_vcpu_init_hook(cpu); } #endif } diff --git a/plugins/core.c b/plugins/core.c index d339b3db4d..3dec3556c3 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -241,7 +241,7 @@ static void plugin_grow_scoreboards__locked(CPUState *cpu) end_exclusive(); } -void qemu_plugin_vcpu_init_hook(CPUState *cpu) +static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused) { bool success; @@ -258,6 +258,12 @@ void qemu_plugin_vcpu_init_hook(CPUState *cpu) plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INIT); } +void qemu_plugin_vcpu_init_hook(CPUState *cpu) +{ + /* Plugin initialization must wait until the cpu start executing code */ + async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); +} + void qemu_plugin_vcpu_exit_hook(CPUState *cpu) { bool success;