Index: kvm/drivers/kvm/kvm.h =================================================================== --- kvm.orig/drivers/kvm/kvm.h 2007-08-17 15:26:16.000000000 +0200 +++ kvm/drivers/kvm/kvm.h 2007-08-17 15:29:46.000000000 +0200 @@ -589,6 +589,19 @@ int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run); +#ifndef PF_VCPU +#define PF_VCPU 0 /* no kernel support */ +#endif + +static inline void kvm_guest_enter(void) +{ + current->flags |= PF_VCPU; +} + +static inline void kvm_guest_exit(void) +{ +} + static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code) { Index: kvm/drivers/kvm/svm.c =================================================================== --- kvm.orig/drivers/kvm/svm.c 2007-08-17 15:26:16.000000000 +0200 +++ kvm/drivers/kvm/svm.c 2007-08-17 15:27:03.000000000 +0200 @@ -1404,6 +1404,7 @@ clgi(); vcpu->guest_mode = 1; + kvm_guest_enter(); if (vcpu->requests) if (test_and_clear_bit(KVM_TLB_FLUSH, &vcpu->requests)) svm_flush_tlb(vcpu); @@ -1536,6 +1537,7 @@ #endif : "cc", "memory" ); + kvm_guest_exit(); vcpu->guest_mode = 0; if (vcpu->fpu_active) { Index: kvm/drivers/kvm/vmx.c =================================================================== --- kvm.orig/drivers/kvm/vmx.c 2007-08-17 15:26:16.000000000 +0200 +++ kvm/drivers/kvm/vmx.c 2007-08-17 15:27:45.000000000 +0200 @@ -2078,6 +2078,7 @@ local_irq_disable(); vcpu->guest_mode = 1; + kvm_guest_enter(); if (vcpu->requests) if (test_and_clear_bit(KVM_TLB_FLUSH, &vcpu->requests)) vmx_flush_tlb(vcpu); @@ -2198,6 +2199,7 @@ [cr2]"i"(offsetof(struct kvm_vcpu, cr2)) : "cc", "memory" ); + kvm_guest_exit(); vcpu->guest_mode = 0; local_irq_enable();