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);