* [PATCH] KVM: SVM: Propagate error from snp_guest_req_init() to userspace
@ 2024-10-31 20:32 Sean Christopherson
2024-11-06 16:02 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2024-10-31 20:32 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Dan Carpenter
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: 88caf544c930 ("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
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/sev.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index c6c852485900..9cfa953088ce 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -450,8 +450,11 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp,
goto e_free;
/* This needs to happen after SEV/SNP firmware initialization. */
- if (vm_type == KVM_X86_SNP_VM && snp_guest_req_init(kvm))
- goto e_free;
+ if (vm_type == KVM_X86_SNP_VM) {
+ ret = snp_guest_req_init(kvm);
+ if (ret)
+ goto e_free;
+ }
INIT_LIST_HEAD(&sev->regions_list);
INIT_LIST_HEAD(&sev->mirror_vms);
base-commit: e466901b947d529f7b091a3b00b19d2bdee206ee
--
2.47.0.163.g1226f6d8fa-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] KVM: SVM: Propagate error from snp_guest_req_init() to userspace
2024-10-31 20:32 [PATCH] KVM: SVM: Propagate error from snp_guest_req_init() to userspace Sean Christopherson
@ 2024-11-06 16:02 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2024-11-06 16:02 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Dan Carpenter
On Thu, 31 Oct 2024 13:32:14 -0700, Sean Christopherson wrote:
> 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.
>
> [...]
Applied to kvm-x86 fixes (yesterday, I forgot to send the thank you mail).
[1/1] KVM: SVM: Propagate error from snp_guest_req_init() to userspace
https://github.com/kvm-x86/linux/commit/e5d253c60e96
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-06 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 20:32 [PATCH] KVM: SVM: Propagate error from snp_guest_req_init() to userspace Sean Christopherson
2024-11-06 16:02 ` 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®