Skip to content

Commit 14aecf2

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Assume timer IRQ was injected if APIC state is protected
If APIC state is protected, i.e. the vCPU is a TDX guest, assume a timer IRQ was injected when deciding whether or not to busy wait in the "timer advanced" path. The "real" vIRR is not readable/writable, so trying to query for a pending timer IRQ will return garbage. Note, TDX can scour the PIR if it wants to be more precise and skip the "wait" call entirely. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Message-ID: <20250222014757.897978-6-binbin.wu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 24c1291 commit 14aecf2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/x86/kvm/lapic.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,8 +1797,17 @@ static void apic_update_lvtt(struct kvm_lapic *apic)
17971797
static bool lapic_timer_int_injected(struct kvm_vcpu *vcpu)
17981798
{
17991799
struct kvm_lapic *apic = vcpu->arch.apic;
1800-
u32 reg = kvm_lapic_get_reg(apic, APIC_LVTT);
1800+
u32 reg;
18011801

1802+
/*
1803+
* Assume a timer IRQ was "injected" if the APIC is protected. KVM's
1804+
* copy of the vIRR is bogus, it's the responsibility of the caller to
1805+
* precisely check whether or not a timer IRQ is pending.
1806+
*/
1807+
if (apic->guest_apic_protected)
1808+
return true;
1809+
1810+
reg = kvm_lapic_get_reg(apic, APIC_LVTT);
18021811
if (kvm_apic_hw_enabled(apic)) {
18031812
int vec = reg & APIC_VECTOR_MASK;
18041813
void *bitmap = apic->regs + APIC_ISR;

0 commit comments

Comments
 (0)