mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds
@ 2025-08-21 21:38 Sean Christopherson
  2025-08-21 22:18 ` Tom Lendacky
  2025-09-16  0:25 ` Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2025-08-21 21:38 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Tom Lendacky, Kim Phillips

Wait until LAUNCH_START fully succeeds to set a VM's SEV/SNP policy so
that KVM doesn't keep a potentially stale policy.  In practice, the issue
is benign as the policy is only used to detect if the VMSA can be
decrypted, and the VMSA only needs to be decrypted if LAUNCH_UPDATE and
thus LAUNCH_START succeeded.

Fixes: 962e2b6152ef ("KVM: SVM: Decrypt SEV VMSA in dump_vmcb() if debugging is enabled")
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 arch/x86/kvm/svm/sev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index f4381878a9e5..65b59939754c 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -583,8 +583,6 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
 	if (copy_from_user(&params, u64_to_user_ptr(argp->data), sizeof(params)))
 		return -EFAULT;
 
-	sev->policy = params.policy;
-
 	memset(&start, 0, sizeof(start));
 
 	dh_blob = NULL;
@@ -632,6 +630,7 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
 		goto e_free_session;
 	}
 
+	sev->policy = params.policy;
 	sev->handle = start.handle;
 	sev->fd = argp->sev_fd;
 
@@ -2201,8 +2200,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
 		start.desired_tsc_khz = kvm->arch.default_tsc_khz;
 	}
 
-	sev->policy = params.policy;
-
 	sev->snp_context = snp_context_create(kvm, argp);
 	if (!sev->snp_context)
 		return -ENOTTY;
@@ -2218,6 +2215,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
 		goto e_free_context;
 	}
 
+	sev->policy = params.policy;
 	sev->fd = argp->sev_fd;
 	rc = snp_bind_asid(kvm, &argp->error);
 	if (rc) {

base-commit: ecbcc2461839e848970468b44db32282e5059925
-- 
2.51.0.261.g7ce5a0a67e-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds
  2025-08-21 21:38 [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds Sean Christopherson
@ 2025-08-21 22:18 ` Tom Lendacky
  2025-09-16  0:25 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Lendacky @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Kim Phillips

On 8/21/25 16:38, Sean Christopherson wrote:
> Wait until LAUNCH_START fully succeeds to set a VM's SEV/SNP policy so
> that KVM doesn't keep a potentially stale policy.  In practice, the issue
> is benign as the policy is only used to detect if the VMSA can be
> decrypted, and the VMSA only needs to be decrypted if LAUNCH_UPDATE and
> thus LAUNCH_START succeeded.
> 
> Fixes: 962e2b6152ef ("KVM: SVM: Decrypt SEV VMSA in dump_vmcb() if debugging is enabled")
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Kim Phillips <kim.phillips@amd.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/kvm/svm/sev.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index f4381878a9e5..65b59939754c 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -583,8 +583,6 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  	if (copy_from_user(&params, u64_to_user_ptr(argp->data), sizeof(params)))
>  		return -EFAULT;
>  
> -	sev->policy = params.policy;
> -
>  	memset(&start, 0, sizeof(start));
>  
>  	dh_blob = NULL;
> @@ -632,6 +630,7 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  		goto e_free_session;
>  	}
>  
> +	sev->policy = params.policy;
>  	sev->handle = start.handle;
>  	sev->fd = argp->sev_fd;
>  
> @@ -2201,8 +2200,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  		start.desired_tsc_khz = kvm->arch.default_tsc_khz;
>  	}
>  
> -	sev->policy = params.policy;
> -
>  	sev->snp_context = snp_context_create(kvm, argp);
>  	if (!sev->snp_context)
>  		return -ENOTTY;
> @@ -2218,6 +2215,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
>  		goto e_free_context;
>  	}
>  
> +	sev->policy = params.policy;
>  	sev->fd = argp->sev_fd;
>  	rc = snp_bind_asid(kvm, &argp->error);
>  	if (rc) {
> 
> base-commit: ecbcc2461839e848970468b44db32282e5059925

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds
  2025-08-21 21:38 [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds Sean Christopherson
  2025-08-21 22:18 ` Tom Lendacky
@ 2025-09-16  0:25 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2025-09-16  0:25 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Tom Lendacky, Kim Phillips

On Thu, 21 Aug 2025 14:38:41 -0700, Sean Christopherson wrote:
> Wait until LAUNCH_START fully succeeds to set a VM's SEV/SNP policy so
> that KVM doesn't keep a potentially stale policy.  In practice, the issue
> is benign as the policy is only used to detect if the VMSA can be
> decrypted, and the VMSA only needs to be decrypted if LAUNCH_UPDATE and
> thus LAUNCH_START succeeded.
> 
> 
> [...]

Applied to kvm-x86 svm, thanks!

[1/1] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds
      https://github.com/kvm-x86/linux/commit/2f5f8fb9de09

--
https://github.com/kvm-x86/linux/tree/next

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-16  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-21 21:38 [PATCH] KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds Sean Christopherson
2025-08-21 22:18 ` Tom Lendacky
2025-09-16  0:25 ` Sean Christopherson

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®