repository: /home/avi/kvm branch: master commit def51adf68b8362ed52b6e61697e812058c52e15 Author: Avi Kivity <[EMAIL PROTECTED]> Date: Wed Dec 5 14:26:38 2007 +0200
kvm: external module: compatibility for vma ops ->fault() Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> diff --git a/kernel/Kbuild b/kernel/Kbuild index 99ffd82..ed02f5a 100644 --- a/kernel/Kbuild +++ b/kernel/Kbuild @@ -4,3 +4,5 @@ kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o i8259.o \ lapic.o ioapic.o preempt.o kvm-intel-objs := vmx.o vmx-debug.o kvm-amd-objs := svm.o + +CFLAGS_kvm_main.o = -DKVM_MAIN diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h index b7f9e8d..ea94f30 100644 --- a/kernel/external-module-compat.h +++ b/kernel/external-module-compat.h @@ -571,3 +571,62 @@ static inline void blahblah(void) #define EFER_LME (1<<_EFER_LME) #define EFER_LMA (1<<_EFER_LMA) #endif + +/* vm ops ->fault() was introduced in 2.6.23. */ +#include <linux/mm.h> + +#ifdef KVM_MAIN +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) + +struct vm_fault { + unsigned int flags; + pgoff_t pgoff; + void __user *virtual_address; + struct page *page; +}; + +static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf); +static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf); + +static inline struct page *kvm_nopage_to_fault( + int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf), + struct vm_area_struct *vma, + unsigned long address, + int *type) +{ + struct vm_fault vmf; + int ret; + + vmf.pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; + vmf.virtual_address = (void __user *)address; + ret = fault(vma, &vmf); + if (ret) + return NOPAGE_SIGBUS; + *type = VM_FAULT_MINOR; + return vmf.page; +} + +static inline struct page *__kvm_vcpu_fault(struct vm_area_struct *vma, + unsigned long address, + int *type) +{ + return kvm_nopage_to_fault(kvm_vcpu_fault, vma, address, type); +} + +static inline struct page *__kvm_vm_fault(struct vm_area_struct *vma, + unsigned long address, + int *type) +{ + return kvm_nopage_to_fault(kvm_vm_fault, vma, address, type); +} + +#define VMA_OPS_FAULT(x) nopage +#define VMA_OPS_FAULT_FUNC(x) __##x + +#else + +#define VMA_OPS_FAULT(x) x +#define VMA_OPS_FAULT_FUNC(x) x + +#endif +#endif diff --git a/kernel/hack-module.awk b/kernel/hack-module.awk index bac93e1..c02fe6e 100644 --- a/kernel/hack-module.awk +++ b/kernel/hack-module.awk @@ -61,6 +61,11 @@ /atomic_inc\(&kvm->mm->mm_count\);/ { $0 = "//" $0 } +/^\t\.fault = / { + fcn = gensub(/,/, "", "g", $3) + $0 = "\t.VMA_OPS_FAULT(fault) = VMA_OPS_FAULT_FUNC(" fcn ")," +} + { print } /kvm_x86_ops->run/ { ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ kvm-commits mailing list kvm-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-commits