From patchwork Tue Jan 28 14:21:44 2025 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: 860404 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp375608wrx; Tue, 28 Jan 2025 06:22:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWuk93HBcgGC9Jy+X4NLmHGMSOq/I3Fe996JNwKiHxr/XGhGcA9YONQeVSnb4oJzl4aKJGCwg==@linaro.org X-Google-Smtp-Source: AGHT+IGsJrlEehKXJlsgcf8XLDaXGGc6kBkx1j+VB2qHH81TG1jFqqjGKA8TtBDMmCYy1Lo1yqTJ X-Received: by 2002:a05:622a:1114:b0:46c:8380:4392 with SMTP id d75a77b69052e-46e12a563f3mr629482971cf.20.1738074167690; Tue, 28 Jan 2025 06:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074167; cv=none; d=google.com; s=arc-20240605; b=D37vB5262MWRNrGDMWX1JLLJ6wtypGio38Hq3obW9qpGJN/rjAAXE2bBoJdKU72QId Ngtm+4vW3Bxx5oOnBI2r2kfrUghIwl1soemr4ZOilcFET/gw11/bJa+9bJnCrxBUJn6u HMWIlc4dkjj7KYP4hy31Fnn3Ja9NfQga/abF+jPKUKFodGsvRB/ywXo9rV9O8MrVEcvk f5VSxbe5WwMAuaDk/ktEexpfoiXMVVQxzcCzNIFHFuVR7Go/MPMCLzLCs9u/QRzpqO+h dmDknP2PzHzK7ZWvpr04dQw+3KsFELYwux+MKRr8F1mkJUL08+Bt9+j+EO9jX8dCS5Kk 8XMQ== 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=kO0uRE/b6a4B7/JlExmMlApMO3OGmNzh+eMs/4hpwh4=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=NadT3XWi+L4HkcTE2EIadq0aLotNBfOLnPeQlqVEI74hzCgIqDOazQPKCWp0eNFSQz gGqdiRyVht2vWp2gLLuX4k6nFenqlnrCf8Cn0IcC+Hg75ZzgI/7SBhfB/X82dTzaMLoU w+sVMJktW/RZSgcGT171V9tqOIHjEDU1kiIFqI3uUK3+dC5HlaSYtA12yJy5pTiiDIEr doJ4UBEX0KMxme9T1rN32U7YqFfsRv3hfTV39cSjusNhBGRyxs0z4kukHs7Yd0mghK5F Otu6YrTomNdgcLGzz3VsDuaa2ZSyy1dJ5qrSJHBq99/WpjuE2nKdbJtxSBPeFUJj5i1u NCDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q7YwtX2e; 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 d75a77b69052e-46e66ba6348si137800681cf.482.2025.01.28.06.22.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:22:47 -0800 (PST) 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=q7YwtX2e; 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 1tcmTf-0007kh-HX; Tue, 28 Jan 2025 09:22:07 -0500 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 1tcmTc-0007jf-VI for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:04 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTa-0002JG-N8 for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:04 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so37750095e9.1 for ; Tue, 28 Jan 2025 06:22:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074119; x=1738678919; 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=kO0uRE/b6a4B7/JlExmMlApMO3OGmNzh+eMs/4hpwh4=; b=q7YwtX2ev05otBtPPal4VgwXNkUdUzIcKGUN0z8E4z4izdflPyA4XNYwRd0MRtmBbD 2QUrmzA4Y15K97GXt6AiRj2Hz6acI9aWQYsaZg+LS1vbrFv+v6hqzEekjbDwEXCYq9WV TbPhm92DzwPaAysLlwe/I6JFfGAOZ9VhWXzKNpdvvnBbfbCqo+kao74dggbmufamN60e llz8hCbVxipkFHu5FsWBvGeUhFQx0NYU90M4F73N4RhxuTwtpc1cTfTVFLzb0TQXxk+D QWoBGMefaaWkMYyCfvXIBplfC3rFBd6hLyjWI3rDOWJILetpZpUA7zhmuAyHZhoXj3fv 8yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074119; x=1738678919; 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=kO0uRE/b6a4B7/JlExmMlApMO3OGmNzh+eMs/4hpwh4=; b=lTFHvF7jjIpl3MIDVuQqkZRaIVGCIKC70H1u/wRUVx8QfwkQyylrZHhNWEkhU1KYPn w6CLrfcyn6s/ot6z4TIK3ixziCw9/C3nInA2EszGD0a/4yVf2t5slggkGPq+H473FO0D FQgNRPmW5mP+0GdjhnmZHvbzyDA04yuUzC/2Y4HcjUfPwbgGX8O/BKIdDhChQ0P8kIYM xWqf5rjuCU+LppkdpmDaZw3g20MPJI/DPlMPDSoqgS9IShau2h1Rm1o8LT8ONzieg9TN t6lBi+qD8hd7DfptSj5D+JuaxiW/Ui0P56aYg/Iq1cVJJTzBnVWOeL0I8Yb+MMQel+hb G/sw== X-Gm-Message-State: AOJu0YxALG2WWmRogHh2iTv0Y2EC0fOiRxL4WHRAlmrB9CgdLMcFM0Xq 0cD69Zqc/c9+bpTxyozmketcpGo7bBI0XfURP/bGJpf3PE0qCV/mETeYowKmTJnIYoq8Ik8KqmJ bkus= X-Gm-Gg: ASbGncvuI0jFWQZWtuf/HY20A/2SQpZPhrw2nU7lQGJhsv4ALwO9A87ASjQatJxJClC l8ivtDBtBHis3nKz5M4Bj6TwsCAyzV9TRYF4BjyuXTNMTmVZSCaeDFXKXLfTys1/sCj4QX+0rzT vBwksLn8gwqZQjQtS1d+EMRp5LqtFCXC2nn/qWv7daWLPuBiQfFZcRkWcLCtcy5B/AHvrsbJl2F tH2uSqMFT7M+u4WGQfpx+MUd8M0m/xLdIbBZM8d5pMVGxLjFFKEV+I3KbyxqPjNLf54gOvFRL4H GO3b42rMujgaP6dLvRJtI/jhAo/bxADMiTPsPjRrn8rASkdzxlNUjnPVhxdUIiFhTrKD0nA5YBF N X-Received: by 2002:a05:600c:4e89:b0:434:f739:7ce3 with SMTP id 5b1f17b1804b1-438913cb518mr403560625e9.8.1738074119339; Tue, 28 Jan 2025 06:21:59 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd47f0fdsm174363075e9.5.2025.01.28.06.21.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:21:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [RFC PATCH 1/9] accel/tcg: Simplify use of &first_cpu in rr_cpu_thread_fn() Date: Tue, 28 Jan 2025 15:21:44 +0100 Message-ID: <20250128142152.9889-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 Let vCPUs wait for themselves being ready first, then other ones. This allows the first thread to starts without the global vcpu queue (thus &first_cpu) being populated. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tcg-accel-ops-rr.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 028b385af9a..5ad3d617bce 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -197,20 +197,21 @@ static void *rr_cpu_thread_fn(void *arg) qemu_guest_random_seed_thread_part2(cpu->random_seed); /* wait for initial kick-off after machine start */ - while (first_cpu->stopped) { - qemu_cond_wait_bql(first_cpu->halt_cond); + while (cpu->stopped) { + CPUState *iter_cpu; + + qemu_cond_wait_bql(cpu->halt_cond); /* process any pending work */ - CPU_FOREACH(cpu) { - current_cpu = cpu; - qemu_wait_io_event_common(cpu); + CPU_FOREACH(iter_cpu) { + current_cpu = iter_cpu; + qemu_wait_io_event_common(iter_cpu); } } + g_assert(first_cpu); rr_start_kick_timer(); - cpu = first_cpu; - /* process any pending work */ cpu->exit_request = 1; From patchwork Tue Jan 28 14:21:45 2025 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: 860403 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp375592wrx; Tue, 28 Jan 2025 06:22:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXojKBI+wnORR7yYvSmdEsCJCM3DZH5EArgbUjC8fm2Qf1+p+nUA0awIwbJwd5++cpmS+hRXg==@linaro.org X-Google-Smtp-Source: AGHT+IGGbIGvtTXai+YzCKGIEi+JKUgPCiuh2uQl1CTeInUtuL34JXWBcNslv8X7J1QhHghc9tKb X-Received: by 2002:a05:620a:2452:b0:7b6:d420:7883 with SMTP id af79cd13be357-7be6320dd11mr6458934985a.33.1738074163621; Tue, 28 Jan 2025 06:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074163; cv=none; d=google.com; s=arc-20240605; b=Xak5TSoXF8NpOzJ8ZuAjjdexoKKN2/cVlA1+P16/mrGtz6rRxd9V7/ylseXvj68saW GVZGywA5zv+heYapK8FGkoyG4DRBNVwnAwBNtPnPd5YW3loG01AbV6hM3e83u7iYvsWO f5vfH0hCocxdzUVpxA1+Mthw++Dn6lIxyHg/n36EBziMAJ5NpS6Cd/6oCYJJhiWkAynq tKiJ9X8NvGBHUBvOFzG9c7oOM+qZFTKSS3liuOIWW5esO5YqduQXX6pEMfMedK/PdRvX jXCYEFA1In0RXRdHSoac/Dbkux7w+7Zv8IY617ivcD9XQAfdcenubUNyBh856z6AF59w 0zWw== 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=seznNsDAaQBVSpbp55D/hE//Nvg+4oVvDGjyXY54BGQ=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=Mv9fRtGnvRQO3hqWCWPSh5lmGmUycUxNp1cO/Zv4T3A6U95CX0Y8XxFSc+pzn7dCMh wXg5rGlhRgRTbnUpwOY+sFQ17E+nGVCde+XP3FAG0SX56ifivSsWTfTSV2c9AITWmABf aV+qiGFK81s+gZutVScZXSkXVzENk4hNyOmM7ypoR1du5u1nREW2drsnxlaY4OHW6ptO NdJxYJ1vVkjKvFUgk5x022x5BrlmWgCortKz7SUyS7jJSrp+xFTT6mCOHM6JWw0Y6sL/ 8sPce/AQpho42ZpJBXPMUI4/Nxq132rPDjX0vaQ3fP2iF4A2MUZFOaErvdLymS9gigur Zyeg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YRx7DfBT; 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-7be9ae8439fsi1259360985a.23.2025.01.28.06.22.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:22:43 -0800 (PST) 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=YRx7DfBT; 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 1tcmTh-0007lK-MW; Tue, 28 Jan 2025 09:22:09 -0500 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 1tcmTg-0007kj-DM for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:08 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTe-0002Jm-TM for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:08 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-38637614567so2782493f8f.3 for ; Tue, 28 Jan 2025 06:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074125; x=1738678925; 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=seznNsDAaQBVSpbp55D/hE//Nvg+4oVvDGjyXY54BGQ=; b=YRx7DfBT86YHuIWIWgciW0Z6EMmb1wgPrN/a2cJ4JkQxd2riiDxE8vVWb0xviFwUMY 8rHpAbXOmTKlDuX6qcGqhmKprMJ5hSUSqk6F4uIU1YGs+5VZfunB2xQ2jy9hsDafvsKY FtB7ssge/POqp3frHoQCRM+ZQEpGH7iST01nZLKQuTGKTSzgoJ5NKJimHiZBWp12BK+t +JAMi+OfDNXfekI6wOHdfu+xhP0roVefm5SbfOtXc+yCguEeYsoD8/qJlrN/UYStvGLE xGezmuHPRZ4kO2b289IGuKchBT3y9fnsOWR+4eeiKTvXrCnTJh6VLCH1wrjtbMoaOavy WNEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074125; x=1738678925; 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=seznNsDAaQBVSpbp55D/hE//Nvg+4oVvDGjyXY54BGQ=; b=Pqz9d7uDlO5YuI4BxUKAN4xiZtB1nG83bISSiKbot2LWqAUC5BATnl5+Pr3yn0kqJb 7rq8t4BqzyUUzVBr1zErCxko58IR6zmvuAJhJ7RVhE6yvghOZTgWzRDQVchPIEis6vQp NV7Rj7++teDpVWNlwh/Jrv7v0D0K04zxysy9ip0eMee0l0jVRBvzbm1L5poy0dwqBZDU 13rglu+jD/bOZ1S1yEk7K2j6PKm+mIfUtKiBG41szEDksESLq8qF7jpYnDBmf2IFebpW dFDhHBtzssbnUpB0SOKRMpAeEt1DRP7tlDfaQTDVuINiQ0CeUC3ey+IaTkZxg1D538qm Gjng== X-Gm-Message-State: AOJu0YwTbQb0xlDkZ7UExQBDbiX5qBmtd710mqzYZqN+oulBBowBjGMM 5WBLRi31vP7XCQiOupp79Z9NyX77zpCWi1zhg2/565yGHZoT1UOFiFuVe7veAasuSVX7vO3WLN0 2v3w= X-Gm-Gg: ASbGncs0R1iyHx3Y9xTyQCPuHfRngf7kjFAOutB8g8mxgMZMgLBl1AmrgtMvPRvNPWs 3Tnk9vUCif+ljg0R75fTfIpwTMm0Hl7XbtY/Jp2btk24KB3GRXWRJjyeN4vVJmyLwwtw9s+FGfe /B+JasWM+5w+I3eLZMMMMZtSLxDOqzKeUEB3gRbf9Trt5Sw9hB+EVsQPWpLIeI03i7rbRp3D5Y7 5uCQIVRK8kjCyDbdZ5zWIc1LuU4BJkxSGfKUCH268g0+jwAInomistefWdVchRfxDLKpx77k0Gw WmxqCdQPUfDRUWAJZ8UAiku1SxQFO0ODNeXFLtOd7vPnsT5BN4q1YnEKgRpxdmvsng== X-Received: by 2002:a5d:6d86:0:b0:385:df6b:7ef6 with SMTP id ffacd0b85a97d-38bf57c94a2mr50508168f8f.51.1738074124946; Tue, 28 Jan 2025 06:22:04 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd5732edsm169125225e9.36.2025.01.28.06.22.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:03 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [RFC PATCH 2/9] accel/tcg: Invalidate TB jump cache with global vCPU queue locked Date: Tue, 28 Jan 2025 15:21:45 +0100 Message-ID: <20250128142152.9889-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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 Invalidate TB with global vCPU queue locked. See commit 4731f89b3b9 ("cpu: free cpu->tb_jmp_cache with RCU"): Fixes the appended use-after-free. The root cause is that during tb invalidation we use CPU_FOREACH, and therefore to safely free a vCPU we must wait for an RCU grace period to elapse. Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/tb-maint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 3f1bebf6ab5..64471af439d 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -891,6 +891,8 @@ static void tb_jmp_cache_inval_tb(TranslationBlock *tb) } else { uint32_t h = tb_jmp_cache_hash_func(tb->pc); + QEMU_LOCK_GUARD(&qemu_cpu_list_lock); + CPU_FOREACH(cpu) { CPUJumpCache *jc = cpu->tb_jmp_cache; From patchwork Tue Jan 28 14:21:46 2025 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: 860411 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp376498wrx; Tue, 28 Jan 2025 06:24:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU8lQ6CeelAr8JvPg/FDM+I7YXNNWi1Prcew+a/Un5ojdWziMqkV4/vc/88vfC08irhwXkB0A==@linaro.org X-Google-Smtp-Source: AGHT+IGd8Tf22WPC6omYZ+v4bbetSescp5gSTTITvQut2mVF1DPJfz07bDxn+OTTYhobtiU3ffa3 X-Received: by 2002:a05:620a:152:b0:7be:82e5:5693 with SMTP id af79cd13be357-7be82e5585amr3670200585a.20.1738074284825; Tue, 28 Jan 2025 06:24:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074284; cv=none; d=google.com; s=arc-20240605; b=cHG+yJdxBjNV6Ke0jOqabJQDeAxtLUEJ9f6fhR3LxRGSj+eNY1sJb7iWmyVN8j/VyJ 3lxM4qQauo4X7o0Wu/UdRGSvb5Ui7nMqLaRxFiC+NbR71c7b8iTGwPaZtuQeXoYUKf4j /4/wjty3hygrIagjj8lNP9yC4ZwPOkOyqjOSLpx3MyGXWlubu6zdNJWyizkALTTWrgTa R456nZNN2x5YP1875DIgw2dti+uIdq63i+8KE6oo+4oeiHniQbSgffXl0jC4Fvaz/Ue3 ogvEJPtQCLWDQ8rF75DYTNqwALmfvY0nOiQ2JOX1espfH/DIh0jhuGsvt8wCk+0ZYo/s 8WAw== 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=cztkPvSxh9km+ESKvRBcfElc50oeVn4euS866OSUDwg=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=gpQvmfwxb+4AzVygwbyIi/K2c08g0D1yLYsgTYPacAJvgVat7pUqzdUCR88iM/+sKq AQOUh3NwAwK0di4QGGgvZK/8MH3pxRZBKZJtSohpdZC/Bekto9RLZQdTdPYbZrgchvUd 2X0djgbxLLp2wIe2xR65cWTepTxcMDMcDOxPV6OUuFwkn7C4/uj2SeYjCXqB+DVU8zZm QP0KfDoJNKqY6MDOCDCQ0NCWc+rJm3+wdTG56dbtvh+FOJj56/G5/aldS+/M1UwFHL+m BwBc4VE+np7NwLnI7QJ7Nla3SUZ11hTr3un1UsQ0WbZK2m0eZGvdZMVBSj9oUmJiul+C wnUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g/hrKUbD"; 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-7be9aeee20asi1423341885a.432.2025.01.28.06.24.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:24:44 -0800 (PST) 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="g/hrKUbD"; 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 1tcmTo-0007nZ-0X; Tue, 28 Jan 2025 09:22:16 -0500 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 1tcmTl-0007mP-I2 for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:13 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTj-0002KR-TK for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:13 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4364a37a1d7so58378195e9.3 for ; Tue, 28 Jan 2025 06:22:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074130; x=1738678930; 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=cztkPvSxh9km+ESKvRBcfElc50oeVn4euS866OSUDwg=; b=g/hrKUbDRZ7AVGBmJVLbpPOwjUuHc3ttkacePEjqXPWvPziZUc8zZdekcZrmhR4mZw dNCTNGOpBAg0JEMuhDXn3M8mNNnAtdnc9tiSD5ud5KwPFArKD7HjWXcjkQHyOHC5jUR3 oPCBYZb27Xmqy3829TYn0gH3Paw4hpsGMovdoZW1h/qzPfSDhb/pUQvDo/Sk88Qx7yT1 Y0eHJtf3jSHo1L3Si2sBa0tK+8k6k4pX1ing+GZNVwi9pCKfK/BxkIdJoh3txTVHu0+W 1lEeEJJdaGEYyLartzDQftwlrfCFE7CBs7lSSeWOkc0J7/p3JPvzdIlZfEYODlHqI2Jl 9svA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074130; x=1738678930; 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=cztkPvSxh9km+ESKvRBcfElc50oeVn4euS866OSUDwg=; b=t/BA7hFqbYNiUwA4bJog8IskAS1v5r19fFKcKQ2uj6O2bcbRC3mzV60pMFirLMqRDE 94xNLKB2NswT/k59y0Bi4/iQ+n0ZXKg3pzOrEGW5AZaqDRD5wYMfZHVLdlQXNo4Z/yrh 7Yvq5noKZRN61OFCsTXEMEbHJIeN2Itd0j3XOctLZKvrIDu9v2yS33FVz7DjYdiBrJhD qyOt0eXj6oXIw4kjl4HiJKDYBzt3W7XPJyv2wctSnp1HV+hq5gjk/OEA2efHJXrWiQlk elA6GL/ScmJcbAMhXMzHPCxcNx2ugSNF3G/kM4K42DJ/UTKfvjJNbnOeIfsdc6cDImvJ 1gpQ== X-Gm-Message-State: AOJu0Yyw/UDRjSXc8hXo1J+PFLa3ODGAR1CpLEXzEsbdxUy6FjrLxwXb ITgNACQ/nCSVLYifiapn9b8KcxN8tBDpbpgqfiden9s+SDRCJHPNqcl5t0weanevZLmpkh/nb6x UrdA= X-Gm-Gg: ASbGnctDOkH2a898Q77CasXZEnc9FtJisBVXWCHVSU5aLt4qMS7yf+iuuq8i1d2bOoG udGfHiWEcAXE2j40cgVaXPxN6l6m5Jqv3TuPDzZ1tdwbSfLqHYMK3iAzSxZjQ46KVOooHWFDLOQ Vq3ZMX3TUKSZVRs0w9k8+VKcB+rrNk/05jzpSGvlnq9OxHzPtqQkkGWEir9lgqcVpoNWr/RqNtQ 1oDWsF3ApEOjMLwQ57CRgETdMqNS8O+WSVwpdMQp1nImZrM184hBfLitVNUz5ALSdOL91NkW1sD yPsJb1EM87leZ1EYC+ArMe0THOjDI3F3Lgc6xm9inujmwgyu/pG2cunCr/wg/w46sQ== X-Received: by 2002:a05:600c:4589:b0:436:f960:3428 with SMTP id 5b1f17b1804b1-4389144fbd4mr437166445e9.29.1738074130042; Tue, 28 Jan 2025 06:22:10 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd4fa57csm178828725e9.4.2025.01.28.06.22.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [RFC PATCH 3/9] cpus: Remove cpu from global queue after UNREALIZE completed Date: Tue, 28 Jan 2025 15:21:46 +0100 Message-ID: <20250128142152.9889-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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 Previous commit removed the restriction on completing the full QDev UNREALIZE step before removing vCPUs from global queue, it is now safe to call cpu_list_remove() after accel_cpu_common_unrealize(). Signed-off-by: Philippe Mathieu-Daudé --- cpu-target.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cpu-target.c b/cpu-target.c index 667688332c9..11592e2583f 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -172,12 +172,9 @@ void cpu_exec_unrealizefn(CPUState *cpu) } #endif - cpu_list_remove(cpu); - /* - * Now that the vCPU has been removed from the RCU list, we can call - * accel_cpu_common_unrealize, which may free fields using call_rcu. - */ accel_cpu_common_unrealize(cpu); + + cpu_list_remove(cpu); } /* From patchwork Tue Jan 28 14:21:47 2025 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: 860407 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp375933wrx; Tue, 28 Jan 2025 06:23:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV7x960iQwwePJfxfrincGBy7zRgODkB3S6VrggTydAZZZO7HKak+mF6jWUtTwBZ9JA2gDeTw==@linaro.org X-Google-Smtp-Source: AGHT+IH2663m2d2zJtFH3Zr6wcxXrR49SmP9CbLBjUZyElTkJ6zx2T7sLYXSDBEKaPbxSuyTNR1J X-Received: by 2002:a05:620a:4107:b0:7af:cf07:905b with SMTP id af79cd13be357-7be631e521dmr6134877185a.2.1738074207324; Tue, 28 Jan 2025 06:23:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074207; cv=none; d=google.com; s=arc-20240605; b=MVkc57lZ/fn2HGs/pDZ/5NrfwcfBn2uKrqToSSFcYB0xkIfYEpJObu1fHCvfY6kS18 IBpE56kZSPCcH6iP9NlhoOjvKkgMFwO1WorknpmktfciTJX+/RZD5HJuMtv/TLFlzs+n M/FTw8oUCJy7JKN86fISg7uTqKu4c8YKkiM9JOw4C3GEjuSi8nEn0IGERTthu3V3ahE6 F1HjZMo1CD2Y4opjim/rdj/lvMxfOWbPb4W69ahGay/p8pHfbrpuyjyiSG0CmZsw+/48 WCbF5KLCzhiQtYS8wsYReYYyqfAc3XnbRIVPS7WUvx+QcAEZIkm/apJciJemheuSiokK /zCg== 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=+boILYhYAtgeHGjq7jZm3ySgVoHBXMK8/hh/+aqTVRc=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=BxEaCnZzzvxH39GmtVrx4k9KC8k1cluMrtT3wyUak9+9IBoYLiijxNExBCtDIcjuhG Ra3Xcg4BJi6W+UBSovfl7efbMu0/8I71LLbZGqCS9ffAC2WaY687SSSOYSu58oV76urV j2JiI6IynCyTfGU+vvsMk6zfDiC8lnMH6vVEWb1rmHWOK8BI7GF+vK+YYELvt3sASKXI fuQ+eC8xPUTgX9bYVPTZqQT5qxhE0hOzCQa47fk4jsPAGJs7bMdNgInpVM3XfggRwkEH yrc7B4vx3FOtjrsr/V0rVmTj12vMXVIu2z1wZj8rasFK+EZnU1dqP0TlWYiEdHOd8Qhr DOFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zDKJ/uzz"; 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-7be9aee0163si1260904185a.247.2025.01.28.06.23.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:23:27 -0800 (PST) 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="zDKJ/uzz"; 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 1tcmTw-0007sL-L2; Tue, 28 Jan 2025 09:22:24 -0500 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 1tcmTs-0007pl-Pc for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:20 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTq-0002LJ-Ob for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:20 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43624b2d453so63131265e9.2 for ; Tue, 28 Jan 2025 06:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074135; x=1738678935; 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=+boILYhYAtgeHGjq7jZm3ySgVoHBXMK8/hh/+aqTVRc=; b=zDKJ/uzzSbnVMhEOyWrbWTzi4EhJrFG1NPvkd+qVf5cp8ivj+C6fplNYZlCvoj3+iX BrkUg9rSTy6zQODNdtrU7UIIHijXiaJfKp1orT0nTU7prNKr/ZDD/Oa8JW99/f2x8PfC pHQjcxv2d0ZbIdzjX0AiaO64AZgA+uKvoWsM3RTZAdEwkZPGp03U21bhswQNaS22EJQJ AK1RewFv5Pa3xenVm13SCiqp3rahKzebYBUrshAmxVF15PVQIjcESCQBwgcm9lBDnoES LKNLYnk9XCoIqnNfalYZWbIhusdcQD/hiaAMdi6IvOYMnomAjAQI7k9eP/tKRgt9f7FO 2Pww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074135; x=1738678935; 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=+boILYhYAtgeHGjq7jZm3ySgVoHBXMK8/hh/+aqTVRc=; b=UKil+ei9nhFmvQF5InLCPKQlPkyUOJkktMCa86WqvBosqZ1oa12523MYWH/nZbiM09 feEnD5bDpBEb91WqtIRvyozCKkH7uV+fu7dkmKQpK17BaU0Yc/VzUp3wQC0Fvlu0f1AL 4FBMAACAJ3Wjyan5YaN44IAEBoacM7U5qTrn0PjjOna7Sl4TW5LmnuqbWn3ANAUcMF0l Sr2lStwfGHowAnO5GYzTrj32ptEkiD7MpZa/b7Bdxd862QKaMc84rtRlxMCQ3FcelDsF 1BgBbi9m59UUPYV5AoDMlSyb6U0/NII2DXD2FXkhmkmbaCPxD+5XEQeeqph1/mvYP9TP 87cQ== X-Gm-Message-State: AOJu0YzUqRA5fitYnDcLZD1hJCqqk3FPYw9fcJSgI/OdQ4iQOfXegMzC OeCgyRP1+yENqQFXvv5oU2bxBBUxEjX5KAECAraQajqMyOEbvlLENdG++q5UCtd3IYSLms7O+is leVE= X-Gm-Gg: ASbGncsyVqMCB1URD9zqaR3vFbdCKPVOLa0t2IFuCwUYlpuwq7WySQuhKf5p60Oo9YU VFxQuBwohq6uYke8DR4UM+w0RwJeQveL+3nTm4EebREKBdpGWWB30/gWI6Obvm9n5IQvags+Vth ta6pptbZHSLla9/AR2BoV1kfpFe0MzXmiXdBW24lUP8QUanftTME4R1bnQLwmiEPafXDaPi6xFy Z2fycsC11uOALXDpogtZ3iNtRxUUGYWmFrmiKsa69ZLG9W/isYzu+1N+hnbtzXqRoOJCNj8YOZq YM43UQ2dQPvdi8zirkYPd2jG08t3V4302P/3Qc8sCxxPbLwwWZSyYiBLJfFAG2ubfQ== X-Received: by 2002:a05:600c:1386:b0:434:f739:7cd9 with SMTP id 5b1f17b1804b1-438913cf349mr381680345e9.9.1738074135029; Tue, 28 Jan 2025 06:22:15 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd4857b8sm168810805e9.15.2025.01.28.06.22.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [RFC PATCH 4/9] hw/qdev: Introduce DeviceClass::[un]wire() handlers Date: Tue, 28 Jan 2025 15:21:47 +0100 Message-ID: <20250128142152.9889-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 We are trying to understand what means "a qdev is realized". One explanation was "the device is guest visible"; however many devices are realized before being mapped, thus are not "guest visible". Some devices map / wire their IRQs before being realized (such ISA devices). There is a need for devices to be "automatically" mapped/wired (see [2]) such CLI-created devices, but this apply generically to dynamic machines. Currently the device creation steps are expected to roughly be: (external use) (QDev core) (Device Impl) ~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~ INIT enter -----> +----------------------+ | Allocate state | +----------------------+ -----> +---------------------+ | INIT children | | | | Alias children properties | | | Expose properties | INIT exit +---------------------+ <----------------------------------- +----------------+ | set properties | | | | set ClkIn | +----------------+ REALIZE enter ----------------------------------> +----------------------+ | Use config properties| | | | Realize children | | | | Init GPIOs/IRQs | | | | Init MemoryRegions | +----------------------+ REALIZE exit <----------------------------------- ---- "realized" / "guest visible" +-----------------+ | Explicit wiring:| | IRQs | | I/O / Mem | | ClkOut | +-----------------+ RESET enter ---------------------------------> +----------------------+ | Reset default values | +----------------------+ But as mentioned, various devices "wire" parts before they exit the "realize" step. In order to clarify, I'm trying to enforce what can be done *before* and *after* realization. *after* a device is expected to be stable (no more configurable) and fully usable. To be able to use internal/auto wiring (such ISA devices) and keep the current external/explicit wiring, I propose to add an extra "internal wiring" step, happening after the REALIZE step as: (external use) (QDev core) (Device Impl) ~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~ INIT enter -----> +----------------------+ | Allocate state | +----------------------+ -----> +---------------------+ | INIT children | | | | Alias children properties | | | Expose properties | INIT exit +---------------------+ <----------------------------------- +----------------+ | set properties | | | | set ClkIn | +----------------+ REALIZE enter ----------------------------------> +----------------------+ | Use config properties| | | | Realize children | | | | Init GPIOs/IRQs | | | | Init MemoryRegions | +----------------------+ REALIZE exit <--- +----------------------+ | Internal auto wiring | | IRQs | (i.e. ISA bus) | I/O / Mem | | ClkOut | +----------------------+ <--- ---- "realized" +-----------------+ | External wiring:| | IRQs | | I/O / Mem | | ClkOut | +-----------------+ RESET enter ---- "guest visible" ---------------------------------> +----------------------+ | Reset default values | +----------------------+ The "realized" point is not changed. "guest visible" concept only occurs *after* wiring, just before the reset phase. This change introduces the DeviceClass::wire handler within qdev core realization code. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/qdev-core.h | 7 +++++++ hw/core/qdev.c | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 530f3da7021..021bb7afdc0 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -102,7 +102,12 @@ typedef int (*DeviceSyncConfig)(DeviceState *dev, Error **errp); * @props: Properties accessing state fields. * @realize: Callback function invoked when the #DeviceState:realized * property is changed to %true. + * @wire: Callback function called after @realize to connect IRQs, + * clocks and map memories. Can not fail. + * @unwire: Callback function to undo @wire. Called before @unrealize. + * Can not fail. * @unrealize: Callback function invoked when the #DeviceState:realized + * property is changed to %false. Can not fail. * property is changed to %false. * @sync_config: Callback function invoked when QMP command device-sync-config * is called. Should synchronize device configuration from host to guest part @@ -171,6 +176,8 @@ struct DeviceClass { */ DeviceReset legacy_reset; DeviceRealize realize; + void (*wire)(DeviceState *dev); + void (*unwire)(DeviceState *dev); DeviceUnrealize unrealize; DeviceSyncConfig sync_config; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82bbdcb654e..38449255365 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -554,6 +554,15 @@ static void device_set_realized(Object *obj, bool value, Error **errp) } } + if (dc->wire) { + if (!dc->unwire) { + warn_report_once("wire() without unwire() for type '%s'", + object_get_typename(OBJECT(dev))); + } + dc->wire(dev); + } + + /* At this point the device is "guest visible". */ qatomic_store_release(&dev->realized, value); } else if (!value && dev->realized) { @@ -573,6 +582,15 @@ static void device_set_realized(Object *obj, bool value, Error **errp) */ smp_wmb(); + if (dc->unwire) { + if (!dc->wire) { + error_report("disconnect() without connect() for type '%s'", + object_get_typename(OBJECT(dev))); + abort(); + } + dc->unwire(dev); + } + QLIST_FOREACH(bus, &dev->child_bus, sibling) { qbus_unrealize(bus); } @@ -585,8 +603,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp) dev->pending_deleted_event = true; DEVICE_LISTENER_CALL(unrealize, Reverse, dev); } - assert(local_err == NULL); + return; child_realize_fail: From patchwork Tue Jan 28 14:21:48 2025 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: 860406 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp375832wrx; Tue, 28 Jan 2025 06:23:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXuGILM/f8ylGAH9i2WXaGArvTLExiYUVvJBQSQlVEAZm0KjlCmqZ50ZVpRc8+OuP1ZMe7R2A==@linaro.org X-Google-Smtp-Source: AGHT+IGGzgFoy70agFCZnfvZwnaD6Pg6s0FmXY7v+9rpAyPKutXFeS2iap+31t+/pDUivIJz8WLY X-Received: by 2002:a05:6214:2aa2:b0:6d8:b733:47c with SMTP id 6a1803df08f44-6e236734864mr49883946d6.22.1738074193220; Tue, 28 Jan 2025 06:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074193; cv=none; d=google.com; s=arc-20240605; b=QNsslU39aO9LVgorEnsXowO/zrQ4IO6oc1TM7u/hh8STdlba1ecULBhEE6MB3MrsJe uULVQ0V/6BilePq9CHpAN6Zr4VlbrP+Cc+6f1yNtnfZ6MH+lPZSYv+Cw9px41TIqFH8P kjRM0bzUnSBgW3swnWThPWFJL9U4U/h4KB+ov95Wp5dW/LmqbHOlQrYsaBk8OngII4+Y g3E8ohHtWBxI2l8w395WTg637A2Tf+R7Cn1W3I/6pxs73pEHKrlUPZSeSEYhtWoXDpJW LNkkdgv5ZznYv+yjUuL4hWyQJlYvjdrd0uHuwLNK7rJW456VW9ONdles9BpQqkVKYSp0 BJPg== 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=mCOhYMyVhf/9MTlWJYC1Pyb8EOr+qnDpIx/K4OIle8U=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=GZ3esfn660+UHmHHpAbcKEsS8fV/UDQMzThJAgxv1NKSVwb7pzArNwxMMiVjsls40l Tvbe2jqbnFHJ3w5Eki/R1hAGDZmzF0VX3NOiX+EUjV4LesywLZwh63SYGbQ9i/eYqoW0 mY8b9NHh8HybWwT0u5vmufha8nfi38cRLy8tP1kZGFtKn8YOCNYgatJyBT04bjJPZbrv BPHpIbef89uI2khHNqi/fpWExBFvkQMk1dm5x1oVaOH7q0Mlvs89jYoq7JdXA3ypW5dJ Y70NyQVN38eCtRyIJzqc8ecEiNdmTHgUQAp55hWY+IviGDBTnJAKfcTrMdRp6r4fnGA5 RDmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HIXX8jpf; 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 6a1803df08f44-6e206011752si131378066d6.371.2025.01.28.06.23.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:23:13 -0800 (PST) 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=HIXX8jpf; 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 1tcmU9-00085u-VE; Tue, 28 Jan 2025 09:22:38 -0500 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 1tcmTx-0007xt-Bd for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:25 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTv-0002Lk-1v for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:24 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso42395915e9.0 for ; Tue, 28 Jan 2025 06:22:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074140; x=1738678940; 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=mCOhYMyVhf/9MTlWJYC1Pyb8EOr+qnDpIx/K4OIle8U=; b=HIXX8jpfYmx3orluh9tJuCSgZoXZhUMxVWmCNBwLqs+lQ2cOELDtbNhEi8FIn7KMTG D9GZrP3o5Rilow385pzHojPZYWXLFSKONzg9KyyLCpoD9iQj8oPEWZIK6c/Mq0GJ9C9N OfBXsSUVdQUSOh8+a844BI9ZyO9bz7JHyy/GxfQYn15nEjaOPfgOINdvVNMnSwWq8Qgk FrerrPoV+7O9Wvr7VnaFC37p4AZzSMme2QfEe0PkLnpa4EfdrlNKBi3wfLMwwrudZr1a 72xjRdu1LEKn5qOx7UCwVbs5iGuYEHahyvqBz+oUIVf27wiMgISfZ/viswW+0f7Eo2Zh D1Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074140; x=1738678940; 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=mCOhYMyVhf/9MTlWJYC1Pyb8EOr+qnDpIx/K4OIle8U=; b=Y69Nu9Tnx/7snDTbOEyFzhP4RlHM+RrQqvuO/fcAKJov8X3kcvykYll/WdL8LrwXFz KkWbYWULLLUy3UPvylJUliedgLa0S69TyFMLXEwMFJXfNUIfVrNCIdb+RF0/fPXPDurC vBWK4/epo6DophsrXfvr3w4rHmaBU6qE0+iCSC1kGx/VXbxCC5agJ1dOuW9G7Qr7YqjB lVEQbXoT/KZXKCiOHpVkHKSZzAmoZ0cSQu30EqM3arGhHuwuERJo1AcH4w+cEM0i3YiY smZR3xcR4wKXGQ0ULIzgecJjWLT6DMo21FfLvcRRVdVCckLvLz7acEaTubgqc3Jj7jL4 K/Wg== X-Gm-Message-State: AOJu0YyOUSpTrPb/fkuv3BfAAHqVIjriASwsgH9IffBBrC+WydGtFkDd eEGBDO4zU2W1YTwSNxe0zyiewFU7zDMMP92dd4K+K0F/cTbEY4tAzT6Om6ZhUeqfYLjhltMWR88 +EYg= X-Gm-Gg: ASbGncuovb0nUC05K6IyTE2cdeCvJo5U1ys9YZp/uI4Gwm399GRlYhWRb5l0LCn7/ri 9+yGeGSTMN3uG+7uosHxx7CVUCEgS6eNTIrJ0netkMg+0LBwE5ypnXQaF5JNnWee3CwgX3hlfLH Wm+aOd40Ppd1bJM9uYRcblXwTIIaY+khv8ora5TNkyADOHyTigxBH4jVxyrYdJtgRzHOUXLHFIw 5AXGv1aC7M4oIik4PfGyunBIOoZVj6OnS+FDwuWgl0Fwm4pDUlqpuJvYls9ZCb4F8HDuwLBW0Ub d8Tji/uUVlnZhKYaEhUsE/EJxomilk9qD/YZErQ/gR96dyCvkIzlPr+IsZCV8OvrAA== X-Received: by 2002:a05:600c:6c92:b0:437:c453:ff19 with SMTP id 5b1f17b1804b1-438d59b566dmr30503145e9.14.1738074139917; Tue, 28 Jan 2025 06:22:19 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438bd57325csm172106435e9.34.2025.01.28.06.22.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [PATCH 5/9] cpus: Add DeviceClass::[un]wire() stubs Date: Tue, 28 Jan 2025 15:21:48 +0100 Message-ID: <20250128142152.9889-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/cpu-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index cb79566cc51..9ee44a00277 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -219,6 +219,14 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) /* NOTE: latest generic point where the cpu is fully realized */ } +static void cpu_common_wire(DeviceState *dev) +{ +} + +static void cpu_common_unwire(DeviceState *dev) +{ +} + static void cpu_common_unrealizefn(DeviceState *dev) { CPUState *cpu = CPU(dev); @@ -311,6 +319,8 @@ static void cpu_common_class_init(ObjectClass *klass, void *data) k->gdb_write_register = cpu_common_gdb_write_register; set_bit(DEVICE_CATEGORY_CPU, dc->categories); dc->realize = cpu_common_realizefn; + dc->wire = cpu_common_wire; + dc->unwire = cpu_common_unwire; dc->unrealize = cpu_common_unrealizefn; rc->phases.hold = cpu_common_reset_hold; cpu_class_init_props(dc); From patchwork Tue Jan 28 14:21:49 2025 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: 860408 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp376173wrx; Tue, 28 Jan 2025 06:23:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXZKFAnT8QgJXpOnZAPqaK3sn/+IBHUj9t4jbCi55qjBWSTPCW7BHqCD1ZSyV9ZGTvWxPN28A==@linaro.org X-Google-Smtp-Source: AGHT+IFIXdNPPCPG266vOiRU4Ut+cDm9jwB4lf6WLI82/5+TX03usk8nK/yTNZMeOv+Lbc4EQUzB X-Received: by 2002:a05:620a:3947:b0:7b6:c540:9530 with SMTP id af79cd13be357-7be6320c460mr7925457985a.25.1738074238432; Tue, 28 Jan 2025 06:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074238; cv=none; d=google.com; s=arc-20240605; b=AyZiNMUeg2ADMgWlNliAh3xO17SWAkg8Bz5a+Pk6IXk8gHgKOELGXZYWvozDmJadqb x62XdW8HvLxxX8EkVPErfMwVSL2PV4atV5WDHaLeDMPqqc9baiZDMOJf5aADK8eAN2L9 p90Y1By2+aQHK8DY0Z1I3kfo80rl3IKSEvOhpTRaTV41Ndp6HSchzwGk9nMoAy+KUNA4 VqIe7pIWDr1ly/PupjLkmE8y9Eq8792Tj4nFVkrHbtPBU43peHG2wxDeolM3Ur95fjSD ehR2Z94ZNtOCF4VPmx8j05u5xKryvRAYvadiNWhGSjkKDLUhE0sQV6fadKFBOdDeAVI/ oJag== 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=Tw046dW5+uhhYJLaed8H1nN+PEtNbdWPjJLIYS364MM=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=LxMRFbwJRPsOoYNIgJohjOazjP21S89W01VlyPFZAMXkXVIlAmFohQj4xECyCGw1ey jmr7lckcOBfqM6GoQyuKcBWlRrDwEQV8giyqxS/IDrSs7507TSH+y7iB9MS8QZ2wj4wi VBOqDWprjnmkAJmzRLZtqDTPbSQxEVu3uEj38zVe4zFOsJ+Txlq/q14hg7LXBIwprSzR zQ/hF3BBhTOyuqfP8BSCwB4irlNszqTX6czmdbKrrERPUp2YDXUTqKBbub/Slz/DiXms Qgz53eCKjzaamRtxbqIqfAZr/+RMZupzwjUnH7SnONXnTosdmLnTZT5GEG0lZdZXlOYj +ifA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKno2KaP; 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-7be9ae84b8esi1209438185a.85.2025.01.28.06.23.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:23:58 -0800 (PST) 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=YKno2KaP; 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 1tcmUK-0008Mw-RI; Tue, 28 Jan 2025 09:22:48 -0500 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 1tcmU0-00085l-NA for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:32 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmTz-0002MH-3H for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:28 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-386329da1d9so2946761f8f.1 for ; Tue, 28 Jan 2025 06:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074145; x=1738678945; 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=Tw046dW5+uhhYJLaed8H1nN+PEtNbdWPjJLIYS364MM=; b=YKno2KaP2dzwxTaB/PiXXuz+K/eXiPdccvmP5hSAxH1W5+BaYZckgTNiYgtREK3+QR CG2aRMqxBLjGcRAIcy/FM8e/+g+0knSti3rPq2CcKDiOokosZJ4H1bAOTvkPa1o8BQ+h 27690LMDUIt1+hVVBgyCVNbQ9KSpmaQndpP2bZFDl0WbgemVMM5TUo05bShR1FoLnoB8 n+/JILks46I06DWwF7VOfsEwSPUKHOynfWXWu9KR/B9lq49FxC5ao6pewTWKWhBCFzqU j6g1iu8V1V/ukBIS8fbHeQ3MbXuIiVu6KBDFjgAsDXBtvJsaHR81PepaAsIeMBBhktaB Ecug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074145; x=1738678945; 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=Tw046dW5+uhhYJLaed8H1nN+PEtNbdWPjJLIYS364MM=; b=QN2Eb9T9pcbm1hoLnx3SSLcX7yQB71DVNN0ADFEyiFq6huy0Nf4DNJYOW2KKqAs3t1 L/tz10/PazGkFezFCCQ7NkhfKerKwHxoOYjppF+6hGMLMqhr/DOR+gc4wr3Jn8urb4Ks gzK5vvm0qbgikcGePN8vK+2X5HBvRWj/TAJ7/lMoET/edbmC04RyZ9FXw1SN7qtTYfbS 2CjKOqKdPoewvDZy7N7w8Jy/ZCZbzFU37wAvEAp1Vn7lIoWTqjFAIrJLE4doRZCFO8dq Gx4VxSn4iU3omUFHzp7XxhFI3pcmuYlDNjjkyDKlglvKssBoD0GZzeav5dYqdcHPyCFs MjwA== X-Gm-Message-State: AOJu0YyxUpYyqb96W0q8JPh298n0KhMJChwv/c6Or70WAGpcJH0tXmUu yyzqruKBuBVYvosGxxRoax5gAnFwy8tsXwPiE4hFM1DsTi8s0c81Ro8uv5wdQgk7e9+r/eDEHyV JnxI= X-Gm-Gg: ASbGncvWaq/Gv0fxPhXRkoX//UZKODyLs7CngiP/qrk+zbMDYuKHmEpl6gcO7hNIZnH k4f/RSc6V+3GhfP1CcCO5/UvFRw3SHvNqbCfaNJ48e0TYJRW0YnmCg4zRjjJ8iPLd65OmFMqR+h 3WAZGpml3fzv9ILAueFfX+nW8Q0fBsDM/DQbLGOi0OuIpAkClz4bOsNhvJf+PHy4IGeOHqxSlME pJsep1APKE+dNVp8Zx0BTLQyDTCS2u+Q23Ia+Yi+i1Q/kGV4THsNOHGQNK3mTqGxiOLP9/pVyIP ihAm5eDPot0qqQznhC9IYnlKxGiYcmSe9L5w1KLxoJysf86uxKZXv3BfK94na/AeIg== X-Received: by 2002:a5d:47ac:0:b0:38b:e919:4053 with SMTP id ffacd0b85a97d-38bf57a993dmr44371093f8f.44.1738074144814; Tue, 28 Jan 2025 06:22:24 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a1bad92sm14282474f8f.61.2025.01.28.06.22.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:24 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [PATCH 6/9] cpus: Call hotplug handlers in DeviceWire() Date: Tue, 28 Jan 2025 15:21:49 +0100 Message-ID: <20250128142152.9889-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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 To call the hotplug handlers with REALIZED vCPU, we can use the DeviceWire handler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/cpu-common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 9ee44a00277..8a02ac146f6 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -211,16 +211,17 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) } } - if (dev->hotplugged) { - cpu_synchronize_post_init(cpu); - cpu_resume(cpu); - } - /* NOTE: latest generic point where the cpu is fully realized */ } static void cpu_common_wire(DeviceState *dev) { + CPUState *cpu = CPU(dev); + + if (dev->hotplugged) { + cpu_synchronize_post_init(cpu); + cpu_resume(cpu); + } } static void cpu_common_unwire(DeviceState *dev) From patchwork Tue Jan 28 14:21:50 2025 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: 860405 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp375669wrx; Tue, 28 Jan 2025 06:22:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVk8+rAn+NDxFlZ4fdEGNpuk6zzYf6BFxGaAKrKOPFCFNVmkvmwL0fMIJIb8gfeSIQZ5xoXcA==@linaro.org X-Google-Smtp-Source: AGHT+IF4tOdgcWMsaTYgFSKvpYXGyjhR//HCLchdsnCacqNV1y8a1cQy7ff1ytBehWE/msTw3Z35 X-Received: by 2002:a05:620a:2a0a:b0:7b1:4547:4910 with SMTP id af79cd13be357-7be6321c579mr6680406485a.20.1738074175301; Tue, 28 Jan 2025 06:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074175; cv=none; d=google.com; s=arc-20240605; b=iEBKqnG9hgxwLXJ+QsjoA3mSehyUU1ugHY/nBMnX7VhDy1pJSqJMTxxk+M8taRjSlv 8A4GhanQiqtxPVwUlHQPFnzNUteQNsf7qGJvHvyr1C3BA6u72OuXZQ0YVy+mP2A/nmKt 8QNdIigqMMlgMKOZwnvjoWpBwK/AYm0AyNC+NE1jaiV6AFnxjoIkGG7FV3DlJvG/5Fhv 6xOSM0Dl4hH0Y22U0vioryJULuRS4pOHHWk41HYJ1OIBUQ9oFppMrOW24vTx8m/7DlWl Te2QmCF9HOyDOngP2HH7fR/ByLxpoAP5+ufr4h+NzQrEFHjlcrt9M8d+KeawtnOg0FNo u9GA== 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=fwXtzSsp3Wrsq7TzutaYeT0jWiU8kps8I7b8yY/9nhU=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=bAKL4qFKJTR1ITym0H5+NuuSxVHA/EF0j2tSLBkosG56TjA7gq1oFoPy5Hy1zWZaZg OOzpN9YrSN8XeUr876KzuwkIpjIXST50QI1+gxPA42/7fCNkLy3wFfzVEqE4+XEXepkI cnYrjvt+uh2PzDl96fU0SzNsJ7p4nQuKHo26wQWomBLhOy18wx7UjdJUVyVEeMwG6Plt gQsXvWEi3cTw/6ZjiUCuMnFTMAdBnc6vgLJlq8gdXhMNQYIzALx6tYxGUgWGmk2O8c15 7h5BzphhpaNEhSAnRiTp+bhwrnbNOOiM+xLuoftUzWcWBHpedfngAr9/q8pAR71M7EsS CkTg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vR+5kYOu; 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-7be9af117bfsi1414383585a.502.2025.01.28.06.22.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:22:55 -0800 (PST) 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=vR+5kYOu; 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 1tcmUJ-0008KG-TO; Tue, 28 Jan 2025 09:22:48 -0500 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 1tcmU5-00089B-FX for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:36 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmU3-0002Mt-JZ for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:33 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso36461625e9.1 for ; Tue, 28 Jan 2025 06:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074150; x=1738678950; 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=fwXtzSsp3Wrsq7TzutaYeT0jWiU8kps8I7b8yY/9nhU=; b=vR+5kYOuo5nLCtHiXUYmRklsOoNxvJ322cR1L7dRRdsUyiqqm457bwG3T4P/beoCK9 vSQ2Z2jwwn4m9CHtLFVGrElEf+HCGiLxUgXVRx0Fva8qvklK8JllId2IVVUtgVOjKTc9 bqxLNDTesKDfcFaSEd9mbgHytoaODMK18PNX3JRwYwvj6hYjsK/jYuwEbnUJriq4AMOz 9YqLaJSkq8FekObaC1FvZqLKUcGPO4KnJ7Tm+oOCaWZ1KuEReV6BJ5Nfs7IYD36NxQlA rEQZhfTG67z/9BrhbKOx9UfX2bksJy04uxqb/YAmJ0nxNEaYzSLihVCWUmfWhbGt0mLs Lm0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074150; x=1738678950; 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=fwXtzSsp3Wrsq7TzutaYeT0jWiU8kps8I7b8yY/9nhU=; b=tW7SvLV2GTkV6Fk7QM6INe/vx5xj7/bFUbV97lRuuNzKCQFJ5Ka2sUOP6UL4xYK7RU qp6FOC3qtyJF7QS9nv6G19biqumSHifbJGBg5uikdqhgc3eHyEjCG5E/+FIky/sddh/x QPiFu7VXY9S9hA8v2eojQelfJPqtXXmBqMPu7fRm/75ikBcw/hTm7KaKPFS1CmQDRqW+ xo41V/LPZBRSUoiWSxAcUas/zeyQ98YdXCY7x8Jk2Kp6riRTY4UiJWqdf0jpKLkwWBhv EahXfgBYIFziDQ1du7yOg0JMsBZkoyJaoHA4i+noRiqVND79KJtV35EMgNOlG40u9Ujy wyqg== X-Gm-Message-State: AOJu0YyU4VLK9UelG+qWVKXhbtpnxGyqSjWtD+qb2ly5X4/rY2t2+xT1 gZ4pA5JEO1tVH2706Ki/jaKGX9oDRrc152Jv0UKKBZIJnsG7qbMxZQMuSA+f77XDXTr4cDPs3Qd 6reM= X-Gm-Gg: ASbGncuRMa007jYHrANpXPvKv/8Nch7TelXd1lP+09+rjIslxJZFfc7X51Lm/lVDglQ DrikQDHKt3RuBle13j77jvw9VUevh5ZjcHU+NY69gAoWSfMr+YqElei+MqBFtC2tcomiFLLcXwk 4kNhWbk2vasuwXwxbHOP+AB1ua7ztx1S5J1YGzLNbPb9nGuZ19f0FgdJc09rOavsh1O/M8Jtgje T23GXkT0CGU0HmXOEogDexBC8CCaTV2vdOrfoHmDX3SvKObYYj/s3MbyQn58LLFpvzznbukSl3l sgqOiOhAGbTftNTYSnG7p208eyA7CSe/t98nY1fuDAFBVBgI28ZD0uHWMl4b97755Q== X-Received: by 2002:a05:600c:46d2:b0:434:f1bd:1e40 with SMTP id 5b1f17b1804b1-438d596d1bamr27108845e9.6.1738074149822; Tue, 28 Jan 2025 06:22:29 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a17d7bfsm14358242f8f.35.2025.01.28.06.22.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [RFC PATCH 7/9] cpus: Only expose REALIZED vCPUs to global &cpus_queue Date: Tue, 28 Jan 2025 15:21:50 +0100 Message-ID: <20250128142152.9889-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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_list_add() was doing 2 distinct things: - assign some index to vCPU - add unrealized (thus in inconsistent state) vcpu to &cpus_queue Code using CPU_FOREACH() macro would iterate over possibly unrealized vCPUs, often dealt with special casing. In order to avoid that, we move the addition of vCPU to global queue to the DeviceWire handler, which is called just before switching the vCPU to REALIZED state. This ensure all &cpus_queue users (like via &first_cpu or CPU_FOREACH) get a realized vCPU in consistent state. Similarly we remove it from the global queue at DeviceUnwire phase, just after marking the vCPU UNREALIZED. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- cpu-common.c | 2 -- hw/core/cpu-common.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cpu-common.c b/cpu-common.c index 4248b2d727e..72ee8dc414e 100644 --- a/cpu-common.c +++ b/cpu-common.c @@ -91,7 +91,6 @@ void cpu_list_add(CPUState *cpu) } else { assert(!cpu_index_auto_assigned); } - QTAILQ_INSERT_TAIL_RCU(&cpus_queue, cpu, node); cpu_list_generation_id++; } @@ -103,7 +102,6 @@ void cpu_list_remove(CPUState *cpu) return; } - QTAILQ_REMOVE_RCU(&cpus_queue, cpu, node); cpu->cpu_index = UNASSIGNED_CPU_INDEX; cpu_list_generation_id++; } diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 8a02ac146f6..df7a6913603 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -218,6 +218,8 @@ static void cpu_common_wire(DeviceState *dev) { CPUState *cpu = CPU(dev); + QTAILQ_INSERT_TAIL_RCU(&cpus_queue, cpu, node); + if (dev->hotplugged) { cpu_synchronize_post_init(cpu); cpu_resume(cpu); @@ -226,6 +228,9 @@ static void cpu_common_wire(DeviceState *dev) static void cpu_common_unwire(DeviceState *dev) { + CPUState *cpu = CPU(dev); + + QTAILQ_REMOVE_RCU(&cpus_queue, cpu, node); } static void cpu_common_unrealizefn(DeviceState *dev) From patchwork Tue Jan 28 14:21:51 2025 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: 860410 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp376382wrx; Tue, 28 Jan 2025 06:24:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVyVb+FaNNa6ss9HWfJwP6sIbY80rv5cb0GGeS/CFDTKF80WGfb1D4WZgRusqI2RFtEh6+ieg==@linaro.org X-Google-Smtp-Source: AGHT+IGez7LfoXj/nTX0Z40aNvDPhCUTI23HVjqn92QbhArgLym6nouHWPxtJxsTfv+DmgHlT3ov X-Received: by 2002:a05:6214:2466:b0:6d9:162a:27a2 with SMTP id 6a1803df08f44-6e23684ce96mr49738046d6.21.1738074265859; Tue, 28 Jan 2025 06:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074265; cv=none; d=google.com; s=arc-20240605; b=eVuaxFb89iBCpZyAJlJigb74qdfZGIJdWjbJS14jmaXJTUV1JCn9OEZBUZq77cNAuq f3Om6QW6VKciOb/suf197GOQC0xzPxNclc70GgQ8HHmZu3mvpNo0p9XuTaqhhDNxzF9a +XPxiON/svfKiatV0X8xm7bHlq5C7LUpF+cfD/9nk6V/gpWEwI6/PLmOF1oraddLXHoU K7jw7g79L0DyZexXHrYnyl/NvTYnTssRe2djlvzTph6Hbf8egTi7CCufBF4gcr0J4cbE sCYqB7nZBUfNqOdfj+WSfYNZOv7fOlRHHpXetgB7+uHmpXehWDFydp+C8K7nw6b25CPi DzHQ== 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=YRDTHlfvyOrER0eUl5RKITSLiEo3HyKeVBvSp+Og3D8=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=BU88JWCNhjzYcDv5pT4Ezne9OVpQwY2GP6I+5KsM8dFvESQUW7NP242LNQ7JYog5nW +BRgb4HDF4Lb0/LJvIxxM+kHqLOZQpgKw7cV4bJanNR8ZVat3vebXwOnm5fUB1e9UeLD /+UA8YAGduGkPPdApShXL+++haoBUKwqbDnXvW/KPPLSCjE/XOQ9Dp3V9hEP5QzOfeqU yXX6Sa8fsh5zxFMLwoQV5de2cpmMCNmVzdMbUpJ5vb7zdAndyR7F2OaIb2gn8nd3Xq3L QMxKzKBXhkcWpqvucfpOoDcnpWY83mUGv2e0rln2Mnqd6HHtwXhysmukPrUXClSiqEgl NqNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EQ6Rz2q1; 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 6a1803df08f44-6e2053623cdsi123516606d6.115.2025.01.28.06.24.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:24:25 -0800 (PST) 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=EQ6Rz2q1; 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 1tcmUn-0000Q0-Er; Tue, 28 Jan 2025 09:23:19 -0500 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 1tcmUA-0008B1-HX for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:39 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmU8-0002Nd-UV for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:38 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3862b40a6e0so4105758f8f.0 for ; Tue, 28 Jan 2025 06:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074155; x=1738678955; 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=YRDTHlfvyOrER0eUl5RKITSLiEo3HyKeVBvSp+Og3D8=; b=EQ6Rz2q1RpHqCwi9yC8iP0Ps8Zmm9RzEwhWHQhgUStLFMG0E+gdFSDrirh7Fhga1bG W7TK1qhm0NA7wqotPZger2/wv5o41QviygPULx+BoPiLfPVLoQ/IVCNQIYL3uHcZcvOa AEIMxQEJNpf4byE9pVwfQoz11IXqs8K9ot15UF214pzhz36OfigOk1Plwh4+xseQUAkp +ktNLAw2gcZ18/IEZydfu0zBzGi+6GBckYg8KCNOhyGt0HVLYBiJYnfaD0Qvsy4v80Y+ 1qrt7qUq2mCuYGscEZ5FBqYOJPi9ByMiI1V6jJ4nmk1Jb1HpkWeK0SZFAHPucPdKcn+u Pe/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074155; x=1738678955; 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=YRDTHlfvyOrER0eUl5RKITSLiEo3HyKeVBvSp+Og3D8=; b=YlEWfEuJZN8M74EobWpV4D+UxqfwTKWMaA+NoTz2UV6UaDK3zSpmByujx43w0Tgr0N e/eiEdwpd9HrpUfR3U+Ec8EAbp3NSnKqSRwjkK9C/21/o4xvQ44dq7lBAZ8vtypea1hA PiUww4cQvCbhMe+Xc2XMvEk7RC2JKLzlCVAnDtg3O4EyaQ7jAcJZY/A9kh9wOSkGpO95 8E2L21yT9OfB3iB92E1wkWzEzV4A46ugqrn/Kqn4PEdRdkuuD0pHnQ2fgMXrkcmNrbTP C7iTTw9RRZenqAbnZDTYirBn36oxYdEtUPBwunX71+4kEhZ7RsUjEszGqVHuNJlLFs5I pLPA== X-Gm-Message-State: AOJu0YxZT3L+ZC31Gs2ym852cU2su7b4OWa5WSggFo1Gt8Wr+oPuAoMI BAAwArOR13Y5gD4ljVo11xyHa7bZp0YAaZFmhhm+rkP010wHh4eltjBAKfMaL6dqRUaKgMA/4QV EnBI= X-Gm-Gg: ASbGncsvaGkPneE9CV+koFTAKZEOgQFo2degNcCQWWsC88WVNEOpZIeVwyL/1zXA3nn xJulGGdQqosPHIcrapx745ORk/x4M2G08IrMRNAB8DSjk2PwCEpEEjKHQs7lCRd+flh7kbnxqoc 5nak4VJLT/Vnli4hXwSeZsYBv5ecu2z1os180ALA8VFt7APRg0glbwVUVVvyq1J6BgHsFjLeHeG zU3KLKTRm+uPAUb4e0MXAdFDpCj3W6TK5QyOdtdCzxdRqgoA0ztXZMcnIyzFGtnDqGIxzp+xKBD gIGCxEmcO/YiNnxLqnZpeVxwvJGmZ44M1NIN8RvpYLDsjaclEYWVY7cas0/PlGmqiw== X-Received: by 2002:a5d:6c65:0:b0:38a:888c:676f with SMTP id ffacd0b85a97d-38bf565f13bmr45683211f8f.15.1738074154855; Tue, 28 Jan 2025 06:22:34 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a1c3fedsm13952511f8f.85.2025.01.28.06.22.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [PATCH 8/9] accel/kvm: Assert vCPU is created when calling kvm_dirty_ring_reap*() Date: Tue, 28 Jan 2025 15:21:51 +0100 Message-ID: <20250128142152.9889-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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 Previous commits made sure vCPUs are realized before accelerators (such KVM) use them. Ensure that by asserting the vCPU is created, no need to return. For more context, see commit 56adee407fc ("kvm: dirty-ring: Fix race with vcpu creation"). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/kvm/kvm-all.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c65b790433c..cb56d120a91 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -831,13 +831,11 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CPUState *cpu) uint32_t count = 0, fetch = cpu->kvm_fetch_index; /* - * It's possible that we race with vcpu creation code where the vcpu is + * It's not possible that we race with vcpu creation code where the vcpu is * put onto the vcpus list but not yet initialized the dirty ring - * structures. If so, skip it. + * structures. */ - if (!cpu->created) { - return 0; - } + assert(cpu->created); assert(dirty_gfns && ring_size); trace_kvm_dirty_ring_reap_vcpu(cpu->cpu_index); From patchwork Tue Jan 28 14:21:52 2025 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: 860409 Delivered-To: patch@linaro.org Received: by 2002:a5d:6b8c:0:b0:385:e875:8a9e with SMTP id n12csp376304wrx; Tue, 28 Jan 2025 06:24:15 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXd4dA81ZT2/2JoBCMY7OrNjZm1KFOH29v6HrGfFyVUpuV0xMOIiXsd8LP7I/5vuYUdGOq6JA==@linaro.org X-Google-Smtp-Source: AGHT+IGYMcnkKrHhalYN36++Dpxo8Z7A1lsqz8VROF/Or4lqlMNu7xEOBt/hLe/NgqGJDvDYJ6ga X-Received: by 2002:ac8:7e90:0:b0:46a:1932:b07f with SMTP id d75a77b69052e-46e12b94a7emr742703031cf.39.1738074255205; Tue, 28 Jan 2025 06:24:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738074255; cv=none; d=google.com; s=arc-20240605; b=e50qPMKY1OirWZjy59x3PqQffbGps/HLxi0CHZ/x1Bq+UrANHFnOv2+TJYcLwEIMIq Y7N7Rv0maP2on7i33b/TVBKtPSkMrVdK6kSinWz3BPZvCYQzBsobouG40qAWLYRC9Ogw a6370Myi8gtQNb0xj1xW49vI4JBZptuQRkHjE9w6sDjPj73mZXtwCZElHwA5f2bPmaFo bt3pKWWDvjdhDreKQ8SsbjcZjHfB1hwUbwbtp8aKdyS/4+1le1INvngWXJgHQ0yqo9EW S/m/Hjth0GGNSjUnp5eOO7hYwHhDWUzW6KeQinA0K79CXGH1/cO8/YNzIaR3NXEAhAI1 /1YA== 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=jN7tNGrfnQkH1jp+7zEAfhWZCNwGy2KakJL6oRXbHIo=; fh=U6T2d4RqSCGJNf6LOIblgdoe4xaHu2Qwae+meUOhpik=; b=C+LZCuF1an81iyURigVLrsii7yScGn++Jv5Tqm+SeeLW5Mk3J/OyQBU0V9Fo6/Lukq v9UEFZm/EpZ0X+KPH+mAGHF1foN8XMmf3AFe5c+zvGqu+fzW6Am3c1Cp6Oot8gSDr9VP TfCDI4QvcfxDXff+/KHi/e8m+XQoCtvtKXNLubpL04GIw8SEdfpU50mq2PsSuRUwS8QG S17j5YV8h/l7vUTVsgzZgQKkeCa+G6qfe6PUtvPwaC5EVFarXCsBJcQYCcDjn8UHRn2o rZaINEW55V9zJd4f8xITotl7Q2eAy6ouvBRsO0QSRqI5RCafzWJ+u2vGyhKfEnP2SyA/ /umQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TV29y09R; 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 d75a77b69052e-46e6688811dsi126445081cf.166.2025.01.28.06.24.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jan 2025 06:24:15 -0800 (PST) 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=TV29y09R; 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 1tcmUn-0000N3-EO; Tue, 28 Jan 2025 09:23:17 -0500 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 1tcmUG-0008EY-3z for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:44 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tcmUD-0002O9-Ia for qemu-devel@nongnu.org; Tue, 28 Jan 2025 09:22:42 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3863c36a731so4736889f8f.1 for ; Tue, 28 Jan 2025 06:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738074159; x=1738678959; 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=jN7tNGrfnQkH1jp+7zEAfhWZCNwGy2KakJL6oRXbHIo=; b=TV29y09RKOW9xtqH++5r4H5mCmJPqDWmlztjWX8yRMiZkGVo/Jbw3GEhZWYSVjX4PY y/ge17IxfBxPD7KroxTHrSd3mgQEdltaM3SJuGG7OLzCbZ3FRTx6XV39yMRAgf7C4sCs lZsj7kKnPaq2dFuzjFufnDXAWvvz8krjU40TSOWItbvPXzuAVyXgoZtr0ysWfq9tzn9D dM3+W+B8SzrnrK0PR1Ec19OP+xP8dobdnzCpHGeWOJAwgm/8OThYMN7ANvhLqoREpImH 8uv65GqO0CDCtfYp3tNGFcy7MbkvuJA0zl6UGq2TaXVEAG6JGhBfZx92nxwEmCWPzyBQ Wc0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738074159; x=1738678959; 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=jN7tNGrfnQkH1jp+7zEAfhWZCNwGy2KakJL6oRXbHIo=; b=h5llxzRwTo168iBSOCU7YWSm3IogJsnPkEjRA4+p+H1AJdhKE6GhMDx3G5AQDhGfz4 L+9SAV1efDii9jlcak2U2lSy5Ncx8HRY9KFGnaBP5cPjUgrNXXSEDGm7NErIPkyMphZC /wU7Gqx2O0R5XljtArKlQ91IrGRo5WIK9ET7ztt+u87mMjeA3jk4MH/TCjDI6foMp7Pp bUZwZ/rLrtdphhHAFHaciHbJ7PliLQNDZxHRcGL6hVr8gX/QqmuuVT9U9KYLeftBYFlN a42Jqn/B7Um/cXafQyjn+SJHUiOUgefID2taxFSmZi87WFC1nukX6dMjeRsqZJVwqqah /leg== X-Gm-Message-State: AOJu0YwbPHk3RKoAtkIAjBLp27r9e3nyVmMGjrR6IpjjnOGzP7/5BBFr gOu9KmS75Tiw4n4c0JxkOiBO+pqFykJjV7l0qALmj1gjLGkT6npDG0gzluVwSBpizaE0xl5Ruav PjmM= X-Gm-Gg: ASbGncuhnzDNKHuzXOgk5Hr2Slz2Gge4iNeCVS/Vvm+EnWQv/k2P/LKbrNExNnRJ7xx 1PqhaAkXloKsQ/GIWoLmx9vLHZCeOT5ZRq0VvIUyBC0trBg13tNzafM+jRpAeIAzWVccSjrRpl2 uar7iz/zJKsJdCx32yWEB02E1Ck6z76+o8YjmJ29HwG2U6wXUHt6qyjDqrcfCwsU7IrRHXQOfAR gE5e9Jmr2awzxDjBlzywTlvcauK6ZUm05m3Ge8bXVHma+NmRj9I4R7B6O37SXXNRUJSrx6far8V J3iKvOr0JDGtw4+zNsl+woGVmsfATRLXdVAioE1RNiGoBmbqNuPY339z1rHz3P8NVQ== X-Received: by 2002:a5d:64e9:0:b0:38a:88bc:bae4 with SMTP id ffacd0b85a97d-38bf5784ab8mr43777014f8f.18.1738074159686; Tue, 28 Jan 2025 06:22:39 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a176434sm14462219f8f.13.2025.01.28.06.22.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Jan 2025 06:22:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Yanan Wang , Eduardo Habkost , Harsh Prateek Bora , kvm@vger.kernel.org, Zhao Liu , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Igor Mammedov , Marcel Apfelbaum , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson Subject: [PATCH 9/9] accel/kvm: Remove unreachable assertion in kvm_dirty_ring_reap*() Date: Tue, 28 Jan 2025 15:21:52 +0100 Message-ID: <20250128142152.9889-10-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250128142152.9889-1-philmd@linaro.org> References: <20250128142152.9889-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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 Previous commit passed all our CI tests, this assertion being never triggered. Remove it as dead code. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/kvm/kvm-all.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index cb56d120a91..814b1a53eb8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -830,13 +830,6 @@ static uint32_t kvm_dirty_ring_reap_one(KVMState *s, CPUState *cpu) uint32_t ring_size = s->kvm_dirty_ring_size; uint32_t count = 0, fetch = cpu->kvm_fetch_index; - /* - * It's not possible that we race with vcpu creation code where the vcpu is - * put onto the vcpus list but not yet initialized the dirty ring - * structures. - */ - assert(cpu->created); - assert(dirty_gfns && ring_size); trace_kvm_dirty_ring_reap_vcpu(cpu->cpu_index);