KVM: SVM: Call SEV Guest Decommission if ASID binding fails
authorAlper Gun <alpergun@google.com>
Thu, 10 Jun 2021 17:46:04 +0000 (17:46 +0000)
committerSasha Levin <sashal@kernel.org>
Wed, 30 Jun 2021 12:47:29 +0000 (08:47 -0400)
commit7570a8b5dd493eebda5c0c826f3a87e2e6117791
tree6c06ce5de492bb34af3c3144483b9379ce9a1aa1
parent377a796e7a7102e543b4d1ccce473ed2df09f0d7
KVM: SVM: Call SEV Guest Decommission if ASID binding fails

commit 934002cd660b035b926438244b4294e647507e13 upstream.

Send SEV_CMD_DECOMMISSION command to PSP firmware if ASID binding
fails. If a failure happens after  a successful LAUNCH_START command,
a decommission command should be executed. Otherwise, guest context
will be unfreed inside the AMD SP. After the firmware will not have
memory to allocate more SEV guest context, LAUNCH_START command will
begin to fail with SEV_RET_RESOURCE_LIMIT error.

The existing code calls decommission inside sev_unbind_asid, but it is
not called if a failure happens before guest activation succeeds. If
sev_bind_asid fails, decommission is never called. PSP firmware has a
limit for the number of guests. If sev_asid_binding fails many times,
PSP firmware will not have resources to create another guest context.

Cc: stable@vger.kernel.org
Fixes: 59414c989220 ("KVM: SVM: Add support for KVM_SEV_LAUNCH_START command")
Reported-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Alper Gun <alpergun@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210610174604.2554090-1-alpergun@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/svm/sev.c