mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Leach <matthew.leach@collabora.com>
To: "Jiaming Fan" <fan.jiaming@hotmail.com>
Cc: "Sean Christopherson" <seanjc@google.com>,
	 "Paolo Bonzini" <pbonzini@redhat.com>,  <kvm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,  <kernel@collabora.com>
Subject: Re: [PATCH] KVM: x86: Reevaluate pending interrupts when enabling ExtINT through LVT0
Date: Mon, 23 Nov 2026 11:28:17 +0000	[thread overview]
Message-ID: <87wlq3n5wu.fsf@collabora.com> (raw)
In-Reply-To: <OS3PR01MB10251C0B5CDCF9538DA3A1727E77C2@OS3PR01MB10251.jpnprd01.prod.outlook.com>

Hi Jiaming,

"Jiaming Fan" <fan.jiaming@hotmail.com> writes:

> On Wed, Nov 04, 2026, Sean Christopherson wrote:
>> Ahh, but there's nowhere for edge-triggered events to be latched, so this only
>> affects level-triggered events.  Which means, this?
>>
>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
>> index d6e5fbc3c58c..b72930a8516d 100644
>> --- a/arch/x86/kvm/lapic.c
>> +++ b/arch/x86/kvm/lapic.c
>> @@ -2554,6 +2554,8 @@ static int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
>>  			val |= APIC_LVT_MASKED;
>>  		val &= apic_lvt_mask[index];
>>  		kvm_lapic_set_reg(apic, reg, val);
>> +		if (!(val & APIC_LVT_MASKED) && (val & APIC_LVT_LEVEL_TRIGGER))
>> +			kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
>>  		break;
>>  	}
>
> The trigger mode check doesn't catch the case Matthew hit. Linux's
> setup_local_APIC() writes LVT0 as plain APIC_DM_EXTINT, without
> APIC_LVT_LEVEL_TRIGGER, so no request is made and the "noapic" hang
> remains.

That's right, this version of the patch wouldn't fix the issue.


> For ExtINT the pending interrupt is latched in the 8259A, whose output
> stays asserted until the guest acks it, not in the LVT entry, so the
> trigger mode bit doesn't tell whether anything is pending. Your first
> version (any unmasked LVT) does work for LVT0.

That matches my understanding. I think the right approach is Sean's
first suggestion (any unmasked LVT).

> There is a second path with the same problem that neither version
> covers: hardware-disabling the APIC through IA32_APIC_BASE. With the
> APIC disabled, kvm_apic_accept_pic_intr() returns true, so an ExtINT
> latched while LVT0 was masked becomes deliverable, but
> __kvm_apic_set_base() doesn't request KVM_REQ_EVENT either:
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -2825,6 +2825,7 @@ static void __kvm_apic_set_base(struct kvm_vcpu *vcpu, u64 value)
>  		} else {
>  			static_branch_inc(&apic_hw_disabled.key);
>  			atomic_set_release(&apic->vcpu->kvm->arch.apic_map_dirty, DIRTY);
> +			kvm_make_request(KVM_REQ_EVENT, vcpu);
>  		}
>  	}

Nice catch! Looks like a very similar problem.

[...]

> Matthew, are you planning a v2? If so, I'm happy to hand over the
> selftest and the APIC_BASE fix. Otherwise I can post a series with
> your patch (reworked per Sean's first suggestion) followed by the
> APIC_BASE fix and the selftest.

Looks like you've done much more digging into this than I have, so
please go ahead and fold my patch into your series.

Regards,
-- 
Matt

      reply	other threads:[~2026-11-23 11:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 12:49 Matthew Leach
2026-11-04 20:09 ` Sean Christopherson
2026-11-16 14:17   ` Jiaming Fan
2026-11-23 11:28     ` Matthew Leach [this message]

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=87wlq3n5wu.fsf@collabora.com \
    --to=matthew.leach@collabora.com \
    --cc=fan.jiaming@hotmail.com \
    --cc=kernel@collabora.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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®