From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 2/2] x86/vMSI-X: add valid bits for read acceleration Date: Fri, 20 Mar 2015 16:27:57 +0000 Message-ID: <550C589D020000780006C2B2@mail.emea.novell.com> References: <550C5065020000780006C27E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE6D2B29D.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 1YYzmB-0004jV-Ua for xen-devel@lists.xenproject.org; Fri, 20 Mar 2015 16:28:00 +0000 In-Reply-To: <550C5065020000780006C27E@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. --=__PartE6D2B29D.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Again because Xen doesn't get to see all guest writes, it shouldn't serve reads from its cache before having seen a write to the respective address. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/vmsi.c +++ b/xen/arch/x86/hvm/vmsi.c @@ -153,12 +153,15 @@ struct msixtbl_entry /* TODO: resolve the potential race by destruction of pdev */ struct pci_dev *pdev; unsigned long gtable; /* gpa of msix table */ - unsigned long table_flags[BITS_TO_LONGS(MAX_MSIX_TABLE_ENTRIES)]; + DECLARE_BITMAP(table_flags, MAX_MSIX_TABLE_ENTRIES); #define MAX_MSIX_ACC_ENTRIES 3 unsigned int table_len; struct {=20 uint32_t msi_ad[3]; /* Shadow of address low, high and data */ } gentries[MAX_MSIX_ACC_ENTRIES]; + DECLARE_BITMAP(acc_valid, 3 * MAX_MSIX_ACC_ENTRIES); +#define acc_bit(what, ent, slot, idx) \ + what##_bit((slot) * 3 + (idx), (ent)->acc_valid) struct rcu_head rcu; }; =20 @@ -233,9 +236,10 @@ static int msixtbl_read( if ( offset !=3D PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET ) { nr_entry =3D (address - entry->gtable) / PCI_MSIX_ENTRY_SIZE; - if ( nr_entry >=3D MAX_MSIX_ACC_ENTRIES ) - goto out; index =3D offset / sizeof(uint32_t); + if ( nr_entry >=3D MAX_MSIX_ACC_ENTRIES || + !acc_bit(test, entry, nr_entry, index) ) + goto out; *pval =3D entry->gentries[nr_entry].msi_ad[index]; } else=20 @@ -281,6 +285,7 @@ static int msixtbl_write(struct vcpu *v, { index =3D offset / sizeof(uint32_t); entry->gentries[nr_entry].msi_ad[index] =3D val; + acc_bit(set, entry, nr_entry, index); } set_bit(nr_entry, &entry->table_flags); goto out; --=__PartE6D2B29D.1__= Content-Type: text/plain; name="x86-vMSI-X-read-valid.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-vMSI-X-read-valid.patch" x86/vMSI-X: add valid bits for read acceleration=0A=0AAgain because Xen = doesn't get to see all guest writes, it shouldn't=0Aserve reads from its = cache before having seen a write to the respective=0Aaddress.=0A=0ASigned-o= ff-by: Jan Beulich =0A=0A--- a/xen/arch/x86/hvm/vmsi.c= =0A+++ b/xen/arch/x86/hvm/vmsi.c=0A@@ -153,12 +153,15 @@ struct msixtbl_ent= ry=0A /* TODO: resolve the potential race by destruction of pdev */=0A = struct pci_dev *pdev;=0A unsigned long gtable; /* gpa of = msix table */=0A- unsigned long table_flags[BITS_TO_LONGS(MAX_MSIX_TABLE= _ENTRIES)];=0A+ DECLARE_BITMAP(table_flags, MAX_MSIX_TABLE_ENTRIES);=0A = #define MAX_MSIX_ACC_ENTRIES 3=0A unsigned int table_len;=0A = struct { =0A uint32_t msi_ad[3]; /* Shadow of address low, = high and data */=0A } gentries[MAX_MSIX_ACC_ENTRIES];=0A+ DECLARE_BI= TMAP(acc_valid, 3 * MAX_MSIX_ACC_ENTRIES);=0A+#define acc_bit(what, ent, = slot, idx) \=0A+ what##_bit((slot) * 3 + (idx), (ent)->acc_valid)=0A= struct rcu_head rcu;=0A };=0A =0A@@ -233,9 +236,10 @@ static int = msixtbl_read(=0A if ( offset !=3D PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET = )=0A {=0A nr_entry =3D (address - entry->gtable) / PCI_MSIX_ENT= RY_SIZE;=0A- if ( nr_entry >=3D MAX_MSIX_ACC_ENTRIES )=0A- = goto out;=0A index =3D offset / sizeof(uint32_t);=0A+ if = ( nr_entry >=3D MAX_MSIX_ACC_ENTRIES ||=0A+ !acc_bit(test, = entry, nr_entry, index) )=0A+ goto out;=0A *pval =3D = entry->gentries[nr_entry].msi_ad[index];=0A }=0A else =0A@@ -281,6 = +285,7 @@ static int msixtbl_write(struct vcpu *v,=0A {=0A = index =3D offset / sizeof(uint32_t);=0A entry->gentries[nr_= entry].msi_ad[index] =3D val;=0A+ acc_bit(set, entry, nr_entry, = index);=0A }=0A set_bit(nr_entry, &entry->table_flags);=0A = goto out;=0A --=__PartE6D2B29D.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 --=__PartE6D2B29D.1__=--