KVM/x86: Replace smp_mb() with smp_store_mb/release() in the walk_shadow_page_lockles...
authorLan Tianyu <tianyu.lan@intel.com>
Sun, 13 Mar 2016 03:10:25 +0000 (11:10 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 22 Mar 2016 15:38:29 +0000 (16:38 +0100)
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c

index fc8ab1f67d008f8b363ee703c3a25aefa821f2ad..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();
 }