From: "Huang, Kai" <kai.huang@intel.com>
To: "seanjc@google.com" <seanjc@google.com>,
"hao_zhang_kdev@163.com" <hao_zhang_kdev@163.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [PATCH v4 4/4] KVM: x86: ioapic: Clear irr_delivered on level-triggered RTE
Date: Tue, 11 Aug 2026 11:43:28 +0000 [thread overview]
Message-ID: <ff25747d2827c847b0b1153177de6c6c004df8fb.camel@intel.com> (raw)
In-Reply-To: <anrSjerPIvO4Ww-T@192.168.1.215>
On Tue, 2026-08-11 at 15:43 +0800, Hao Zhang wrote:
> From: Hao Zhang <zhanghao1@kylinos.cn>
>
> irr_delivered hides delivered edge interrupts from KVM_GET_IRQCHIP.
> The interrupt remains in IRR until the guest deasserts the line.
>
> The guest can reprogram an IOAPIC RTE from edge to level via MMIO.
> If an edge interrupt was delivered before the trigger mode change, a
> stale irr_delivered bit can incorrectly mask a subsequent pending level
> interrupt from KVM_GET_IRQCHIP.
>
> That can cause userspace to migrate the VM without a pending level
> interrupt that is still present in KVM's in-kernel IOAPIC.
>
[...]
> --- a/arch/x86/kvm/ioapic.c
> +++ b/arch/x86/kvm/ioapic.c
> @@ -377,8 +377,17 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
> * as edge-triggered. This behavior is used to simulate an
> * explicit EOI on IOAPICs that don't have the EOI register.
> */
> - if (e->fields.trig_mode == IOAPIC_EDGE_TRIG)
> + if (e->fields.trig_mode == IOAPIC_EDGE_TRIG) {
> e->fields.remote_irr = 0;
> + } else {
> + /*
> + * irr_delivered tracks edge-triggered interrupts that
> + * have already been delivered. Clear stale edge-triggered
> + * delivery state when the entry is configured for
> + * level-triggered interrupts.
> + */
> + ioapic->irr_delivered &= ~(1 << index);
> + }
To be honest I am not sure whether we should consider this case, but IIUC this
code change doesn't seem to have any harm, so will leave to others.
>
> mask_after = e->fields.mask;
> if (mask_before != mask_after)
> diff --git a/tools/testing/selftests/kvm/x86/ioapic_state_test.c b/tools/testing/selftests/kvm/x86/ioapic_state_test.c
> index da0276a1542f..f024f4f01571 100644
> --- a/tools/testing/selftests/kvm/x86/ioapic_state_test.c
> +++ b/tools/testing/selftests/kvm/x86/ioapic_state_test.c
Again, I think you should split selftest code change as a separate patch.
And it's better to have a cover letter for such series with multiple patches.
next prev parent reply other threads:[~2026-08-11 11:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 7:34 [PATCH v4 1/4] KVM: x86: ioapic: Update remote_irr only after successful delivery Hao Zhang
2026-08-11 7:39 ` [PATCH v4 2/4] KVM: selftests: Verify failed IOAPIC delivery preserves state Hao Zhang
2026-08-11 7:41 ` [PATCH v4 3/4] KVM: x86: ioapic: Preserve irr_delivered for duplicate edge interrupts Hao Zhang
2026-08-11 11:27 ` Huang, Kai
2026-08-11 7:43 ` [PATCH v4 4/4] KVM: x86: ioapic: Clear irr_delivered on level-triggered RTE Hao Zhang
2026-08-11 11:43 ` Huang, Kai [this message]
2026-08-11 11:11 ` [PATCH v4 1/4] KVM: x86: ioapic: Update remote_irr only after successful delivery Huang, Kai
2026-08-11 23:32 ` Huang, Kai
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=ff25747d2827c847b0b1153177de6c6c004df8fb.camel@intel.com \
--to=kai.huang@intel.com \
--cc=hao_zhang_kdev@163.com \
--cc=kvm@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