From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Thomas Lendacky <thomas.lendacky@amd.com>,
Michael Roth <michael.roth@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>,
Borislav Petkov <bp@alien8.de>,
Vaishali Thakkar <vaishali.thakkar@suse.com>,
Ketan Chaturvedi <Ketan.Chaturvedi@amd.com>,
Kai Huang <kai.huang@intel.com>
Subject: [PATCH v11 7/8] KVM: SEV: Fold sev_es_vcpu_reset() into sev_vcpu_create()
Date: Tue, 19 Aug 2025 16:48:32 -0700 [thread overview]
Message-ID: <20250819234833.3080255-8-seanjc@google.com> (raw)
In-Reply-To: <20250819234833.3080255-1-seanjc@google.com>
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.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/sev.c | 7 ++-----
arch/x86/kvm/svm/svm.c | 3 ---
arch/x86/kvm/svm/svm.h | 1 -
3 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index ee7a05843548..7d1d34e45310 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4577,6 +4577,8 @@ int sev_vcpu_create(struct kvm_vcpu *vcpu)
struct vcpu_svm *svm = to_svm(vcpu);
struct page *vmsa_page;
+ mutex_init(&svm->sev_es.snp_vmsa_mutex);
+
if (!sev_es_guest(vcpu->kvm))
return 0;
@@ -4592,11 +4594,6 @@ int sev_vcpu_create(struct kvm_vcpu *vcpu)
return 0;
}
-void sev_es_vcpu_reset(struct vcpu_svm *svm)
-{
- mutex_init(&svm->sev_es.snp_vmsa_mutex);
-}
-
void sev_es_prepare_switch_to_guest(struct vcpu_svm *svm, struct sev_es_save_area *hostsa)
{
struct kvm *kvm = svm->vcpu.kvm;
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 8ed135dbd649..b237b4081c91 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1244,9 +1244,6 @@ static void __svm_vcpu_reset(struct kvm_vcpu *vcpu)
svm->nmi_masked = false;
svm->awaiting_iret_completion = false;
-
- if (sev_es_guest(vcpu->kvm))
- sev_es_vcpu_reset(svm);
}
static void svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 321480ebe62f..3c7f208b7935 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -829,7 +829,6 @@ int pre_sev_run(struct vcpu_svm *svm, int cpu);
void sev_init_vmcb(struct vcpu_svm *svm, bool init_event);
void sev_vcpu_after_set_cpuid(struct vcpu_svm *svm);
int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in);
-void sev_es_vcpu_reset(struct vcpu_svm *svm);
void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu);
void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
void sev_es_prepare_switch_to_guest(struct vcpu_svm *svm, struct sev_es_save_area *hostsa);
--
2.51.0.rc1.167.g924127e9c0-goog
next prev parent reply other threads:[~2025-08-19 23:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 23:48 [PATCH v11 0/8] KVM: SVM: Enable Secure TSC for SEV-SNP Sean Christopherson
2025-08-19 23:48 ` [PATCH v11 1/8] KVM: SEV: Drop GHCB_VERSION_DEFAULT and open code it Sean Christopherson
2025-08-19 23:48 ` [PATCH v11 2/8] KVM: SEV: Enforce minimum GHCB version requirement for SEV-SNP guests Sean Christopherson
2025-08-19 23:48 ` [PATCH v11 3/8] x86/cpufeatures: Add SNP Secure TSC Sean Christopherson
2025-08-19 23:48 ` [PATCH v11 4/8] KVM: SVM: Move SEV-ES VMSA allocation to a dedicated sev_vcpu_create() helper Sean Christopherson
2025-08-20 9:00 ` Nikunj A. Dadhania
2025-08-19 23:48 ` [PATCH v11 5/8] KVM: SEV: Move init of SNP guest state into sev_init_vmcb() Sean Christopherson
2025-08-20 9:21 ` Nikunj A. Dadhania
2025-08-19 23:48 ` [PATCH v11 6/8] KVM: SEV: Set RESET GHCB MSR value during sev_es_init_vmcb() Sean Christopherson
2025-08-20 9:32 ` Nikunj A. Dadhania
2025-08-19 23:48 ` Sean Christopherson [this message]
2025-08-20 9:33 ` [PATCH v11 7/8] KVM: SEV: Fold sev_es_vcpu_reset() into sev_vcpu_create() Nikunj A. Dadhania
2025-08-19 23:48 ` [PATCH v11 8/8] KVM: SVM: Enable Secure TSC for SNP guests Sean Christopherson
2025-08-20 4:53 ` Nikunj A. Dadhania
2025-08-20 13:01 ` Sean Christopherson
2025-08-20 13:11 ` Nikunj A. Dadhania
2025-08-20 8:48 ` [PATCH v11 0/8] KVM: SVM: Enable Secure TSC for SEV-SNP Nikunj A. Dadhania
2025-08-20 11:25 ` Huang, Kai
2025-08-20 11:30 ` Nikunj A. Dadhania
2025-08-20 15:10 ` Sean Christopherson
2025-08-21 21:35 ` Sean Christopherson
2025-08-25 5:37 ` Nikunj A. Dadhania
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250819234833.3080255-8-seanjc@google.com \
--to=seanjc@google.com \
--cc=Ketan.Chaturvedi@amd.com \
--cc=bp@alien8.de \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=thomas.lendacky@amd.com \
--cc=vaishali.thakkar@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®