kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Suthikulpanit, Suravee" <suravee.suthikulpanit@amd.com>
To: Sean Christopherson <seanjc@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	pbonzini@redhat.com, jon.grimm@amd.com,
	Maxim Levitsky <mlevitsk@redhat.com>
Subject: Re: [PATCH] KVM: SVM: Fix x2apic logical cluster mode decoding and sanity check
Date: Thu, 15 Sep 2022 17:47:26 -0500	[thread overview]
Message-ID: <7c43a6f2-ec11-5af2-6574-68a32eb7fd41@amd.com> (raw)
In-Reply-To: <YyAVOBXZ+O3hnU9y@google.com>



On 9/13/2022 12:29 AM, Sean Christopherson wrote:
> On Mon, Sep 12, 2022, Suravee Suthikulpanit wrote:
>> When sending IPI in the X2APIC logical cluster mode, the destination
>> APIC ID is encoded as:
>>
>>    * Cluster ID = ICRH[31:16]
>>    * Logical ID = ICRH[15:0]
>>
>> Current logic incorrectly decode the ICRH, which causes VM running
>> with x2AVIC support to fail to boot. Therefore, fix the decoding logic.
> 
> There are already patches pending[1][2] for the x2AVIC bugs.
> 
> [1] https://lore.kernel.org/all/20220903002254.2411750-9-seanjc@xxxxxxxxxx
> [2] https://lore.kernel.org/all/20220903002254.2411750-10-seanjc@xxxxxxxxxx

Ok. Thanks for the pointer.

>>
>> The commit 603ccef42ce9 ("KVM: x86: SVM: fix avic_kick_target_vcpus_fast")
>> also added a check for multiple logical destinations before using
>> the fast-path. However, the same logic is already existed prior to
>> the commit. Therefore, remove redundant checking logic.
>>
>> Fixes: 603ccef42ce9 ("KVM: x86: SVM: fix avic_kick_target_vcpus_fast")
>> Cc: Maxim Levitsky <mlevitsk@redhat.com>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>> ---
>>   arch/x86/kvm/svm/avic.c | 19 ++++---------------
>>   1 file changed, 4 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
>> index 6919dee69f18..45ab49d1f0b8 100644
>> --- a/arch/x86/kvm/svm/avic.c
>> +++ b/arch/x86/kvm/svm/avic.c
>> @@ -378,8 +378,8 @@ static int avic_kick_target_vcpus_fast(struct kvm *kvm, struct kvm_lapic *source
>>   
>>   		if (apic_x2apic_mode(source)) {
>>   			/* 16 bit dest mask, 16 bit cluster id */
>> -			bitmap = dest & 0xFFFF0000;
>> -			cluster = (dest >> 16) << 4;
>> +			bitmap = dest & 0xffff;
>> +			cluster = (dest & 0xffff0000) >> 16;
>>   		} else if (kvm_lapic_get_reg(source, APIC_DFR) == APIC_DFR_FLAT) {
>>   			/* 8 bit dest mask*/
>>   			bitmap = dest;
>> @@ -387,7 +387,7 @@ static int avic_kick_target_vcpus_fast(struct kvm *kvm, struct kvm_lapic *source
>>   		} else {
>>   			/* 4 bit desk mask, 4 bit cluster id */
>>   			bitmap = dest & 0xF;
>> -			cluster = (dest >> 4) << 2;
>> +			cluster = (dest & 0xf0) >> 4;
> 
> This is wrong and unrelated.  The cluster needs to be shifted back by 2, i.e. multiplied
> by 4, to leap over each cluster of 4 IDs.

Ah, I missed the logic that was using the _cluster_ value below.

Thanks,
Suravee

      reply	other threads:[~2022-09-15 22:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 21:46 [PATCH] KVM: SVM: Fix x2apic logical cluster mode decoding and sanity check Suravee Suthikulpanit
2022-09-13  5:29 ` Sean Christopherson
2022-09-15 22:47   ` Suthikulpanit, Suravee [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=7c43a6f2-ec11-5af2-6574-68a32eb7fd41@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=jon.grimm@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).