From: Paolo Bonzini <pbonzini@redhat.com>
To: "Suthikulpanit, Suravee" <suravee.suthikulpanit@amd.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
x86@kernel.org
Cc: seanjc@google.com, mlevitsk@redhat.com, joro@8bytes.org,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
peterz@infradead.org, hpa@zytor.com, jon.grimm@amd.com,
wei.huang2@amd.com, terry.bowman@amd.com, stable@vger.kernel.org
Subject: Re: [PATCH v6] KVM: SVM: Allow AVIC support on system w/ physical APIC ID > 255
Date: Mon, 21 Feb 2022 19:32:29 +0100 [thread overview]
Message-ID: <3ec04333-7988-16ca-a176-2eeb237851a7@redhat.com> (raw)
In-Reply-To: <5dd76348-f89c-58d9-1f6b-a6031b984330@amd.com>
On 2/16/22 23:59, Suthikulpanit, Suravee wrote:
> Paolo,
>
> Do you have any other concerns regarding this patch?
Queued it now, thanks. I had left it aside for a second because it
didn't apply cleanly. I'll include it in 5.18 for now; we'll then have
to repost this version as a <=5.17 backport for Greg, after the merge
window.
Paolo
> Regards,
> Suravee
>
> On 2/11/2022 7:08 AM, Suravee Suthikulpanit wrote:
>> Expand KVM's mask for the AVIC host physical ID to the full 12 bits
>> defined
>> by the architecture. The number of bits consumed by hardware is model
>> specific, e.g. early CPUs ignored bits 11:8, but there is no way for KVM
>> to enumerate the "true" size. So, KVM must allow using all bits, else it
>> risks rejecting completely legal x2APIC IDs on newer CPUs.
>>
>> This means KVM relies on hardware to not assign x2APIC IDs that exceed
>> the
>> "true" width of the field, but presumably hardware is smart enough to tie
>> the width to the max x2APIC ID. KVM also relies on hardware to
>> support at
>> least 8 bits, as the legacy xAPIC ID is writable by software. But, those
>> assumptions are unavoidable due to the lack of any way to enumerate the
>> "true" width.
>>
>> Cc: stable@vger.kernel.org
>> Cc: Maxim Levitsky <mlevitsk@redhat.com>
>> Suggested-by: Sean Christopherson <seanjc@google.com>
>> Reviewed-by: Sean Christopherson <seanjc@google.com>
>> Fixes: 44a95dae1d22 ("KVM: x86: Detect and Initialize AVIC support")
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>> arch/x86/kvm/svm/avic.c | 7 +------
>> arch/x86/kvm/svm/svm.h | 2 +-
>> 2 files changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
>> index 90364d02f22a..e4cfd8bf4f24 100644
>> --- a/arch/x86/kvm/svm/avic.c
>> +++ b/arch/x86/kvm/svm/avic.c
>> @@ -974,17 +974,12 @@ avic_update_iommu_vcpu_affinity(struct kvm_vcpu
>> *vcpu, int cpu, bool r)
>> void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>> {
>> u64 entry;
>> - /* ID = 0xff (broadcast), ID > 0xff (reserved) */
>> int h_physical_id = kvm_cpu_get_apicid(cpu);
>> struct vcpu_svm *svm = to_svm(vcpu);
>> lockdep_assert_preemption_disabled();
>> - /*
>> - * Since the host physical APIC id is 8 bits,
>> - * we can support host APIC ID upto 255.
>> - */
>> - if (WARN_ON(h_physical_id >
>> AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
>> + if (WARN_ON(h_physical_id &
>> ~AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK))
>> return;
>> /*
>> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
>> index 47ef8f4a9358..cede59cd8999 100644
>> --- a/arch/x86/kvm/svm/svm.h
>> +++ b/arch/x86/kvm/svm/svm.h
>> @@ -565,7 +565,7 @@ extern struct kvm_x86_nested_ops svm_nested_ops;
>> #define AVIC_LOGICAL_ID_ENTRY_VALID_BIT 31
>> #define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31)
>> -#define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL)
>> +#define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK
>> GENMASK_ULL(11, 0)
>> #define AVIC_PHYSICAL_ID_ENTRY_BACKING_PAGE_MASK (0xFFFFFFFFFFULL
>> << 12)
>> #define AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK (1ULL << 62)
>> #define AVIC_PHYSICAL_ID_ENTRY_VALID_MASK (1ULL << 63)
next prev parent reply other threads:[~2022-02-21 18:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 0:08 Suravee Suthikulpanit
2022-02-16 22:59 ` Suthikulpanit, Suravee
2022-02-21 18:32 ` Paolo Bonzini [this message]
2022-02-22 7:35 ` Suthikulpanit, Suravee
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=3ec04333-7988-16ca-a176-2eeb237851a7@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jon.grimm@amd.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=terry.bowman@amd.com \
--cc=tglx@linutronix.de \
--cc=wei.huang2@amd.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®