From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: =?utf-8?q?=5BPATCH_v4_RFC_2/6=5D_x86/MSI-X=3A_track_h?= =?utf-8?q?ost_and_guest_mask=E2=80=91all_requests_separately?= Date: Mon, 22 Jun 2015 15:47:32 +0100 Message-ID: <55883C240200007800087A24@mail.emea.novell.com> References: <558839ED02000078000879FE@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part81B55114.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 1Z730b-0000N6-1I for xen-devel@lists.xenproject.org; Mon, 22 Jun 2015 14:47:37 +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. --=__Part81B55114.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 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -846,6 +846,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(); @@ -1114,6 +1120,36 @@ 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; +printk("%04x:%02x:%02x.%u: MSI-X %03x:%u->%04x (%d,%d)\n",//temp + seg, bus, slot, func, reg, size, *data, pdev->msix->host_maskall, = pdev->msix->guest_maskall);//temp + + 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 --=__Part81B55114.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 =0A=0A--- a/xen/arch/x86/m= si.c=0A+++ b/xen/arch/x86/msi.c=0A@@ -846,6 +846,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@@ -1114,6 = +1120,36 @@ void pci_cleanup_msi(struct pci_dev *pde=0A int pci_msi_conf_wr= ite_intercept(struct 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->d= evfn);=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_off= set(seg, bus, slot, func,=0A+ = PCI_CAP_ID_MSIX);=0A+ ASSERT(pos);=0A+=0A+ if ( reg < pos || = reg >=3D msix_pba_offset_reg(pos) + 4 )=0A+ return 0;=0A+printk(= "%04x:%02x:%02x.%u: MSI-X %03x:%u->%04x (%d,%d)\n",//temp=0A+ seg, = bus, slot, func, reg, size, *data, pdev->msix->host_maskall, pdev->msix->gu= est_maskall);//temp=0A+=0A+ if ( reg !=3D msix_control_reg(pos) || = size !=3D 2 )=0A+ return -EACCES;=0A+=0A+ pdev->msix->gue= st_maskall =3D !!(*data & PCI_MSIX_FLAGS_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_TABLE_PAGES];=0A spinlock_t table_lock;= =0A+ bool_t host_maskall, guest_maskall;=0A domid_t warned;=0A = };=0A =0A --=__Part81B55114.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 --=__Part81B55114.1__=--