Commit 57e972ec authored by Jim Mattson's avatar Jim Mattson Committed by Greg Kroah-Hartman
Browse files

kvm: svm: Ensure an IBPB on all affected CPUs when freeing a vmcb

commit fd65d314 upstream.

Previously, we only called indirect_branch_prediction_barrier on the
logical CPU that freed a vmcb. This function should be called on all
logical CPUs that last loaded the vmcb in question.

Fixes: 15d45071

 ("KVM/x86: Add IBPB support")
Reported-by: default avatarNeel Natu <>
Signed-off-by: default avatarJim Mattson <>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <>
Signed-off-by: default avatarPaolo Bonzini <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent a0636152
......@@ -1733,21 +1733,31 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
return ERR_PTR(err);
static void svm_clear_current_vmcb(struct vmcb *vmcb)
int i;
cmpxchg(&per_cpu(svm_data, i)->current_vmcb, vmcb, NULL);
static void svm_free_vcpu(struct kvm_vcpu *vcpu)
struct vcpu_svm *svm = to_svm(vcpu);
* The vmcb page can be recycled, causing a false negative in
* svm_vcpu_load(). So, ensure that no logical CPU has this
* vmcb page recorded as its current vmcb.
__free_page(pfn_to_page(__sme_clr(svm->vmcb_pa) >> PAGE_SHIFT));
__free_pages(virt_to_page(svm->msrpm), MSRPM_ALLOC_ORDER);
__free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER);
kmem_cache_free(kvm_vcpu_cache, svm);
* The vmcb page can be recycled, causing a false negative in
* svm_vcpu_load(). So do a full IBPB now.
static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment