From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: [PATCH] kvm-kmod: Various compat fixes for older kernels
Date: Mon, 25 May 2009 09:06:31 +0200 [thread overview]
Message-ID: <4A1A4377.7090903@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 4103 bytes --]
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@siemens.com>
---
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next reply other threads:[~2009-05-25 7:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-25 7:06 Jan Kiszka [this message]
2009-05-26 7:49 ` [PATCH] kvm-kmod: Various compat fixes for older kernels Avi Kivity
2009-05-26 8:26 ` Amit Shah
2009-05-26 9:01 ` Jan Kiszka
2009-05-26 9:11 ` Avi Kivity
2009-05-26 9:22 ` Jan Kiszka
2009-05-26 9:30 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A1A4377.7090903@web.de \
--to=jan.kiszka@web.de \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.