[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20221108213226.3340496-3-dionnaglaze@google.com>
Date: Tue, 8 Nov 2022 21:32:26 +0000
From: Dionna Glaze <dionnaglaze@...gle.com>
To: linux-kernel@...r.kernel.org, x86@...nel.org
Cc: Dionna Glaze <dionnaglaze@...gle.com>
Subject: [PATCH 2/2] kvm: sev: If ccp is busy, report throttled to guest
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, we report that to userspace as the
throttling return value.
Signed-off-by: Dionna Glaze <dionnaglaze@...gle.com>
---
arch/x86/kvm/svm/sev.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index a9f67bfd60d9..6493fb527110 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3641,7 +3641,13 @@ 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
+ * we offer that as a throttling signal too.
+ */
+ if (rc == -EBUSY)
+ rc = SNP_GUEST_REQ_THROTTLED;
+ else if (rc)
/* use the firmware error code */
rc = err;
@@ -3698,7 +3704,14 @@ static void snp_handle_ext_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gp
rc = snp_guest_ext_guest_request(&req, (unsigned long)sev->snp_certs_data,
&data_npages, &err);
- if (rc) {
+ /*
+ * The ccp driver can return -EBUSY if the PSP is overloaded, so
+ * we offer that as a throttling signal too.
+ */
+ 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.38.1.431.g37b22c650d-goog
Powered by blists - more mailing lists