Skip to content

Commit 65a4de0

Browse files
yanzhao56sean-jc
authored andcommitted
KVM: x86: Ensure a full memory barrier is emitted in the VM-Exit path
Ensure a full memory barrier is emitted in the VM-Exit path, as a full barrier is required on Intel CPUs to evict WC buffers. This will allow unconditionally honoring guest PAT on Intel CPUs that support self-snoop. As srcu_read_lock() is always called in the VM-Exit path and it internally has a smp_mb(), call smp_mb__after_srcu_read_lock() to avoid adding a second fence and make sure smp_mb() is called without dependency on implementation details of srcu_read_lock(). Cc: Paolo Bonzini <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Kevin Tian <[email protected]> Signed-off-by: Yan Zhao <[email protected]> [sean: massage changelog] Tested-by: Xiangfei Ma <[email protected]> Tested-by: Yongwei Ma <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent f05eda1 commit 65a4de0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/x86/kvm/x86.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11135,6 +11135,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1113511135

1113611136
kvm_vcpu_srcu_read_lock(vcpu);
1113711137

11138+
/*
11139+
* Call this to ensure WC buffers in guest are evicted after each VM
11140+
* Exit, so that the evicted WC writes can be snooped across all cpus
11141+
*/
11142+
smp_mb__after_srcu_read_lock();
11143+
1113811144
/*
1113911145
* Profile KVM exit RIPs:
1114011146
*/

0 commit comments

Comments
 (0)