Skip to contentSkip to conversation

x86/MSI-X: correctly track interrupt masking state

PATCH In review Jan Beulich 3 participants 4 messages Apr 22, 2016 – Apr 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/MSI-X: correctly track interrupt masking state

When a guest unmasks MSI-X interrupts before enabling MSI-X on the device, so far nothing updates the {host,guest}_masked internal state; this to date only gets done when MSI-X is already enabled. This is why half way recent Linux works (as it enables MSI-X first), while Windows doesn't (as it enables MSI-X only after having set up und unmasked all vectors). Since with a successful write to the vector control field everything is ready internally, we should also update internal tracking state there, regardless of the device's MSI-X enabled state.

xen/arch/x86/msi.c +5 -0
@@ -434,8 +434,13 @@ static bool_t msi_set_mask_bit(struct ir
         {
             writel(flag, entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
             readl(entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
+
             if ( likely(control & PCI_MSIX_FLAGS_ENABLE) )
                 break;
+
+            entry->msi_attrib.host_masked = host;
+            entry->msi_attrib.guest_masked = guest;
+
             flag = 1;
         }
         else if ( flag && !(control & PCI_MSIX_FLAGS_MASKALL) )

x86/MSI-X: correctly track interrupt masking state

When a guest unmasks MSI-X interrupts before enabling MSI-X on the device, so far nothing updates the {host,guest}_masked internal state; this to date only gets done when MSI-X is already enabled. This is why half way recent Linux works (as it enables MSI-X first), while Windows doesn't (as it enables MSI-X only after having set up und unmasked all vectors). Since with a successful write to the vector control field everything is ready internally, we should also update internal tracking state there, regardless of the device's MSI-X enabled state.

xen/arch/x86/msi.c +5 -0
@@ -434,8 +434,13 @@ static bool_t msi_set_mask_bit(struct ir
         {
             writel(flag, entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
             readl(entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
+
             if ( likely(control & PCI_MSIX_FLAGS_ENABLE) )
                 break;
+
+            entry->msi_attrib.host_masked = host;
+            entry->msi_attrib.guest_masked = guest;
+
             flag = 1;
         }
         else if ( flag && !(control & PCI_MSIX_FLAGS_MASKALL) )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jan Beulich

When a guest unmasks MSI-X interrupts before enabling MSI-X on the device, so far nothing updates the {host,guest}_masked internal state; this to date only gets done when MSI-X is already enabled. This is why half way recent Linux works (as it enables MSI-X first), while Windows doesn't (as it enables MSI-X only after having set up und unmasked all vectors). Since with a successful write to the vector control field everything is ready internally, we should also update internal tracking state there, regardless of the device's MSI-X enabled state.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 22.04.16 at 18:35, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

When a guest unmasks MSI-X interrupts before enabling MSI-X on the device, so far nothing updates the {host,guest}_masked internal state; this to date only gets done when MSI-X is already enabled. This is why half way recent Linux works (as it enables MSI-X first), while Windows doesn't (as it enables MSI-X only after having set up und unmasked all vectors). Since with a successful write to the vector control field everything is ready internally, we should also update internal tracking state there, regardless of the device's MSI-X enabled state.

Quoted 3 lines
Quoted 1 line

Wei,

just noticed I forgot to Cc you on this one, which definitely is intended for 4.7 (along with the other two MSI related ones).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 22.04.16 at 18:35, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

When a guest unmasks MSI-X interrupts before enabling MSI-X on the device, so far nothing updates the {host,guest}_masked internal state; this to date only gets done when MSI-X is already enabled. This is why half way recent Linux works (as it enables MSI-X first), while Windows doesn't (as it enables MSI-X only after having set up und unmasked all vectors). Since with a successful write to the vector control field everything is ready internally, we should also update internal tracking state there, regardless of the device's MSI-X enabled state.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel