Skip to content

Commit 2f5f8fb

Browse files
committed
KVM: SEV: Save the SEV policy if and only if LAUNCH_START succeeds
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: 962e2b6 ("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> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20250821213841.3462339-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent a311fce commit 2f5f8fb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,6 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
583583
if (copy_from_user(&params, u64_to_user_ptr(argp->data), sizeof(params)))
584584
return -EFAULT;
585585

586-
sev->policy = params.policy;
587-
588586
memset(&start, 0, sizeof(start));
589587

590588
dh_blob = NULL;
@@ -632,6 +630,7 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
632630
goto e_free_session;
633631
}
634632

633+
sev->policy = params.policy;
635634
sev->handle = start.handle;
636635
sev->fd = argp->sev_fd;
637636

@@ -2205,8 +2204,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
22052204
start.desired_tsc_khz = kvm->arch.default_tsc_khz;
22062205
}
22072206

2208-
sev->policy = params.policy;
2209-
22102207
sev->snp_context = snp_context_create(kvm, argp);
22112208
if (!sev->snp_context)
22122209
return -ENOTTY;
@@ -2222,6 +2219,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
22222219
goto e_free_context;
22232220
}
22242221

2222+
sev->policy = params.policy;
22252223
sev->fd = argp->sev_fd;
22262224
rc = snp_bind_asid(kvm, &argp->error);
22272225
if (rc) {

0 commit comments

Comments
 (0)