Skip to contentSkip to conversation

xen: Remove dependency between pciback and privcmd

PATCH Superseded Jiqian Chen 3 participants 13 messages Oct 11, 2024 – Oct 12, 2024 Xen hypervisor interface

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xen: Remove dependency between pciback and privcmd

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

---
v2->v3 changes:
Added rwlock get_gsi_from_sbdf_lock to avoid races.
Called xen_acpi_register_get_gsi_func to register function in xen_pcibk_init and set NULL to hook in xen_pcibk_cleanup when unloading.

v1->v2 changes:
Added hook xen_acpi_get_gsi_from_sbdf.
Changed pcistub_get_gsi_from_sbdf to static and pciback register it as the real hook function.

---
 drivers/xen/Kconfig                |  1 -
 drivers/xen/acpi.c                 | 24 ++++++++++++++++++++++++
 drivers/xen/privcmd.c              |  6 ++----
 drivers/xen/xen-pciback/pci_stub.c | 11 +++++++++--
 include/xen/acpi.h                 | 12 ++++--------
 5 files changed, 39 insertions(+), 15 deletions(-)
drivers/xen/Kconfig +0 -1
index 72ddee4c1544..f7d6f47971fd 100644
@@ -261,7 +261,6 @@ config XEN_SCSI_BACKEND
 config XEN_PRIVCMD
 	tristate "Xen hypercall passthrough driver"
 	depends on XEN
-	imply XEN_PCIDEV_BACKEND
 	default m
 	help
 	  The hypercall passthrough driver allows privileged user programs to
drivers/xen/acpi.c +24 -0
index 9e2096524fbc..d2ee605c5ca1 100644
@@ -125,3 +125,27 @@ int xen_acpi_get_gsi_info(struct pci_dev *dev,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(xen_acpi_get_gsi_info);
+
+static get_gsi_from_sbdf_t get_gsi_from_sbdf;
+static DEFINE_RWLOCK(get_gsi_from_sbdf_lock);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func)
+{
+	write_lock(&get_gsi_from_sbdf_lock);
+	get_gsi_from_sbdf = func;
+	write_unlock(&get_gsi_from_sbdf_lock);
+}
+EXPORT_SYMBOL_GPL(xen_acpi_register_get_gsi_func);
+
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf)
+{
+	int ret = -EOPNOTSUPP;
+
+	read_lock(&get_gsi_from_sbdf_lock);
+	if (get_gsi_from_sbdf)
+		ret = get_gsi_from_sbdf(sbdf);
+	read_unlock(&get_gsi_from_sbdf_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(xen_acpi_get_gsi_from_sbdf);
drivers/xen/privcmd.c +2 -4
index 3273cb8c2a66..4f75bc876454 100644
@@ -850,15 +850,13 @@ static long privcmd_ioctl_mmap_resource(struct file *file,
 static long privcmd_ioctl_pcidev_get_gsi(struct file *file, void __user *udata)
 {
 #if defined(CONFIG_XEN_ACPI)
-	int rc = -EINVAL;
+	int rc;
 	struct privcmd_pcidev_get_gsi kdata;
 
 	if (copy_from_user(&kdata, udata, sizeof(kdata)))
 		return -EFAULT;
 
-	if (IS_REACHABLE(CONFIG_XEN_PCIDEV_BACKEND))
-		rc = pcistub_get_gsi_from_sbdf(kdata.sbdf);
-
+	rc = xen_acpi_get_gsi_from_sbdf(kdata.sbdf);
 	if (rc < 0)
 		return rc;
 
drivers/xen/xen-pciback/pci_stub.c +9 -2
index 2f3da5ac62cd..b616b7768c3b 100644
@@ -227,7 +227,7 @@ static struct pci_dev *pcistub_device_get_pci_dev(struct xen_pcibk_device *pdev,
 }
 
 #ifdef CONFIG_XEN_ACPI
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
+static int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
 {
 	struct pcistub_device *psdev;
 	int domain = (sbdf >> 16) & 0xffff;
@@ -242,7 +242,6 @@ int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
 
 	return psdev->gsi;
 }
-EXPORT_SYMBOL_GPL(pcistub_get_gsi_from_sbdf);
 #endif
 
 struct pci_dev *pcistub_get_pci_dev_by_slot(struct xen_pcibk_device *pdev,
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
 		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);
+#endif
+
 	return err;
 }
 
 static void __exit xen_pcibk_cleanup(void)
 {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif
+
 #ifdef CONFIG_PCI_IOV
 	bus_unregister_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
include/xen/acpi.h +4 -8
index daa96a22d257..8cb081c633cc 100644
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
 }
 #endif
 
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);
 
 #endif	/* _XEN_ACPI_H */
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Jiqian Chen
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
 		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);

drivers/xen/xen-pciback/pci_stub.c static int __init xen_pcibk_init(void) · line 1770

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+#endif
+
 	return err;
 }
 
 static void __exit xen_pcibk_cleanup(void)
 {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif

Just wondering - instead of these two #ifdef-s, ...

Quoted 8 lines
include/xen/acpi.h +0 -2
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
 }
 #endif
 
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);

