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