From: Dionna Glaze <dionnaglaze@google.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Dionna Glaze <dionnaglaze@google.com>,
Thomas Lendacky <Thomas.Lendacky@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Joerg Roedel <jroedel@suse.de>, Ingo Molnar <mingo@redhat.com>,
Andy Lutomirsky <luto@kernel.org>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Peter Gonda <pgonda@google.com>
Subject: [PATCH v2 2/2] kvm: sev: If ccp is busy, report throttled to guest
Date: Thu, 17 Nov 2022 18:11:27 +0000 [thread overview]
Message-ID: <20221117181127.1859634-3-dionnaglaze@google.com> (raw)
In-Reply-To: <20221117181127.1859634-1-dionnaglaze@google.com>
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.
Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andy Lutomirsky <luto@kernel.org>
Cc: John Allen <john.allen@amd.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Peter Gonda <pgonda@google.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
arch/x86/kvm/svm/sev.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 3ced06c6e07a..81e4862126fb 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3335,7 +3335,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;
@@ -3368,7 +3374,7 @@ static void snp_handle_ext_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gp
if (snp_throttle_guest_request(sev)) {
rc = SNP_GUEST_REQ_THROTTLED;
goto e_fail;
- }
+ }
data_gpa = vcpu->arch.regs[VCPU_REGS_RAX];
data_npages = vcpu->arch.regs[VCPU_REGS_RBX];
@@ -3392,7 +3398,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.584.g0f3c55d4c2-goog
next prev parent reply other threads:[~2022-11-17 18:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 18:11 [PATCH v2 0/2] kvm: sev: Add SNP guest request throttling Dionna Glaze
2022-11-17 18:11 ` [PATCH v2 1/2] kvm: sev: Add SEV-SNP " Dionna Glaze
2022-11-17 19:10 ` Dionna Amalie Glaze
2022-11-17 18:11 ` Dionna Glaze [this message]
2022-11-17 19:11 ` [PATCH v2 2/2] kvm: sev: If ccp is busy, report throttled to guest Dionna Amalie Glaze
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117181127.1859634-3-dionnaglaze@google.com \
--to=dionnaglaze@google.com \
--cc=Thomas.Lendacky@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=john.allen@amd.com \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pgonda@google.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®