diff mbox

[5/6] kvm/x86: call kvm_lapic_sync_from_vapic with preemption disabled

Message ID 1236255153-4432-6-git-send-email-joerg.roedel@amd.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Joerg Roedel March 5, 2009, 12:12 p.m. UTC
The function uses kmap_atomic. Calling it with preemption enabled is
racy.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/x86.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Marcelo Tosatti March 5, 2009, 9:39 p.m. UTC | #1
On Thu, Mar 05, 2009 at 01:12:32PM +0100, Joerg Roedel wrote:
> The function uses kmap_atomic. Calling it with preemption enabled is
> racy.

kmap_atomic disables preemption?

void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
{                       
        enum fixed_addresses idx;
        unsigned long vaddr;    
                        
        /* even !CONFIG_PREEMPT needs this, for in_atomic in  * do_page_fault */
        pagefault_disable();


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b556b6a..ff833f4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3203,6 +3203,8 @@  static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 
 	kvm_guest_exit();
 
+	kvm_lapic_sync_from_vapic(vcpu);
+
 	preempt_enable();
 
 	down_read(&vcpu->kvm->slots_lock);
@@ -3218,7 +3220,6 @@  static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	if (vcpu->arch.exception.pending && kvm_x86_ops->exception_injected(vcpu))
 		vcpu->arch.exception.pending = false;
 
-	kvm_lapic_sync_from_vapic(vcpu);
 
 	r = kvm_x86_ops->handle_exit(kvm_run, vcpu);
 out: