Re: [RFC PATCH 07/13] KVM: SVM: Update avic_kick_target_vcpus to support 32-bit APIC ID

From: Suravee Suthikulpanit
Date: Thu Mar 03 2022 - 09:41:36 EST


Maxim,

On 2/25/22 12:35 AM, Maxim Levitsky wrote:
On Sun, 2022-02-20 at 20:19 -0600, Suravee Suthikulpanit wrote:
In x2APIC mode, ICRH contains 32-bit destination APIC ID.
So, update the avic_kick_target_vcpus() accordingly.

Signed-off-by: Suravee Suthikulpanit<suravee.suthikulpanit@xxxxxxx>
---
arch/x86/kvm/svm/avic.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index 60f30e48d816..215d8a7dbc1d 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -307,10 +307,16 @@ void avic_ring_doorbell(struct kvm_vcpu *vcpu)
}
static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source,
- u32 icrl, u32 icrh)
+ u32 icrl, u32 icrh, bool x2apic_enabled)
{
struct kvm_vcpu *vcpu;
unsigned long i;
+ u32 dest;
+
+ if (x2apic_enabled)
+ dest = icrh;
+ else
+ dest = GET_APIC_DEST_FIELD(icrh);

Just use 'apic_x2apic_mode(apic)', no need for x2apic_enabled parameter
as I said in patch 6.

Also maybe rename GET_APIC_DEST_FIELD to GET_XAPIC_DEST_FIELD or something as it is
wrong for x2apic.

I'll send a separate patch to rename the macros as you suggested.

Regards,
Suravee