Skip to contentSkip to conversation

x86/HVM: don't mark external IRQs as pending when vLAPIC is disabled

PATCH In review Jan Beulich 2 participants 2 messages Nov 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/HVM: don't mark external IRQs as pending when vLAPIC is disabled

In software-disabled state an LAPIC does not accept any interrupt requests and hence no IRR bit would newly become set while in this state. As a result it is also wrong for us to mark IO-APIC or MSI originating vectors as having a pending request when the vLAPIC is in this state. Such interrupts are simply lost.

Introduce (IO-APIC) or re-use (MSI) a local variable to help readability.

Fixes 4fe21ad3712e ("This patch add virtual IOAPIC support for VMX guest")
Fixes 85715f4bc7c9 ("MSI 5/6: add MSI support to passthrough HVM domain")
xen/arch/x86/hvm/vioapic.c +7 -2
@@ -460,9 +460,14 @@ static void vioapic_deliver(struct hvm_v
 
     case dest_Fixed:
         for_each_vcpu ( d, v )
-            if ( vlapic_match_dest(vcpu_vlapic(v), NULL, 0, dest, dest_mode) )
-                ioapic_inj_irq(vioapic, vcpu_vlapic(v), vector, trig_mode,
+        {
+            struct vlapic *vlapic = vcpu_vlapic(v);
+
+            if ( vlapic_enabled(vlapic) &&
+                 vlapic_match_dest(vlapic, NULL, 0, dest, dest_mode) )
+                ioapic_inj_irq(vioapic, vlapic, vector, trig_mode,
                                delivery_mode);
+        }
         break;
 
     case dest_NMI:
xen/arch/x86/hvm/vmsi.c +6 -4
@@ -87,10 +87,12 @@ int vmsi_deliver(
 
     case dest_Fixed:
         for_each_vcpu ( d, v )
-            if ( vlapic_match_dest(vcpu_vlapic(v), NULL,
-                                   0, dest, dest_mode) )
-                vmsi_inj_irq(vcpu_vlapic(v), vector,
-                             trig_mode, delivery_mode);
+        {
+            target = vcpu_vlapic(v);
+            if ( vlapic_enabled(target) &&
+                 vlapic_match_dest(target, NULL, 0, dest, dest_mode) )
+                vmsi_inj_irq(target, vector, trig_mode, delivery_mode);
+        }
         break;
 
     default:
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jan Beulich

In software-disabled state an LAPIC does not accept any interrupt requests and hence no IRR bit would newly become set while in this state. As a result it is also wrong for us to mark IO-APIC or MSI originating vectors as having a pending request when the vLAPIC is in this state. Such interrupts are simply lost.

Quoted 6 lines

Introduce (IO-APIC) or re-use (MSI) a local variable to help readability.

Fixes 4fe21ad3712e ("This patch add virtual IOAPIC support for VMX guest")
Fixes 85715f4bc7c9 ("MSI 5/6: add MSI support to passthrough HVM domain")