From patchwork Fri Jul 5 15:30:39 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: 810416 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1669786wru; Fri, 5 Jul 2024 08:38:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXp6HaD6sgTpKWYNVkC5U4nfcd6t0Q5sdJoYze4efiYHYeQ9WpQ9LsxLcOhfRRMCEPKl1oawzgvszNe+hvodnLz X-Google-Smtp-Source: AGHT+IH/tpdaXuWdWIaUSbkorI1ImzyFHqm7lYH6AtkfcTik9XNdK6cBI5rjVYbCz4GNZ5DyLJ6m X-Received: by 2002:a05:622a:1814:b0:446:4504:3c with SMTP id d75a77b69052e-447cbf3d988mr58639601cf.32.1720193895412; Fri, 05 Jul 2024 08:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720193895; cv=none; d=google.com; s=arc-20160816; b=L0uCKfIgx+nKFhUVZQ96vU4iNYR0YvheBFeFIE3977uMEve5w6+Q2eXgl06ha/kPhi BDYnMmDb+tqIoEWNNX+yPG3D4kScGFyuPD5MB4YaNS4eebN7nIcxAimklRDWBpYQeXKz H5l6Y6dcy7vcIrxvrDIubG+SQhisM79PDQ8nhW8SrW0CDr7d15BeryIFACULS0IdgENh +GhreBkdiQyS9kM94imjksf69XiPSI7Rz2s2pYLGxUHQWcgyLmoWYBVhtNB+o/3LkdrS /XWLNLT4oUIVQ+A0HqKj6yhQFEZ/t7BrsVP2DGeot/+Z8TXAifSODXyGe8vD2Me+XWQM I2KA== 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=Ua23xrZ298Q42RDQyaYLhWTnQd77z5dPlxT8bKsVuUY=; fh=CrdRUL1fpLQTFCPN9ZMN8/bK2Q1k2eAmf1YOdKR0toA=; b=YBeqgPcP/i1f6F2wOAiFo3F6mz2BMKyIyUK4bs8i9br8ofpwFqtLOCd6fOAdRaadbH 3o6VyIz6xKDnY1vtPVGq+9U+B0yOHAKAGSEC46+kHKW40vLlfQkInBEtOXqtLsCJwz6R 5k1dmAnfjZmcjFBqGjUK2cKL0hGprWevuzJyoxRvNociH5V/4jy59LRXnbKNzJQ0fXpj wrc8r+qwTRx4R4PJ7+rkR8OqgZupmdRDKKjMxJA07ujp1AgHeJq9MBB4WEtGbWt+NgKA f4jTu5r4acnQphbXe7zt/A7eZlYKFzv+RSFbLQkQ8O+bVjQPL0TWL+MrzU5uMDo14A9Q 2GhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9OaeGVB; 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-4466ff50f1bsi133953881cf.665.2024.07.05.08.38.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2024 08:38:15 -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=T9OaeGVB; 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 1sPkzw-0002b6-Gu; Fri, 05 Jul 2024 11:37:20 -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 1sPkzs-0002Zq-F2 for qemu-devel@nongnu.org; Fri, 05 Jul 2024 11:37:16 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPkzp-0001GP-Id for qemu-devel@nongnu.org; Fri, 05 Jul 2024 11:37:16 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-58b5f7bf3edso1118672a12.0 for ; Fri, 05 Jul 2024 08:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720193832; x=1720798632; 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=Ua23xrZ298Q42RDQyaYLhWTnQd77z5dPlxT8bKsVuUY=; b=T9OaeGVBYQU0WVa+fs/1TSFsI2Ra0XfWN6SmbU2MCwsrwBM9Nd1NUlnHgpNVo3HMZU /KvfSlU7pS69DQwacEeFvsNy2MnzesDOqMfSwX9N1XZ8oACPR1bYcu9nyHRT80z0TwlB fEtNv9IWOAYg2hve9mKiLVhvIWoN+cDejvStI+rVwzXWQmu+Jg+kBrj5Dw5lrC+55DT3 m5QXW3lkoEP+tyQrvm0lHnQ2FwdhLMSgZLMC+vGSkOm0HvQ/72Ja/bKAwhV1mMdHiYfq cAjZRWnMIl5QSOuHBm79sFDE06VN5YdlbWfGhQ3/hR/Hvgui8YOr+DKps2Bn7S3iexD5 Zu5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720193832; x=1720798632; 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=Ua23xrZ298Q42RDQyaYLhWTnQd77z5dPlxT8bKsVuUY=; b=p4D6qxljGzmHviwGs6cfIIXTFv97hXYpOz+JElLpqNZ/5QVgWiX//VxmCXGei7pC18 EiQnG686TeN3p+ORE8OUcUZlVoQ97KuQp9JJsq+HvP/0wjG+Qd8cS2FtntMK557VSGFv 6Rle/titkftRyBSd3NioLQ6vcRFzI/l1i+sUc27GcrDUt5SMUyuv46opGyFUcCtrzcXQ 7SRLuMnj2iyOQYh4pQd9ud0rYGmPCTZFVge7QrDYR+nR3r9driEDtGVyzkLzgRjKZkvl YioO8fs6eO8wQTE/bGujc4MA+v7a5gxGZZ+yl26tvzabIDCOxEVaP71sgt5zGSkR4L2E ucqA== X-Gm-Message-State: AOJu0YzcGPUcChp5U+uH4HLehFfquFbqaRPVhYGWnkkUKWWMa0YaMvHv W1OiAOlFZhpCHg5Z2QDjYJx4Nx6SbZSUspqL5OaA9NfcO4kCFI7bWIrvKgnLMDE= X-Received: by 2002:a05:6402:1ece:b0:57d:496:209a with SMTP id 4fb4d7f45d1cf-58e5994eb84mr4943921a12.6.1720193831410; Fri, 05 Jul 2024 08:37:11 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5907e4d79ddsm212536a12.59.2024.07.05.08.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 08:37:10 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 896355F876; Fri, 5 Jul 2024 16:30:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 27/40] plugins: Ensure vCPU index is assigned in init/exit hooks Date: Fri, 5 Jul 2024 16:30:39 +0100 Message-Id: <20240705153052.1219696-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240705153052.1219696-1-alex.bennee@linaro.org> References: <20240705153052.1219696-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.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: Philippe Mathieu-Daudé 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 Message-Id: <20240606124010.2460-2-philmd@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240705084047.857176-28-alex.bennee@linaro.org> diff --git a/plugins/core.c b/plugins/core.c index 9d737d8278..a864275ae7 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);