Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4989253rwb; Tue, 8 Aug 2023 18:14:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtwt7KaLaDEnd9yUP4Jpv+T0f/lAhJRsMmllHFfKmoujwb4CLb1LRkF/w31MmsDFWYaBGK X-Received: by 2002:a17:902:d48e:b0:1b8:a67f:1c15 with SMTP id c14-20020a170902d48e00b001b8a67f1c15mr14628271plg.25.1691543656138; Tue, 08 Aug 2023 18:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691543656; cv=none; d=google.com; s=arc-20160816; b=TktoLEv+heImGbqVQpxC0AIJnZq5dz3A74MUscAXNShlfJj0diHYew7AROcS/T8k91 +fYTpkGfwQccSl12vkTvrwV4Z58YFJA37MIYdlNm+sHId0ccmTG/aTNpr0/SpWzLytd9 oSlnBpug0ABgwrdIaxwsPz4x2Doh8RdZApCei3pTUbwt4HqE0JRbtw7fxO2MmIsxdYjM BlMj/2IYbfqboKjwvqrVh41Zx+8C7Lb/NEks9BywW/HY7OMw7glQBmMj1kRQMlnleMzU XZ8+DUrFhAMkJieg+aU5rywfE9YZMTxJISbJfHIltk/z1JZml4iAOFD/MuayDOxF4xvK y4Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :reply-to:dkim-signature; bh=h31RifgLdWj/uBkkEanO2XNAftVRa4x/sEAr5Du6O7s=; fh=sfjHnwRlidOi3F5iHQTu+NUMHKPrc0GlPFO2M8U3Zas=; b=mBJ0xnpVt/JrqJajAxhcF4bP72ngTnH0f/navABj9xLttD3t8V+8oWakAzCjnpZ8y+ f/8ilLHgC/oIPyIHDtjxhxe7kguvb2lbTugqJWUkM6pNvOypZJkhg2aj5MgPeLcsWMLj 6pXEeUlE1nicF4AOOCOus5Ivwr1qhVK2/+xcV6gDQPc6+y/AuJ5erJT7nTrBIvX0axVn yxa4lurDNiNkmbT2cMfJdsPLZyHwhL8+HDOZwaLd9qdnp8CmC4n0XhHOsk6ud2w1thwa NELT0bPdcsepgQq1ocDGLuwnhu5J9nCCkTgbf9ak76Gdjwqdky0anMImiUeoRjy7T521 mvDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3HkpHRvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a1709027fc700b001aafb271d13si8257554plb.235.2023.08.08.18.14.02; Tue, 08 Aug 2023 18:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=3HkpHRvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjHHXVB (ORCPT + 99 others); Tue, 8 Aug 2023 19:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbjHHXVB (ORCPT ); Tue, 8 Aug 2023 19:21:01 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FB7619BC for ; Tue, 8 Aug 2023 16:21:00 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-585fb08172bso74060457b3.2 for ; Tue, 08 Aug 2023 16:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691536859; x=1692141659; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=h31RifgLdWj/uBkkEanO2XNAftVRa4x/sEAr5Du6O7s=; b=3HkpHRvUGz0wWRT9OA2Ov4hn6J6IuWP0KypK80EvpNWkaxvw5xrqpgKSc6cN/pQUeS BTy0QrS4OgiVI2hc16+7oGnfLI3JzDXO3tZCfX3Ga31R7/IEG9HQVP49xveMYR2Sy096 t+cBlH5TzUA4S+paOIda4LbGc2Mp/7c3DM7mNrOQuHOZ1W0Zhu/4Z4QjMaZuOF6vlKYt rJ3Wfol3W8ZzlZQEZ4/84C3qOsIssVV4BC+kcMmhQ28SBdY+slKFRYau7RtFnSaRpGUR y3JbWRiPUgHG0pZlHoQ8PusqX5v0e3hDdT90UCtfbztjJo/RI5+6Waht9EJSCMWPjTTM mEHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691536859; x=1692141659; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h31RifgLdWj/uBkkEanO2XNAftVRa4x/sEAr5Du6O7s=; b=eSP5oaBRGMYLb2zBCnRkL9GcdKnZHwG+YUD1E2Hcc56X3sfzn9hbDKY4p2OkazjxtR 8KGKrmfiTw/OUUhSNGhvgRoVpkarqfZ0c4FB2GsFyNPX8tpBLtg0Cv88CYabaXHM8khx TVCupjmha+wBqSRDhzPhO0NbvFWKn8LuhWdyIPsX6VBIg2SyeddzYDH9I9OggZD1cho0 cJRSPRjvrPnfJ3omVTWbooEpyS2FbQxvJIPzWvt/H8kU2sgmOHbZhkVOo+5c1cVYKvig a9fIBHxhnWk5Zqd9I9m8G1Rh3MoOf+srmK3Ibxg7skmCSIS2qVppQu2/0tQ95uSCcFBd /azA== X-Gm-Message-State: AOJu0Yy3Tn3O1EHTip50YWIkXyT2lojfnEUKgoXVGVCxPhOL7+J6vp8h +ajhdylj4rQtkMzy0ozZ4koWTdEowXs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b707:0:b0:586:a689:eb69 with SMTP id v7-20020a81b707000000b00586a689eb69mr25680ywh.2.1691536859434; Tue, 08 Aug 2023 16:20:59 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 8 Aug 2023 16:20:57 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog Message-ID: <20230808232057.2498287-1-seanjc@google.com> Subject: [PATCH] KVM: x86: Remove WARN sanity check on hypervisor timer vs. UNINITIALIZED vCPU From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yikebaer Aizezi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drop the WARN in KVM_RUN that asserts that KVM isn't using the hypervisor timer, a.k.a. the VMX preemption timer, for a vCPU that is in the UNINITIALIZIED activity state. The intent of the WARN is to sanity check that KVM won't drop a timer interrupt due to an unexpected transition to UNINITIALIZED, but unfortunately userspace can use various ioctl()s to force the unexpected state. Drop the sanity check instead of switching from the hypervisor timer to a software based timer, as the only reason to switch to a software timer when a vCPU is blocking is to ensure the timer interrupt wakes the vCPU, but said interrupt isn't a valid wake event for vCPUs in UNINITIALIZED state *and* the interrupt will be dropped in the end. Reported-by: Yikebaer Aizezi Closes: https://lore.kernel.org/all/CALcu4rbFrU4go8sBHk3FreP+qjgtZCGcYNpSiEXOLm==qFv7iQ@mail.gmail.com Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a6b9bea62fb8..fa7eeb45b8e3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11091,12 +11091,17 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) r = -EINTR; goto out; } + /* - * It should be impossible for the hypervisor timer to be in - * use before KVM has ever run the vCPU. + * Don't bother switching APIC timer emulation from the + * hypervisor timer to the software timer, the only way for the + * APIC timer to be active is if userspace stuffed vCPU state, + * i.e. put the vCPU into a nonsensical state. Only an INIT + * will transition the vCPU out of UNINITIALIZED (without more + * state stuffing from userspace), which will reset the local + * APIC and thus smother the timer anyways, i.e. the APIC timer + * IRQ(s) will be dropped no matter what. */ - WARN_ON_ONCE(kvm_lapic_hv_timer_in_use(vcpu)); - kvm_vcpu_srcu_read_unlock(vcpu); kvm_vcpu_block(vcpu); kvm_vcpu_srcu_read_lock(vcpu); base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c -- 2.41.0.640.ga95def55d0-goog