From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Stefan Teodorescu <fane@google.com>
Subject: [PATCH 1/2] KVM: x86: Convert WARN_ON(preemptible()) to lockdep assertion
Date: Thu, 22 Oct 2026 14:55:40 -0700 [thread overview]
Message-ID: <20261022215541.631694-2-seanjc@google.com> (raw)
In-Reply-To: <20261022215541.631694-1-seanjc@google.com>
Use lockdep_assert_preemption_disabled() in the local APIC code instead of
open-coding a rough equivalent that would likely do more harm than good if
it were to ever fire (the non-ONCE WARN_ON() would likely spam the kernel
log and hang the host).
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/lapic.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index ecf611845fb1..61bf09badb5a 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -2270,7 +2270,8 @@ bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu)
static void cancel_hv_timer(struct kvm_lapic *apic)
{
- WARN_ON(preemptible());
+ lockdep_assert_preemption_disabled();
+
WARN_ON(!apic->lapic_timer.hv_timer_in_use);
kvm_x86_call(cancel_hv_timer)(apic->vcpu);
apic->lapic_timer.hv_timer_in_use = false;
@@ -2282,7 +2283,8 @@ static bool start_hv_timer(struct kvm_lapic *apic)
struct kvm_vcpu *vcpu = apic->vcpu;
bool expired;
- WARN_ON(preemptible());
+ lockdep_assert_preemption_disabled();
+
if (!kvm_can_use_hv_timer(vcpu))
return false;
@@ -2322,7 +2324,8 @@ static void start_sw_timer(struct kvm_lapic *apic)
{
struct kvm_timer *ktimer = &apic->lapic_timer;
- WARN_ON(preemptible());
+ lockdep_assert_preemption_disabled();
+
if (apic->lapic_timer.hv_timer_in_use)
cancel_hv_timer(apic);
if (!apic_lvtt_period(apic) && atomic_read(&ktimer->pending))
--
2.56.0.257.gf7497c7d27-goog
next prev parent reply other threads:[~2026-10-22 21:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 21:55 [PATCH 0/2] KVM: x86: Convert all runtime WARNs to ONCE Sean Christopherson
2026-10-22 21:55 ` Sean Christopherson [this message]
2026-10-22 21:55 ` [PATCH 2/2] KVM: x86: Convert all runtime WARNs to ONCE variants Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022215541.631694-2-seanjc@google.com \
--to=seanjc@google.com \
--cc=fane@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®