kvm-kmod: Various compat fixes for older kernels
PATCH 1/1 kvm-kmod: Various compat fixes for older kernels
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
---
external-module-compat-comm.h | 17 +++++++++++++++++ sync | 6 +++--- x86/external-module-compat.h | 27 ++++++++++++++++----------- 3 files changed, 36 insertions(+), 14 deletions(-)
external-module-compat-comm.h +17 -0
@@ -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 */
sync +3 -3
@@ -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'), }
x86/external-module-compat.h +16 -11
@@ -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
Quoted 9 lines · Jan Kiszka
Various fixes that were required to build against a 2.6.18 kernel, but some affect newer kernels, too:
- replacements for
uaccess.handrelay.h
-flush_workcompat wrapper
- fixmsi_enabledhack
- hackeventfd.cforINIT_WORK
Please split into separate patches.
Quoted 5 lines
- move
phys_addr_tand true/false definitions as headers require it earlier
- addMSR_K7_HWCRdefinition
I had these two already, but not pushed. Maybe I need to have a script push my master branch somewhere, so you don't duplicate my work needlessly.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 3 lines · Avi Kivity
I had these two already, but not pushed. Maybe I need to have a script push my master branch somewhere, so you don't duplicate my work needlessly.
A 'next' branch that's the real bleeding-edge, while the patches get tested and master gets pushed out?
Amit
Quoted 4 lines · Avi Kivity
Quoted 3 lines · Jan Kiszka
Various fixes that were required to build against a 2.6.18 kernel, but some affect newer kernels, too:
Quoted 8 lines
Quoted 5 lines
- replacements for
uaccess.handrelay.h
-flush_workcompat wrapper
- fixmsi_enabledhack
- hackeventfd.cforINIT_WORKPlease split into separate patches.
OK, will do.
Quoted 11 lines
Quoted 7 lines
- move
phys_addr_tand true/false definitions as headers require it earlier
- addMSR_K7_HWCRdefinitionI had these two already, but not pushed. Maybe I need to have a script push my master branch somewhere, so you don't duplicate my work needlessly.
That would be highly appreciated. There is another MSR-related one pending here (MSR_IA32_TSC).
Jan
Quoted 7 lines · Jan Kiszka
Quoted 4 lines
Maybe I need to have a script
push my master branch somewhere, so you don't duplicate my work needlessly.That would be highly appreciated.
I'm thinking how to do it. pushing requires an ssh key, and I don't want to leave one around without a passphrase, which would be required by a cron job.
Any ideas?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 10 lines · Avi Kivity
Quoted 6 lines · Jan Kiszka
Quoted 5 lines
Maybe I need to have a script
push my master branch somewhere, so you don't duplicate my work needlessly.
Quoted 9 lines
Quoted 2 lines
That would be highly appreciated.
I'm thinking how to do it. pushing requires an ssh key, and I don't want to leave one around without a passphrase, which would be required by a cron job.
Any ideas?
Local commit hook that triggers the push (and ask you for the phrase interactively)? But that also depends on how frequent you would like to publish the tree.
Jan
Quoted 4 lines · Jan Kiszka
Quoted 4 lines
I'm thinking how to do it. pushing requires an ssh key, and I don't want to leave one around without a passphrase, which would be required by a cron job.
Quoted 8 lines
Quoted 3 lines
Any ideas?
Local commit hook that triggers the push (and ask you for the phrase interactively)? But that also depends on how frequent you would like to publish the tree.
When I'm working interactively the ssh key is in my keyring, so it would be transparent for me. But the problem is that I sometimes work from home and push into the repository, so there'd be no commit to trigger the hook.
(hmm, when I push I also have the kernel.org ssh key in my keyring, and with ssh-agent, maybe it could work remotely)
Signature · 1 line
error compiling committee.c: too many arguments to function