From: "Jan Beulich" Subject: [PATCH v5 2/7] x86/MSI-X: track host and guest mask-all requests separately Date: Mon, 20 Jul 2015 15:19:15 +0100 Message-ID: <55AD1F830200007800093274@mail.emea.novell.com> References: <55AD1E830200007800093243@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE0D41573.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 1ZHBua-0004GV-2B for xen-devel@lists.xenproject.org; Mon, 20 Jul 2015 14:19:20 +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. --=__PartE0D41573.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Host uses of the bits will be added subsequently, and must not be overridden by guests (including Dom0, namely when acting on behalf of a guest). Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -843,6 +843,12 @@ static int msix_capability_init(struct p =20 if ( !msix->used_entries ) { + msix->host_maskall =3D 0; + if ( !msix->guest_maskall ) + control &=3D ~PCI_MSIX_FLAGS_MASKALL; + else + control |=3D PCI_MSIX_FLAGS_MASKALL; + if ( rangeset_add_range(mmio_ro_ranges, msix->table.first, msix->table.last) ) WARN(); @@ -1111,6 +1117,34 @@ void pci_cleanup_msi(struct pci_dev *pde int pci_msi_conf_write_intercept(struct pci_dev *pdev, unsigned int reg, unsigned int size, uint32_t *data) { + u16 seg =3D pdev->seg; + u8 bus =3D pdev->bus; + u8 slot =3D PCI_SLOT(pdev->devfn); + u8 func =3D PCI_FUNC(pdev->devfn); + struct msi_desc *entry; + unsigned int pos; + + if ( pdev->msix ) + { + entry =3D find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX); + pos =3D entry ? entry->msi_attrib.pos + : pci_find_cap_offset(seg, bus, slot, func, + PCI_CAP_ID_MSIX); + ASSERT(pos); + + if ( reg < pos || reg >=3D msix_pba_offset_reg(pos) + 4 ) + return 0; + + if ( reg !=3D msix_control_reg(pos) || size !=3D 2 ) + return -EACCES; + + pdev->msix->guest_maskall =3D !!(*data & PCI_MSIX_FLAGS_MASKALL); + if ( pdev->msix->host_maskall ) + *data |=3D PCI_MSIX_FLAGS_MASKALL; + + return 1; + } + return 0; } =20 --- a/xen/include/asm-x86/msi.h +++ b/xen/include/asm-x86/msi.h @@ -233,6 +233,7 @@ struct arch_msix { int table_refcnt[MAX_MSIX_TABLE_PAGES]; int table_idx[MAX_MSIX_TABLE_PAGES]; spinlock_t table_lock; + bool_t host_maskall, guest_maskall; domid_t warned; }; =20 --=__PartE0D41573.1__= Content-Type: text/plain; name="x86-MSI-X-maskall.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-MSI-X-maskall.patch" x86/MSI-X: track host and guest mask-all requests separately=0A=0AHost = uses of the bits will be added subsequently, and must not be=0Aoverridden = by guests (including Dom0, namely when acting on behalf of=0Aa guest).=0A= =0ASigned-off-by: Jan Beulich =0AReviewed-by: Andrew = Cooper =0A=0A--- a/xen/arch/x86/msi.c=0A+++ = b/xen/arch/x86/msi.c=0A@@ -843,6 +843,12 @@ static int msix_capability_init= (struct p=0A =0A if ( !msix->used_entries )=0A {=0A+ = msix->host_maskall =3D 0;=0A+ if ( !msix->guest_maskall )=0A+ = control &=3D ~PCI_MSIX_FLAGS_MASKALL;=0A+ else=0A+ = control |=3D PCI_MSIX_FLAGS_MASKALL;=0A+=0A if ( rangeset_add_range= (mmio_ro_ranges, msix->table.first,=0A = msix->table.last) )=0A WARN();=0A@@ -1111,6 +1117,34 @@ void = pci_cleanup_msi(struct pci_dev *pde=0A int pci_msi_conf_write_intercept(str= uct pci_dev *pdev, unsigned int reg,=0A = unsigned int size, uint32_t *data)=0A {=0A+ u16 seg =3D pdev->seg;=0A+ = u8 bus =3D pdev->bus;=0A+ u8 slot =3D PCI_SLOT(pdev->devfn);=0A+ = u8 func =3D PCI_FUNC(pdev->devfn);=0A+ struct msi_desc *entry;=0A+ = unsigned int pos;=0A+=0A+ if ( pdev->msix )=0A+ {=0A+ entry = =3D find_msi_entry(pdev, -1, PCI_CAP_ID_MSIX);=0A+ pos =3D entry ? = entry->msi_attrib.pos=0A+ : pci_find_cap_offset(seg, = bus, slot, func,=0A+ PCI_CAP_ID_MS= IX);=0A+ ASSERT(pos);=0A+=0A+ if ( reg < pos || reg >=3D = msix_pba_offset_reg(pos) + 4 )=0A+ return 0;=0A+=0A+ if = ( reg !=3D msix_control_reg(pos) || size !=3D 2 )=0A+ return = -EACCES;=0A+=0A+ pdev->msix->guest_maskall =3D !!(*data & PCI_MSIX_F= LAGS_MASKALL);=0A+ if ( pdev->msix->host_maskall )=0A+ = *data |=3D PCI_MSIX_FLAGS_MASKALL;=0A+=0A+ return 1;=0A+ = }=0A+=0A return 0;=0A }=0A =0A--- a/xen/include/asm-x86/msi.h=0A+++ = b/xen/include/asm-x86/msi.h=0A@@ -233,6 +233,7 @@ struct arch_msix {=0A = int table_refcnt[MAX_MSIX_TABLE_PAGES];=0A int table_idx[MAX_MSIX_TABL= E_PAGES];=0A spinlock_t table_lock;=0A+ bool_t host_maskall, = guest_maskall;=0A domid_t warned;=0A };=0A =0A --=__PartE0D41573.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 --=__PartE0D41573.1__=--