[PATCH] kvm-kmod: Various compat fixes for older kernels

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

 



Various fixes that were required to build against a 2.6.18 kernel, but
some affect newer kernels, too:

 - replacements for uaccess.h and relay.h
 - flush_work compat wrapper
 - fix msi_enabled hack
 - hack eventfd.c for INIT_WORK
 - move phys_addr_t and true/false definitions as headers require it
   earlier
 - add MSR_K7_HWCR definition

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---

 external-module-compat-comm.h |   17 +++++++++++++++++
 sync                          |    6 +++---
 x86/external-module-compat.h  |   27 ++++++++++++++++-----------
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/external-module-compat-comm.h b/external-module-compat-comm.h
index 581d867..dc02349 100644
--- a/external-module-compat-comm.h
+++ b/external-module-compat-comm.h
@@ -299,7 +299,11 @@ static inline void pagefault_enable(void)
 
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#include <asm/uaccess.h>
+#else
 #include <linux/uaccess.h>
+#endif
 
 /* vm ops ->fault() was introduced in 2.6.23. */
 #include <linux/mm.h>
@@ -555,6 +559,15 @@ static inline int cancel_work_sync(struct work_struct *work)
 
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+
+static inline void flush_work(struct work_struct *work)
+{
+	cancel_work_sync(work);
+}
+
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
 
 struct pci_dev;
@@ -565,7 +578,11 @@ struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)
+#include <linux/relayfs_fs.h>
+#else
 #include <linux/relay.h>
+#endif
 
 /* relay_open() interface has changed on 2.6.21 */
 
diff --git a/sync b/sync
index f3f4d6a..18f0200 100755
--- a/sync
+++ b/sync
@@ -67,8 +67,8 @@ def __hack(data):
         if match(r'^}'): kvm_arch_init = False
         if match(r'MODULE_AUTHOR'):
             w('MODULE_INFO(version, "%s");' % (version,))
-        line = sub(r'match->dev->msi_enabled',
-                      'kvm_pcidev_msi_enabled(match->dev)', line)
+        line = sub(r'(\w+)->dev->msi_enabled',
+                   r'kvm_pcidev_msi_enabled(\1->dev)', line)
         if match(r'atomic_inc\(&kvm->mm->mm_count\);'):
             line = 'mmget(&kvm->mm->mm_count);'
         if match(r'^\t\.fault = '):
@@ -124,7 +124,7 @@ def hack(T, arch, file):
 
 hack_files = {
     'x86': str.split('kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c'
-                     ' i8254.c kvm_trace.c timer.c'),
+                     ' i8254.c kvm_trace.c timer.c eventfd.c'),
     'ia64': str.split('kvm_main.c kvm_fw.c kvm_lib.c kvm-ia64.c'),
 }
 
diff --git a/x86/external-module-compat.h b/x86/external-module-compat.h
index d74aaaa..6c23a03 100644
--- a/x86/external-module-compat.h
+++ b/x86/external-module-compat.h
@@ -5,6 +5,18 @@
 
 #include <linux/compiler.h>
 #include <linux/version.h>
+#include <linux/types.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+
+typedef u64 phys_addr_t;
+
+#endif
+
+#undef true
+#define true 1
+#undef false
+#define false 0
 
 #include "../external-module-compat-comm.h"
 
@@ -352,11 +364,6 @@ static inline void preempt_notifier_sys_exit(void) {}
 #define X86_FEATURE_NX (1*32+20)
 #endif
 
-#undef true
-#define true 1
-#undef false
-#define false 0
-
 /* EFER_LMA and EFER_LME are missing in pre 2.6.24 i386 kernels */
 #ifndef EFER_LME
 #define _EFER_LME           8  /* Long mode enable */
@@ -486,6 +493,10 @@ struct kvm_desc_ptr {
 #define FEATURE_CONTROL_VMXON_ENABLED	(1<<2)
 #endif
 
+#ifndef MSR_K7_HWCR
+#define MSR_K7_HWCR                     0xc0010015
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(__x86_64__)
 
 #undef set_debugreg
@@ -522,12 +533,6 @@ struct mtrr_state_type {
 
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
-
-typedef u64 phys_addr_t;
-
-#endif
-
 #ifndef CONFIG_HAVE_KVM_IRQCHIP
 #define CONFIG_HAVE_KVM_IRQCHIP 1
 #endif

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux