From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH] kvm-kmod: Various compat fixes for older kernels Date: Mon, 25 May 2009 09:06:31 +0200 Message-ID: <4A1A4377.7090903@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigBEC7863116ECBA13D2BEB5D9" Cc: kvm-devel To: Avi Kivity Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:35310 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbZEYHGb (ORCPT ); Mon, 25 May 2009 03:06:31 -0400 Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBEC7863116ECBA13D2BEB5D9 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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 --- 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) =20 #endif =20 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) +#include +#else #include +#endif =20 /* vm ops ->fault() was introduced in 2.6.23. */ #include @@ -555,6 +559,15 @@ static inline int cancel_work_sync(struct work_struc= t *work) =20 #endif =20 +#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) =20 struct pci_dev; @@ -565,7 +578,11 @@ struct pci_dev *pci_get_bus_and_slot(unsigned int bu= s, unsigned int devfn); =20 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) =20 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) +#include +#else #include +#endif =20 /* relay_open() interface has changed on 2.6.21 */ =20 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 =3D False if match(r'MODULE_AUTHOR'): w('MODULE_INFO(version, "%s");' % (version,)) - line =3D sub(r'match->dev->msi_enabled', - 'kvm_pcidev_msi_enabled(match->dev)', line) + line =3D sub(r'(\w+)->dev->msi_enabled', + r'kvm_pcidev_msi_enabled(\1->dev)', line) if match(r'atomic_inc\(&kvm->mm->mm_count\);'): line =3D 'mmget(&kvm->mm->mm_count);' if match(r'^\t\.fault =3D '): @@ -124,7 +124,7 @@ def hack(T, arch, file): =20 hack_files =3D { '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'), } =20 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 @@ =20 #include #include +#include + +#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 =20 #include "../external-module-compat-comm.h" =20 @@ -352,11 +364,6 @@ static inline void preempt_notifier_sys_exit(void) {= } #define X86_FEATURE_NX (1*32+20) #endif =20 -#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 =20 +#ifndef MSR_K7_HWCR +#define MSR_K7_HWCR 0xc0010015 +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) && defined(__x86_64__) =20 #undef set_debugreg @@ -522,12 +533,6 @@ struct mtrr_state_type { =20 #endif =20 -#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 --------------enigBEC7863116ECBA13D2BEB5D9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkoaQ3cACgkQniDOoMHTA+mxoACeJX0nymogeduzzHMLvESLU9cG qn0AnievkVINTLQd8E7EJT6x7XZYR7On =ss7k -----END PGP SIGNATURE----- --------------enigBEC7863116ECBA13D2BEB5D9--