lkml.org 
[lkml]   [2023]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v3 2/2] kvm: sev: If ccp is busy, report throttled to guest
From
The ccp driver can be overloaded even with 1 HZ throttling. The return
value of -EBUSY means that there is no firmware error to report back to
user space, so the guest VM would see this as exitinfo2 = 0. The false
success can trick the guest to update its the message sequence number
when it shouldn't have.

Instead, when ccp returns -EBUSY, that is reported to userspace as the
throttling return value.

Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Peter Gonda <pgonda@google.com>
Cc: Borislav Petkov <bp@alien8.de>

Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
arch/x86/kvm/svm/sev.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index cd9372ce6fc2..7da1cc300d7b 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3642,7 +3642,14 @@ static void snp_handle_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t
goto unlock;

rc = sev_issue_cmd(kvm, SEV_CMD_SNP_GUEST_REQUEST, &data, &err);
- if (rc)
+
+ /*
+ * The ccp driver can return -EBUSY if the PSP is overloaded, so signal
+ * the request has been throttled.
+ */
+ if (rc == -EBUSY)
+ rc = SNP_GUEST_REQ_THROTTLED;
+ else if (rc)
/* use the firmware error code */
rc = err;

@@ -3713,7 +3720,14 @@ static void snp_handle_ext_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gp
if (sev->snp_certs_len)
data_npages = sev->snp_certs_len >> PAGE_SHIFT;

- if (rc) {
+ /*
+ * The ccp driver can return -EBUSY if the PSP is overloaded, so signal
+ * the request has been throttled.
+ */
+ if (rc == -EBUSY) {
+ rc = SNP_GUEST_REQ_THROTTLED;
+ goto cleanup;
+ } else if (rc) {
/*
* If buffer length is small then return the expected
* length in rbx.
--
2.39.0.246.g2a6d74b583-goog
\
 
 \ /
  Last update: 2023-03-26 23:48    [W:0.081 / U:0.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site