From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Mingwei Zhang <mizhang@google.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Lendacky <thomas.lendacky@amd.com>,
Marc Orr <marcorr@google.com>,
David Rientjes <rientjes@google.com>,
Alper Gun <alpergun@google.com>,
Dionna Glaze <dionnaglaze@google.com>,
Vipin Sharma <vipinsh@google.com>,
Peter Gonda <pgonda@google.com>,
Brijesh Singh <brijesh.singh@amd.com>
Subject: Re: [PATCH v2] KVM: SVM: improve the code readability for ASID management
Date: Wed, 4 Aug 2021 12:53:07 +0200 [thread overview]
Message-ID: <3226fb50-94c3-49d2-de9a-d4fea81b5b0a@redhat.com> (raw)
In-Reply-To: <YQlz4YDu/W8+YsZl@google.com>
On 03/08/21 18:50, Sean Christopherson wrote:
> This patch missed sev_asid_free().
>
> And on a very related topic, I'm pretty sure the VMCB+ASID invalidation logic
> indexes sev_vmcbs incorrectly. pre_sev_run() indexes sev_vmcbs by the ASID,
> whereas sev_asid_free() indexes by ASID-1, i.e. on free KVM nullifies the wrong
> sev_vmcb entry. sev_cpu_init() allocates for max_sev_asid+1, so indexing by
> ASID appears to be the intended behavior. That code is also a good candidate for
> conversion to nr_asids in this patch.
It's also missing this (off by one for SEV guests, pointless extra work for
SEV-ES):
index da5b9515a47b..7fbce342eec4 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -147,7 +147,7 @@ static int sev_asid_new(struct kvm_sev_info *sev)
min_asid = sev->es_active ? 1 : min_sev_asid;
max_asid = sev->es_active ? min_sev_asid - 1 : max_sev_asid;
again:
- asid = find_next_zero_bit(sev_asid_bitmap, max_sev_asid, min_asid);
+ asid = find_next_zero_bit(sev_asid_bitmap, max_asid + 1, min_asid);
if (asid > max_asid) {
if (retry && __sev_recycle_asids(min_asid, max_asid)) {
retry = false;
Queued both Mingwei's patch and yours, thanks (to 5.14-rc in order to avoid conflicts).
Paolo
prev parent reply other threads:[~2021-08-04 10:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 18:09 Mingwei Zhang
2021-08-03 7:22 ` Paolo Bonzini
2021-08-03 16:50 ` Sean Christopherson
2021-08-04 10:53 ` Paolo Bonzini [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=3226fb50-94c3-49d2-de9a-d4fea81b5b0a@redhat.com \
--to=pbonzini@redhat.com \
--cc=alpergun@google.com \
--cc=brijesh.singh@amd.com \
--cc=dionnaglaze@google.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcorr@google.com \
--cc=mizhang@google.com \
--cc=pgonda@google.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=thomas.lendacky@amd.com \
--cc=vipinsh@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/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®