From: "Nikunj A. Dadhania" <nikunj@amd.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>,
"Borislav Petkov" <bp@alien8.de>,
Vaishali Thakkar <vaishali.thakkar@suse.com>,
"Ketan Chaturvedi" <Ketan.Chaturvedi@amd.com>,
Kai Huang <kai.huang@intel.com>
Subject: Re: [PATCH v11 6/8] KVM: SEV: Set RESET GHCB MSR value during sev_es_init_vmcb()
Date: Wed, 20 Aug 2025 15:02:18 +0530 [thread overview]
Message-ID: <0f29c54c-e471-4323-ba75-2df19d67479c@amd.com> (raw)
In-Reply-To: <20250819234833.3080255-7-seanjc@google.com>
On 8/20/2025 5:18 AM, Sean Christopherson wrote:
> Set the RESET value for the GHCB "MSR" during sev_es_init_vmcb() instead
> of sev_es_vcpu_reset() to allow for dropping sev_es_vcpu_reset() entirely.
>
> Note, the call to sev_init_vmcb() from sev_migrate_from() also kinda sorta
> emulates a RESET, but sev_migrate_from() immediate overwrites ghcb_gpa
s/immediate/immediately/
> with the source's current value, so whether or not stuffing the GHCB
> version is correct/desirable is moot.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
> ---
> arch/x86/kvm/svm/sev.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index c5726b091680..ee7a05843548 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -4480,7 +4480,7 @@ void sev_vcpu_after_set_cpuid(struct vcpu_svm *svm)
> vcpu->arch.reserved_gpa_bits &= ~(1UL << (best->ebx & 0x3f));
> }
>
> -static void sev_es_init_vmcb(struct vcpu_svm *svm)
> +static void sev_es_init_vmcb(struct vcpu_svm *svm, bool init_event)
> {
> struct kvm_sev_info *sev = to_kvm_sev_info(svm->vcpu.kvm);
> struct vmcb *vmcb = svm->vmcb01.ptr;
> @@ -4541,6 +4541,15 @@ static void sev_es_init_vmcb(struct vcpu_svm *svm)
>
> /* Can't intercept XSETBV, HV can't modify XCR0 directly */
> svm_clr_intercept(svm, INTERCEPT_XSETBV);
> +
> + /*
> + * Set the GHCB MSR value as per the GHCB specification when emulating
> + * vCPU RESET for an SEV-ES guest.
> + */
> + if (!init_event)
> + set_ghcb_msr(svm, GHCB_MSR_SEV_INFO((__u64)sev->ghcb_version,
> + GHCB_VERSION_MIN,
> + sev_enc_bit));
> }
>
> void sev_init_vmcb(struct vcpu_svm *svm, bool init_event)
> @@ -4560,7 +4569,7 @@ void sev_init_vmcb(struct vcpu_svm *svm, bool init_event)
> sev_snp_init_protected_guest_state(vcpu);
>
> if (sev_es_guest(vcpu->kvm))
> - sev_es_init_vmcb(svm);
> + sev_es_init_vmcb(svm, init_event);
> }
>
> int sev_vcpu_create(struct kvm_vcpu *vcpu)
> @@ -4585,17 +4594,6 @@ int sev_vcpu_create(struct kvm_vcpu *vcpu)
>
> void sev_es_vcpu_reset(struct vcpu_svm *svm)
> {
> - struct kvm_vcpu *vcpu = &svm->vcpu;
> - struct kvm_sev_info *sev = to_kvm_sev_info(vcpu->kvm);
> -
> - /*
> - * Set the GHCB MSR value as per the GHCB specification when emulating
> - * vCPU RESET for an SEV-ES guest.
> - */
> - set_ghcb_msr(svm, GHCB_MSR_SEV_INFO((__u64)sev->ghcb_version,
> - GHCB_VERSION_MIN,
> - sev_enc_bit));
> -
> mutex_init(&svm->sev_es.snp_vmsa_mutex);
> }
>
next prev parent reply other threads:[~2025-08-20 9:32 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 [this message]
2025-08-19 23:48 ` [PATCH v11 7/8] KVM: SEV: Fold sev_es_vcpu_reset() into sev_vcpu_create() Sean Christopherson
2025-08-20 9:33 ` 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=0f29c54c-e471-4323-ba75-2df19d67479c@amd.com \
--to=nikunj@amd.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=pbonzini@redhat.com \
--cc=seanjc@google.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®