From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH v4 RFC 6/6] x86/MSI: properly track guest masking requests Date: Mon, 22 Jun 2015 15:51:53 +0100 Message-ID: <55883D290200007800087A67@mail.emea.novell.com> References: <558839ED02000078000879FE@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part8DB95D19.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z734p-0000yl-HU for xen-devel@lists.xenproject.org; Mon, 22 Jun 2015 14:51:59 +0000 In-Reply-To: <558839ED02000078000879FE@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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. --=__Part8DB95D19.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... by monitoring writes to the mask register. This allows reverting the main effect of the XSA-129 patches in qemu. Signed-off-by: Jan Beulich --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -1308,6 +1308,39 @@ printk("%04x:%02x:%02x.%u: MSI-X %03x:%u return 1; } =20 + entry =3D find_msi_entry(pdev, -1, PCI_CAP_ID_MSI); + if ( entry && entry->msi_attrib.maskbit ) + { + uint16_t cntl; + uint32_t unused; + + pos =3D entry->msi_attrib.pos; + if ( reg < pos || reg >=3D entry->msi.mpos + 8 ) + return 0; +printk("%04x:%02x:%02x.%u: MSI %03x:%u->%04x\n", seg, bus, slot, func, = reg, size, *data);//temp + + if ( reg =3D=3D msi_control_reg(pos) ) + return size =3D=3D 2 ? 1 : -EACCES; + if ( reg < entry->msi.mpos || reg >=3D entry->msi.mpos + 4 || = size !=3D 4 ) + return -EACCES; + + cntl =3D pci_conf_read16(seg, bus, slot, func, msi_control_reg(pos= )); + unused =3D ~(uint32_t)0 >> (32 - multi_msi_capable(cntl)); + for ( pos =3D 0; pos < entry->msi.nvec; ++pos, ++entry ) + { + entry->msi_attrib.guest_masked =3D + *data >> entry->msi_attrib.entry_nr; + if ( entry->msi_attrib.host_masked ) + *data |=3D 1 << pos; + unused &=3D ~(1 << pos); + } +printk("%04x:%02x:%02x.%u: MSI -> %08x (%08x)\n", seg, bus, slot, func, = *data, unused);//temp + + *data |=3D unused; + + return 1; + } + return 0; } =20 --=__Part8DB95D19.1__= Content-Type: text/plain; name="x86-MSI-mask.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-MSI-mask.patch" x86/MSI: properly track guest masking requests=0A=0A... by monitoring = writes to the mask register.=0A=0AThis allows reverting the main effect of = the XSA-129 patches in qemu.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/msi.c=0A+++ b/xen/arch/x86/msi.c=0A@@ = -1308,6 +1308,39 @@ printk("%04x:%02x:%02x.%u: MSI-X %03x:%u=0A = return 1;=0A }=0A =0A+ entry =3D find_msi_entry(pdev, -1, PCI_CAP_ID= _MSI);=0A+ if ( entry && entry->msi_attrib.maskbit )=0A+ {=0A+ = uint16_t cntl;=0A+ uint32_t unused;=0A+=0A+ pos =3D = entry->msi_attrib.pos;=0A+ if ( reg < pos || reg >=3D entry->msi.mpo= s + 8 )=0A+ return 0;=0A+printk("%04x:%02x:%02x.%u: MSI = %03x:%u->%04x\n", seg, bus, slot, func, reg, size, *data);//temp=0A+=0A+ = if ( reg =3D=3D msi_control_reg(pos) )=0A+ return size = =3D=3D 2 ? 1 : -EACCES;=0A+ if ( reg < entry->msi.mpos || reg >=3D = entry->msi.mpos + 4 || size !=3D 4 )=0A+ return -EACCES;=0A+=0A+= cntl =3D pci_conf_read16(seg, bus, slot, func, msi_control_reg(pos)= );=0A+ unused =3D ~(uint32_t)0 >> (32 - multi_msi_capable(cntl));=0A= + for ( pos =3D 0; pos < entry->msi.nvec; ++pos, ++entry )=0A+ = {=0A+ entry->msi_attrib.guest_masked =3D=0A+ = *data >> entry->msi_attrib.entry_nr;=0A+ if ( entry->msi_attrib.= host_masked )=0A+ *data |=3D 1 << pos;=0A+ = unused &=3D ~(1 << pos);=0A+ }=0A+printk("%04x:%02x:%02x.%u: MSI -> = %08x (%08x)\n", seg, bus, slot, func, *data, unused);//temp=0A+=0A+ = *data |=3D unused;=0A+=0A+ return 1;=0A+ }=0A+=0A return = 0;=0A }=0A =0A --=__Part8DB95D19.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part8DB95D19.1__=--