[PATCH] hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends

rickgcn posted 1 patch 3 days, 6 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260418061429.16898-1-rickgcn@gmail.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
hw/i386/vapic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends
Posted by rickgcn 3 days, 6 hours ago
69dfc078 extended vAPIC handling for WHPX with user-mode irqchip, but it
also changed vapic_write() case 4 in a way that excludes TCG from
apic_poll_irq().

Before that change, IRQ polling happened whenever no in-kernel irqchip
was active. After the change, it only happened for KVM or WHPX with a
user-mode irqchip. Under TCG, both kvm_enabled() and whpx_enabled() are
false, so the poll never happens.

This regresses 32-bit Windows XP guests on a Windows host with
-machine pc-i440fx-10.0,accel=tcg, causing a STOP 0x0000000A during boot.

Fix it by making the decision depend on whether KVM or WHPX is using an
in-kernel irqchip, instead of whether either accelerator is enabled.

Fixes: 69dfc078a6f0 ("hw: i386: vapic: enable on WHPX with user-mode irqchip")

Signed-off-by: rickgcn <rickgcn@gmail.com>
---
 hw/i386/vapic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
index 41e5ca26df..1acb9f91b2 100644
--- a/hw/i386/vapic.c
+++ b/hw/i386/vapic.c
@@ -716,8 +716,7 @@ static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
         break;
     default:
     case 4:
-        if ((kvm_enabled() && !kvm_irqchip_in_kernel())
-          || (whpx_enabled() && !whpx_irqchip_in_kernel())) {
+        if (!kvm_irqchip_in_kernel() && !whpx_irqchip_in_kernel()) {
             apic_poll_irq(cpu->apic_state);
         }
         break;
-- 
2.53.0
Re: [PATCH] hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends
Posted by Mohamed Mediouni 2 days, 12 hours ago

> On 18. Apr 2026, at 08:14, rickgcn <rickgcn@gmail.com> wrote:
> 
> 69dfc078 extended vAPIC handling for WHPX with user-mode irqchip, but it
> also changed vapic_write() case 4 in a way that excludes TCG from
> apic_poll_irq().
> 
> Before that change, IRQ polling happened whenever no in-kernel irqchip
> was active. After the change, it only happened for KVM or WHPX with a
> user-mode irqchip. Under TCG, both kvm_enabled() and whpx_enabled() are
> false, so the poll never happens.
> 
> This regresses 32-bit Windows XP guests on a Windows host with
> -machine pc-i440fx-10.0,accel=tcg, causing a STOP 0x0000000A during boot.
> 
> Fix it by making the decision depend on whether KVM or WHPX is using an
> in-kernel irqchip, instead of whether either accelerator is enabled.
> 
> Fixes: 69dfc078a6f0 ("hw: i386: vapic: enable on WHPX with user-mode irqchip")
> 
> Signed-off-by: rickgcn <rickgcn@gmail.com>
> ---
> hw/i386/vapic.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
> index 41e5ca26df..1acb9f91b2 100644
> --- a/hw/i386/vapic.c
> +++ b/hw/i386/vapic.c
> @@ -716,8 +716,7 @@ static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
>         break;
>     default:
>     case 4:
> -        if ((kvm_enabled() && !kvm_irqchip_in_kernel())
> -          || (whpx_enabled() && !whpx_irqchip_in_kernel())) {
> +        if (!kvm_irqchip_in_kernel() && !whpx_irqchip_in_kernel()) {

Hi,

I think we want to keep the kvm_enabled/whpx_enabled checks.

How does this sound?

	if (!(kvm_enabled() && kvm_irqchip_in_kernel())
	 || !(whpx_enabled() && whpx_irqchip_in_kernel())) {

Or

        if ((kvm_enabled() && !kvm_irqchip_in_kernel())
          || (whpx_enabled() && !whpx_irqchip_in_kernel())
	  || tcg_enabled()) {

Thank you,
Re: [PATCH] hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends
Posted by Paolo Bonzini 2 days, 4 hours ago
On Sun, Apr 19, 2026 at 1:14 AM Mohamed Mediouni
<mohamed@unpredictable.fr> wrote:
>
>
>
> > On 18. Apr 2026, at 08:14, rickgcn <rickgcn@gmail.com> wrote:
> >
> > 69dfc078 extended vAPIC handling for WHPX with user-mode irqchip, but it
> > also changed vapic_write() case 4 in a way that excludes TCG from
> > apic_poll_irq().
> >
> > Before that change, IRQ polling happened whenever no in-kernel irqchip
> > was active. After the change, it only happened for KVM or WHPX with a
> > user-mode irqchip. Under TCG, both kvm_enabled() and whpx_enabled() are
> > false, so the poll never happens.
> >
> > This regresses 32-bit Windows XP guests on a Windows host with
> > -machine pc-i440fx-10.0,accel=tcg, causing a STOP 0x0000000A during boot.
> >
> > Fix it by making the decision depend on whether KVM or WHPX is using an
> > in-kernel irqchip, instead of whether either accelerator is enabled.
> >
> > Fixes: 69dfc078a6f0 ("hw: i386: vapic: enable on WHPX with user-mode irqchip")
> >
> > Signed-off-by: rickgcn <rickgcn@gmail.com>
> > ---
> > hw/i386/vapic.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c
> > index 41e5ca26df..1acb9f91b2 100644
> > --- a/hw/i386/vapic.c
> > +++ b/hw/i386/vapic.c
> > @@ -716,8 +716,7 @@ static void vapic_write(void *opaque, hwaddr addr, uint64_t data,
> >         break;
> >     default:
> >     case 4:
> > -        if ((kvm_enabled() && !kvm_irqchip_in_kernel())
> > -          || (whpx_enabled() && !whpx_irqchip_in_kernel())) {
> > +        if (!kvm_irqchip_in_kernel() && !whpx_irqchip_in_kernel()) {
>
> Hi,
>
> I think we want to keep the kvm_enabled/whpx_enabled checks.

No, it's not needed.  If kvm_enabled() is false either the checks are
compiled out or the variable is false.

The check is for "is it using the userspace APIC", so rickgcn's patch
is correct.

Paolo

> How does this sound?
>
>         if (!(kvm_enabled() && kvm_irqchip_in_kernel())
>          || !(whpx_enabled() && whpx_irqchip_in_kernel())) {
>
> Or
>
>         if ((kvm_enabled() && !kvm_irqchip_in_kernel())
>           || (whpx_enabled() && !whpx_irqchip_in_kernel())
>           || tcg_enabled()) {
>
> Thank you,
>