From: "Jan Beulich" Subject: [PATCH] x86/MSI-X: correctly track interrupt masking state Date: Fri, 22 Apr 2016 01:20:11 -0600 Message-ID: <5719ECCB02000078000E486F@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part4D7B0EBB.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atVNv-0000ax-Do for xen-devel@lists.xenproject.org; Fri, 22 Apr 2016 07:20:15 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part4D7B0EBB.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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. Signed-off-by: Jan Beulich --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -434,8 +434,13 @@ static bool_t msi_set_mask_bit(struct ir { writel(flag, entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFF= SET); readl(entry->mask_base + PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET); + if ( likely(control & PCI_MSIX_FLAGS_ENABLE) ) break; + + entry->msi_attrib.host_masked =3D host; + entry->msi_attrib.guest_masked =3D guest; + flag =3D 1; } else if ( flag && !(control & PCI_MSIX_FLAGS_MASKALL) ) --=__Part4D7B0EBB.1__= Content-Type: text/plain; name="x86-MSI-X-track-masking-state.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-MSI-X-track-masking-state.patch" x86/MSI-X: correctly track interrupt masking state=0A=0AWhen a guest = unmasks MSI-X interrupts before enabling MSI-X on the=0Adevice, so far = nothing updates the {host,guest}_masked internal state;=0Athis to date = only gets done when MSI-X is already enabled. This is why=0Ahalf way = recent Linux works (as it enables MSI-X first), while Windows=0Adoesn't = (as it enables MSI-X only after having set up und unmasked all=0Avectors). = Since with a successful write to the vector control field=0Aeverything is = ready internally, we should also update internal tracking=0Astate there, = regardless of the device's MSI-X enabled state.=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/arch/x86/msi.c=0A+++ b/xen/arch/= x86/msi.c=0A@@ -434,8 +434,13 @@ static bool_t msi_set_mask_bit(struct = ir=0A {=0A writel(flag, entry->mask_base + PCI_MSIX_ENT= RY_VECTOR_CTRL_OFFSET);=0A readl(entry->mask_base + PCI_MSIX_EN= TRY_VECTOR_CTRL_OFFSET);=0A+=0A if ( likely(control & = PCI_MSIX_FLAGS_ENABLE) )=0A break;=0A+=0A+ = entry->msi_attrib.host_masked =3D host;=0A+ entry->msi_attrib.gu= est_masked =3D guest;=0A+=0A flag =3D 1;=0A }=0A = else if ( flag && !(control & PCI_MSIX_FLAGS_MASKALL) )=0A --=__Part4D7B0EBB.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part4D7B0EBB.1__=--