Skip to contentSkip to conversation

external modules: Fix pre-2.6.18 kernels

PATCH Applied Jan Kiszka 2 participants 2 messages Feb 4, 2009 – Feb 5, 2009 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH v2 1/1 external modules: Fix pre-2.6.18 kernels

pci_dev.msi_enabled was introduced in 2.6.18, thus building against older kernels now fails. Fix via a compat wrapper that reads directly from the PCI config space.

---

 kernel/external-module-compat-comm.h |   13 +++++++++++++
 kernel/external-module-compat.c      |   21 +++++++++++++++++++++
 kernel/x86/hack-module.awk           |    2 ++
 3 files changed, 36 insertions(+), 0 deletions(-)
kernel/external-module-compat-comm.h +13 -0
index 239590e..4a9ad4c 100644
@@ -729,3 +729,16 @@ static inline void cpumask_clear_cpu(int cpu, cpumask_var_t mask)
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
 #define marker_synchronize_unregister() synchronize_sched()
 #endif
+
+/* pci_dev.msi_enable was introduced in 2.6.18 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+struct pci_dev;
+
+int kvm_pcidev_msi_enabled(struct pci_dev *dev);
+
+#else
+
+#define kvm_pcidev_msi_enabled(dev)	(dev)->msi_enabled
+
+#endif
kernel/external-module-compat.c +21 -0
index 823ce82..f425e08 100644
@@ -313,3 +313,24 @@ struct rchan *kvm_relay_open(const char *base_filename,
 }
 
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+#include <linux/pci.h>
+
+int kvm_pcidev_msi_enabled(struct pci_dev *dev)
+{
+	int pos;
+	u16 control;
+
+	if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI)))
+		return 0;
+
+	pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control);
+	if (control & PCI_MSI_FLAGS_ENABLE)
+		return 1;
+
+	return 0;
+}
+
+#endif
kernel/x86/hack-module.awk +2 -0
index deb68f4..a05c0c3 100644
@@ -29,6 +29,8 @@ BEGIN { split("INIT_WORK tsc_khz desc_struct ldttss_desc64 desc_ptr " \
     printf("MODULE_INFO(version, \"%s\");\n", version)
 }
 
+{ sub(/match->dev->msi_enabled/, "kvm_pcidev_msi_enabled(match->dev)") }
+
 /^static void __vmx_load_host_state/ {
     vmx_load_host_state = 1
 }
Applied
#1 lore raw
Quoted 4 lines · Jan Kiszka

pci_dev.msi_enabled was introduced in 2.6.18, thus building against older kernels now fails. Fix via a compat wrapper that reads directly from the PCI config space.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function