The per-vCPU ASID does not change for SEV guests, so move the per-vCPU (and per-VMCB) ASID initialization to sev_init_vmcb() to do it once, instead of setting it before every VMRUN. No functional change intended. Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/sev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 74c4555a32650..b58e3831b8f05 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3623,9 +3623,6 @@ int pre_sev_run(struct vcpu_svm *svm, int cpu) if (!cpumask_test_cpu(cpu, to_kvm_sev_info(kvm)->have_run_cpus)) cpumask_set_cpu(cpu, to_kvm_sev_info(kvm)->have_run_cpus); - /* Assign the asid allocated with this SEV guest */ - svm->asid = asid; - /* * Flush guest TLB: * @@ -4889,6 +4886,10 @@ void sev_init_vmcb(struct vcpu_svm *svm, bool init_event) svm->vmcb->control.misc_ctl |= SVM_MISC_ENABLE_SEV; clr_exception_intercept(svm, UD_VECTOR); + svm->asid = sev_get_asid(vcpu->kvm); + svm->vmcb->control.asid = svm->asid; + vmcb_mark_dirty(svm->vmcb, VMCB_ASID); + /* * Don't intercept #GP for SEV guests, e.g. for the VMware backdoor, as * KVM can't decrypt guest memory to decode the faulting instruction. -- 2.56.0.385.gd3acb90ef8-goog