include/xen/acpi.h static inline int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 97

Quoted 10 lines
include/xen/acpi.h +4 -6
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);

... wouldn't a static inline stub (for the !XEN_ACPI case) aid overall readability?

Jan

#2 lore raw
Quoted 26 lines · Jan Beulich
Quoted 6 lines · Jiqian Chen
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
 		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);

drivers/xen/xen-pciback/pci_stub.c static int __init xen_pcibk_init(void) · line 1770

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+#endif
+
 	return err;
 }
 
 static void __exit xen_pcibk_cleanup(void)
 {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif

Just wondering - instead of these two #ifdef-s, ...

Quoted 6 lines
include/xen/acpi.h +0 -0
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
 }
 #endif
 
Quoted 14 lines

include/xen/acpi.h static inline int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 97

Quoted 12 lines
include/xen/acpi.h +4 -8
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);

... wouldn't a static inline stub (for the !XEN_ACPI case) aid overall readability?

I'm not sure if other files do this. But for me, it feels a little strange to use "#ifdef CONFIG_XEN_ACPI #else" in apci.h, like self-containment. And "#include apci.h" in pic_stub.c is also wraped with CONFIG_XEN_ACPI.

Quoted 2 lines

Jan

Signature · 2 lines
Best regards,
Jiqian Chen.
#3 lore raw
Quoted 41 lines · Jiqian
Quoted 26 lines · Jan Beulich
Quoted 6 lines · Jiqian Chen
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
 		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);

drivers/xen/xen-pciback/pci_stub.c static int __init xen_pcibk_init(void) · line 1770

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+#endif
+
 	return err;
 }
 
 static void __exit xen_pcibk_cleanup(void)
 {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif

Just wondering - instead of these two #ifdef-s, ...

Quoted 6 lines
include/xen/acpi.h +0 -0
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
 }
 #endif
 
Quoted 14 lines

include/xen/acpi.h static inline int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 97

Quoted 12 lines
include/xen/acpi.h +4 -8
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);

... wouldn't a static inline stub (for the !XEN_ACPI case) aid overall readability?

Quoted 2 lines

I'm not sure if other files do this. But for me, it feels a little strange to use "#ifdef CONFIG_XEN_ACPI #else" in apci.h, like self-containment. And "#include apci.h" in pic_stub.c is also wraped with CONFIG_XEN_ACPI.

OK, I saw other files also do this.
If you insist, I will make modifications in the next version. Thank you!

Quoted 4 lines
Quoted 3 lines

Jan

Signature · 2 lines
Best regards,
Jiqian Chen.
#4 lore raw
Quoted 42 lines · Jiqian
Quoted 41 lines · Jiqian
Quoted 40 lines · Jan Beulich
Quoted 6 lines · Jiqian Chen
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
 		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
 #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);

drivers/xen/xen-pciback/pci_stub.c static int __init xen_pcibk_init(void) · line 1770

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+#endif
+
 	return err;
 }
 
 static void __exit xen_pcibk_cleanup(void)
 {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif

Just wondering - instead of these two #ifdef-s, ...

Quoted 8 lines
include/xen/acpi.h +0 -2
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
 }
 #endif
 
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);

include/xen/acpi.h static inline int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 97

Quoted 10 lines
include/xen/acpi.h +4 -6
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);

