KVM/x86: Replace smp_mb() with smp_store_mb/release() in the walk_shadow_page_lockles...
[deliverable/linux.git] / arch / x86 / kvm / mmu.c
index e46a81f4856e6f212e383f7f2c39b7a9c59712b8..6bdfbc23ecaa8fc779085076bc08f340fc704513 100644 (file)
@@ -632,12 +632,12 @@ static void walk_shadow_page_lockless_begin(struct kvm_vcpu *vcpu)
         * kvm_flush_remote_tlbs() IPI to all active vcpus.
         */
        local_irq_disable();
-       vcpu->mode = READING_SHADOW_PAGE_TABLES;
+
        /*
         * Make sure a following spte read is not reordered ahead of the write
         * to vcpu->mode.
         */
-       smp_mb();
+       smp_store_mb(vcpu->mode, READING_SHADOW_PAGE_TABLES);
 }
 
 static void walk_shadow_page_lockless_end(struct kvm_vcpu *vcpu)
@@ -647,8 +647,7 @@ static void walk_shadow_page_lockless_end(struct kvm_vcpu *vcpu)
         * reads to sptes.  If it does, kvm_commit_zap_page() can see us
         * OUTSIDE_GUEST_MODE and proceed to free the shadow page table.
         */
-       smp_mb();
-       vcpu->mode = OUTSIDE_GUEST_MODE;
+       smp_store_release(&vcpu->mode, OUTSIDE_GUEST_MODE);
        local_irq_enable();
 }
 
@@ -2390,14 +2389,13 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
                return;
 
        /*
-        * wmb: make sure everyone sees our modifications to the page tables
-        * rmb: make sure we see changes to vcpu->mode
-        */
-       smp_mb();
-
-       /*
-        * Wait for all vcpus to exit guest mode and/or lockless shadow
-        * page table walks.
+        * We need to make sure everyone sees our modifications to
+        * the page tables and see changes to vcpu->mode here. The barrier
+        * in the kvm_flush_remote_tlbs() achieves this. This pairs
+        * with vcpu_enter_guest and walk_shadow_page_lockless_begin/end.
+        *
+        * In addition, kvm_flush_remote_tlbs waits for all vcpus to exit
+        * guest mode and/or lockless shadow page table walks.
         */
        kvm_flush_remote_tlbs(kvm);
 
This page took 0.025063 seconds and 5 git commands to generate.