From: "Jan Beulich" Subject: [PATCH 3/3] x86/HVM: vMSI simplification Date: Thu, 08 Jan 2015 15:52:14 +0000 Message-ID: <54AEB5BE0200007800052BF9@mail.emea.novell.com> References: <54AEB49C0200007800052BDE@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part8BBE7CBE.0__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y9FNi-0002bw-5b for xen-devel@lists.xenproject.org; Thu, 08 Jan 2015 15:52:18 +0000 In-Reply-To: <54AEB49C0200007800052BDE@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: 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. --=__Part8BBE7CBE.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - struct msixtbl_entry's table_len field can be unsigned int, and by moving it down a little the structure size can be reduced slightly - a disjoint xmalloc()/memset() pair can be converted to xzalloc() - a pointless local variable can be dropped Signed-off-by: Jan Beulich --- unstable.orig/xen/arch/x86/hvm/vmsi.c 2014-11-17 11:40:49.0000000= 00 +0100 +++ unstable/xen/arch/x86/hvm/vmsi.c 2014-11-17 11:43:18.000000000 = +0100 @@ -153,9 +153,9 @@ 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_len; unsigned long table_flags[BITS_TO_LONGS(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]; @@ -380,16 +380,11 @@ static void add_msixtbl_entry(struct dom uint64_t gtable, struct msixtbl_entry *entry) { - u32 len; - - memset(entry, 0, sizeof(struct msixtbl_entry)); - =20 INIT_LIST_HEAD(&entry->list); INIT_RCU_HEAD(&entry->rcu); atomic_set(&entry->refcnt, 0); =20 - len =3D pci_msix_get_table_len(pdev); - entry->table_len =3D len; + entry->table_len =3D pci_msix_get_table_len(pdev); entry->pdev =3D pdev; entry->gtable =3D (unsigned long) gtable; =20 @@ -426,7 +421,7 @@ int msixtbl_pt_register(struct domain *d * xmalloc() with irq_disabled causes the failure of check_lock()=20 * for xenpool->lock. So we allocate an entry beforehand. */ - new_entry =3D xmalloc(struct msixtbl_entry); + new_entry =3D xzalloc(struct msixtbl_entry); if ( !new_entry ) return -ENOMEM; =20 --=__Part8BBE7CBE.0__= Content-Type: text/plain; name="x86-vMSI-table-len.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-vMSI-table-len.patch" x86/HVM: vMSI simplification=0A=0A- struct msixtbl_entry's table_len field = can be unsigned int, and by=0A moving it down a little the structure size = can be reduced slightly=0A- a disjoint xmalloc()/memset() pair can be = converted to xzalloc()=0A- a pointless local variable can be dropped=0A=0AS= igned-off-by: Jan Beulich =0A=0A--- unstable.orig/xen/ar= ch/x86/hvm/vmsi.c 2014-11-17 11:40:49.000000000 +0100=0A+++ = unstable/xen/arch/x86/hvm/vmsi.c 2014-11-17 11:43:18.000000000 = +0100=0A@@ -153,9 +153,9 @@ struct msixtbl_entry=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_len;=0A unsigned long table_flags[BITS_TO_LONGS(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@@ -380,16 +380,11 @@ static void add_msixtbl_entry(struct dom=0A = uint64_t gtable,=0A = struct msixtbl_entry *entry)=0A {=0A- u32 len;=0A-=0A- memset(entry, = 0, sizeof(struct msixtbl_entry));=0A- =0A INIT_LIST_HEAD(&entry-= >list);=0A INIT_RCU_HEAD(&entry->rcu);=0A atomic_set(&entry->refcnt= , 0);=0A =0A- len =3D pci_msix_get_table_len(pdev);=0A- entry->table_= len =3D len;=0A+ entry->table_len =3D pci_msix_get_table_len(pdev);=0A = entry->pdev =3D pdev;=0A entry->gtable =3D (unsigned long) = gtable;=0A =0A@@ -426,7 +421,7 @@ int msixtbl_pt_register(struct domain = *d=0A * xmalloc() with irq_disabled causes the failure of check_lock()= =0A * for xenpool->lock. So we allocate an entry beforehand.=0A = */=0A- new_entry =3D xmalloc(struct msixtbl_entry);=0A+ new_entry = =3D xzalloc(struct msixtbl_entry);=0A if ( !new_entry )=0A = return -ENOMEM;=0A =0A --=__Part8BBE7CBE.0__= 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 --=__Part8BBE7CBE.0__=--