... wouldn't a static inline stub (for the !XEN_ACPI case) aid overall readability?

Quoted 4 lines
Quoted 2 lines

I'm not sure if other files do this. But for me, it feels a little strange to use "#ifdef CONFIG_XEN_ACPI #else" in apci.h, like self-containment. And "#include apci.h" in pic_stub.c is also wraped with CONFIG_XEN_ACPI.

OK, I saw other files also do this.
If you insist, I will make modifications in the next version.

Well, I'm not a maintainer of this code, so I can't very well insist.

Jan

maintainer
#5 lore raw
Quoted 43 lines · Jan Beulich
Quoted 42 lines · Jiqian
Quoted 41 lines · Jiqian
Quoted 40 lines · Jan Beulich
Quoted 6 lines · Jiqian Chen
drivers/xen/xen-pciback/pci_stub.c +2 -0
@@ -1757,11 +1756,19 @@ static int __init xen_pcibk_init(void)
  		bus_register_notifier(&pci_bus_type, &pci_stub_nb);
  #endif
 
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf);

drivers/xen/xen-pciback/pci_stub.c static int __init xen_pcibk_init(void) · line 1770

Quoted 10 lines
drivers/xen/xen-pciback/pci_stub.c +5 -0
+#endif
+
  	return err;
  }
 
  static void __exit xen_pcibk_cleanup(void)
  {
+#ifdef CONFIG_XEN_ACPI
+	xen_acpi_register_get_gsi_func(NULL);
+#endif

Just wondering - instead of these two #ifdef-s, ...

Quoted 8 lines
include/xen/acpi.h +0 -2
@@ -91,13 +91,9 @@ static inline int xen_acpi_get_gsi_info(struct pci_dev *dev,
  }
  #endif
 
-#ifdef CONFIG_XEN_PCI_STUB
-int pcistub_get_gsi_from_sbdf(unsigned int sbdf);

include/xen/acpi.h static inline int xen_acpi_get_gsi_info(struct pci_dev *dev, · line 97

Quoted 10 lines
include/xen/acpi.h +4 -6
-#else
-static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
-{
-	return -1;
-}
-#endif
+typedef int (*get_gsi_from_sbdf_t)(u32 sbdf);
+
+void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func);
+int xen_acpi_get_gsi_from_sbdf(u32 sbdf);

... wouldn't a static inline stub (for the !XEN_ACPI case) aid overall readability?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I'm not sure if other files do this. But for me, it feels a little strange to use "#ifdef CONFIG_XEN_ACPI #else" in apci.h, like self-containment. And "#include apci.h" in pic_stub.c is also wraped with CONFIG_XEN_ACPI.

OK, I saw other files also do this.
If you insist, I will make modifications in the next version.

Well, I'm not a maintainer of this code, so I can't very well insist.

In this case I'm in favor of having the #ifdefs at the calling site.

The amount of code isn't larger this way, while it is more clear when reading the code that the calls are only done in the CONFIG_XEN_ACPI case.

Juergen

maintainer Reviewed-by on v3 1/1
#6 lore raw
In reply to Jiqian Chen
Quoted 5 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

Quoted 8 lines

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

Juergen

maintainer
#7 lore raw
In reply to Jiqian Chen
Quoted 5 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

Quoted 8 lines

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Reason is that drivers/xen/acpi.c is being built for Dom0 only, so having CONFIG_XEN_ACPI defined is not enough for ensuring the new functions are present.

I suggest to add a new CONFIG item CONFIG_XEN_DOM0_ACPI like

config XEN_DOM0_ACPI

	def_bool y
	depends on XEN_ACPI && XEN_DOM0

and then replace all CONFIG_XEN_ACPI instances in your patch with CONFIG_XEN_DOM0_ACPI. This includes the use case in privcmd_ioctl_pcidev_get_gsi().

Juergen

#8 lore raw
Quoted 23 lines · Juergen Gross
Quoted 5 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

Quoted 8 lines

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Reason is that drivers/xen/acpi.c is being built for Dom0 only, so having CONFIG_XEN_ACPI defined is not enough for ensuring the new functions are present.

I suggest to add a new CONFIG item CONFIG_XEN_DOM0_ACPI like

Quoted 7 lines

config XEN_DOM0_ACPI
    def_bool y
    depends on XEN_ACPI && XEN_DOM0

and then replace all CONFIG_XEN_ACPI instances in your patch with CONFIG_XEN_DOM0_ACPI. This includes the use case in privcmd_ioctl_pcidev_get_gsi().

How about add stubs for xen_acpi_register_get_gsi_func and xen_acpi_get_gsi_from_sbdf when "!CONFIG_XEN_DOM0" in acpi.h, like the other functions in that file do.

Quoted 3 lines

Juergen

Signature · 2 lines
Best regards,
Jiqian Chen.
#9 lore raw
Quoted 12 lines · Jiqian
Quoted 11 lines · Juergen Gross
Quoted 10 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Could you please attach the link or steps?
Then I can reproduce it, and validate it locally with new changes.

Quoted 21 lines
Quoted 7 lines

Reason is that drivers/xen/acpi.c is being built for Dom0 only, so having CONFIG_XEN_ACPI defined is not enough for ensuring the new functions are present.

I suggest to add a new CONFIG item CONFIG_XEN_DOM0_ACPI like

Quoted 7 lines

config XEN_DOM0_ACPI
    def_bool y
    depends on XEN_ACPI && XEN_DOM0

and then replace all CONFIG_XEN_ACPI instances in your patch with CONFIG_XEN_DOM0_ACPI. This includes the use case in privcmd_ioctl_pcidev_get_gsi().

How about add stubs for xen_acpi_register_get_gsi_func and xen_acpi_get_gsi_from_sbdf when "!CONFIG_XEN_DOM0" in acpi.h, like the other functions in that file do.

Quoted 3 lines

Juergen

Signature · 2 lines
Best regards,
Jiqian Chen.
maintainer
#10 lore raw
Quoted 13 lines · Jiqian
Quoted 12 lines · Jiqian
Quoted 11 lines · Juergen Gross
Quoted 10 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Could you please attach the link or steps?
Then I can reproduce it, and validate it locally with new changes.

I'm using the attached kernel config.

Juergen

#11 lore raw
Quoted 18 lines · Jürgen Groß
Quoted 17 lines · Jiqian
Quoted 16 lines · Jiqian
Quoted 15 lines · Juergen Gross
Quoted 13 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Could you please attach the link or steps?
Then I can reproduce it, and validate it locally with new changes.

I'm using the attached kernel config.

Thanks, I can reproduce the 32-bit build error locally.
And this "Add stubs for xen_acpi_register_get_gsi_func and xen_acpi_get_gsi_from_sbdf when "!CONFIG_XEN_DOM0" in acpi.h, like the other functions in that file do." can fix it. Is it okay?

Quoted 4 lines

Juergen

Signature · 2 lines
Best regards,
Jiqian Chen.
maintainer
#12 lore raw
Quoted 19 lines · Jiqian
Quoted 18 lines · Jürgen Groß
Quoted 17 lines · Jiqian
Quoted 16 lines · Jiqian
Quoted 15 lines · Juergen Gross
Quoted 13 lines · Jiqian Chen

Commit 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev") adds a weak reverse dependency to the config XEN_PRIVCMD definition, that dependency causes xen-privcmd can't be loaded on domU, because dependent xen-pciback isn't always be loaded successfully on domU.

To solve above problem, remove that dependency, and do not call pcistub_get_gsi_from_sbdf() directly, instead add a hook in drivers/xen/apci.c, xen-pciback register the real call function, then in privcmd_ioctl_pcidev_get_gsi call that hook.

Fixes 2fae6bb7be32 ("xen/privcmd: Add new syscall to get gsi from dev")
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

Unfortunately I'm seeing a build breakage for the 32-bit x86 build.

Could you please attach the link or steps?
Then I can reproduce it, and validate it locally with new changes.

I'm using the attached kernel config.

Thanks, I can reproduce the 32-bit build error locally.
And this "Add stubs for xen_acpi_register_get_gsi_func and xen_acpi_get_gsi_from_sbdf when "!CONFIG_XEN_DOM0" in acpi.h, like the other functions in that file do." can fix it. Is it okay?

Fine with me.

Juergen