KVM: SVM: fix missing sev_decommission() in sev_receive_start()
PATCH v2 1/1 KVM: SVM: fix missing sev_decommission() in sev_receive_start()
DECOMMISSION the current SEV context if binding an ASID fails after RECEIVE_START. Per AMD's SEV API, RECEIVE_START generates a new guest context and thus needs to be paired with DECOMMISSION:
AMD SEV API v0.24 Section 1.3.3
"The RECEIVE_START command is the only command other than the LAUNCH_START command that generates a new guest context and guest handle."
The missing DECOMMISSION can result in subsequent SEV launch failures due to insufficient resource. In particular, both LAUNCH_START and RECEIVE_START command will fail with SEV_RET_RESOURCE_LIMIT error.
Note, LAUNCH_START suffered from the same bug, but was previously fixed by [1]. However, the same bug could come back to LAUNCH_START if RECEIVE_START part was not fixed.
So add the sev_decommission() function in sev_receive_start.
[1] commit 934002cd660b ("KVM: SVM: Call SEV Guest Decommission if ASID binding fails").
--- arch/x86/kvm/svm/sev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +3 -1
@@ -1397,8 +1397,10 @@ static int sev_receive_start(struct kvm *kvm, struct kvm_sev_cmd *argp)/* Bind ASID to this guest */ ret =sev_bind_asid (kvm, start.handle, error); -if (ret) +if (ret) { +sev_decommission (start.handle); goto e_free_session; + } params.handle = start.handle; if (copy_to_user((void __user *)(uintptr_t)argp->data,
Signature · 1 line
2.33.0.464.g1972c5931b-goog