Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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")
Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Message-ID: <20241012084537.1543059-1-Jiqian.Chen@amd.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Jiqian Chen and committed by
Juergen Gross
0fd2a743 bf56c410

+44 -12
-1
drivers/xen/Kconfig
··· 261 261 config XEN_PRIVCMD 262 262 tristate "Xen hypercall passthrough driver" 263 263 depends on XEN 264 - imply XEN_PCIDEV_BACKEND 265 264 default m 266 265 help 267 266 The hypercall passthrough driver allows privileged user programs to
+24
drivers/xen/acpi.c
··· 125 125 return 0; 126 126 } 127 127 EXPORT_SYMBOL_GPL(xen_acpi_get_gsi_info); 128 + 129 + static get_gsi_from_sbdf_t get_gsi_from_sbdf; 130 + static DEFINE_RWLOCK(get_gsi_from_sbdf_lock); 131 + 132 + void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func) 133 + { 134 + write_lock(&get_gsi_from_sbdf_lock); 135 + get_gsi_from_sbdf = func; 136 + write_unlock(&get_gsi_from_sbdf_lock); 137 + } 138 + EXPORT_SYMBOL_GPL(xen_acpi_register_get_gsi_func); 139 + 140 + int xen_acpi_get_gsi_from_sbdf(u32 sbdf) 141 + { 142 + int ret = -EOPNOTSUPP; 143 + 144 + read_lock(&get_gsi_from_sbdf_lock); 145 + if (get_gsi_from_sbdf) 146 + ret = get_gsi_from_sbdf(sbdf); 147 + read_unlock(&get_gsi_from_sbdf_lock); 148 + 149 + return ret; 150 + } 151 + EXPORT_SYMBOL_GPL(xen_acpi_get_gsi_from_sbdf);
+2 -4
drivers/xen/privcmd.c
··· 850 850 static long privcmd_ioctl_pcidev_get_gsi(struct file *file, void __user *udata) 851 851 { 852 852 #if defined(CONFIG_XEN_ACPI) 853 - int rc = -EINVAL; 853 + int rc; 854 854 struct privcmd_pcidev_get_gsi kdata; 855 855 856 856 if (copy_from_user(&kdata, udata, sizeof(kdata))) 857 857 return -EFAULT; 858 858 859 - if (IS_REACHABLE(CONFIG_XEN_PCIDEV_BACKEND)) 860 - rc = pcistub_get_gsi_from_sbdf(kdata.sbdf); 861 - 859 + rc = xen_acpi_get_gsi_from_sbdf(kdata.sbdf); 862 860 if (rc < 0) 863 861 return rc; 864 862
+9 -2
drivers/xen/xen-pciback/pci_stub.c
··· 227 227 } 228 228 229 229 #ifdef CONFIG_XEN_ACPI 230 - int pcistub_get_gsi_from_sbdf(unsigned int sbdf) 230 + static int pcistub_get_gsi_from_sbdf(unsigned int sbdf) 231 231 { 232 232 struct pcistub_device *psdev; 233 233 int domain = (sbdf >> 16) & 0xffff; ··· 242 242 243 243 return psdev->gsi; 244 244 } 245 - EXPORT_SYMBOL_GPL(pcistub_get_gsi_from_sbdf); 246 245 #endif 247 246 248 247 struct pci_dev *pcistub_get_pci_dev_by_slot(struct xen_pcibk_device *pdev, ··· 1756 1757 bus_register_notifier(&pci_bus_type, &pci_stub_nb); 1757 1758 #endif 1758 1759 1760 + #ifdef CONFIG_XEN_ACPI 1761 + xen_acpi_register_get_gsi_func(pcistub_get_gsi_from_sbdf); 1762 + #endif 1763 + 1759 1764 return err; 1760 1765 } 1761 1766 1762 1767 static void __exit xen_pcibk_cleanup(void) 1763 1768 { 1769 + #ifdef CONFIG_XEN_ACPI 1770 + xen_acpi_register_get_gsi_func(NULL); 1771 + #endif 1772 + 1764 1773 #ifdef CONFIG_PCI_IOV 1765 1774 bus_unregister_notifier(&pci_bus_type, &pci_stub_nb); 1766 1775 #endif
+9 -5
include/xen/acpi.h
··· 35 35 36 36 #include <linux/types.h> 37 37 38 + typedef int (*get_gsi_from_sbdf_t)(u32 sbdf); 39 + 38 40 #ifdef CONFIG_XEN_DOM0 39 41 #include <asm/xen/hypervisor.h> 40 42 #include <xen/xen.h> ··· 74 72 int *gsi_out, 75 73 int *trigger_out, 76 74 int *polarity_out); 75 + void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func); 76 + int xen_acpi_get_gsi_from_sbdf(u32 sbdf); 77 77 #else 78 78 static inline void xen_acpi_sleep_register(void) 79 79 { ··· 93 89 { 94 90 return -1; 95 91 } 96 - #endif 97 92 98 - #ifdef CONFIG_XEN_PCI_STUB 99 - int pcistub_get_gsi_from_sbdf(unsigned int sbdf); 100 - #else 101 - static inline int pcistub_get_gsi_from_sbdf(unsigned int sbdf) 93 + static inline void xen_acpi_register_get_gsi_func(get_gsi_from_sbdf_t func) 94 + { 95 + } 96 + 97 + static inline int xen_acpi_get_gsi_from_sbdf(u32 sbdf) 102 98 { 103 99 return -1; 104 100 }