Skip to contentSkip to conversation

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

PATCH In review rickgcn 3 participants 4 messages Apr 18 – Apr 21

lore
Share & tools
lore

rickgcn

author
#0 lore raw

PATCH 1/1 hw: i386: vapic: restore IRQ polling for non-kernel irqchip backends

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")
---
 hw/i386/vapic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/vapic.c +1 -2
index 41e5ca26df..1acb9f91b2 100644
@@ -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;
Signature · 1 line
2.53.0
#1 lore raw
Quoted 31 lines · rickgcn

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")

---
hw/i386/vapic.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/vapic.c +0 -0
index 41e5ca26df..1acb9f91b2 100644

hw/i386/vapic.c static void vapic_write(void *opaque, hwaddr addr, uint64_t data, · line 719

Quoted 6 lines
hw/i386/vapic.c +1 -2
@@ -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,

#2 lore raw
Quoted 41 lines · Mohamed Mediouni
Quoted 32 lines · rickgcn

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")

---
hw/i386/vapic.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/vapic.c +0 -0
index 41e5ca26df..1acb9f91b2 100644

hw/i386/vapic.c static void vapic_write(void *opaque, hwaddr addr, uint64_t data, · line 719

Quoted 6 lines
hw/i386/vapic.c +1 -2
@@ -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,

Quoted 1 line

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

Quoted 13 lines

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,

Reviewed-by on v1 1/1
#3 lore raw
In reply to rickgcn
Quoted 16 lines · rickgcn

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.

Quoted 6 lines

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")
Reviewed-by Mohamed Mediouni <[email protected] <mailto:[email protected]>>

Also a good candidate for backporting for QEMU 11.0(.1)

cc qemu-stable

Quoted 22 lines

---
hw/i386/vapic.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/vapic.c +1 -2
index 41e5ca26df..1acb9f91b2 100644
@@ -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;
Signature · 1 line
2.53.0