Skip to content

Commit e5d253c

Browse files
committed
KVM: SVM: Propagate error from snp_guest_req_init() to userspace
If snp_guest_req_init() fails, return the provided error code up the stack to userspace, e.g. so that userspace can log that KVM_SEV_INIT2 failed, as opposed to some random operation later in VM setup failing because SNP wasn't actually enabled for the VM. Note, KVM itself doesn't consult the return value from __sev_guest_init(), i.e. the fallout is purely that userspace may be confused. Fixes: 88caf54 ("KVM: SEV: Provide support for SNP_GUEST_REQUEST NAE event") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202410192220.MeTyHPxI-lkp@intel.com Link: https://lore.kernel.org/r/20241031203214.1585751-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 2657b82 commit e5d253c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

arch/x86/kvm/svm/sev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,11 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp,
450450
goto e_free;
451451

452452
/* This needs to happen after SEV/SNP firmware initialization. */
453-
if (vm_type == KVM_X86_SNP_VM && snp_guest_req_init(kvm))
454-
goto e_free;
453+
if (vm_type == KVM_X86_SNP_VM) {
454+
ret = snp_guest_req_init(kvm);
455+
if (ret)
456+
goto e_free;
457+
}
455458

456459
INIT_LIST_HEAD(&sev->regions_list);
457460
INIT_LIST_HEAD(&sev->mirror_vms);

0 commit comments

Comments
 (0)