Skip to contentSkip to conversation

external modules: Fix pre-2.6.18 kernels

PATCH Superseded Jan Kiszka 3 participants 3 messages Jan 27, 2009 – Jan 29, 2009 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 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 fail. Fix via a compat wrapper.

---

 kernel/external-module-compat-comm.h |    7 +++++++
 kernel/x86/hack-module.awk           |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
kernel/external-module-compat-comm.h +7 -0
index 06af36d..937ba12 100644
@@ -718,3 +718,10 @@ 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)
+#define kvm_pcidev_msi_enabled(dev)	1
+#else
+#define kvm_pcidev_msi_enabled(dev)	(dev)->msi_enabled
+#endif
kernel/x86/hack-module.awk +2 -0
index cc50856..dbca4d6 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
 }
#1 lore raw
Quoted 15 lines · Jan Kiszka

pci_dev.msi_enabled was introduced in 2.6.18, thus building against older kernels now fail. Fix via a compat wrapper.

---

 kernel/external-module-compat-comm.h |    7 +++++++
 kernel/x86/hack-module.awk           |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
kernel/external-module-compat-comm.h +0 -0
index 06af36d..937ba12 100644

kernel/external-module-compat-comm.h static inline void cpumask_clear_cpu(int cpu, cpumask_var_t mask) · line 727

Quoted 10 lines
kernel/external-module-compat-comm.h +7 -0
@@ -718,3 +718,10 @@ 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)
+#define kvm_pcidev_msi_enabled(dev)	1
+#else
+#define kvm_pcidev_msi_enabled(dev)	(dev)->msi_enabled
+#endif

I think this will break device assignment for if the device is not MSI capable (if works at all in such older kernels).

Need some other way to check if the device is MSI enabled. Perhaps PCI_MSI_FLAGS_ENABLE bit? Sheng?

#2 lore raw
Quoted 30 lines · Marcelo Tosatti
Quoted 15 lines · Jan Kiszka

pci_dev.msi_enabled was introduced in 2.6.18, thus building against older kernels now fail. Fix via a compat wrapper.

---

 kernel/external-module-compat-comm.h |    7 +++++++
 kernel/x86/hack-module.awk           |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
kernel/external-module-compat-comm.h +0 -0
index 06af36d..937ba12 100644

kernel/external-module-compat-comm.h static inline void cpumask_clear_cpu(int cpu, cpumask_var_t mask) · line 727

Quoted 10 lines
kernel/external-module-compat-comm.h +7 -0
@@ -718,3 +718,10 @@ 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)
+#define kvm_pcidev_msi_enabled(dev)	1
+#else
+#define kvm_pcidev_msi_enabled(dev)	(dev)->msi_enabled
+#endif

I think this will break device assignment for if the device is not MSI capable (if works at all in such older kernels).

Quoted 2 lines

Need some other way to check if the device is MSI enabled. Perhaps PCI_MSI_FLAGS_ENABLE bit? Sheng?

Yes. I checked 2.6.17's code, seems if we indeed need this, the only way is converting it to a function which read from PCI configuration space and check PCI_MSI_FLAGS_ENABLE bit... (Or we can simply disable it for the old ones, but I think it's not desired).

Signature · 2 lines
regards
Yang, Sheng	|Intel Opensource Technology Center