From: "Jan Beulich" Subject: [PATCH v5 6/7] x86/MSI: properly track guest masking requests Date: Mon, 20 Jul 2015 15:22:52 +0100 Message-ID: <55AD205C02000078000932BD@mail.emea.novell.com> References: <55AD1E830200007800093243@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB88C4D2C.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZHBy7-0004vb-3a for xen-devel@lists.xenproject.org; Mon, 20 Jul 2015 14:22:59 +0000 In-Reply-To: <55AD1E830200007800093243@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 , Roger Pau Monne 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. --=__PartB88C4D2C.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 @@ -1303,6 +1303,37 @@ int pci_msi_conf_write_intercept(struct=20 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; + + 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); + } + + *data |=3D unused; + + return 1; + } + return 0; } =20 --=__PartB88C4D2C.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@@ = -1303,6 +1303,37 @@ int pci_msi_conf_write_intercept(struct =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+=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(se= g, 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_at= trib.guest_masked =3D=0A+ *data >> entry->msi_attrib.entry_n= r;=0A+ if ( entry->msi_attrib.host_masked )=0A+ = *data |=3D 1 << pos;=0A+ unused &=3D ~(1 << pos);=0A+ = }=0A+=0A+ *data |=3D unused;=0A+=0A+ return 1;=0A+ = }=0A+=0A return 0;=0A }=0A =0A --=__PartB88C4D2C.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 --=__PartB88C4D2C.1__=--