[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v10 09/11] vpci/msi: add MSI handlers



On Fri, Mar 16, 2018 at 09:05:44AM -0600, Jan Beulich wrote:
> >>> On 16.03.18 at 15:34, <roger.pau@xxxxxxxxxx> wrote:
> > vpci_remove_device is never called from the user-space test harness,
> > so it just needs to build, but not necessarily be correct in that
> > context.
> > 
> > The test harness doesn't use vpci_add_handlers or vpci_remove_device,
> > it just adds and removes handlers using vpci_add_register and
> > vpci_remove_register.
> 
> I dislike such a setup - then you'd better #ifdef out the entire
> function, and undo some of the other recently added #ifdef-ary.

OK, I've done it that way initially to prevent polluting vpci.c with
__XEN__ ifdefs. The patch below ifdefs those unused functions.

Roger.
---
From 2ae9cae018054162eeae29ed42f6fcfba6b1a4e0 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
Date: Fri, 16 Mar 2018 15:20:27 +0000
Subject: [PATCH] vpci: do not expose unneeded functions to the user-space test
 harness
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some functions in vpci.c (vpci_remove_device and vpci_add_handlers)
are not used by the user-space test harness, so guard them with
__XEN__ in order to avoid exposing them to the user-space test
harness.

Requested-by: Jan Beulich <JBeulich@xxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/tests/vpci/Makefile |  8 ++------
 xen/drivers/vpci/vpci.c   | 10 ++++++----
 xen/include/xen/vpci.h    |  6 +-----
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/tools/tests/vpci/Makefile b/tools/tests/vpci/Makefile
index e45fcb5cd9..5075bc2be2 100644
--- a/tools/tests/vpci/Makefile
+++ b/tools/tests/vpci/Makefile
@@ -24,12 +24,8 @@ distclean: clean
 install:
 
 vpci.c: $(XEN_ROOT)/xen/drivers/vpci/vpci.c
-       # Trick the compiler so it doesn't complain about missing symbols
-       sed -e '/#include/d' \
-           -e '1s;^;#include "emul.h"\
-                    vpci_register_init_t *const __start_vpci_array[1]\;\
-                    vpci_register_init_t *const __end_vpci_array[1]\;\
-                    ;' <$< >$@
+       # Remove includes and add the test harness header
+       sed -e '/#include/d' -e '1s/^/#include "emul.h"/' <$< >$@
 
 list.h: $(XEN_ROOT)/xen/include/xen/list.h
 vpci.h: $(XEN_ROOT)/xen/include/xen/vpci.h
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 8ec9c916ea..2913b56500 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -20,10 +20,6 @@
 #include <xen/sched.h>
 #include <xen/vpci.h>
 
-extern vpci_register_init_t *const __start_vpci_array[];
-extern vpci_register_init_t *const __end_vpci_array[];
-#define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
-
 /* Internal struct to store the emulated PCI registers. */
 struct vpci_register {
     vpci_read_t *read;
@@ -34,6 +30,11 @@ struct vpci_register {
     struct list_head node;
 };
 
+#ifdef __XEN__
+extern vpci_register_init_t *const __start_vpci_array[];
+extern vpci_register_init_t *const __end_vpci_array[];
+#define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
+
 void vpci_remove_device(struct pci_dev *pdev)
 {
     spin_lock(&pdev->vpci->lock);
@@ -80,6 +81,7 @@ int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
 
     return rc;
 }
+#endif /* __XEN__ */
 
 static int vpci_register_cmp(const struct vpci_register *r1,
                              const struct vpci_register *r2)
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index fc47163ba6..cb39e0ebea 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -90,11 +90,9 @@ struct vpci {
         bool rom_enabled      : 1;
         /* FIXME: currently there's no support for SR-IOV. */
     } header;
-#endif
 
     /* MSI data. */
     struct vpci_msi {
-#ifdef __XEN__
       /* Address. */
         uint64_t address;
         /* Mask bitfield. */
@@ -113,12 +111,10 @@ struct vpci {
         uint8_t vectors     : 5;
         /* Arch-specific data. */
         struct vpci_arch_msi arch;
-#endif
     } *msi;
 
     /* MSI-X data. */
     struct vpci_msix {
-#ifdef __XEN__
         struct pci_dev *pdev;
         /* List link. */
         struct list_head next;
@@ -141,8 +137,8 @@ struct vpci {
             bool updated : 1;
             struct vpci_arch_msix_entry arch;
         } entries[];
-#endif
     } *msix;
+#endif
 };
 
 struct vpci_vcpu {
-- 
2.16.2

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.