Skip to content

Commit f7b1f0c

Browse files
committed
KVM: SEV: Fold sev_es_vcpu_reset() into sev_vcpu_create()
Fold the remaining line of sev_es_vcpu_reset() into sev_vcpu_create() as there's no need for a dedicated RESET hook just to init a mutex, and the mutex should be initialized as early as possible anyways. No functional change intended. Reviewed-by: Nikunj A Dadhania <nikunj@amd.com> Link: https://lore.kernel.org/r/20250819234833.3080255-8-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent baf6ed1 commit f7b1f0c

3 files changed

Lines changed: 2 additions & 9 deletions

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,6 +4577,8 @@ int sev_vcpu_create(struct kvm_vcpu *vcpu)
45774577
struct vcpu_svm *svm = to_svm(vcpu);
45784578
struct page *vmsa_page;
45794579

4580+
mutex_init(&svm->sev_es.snp_vmsa_mutex);
4581+
45804582
if (!sev_es_guest(vcpu->kvm))
45814583
return 0;
45824584

@@ -4592,11 +4594,6 @@ int sev_vcpu_create(struct kvm_vcpu *vcpu)
45924594
return 0;
45934595
}
45944596

4595-
void sev_es_vcpu_reset(struct vcpu_svm *svm)
4596-
{
4597-
mutex_init(&svm->sev_es.snp_vmsa_mutex);
4598-
}
4599-
46004597
void sev_es_prepare_switch_to_guest(struct vcpu_svm *svm, struct sev_es_save_area *hostsa)
46014598
{
46024599
struct kvm *kvm = svm->vcpu.kvm;

arch/x86/kvm/svm/svm.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,6 @@ static void __svm_vcpu_reset(struct kvm_vcpu *vcpu)
12441244

12451245
svm->nmi_masked = false;
12461246
svm->awaiting_iret_completion = false;
1247-
1248-
if (sev_es_guest(vcpu->kvm))
1249-
sev_es_vcpu_reset(svm);
12501247
}
12511248

12521249
static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)

arch/x86/kvm/svm/svm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ int pre_sev_run(struct vcpu_svm *svm, int cpu);
829829
void sev_init_vmcb(struct vcpu_svm *svm, bool init_event);
830830
void sev_vcpu_after_set_cpuid(struct vcpu_svm *svm);
831831
int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
832-
void sev_es_vcpu_reset(struct vcpu_svm *svm);
833832
void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu);
834833
void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
835834
void sev_es_prepare_switch_to_guest(struct vcpu_svm *svm, struct sev_es_save_area *hostsa);

0 commit comments

Comments
 (0)