From: Tom Lendacky <thomas.lendacky@amd.com>
To: Dionna Glaze <dionnaglaze@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, Ashish Kalra <Ashish.Kalra@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Joerg Roedel <jroedel@suse.de>, Peter Gonda <pgonda@google.com>,
Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH v3 2/2] kvm: sev: If ccp is busy, report throttled to guest
Date: Fri, 20 Jan 2023 11:15:48 -0600 [thread overview]
Message-ID: <61e64ce5-df76-f34a-1dc8-a0f1a856e2e5@amd.com> (raw)
In-Reply-To: <20230119213426.379312-3-dionnaglaze@google.com>
On 1/19/23 15:34, Dionna Glaze wrote:
Since you're building on SNP hypervisor patches, please keep @Ashish on
direct copy.
> 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.
Except the CCP driver doesn't return -EBUSY because it is overloaded. It
will simply try to acquire the mutex and continue once it has it.
There are a couple of places that return -EBUSY in the driver for other
reasons, as well as other -E* values. It looks like these need to be
handled properly by the SNP hypervisor patches so that a "success" isn't
reported back.
So this patch isn't necessary, but any -E* return value without having
actually called the firmware needs to be handled properly. @Ashish, please
work with Dionna on this.
Thanks,
Tom
>
> 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.
prev parent reply other threads:[~2023-01-20 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 21:34 [PATCH v3 0/2] kvm: sev: Add SNP guest request throttling Dionna Glaze
2023-01-19 21:34 ` [PATCH v3 1/2] kvm: sev: Add SEV-SNP " Dionna Glaze
2023-01-20 16:40 ` Sean Christopherson
2023-01-19 21:34 ` [PATCH v3 2/2] kvm: sev: If ccp is busy, report throttled to guest Dionna Glaze
2023-01-20 17:15 ` Tom Lendacky [this message]
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=61e64ce5-df76-f34a-1dc8-a0f1a856e2e5@amd.com \
--to=thomas.lendacky@amd.com \
--cc=Ashish.Kalra@amd.com \
--cc=bp@alien8.de \
--cc=dionnaglaze@google.com \
--cc=jroedel@suse.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).