Re: [PATCH v2 3/3] KVM: SVM: Extend host physical APIC ID field to support more than 8-bit

From: Tom Lendacky
Date: Fri Dec 03 2021 - 11:35:04 EST


On 12/3/21 1:46 AM, Maxim Levitsky wrote:
On Thu, 2021-12-02 at 17:58 -0600, Suravee Suthikulpanit wrote:

@@ -63,6 +64,7 @@
static DEFINE_HASHTABLE(svm_vm_data_hash, SVM_VM_DATA_HASH_BITS);
static u32 next_vm_id = 0;
static bool next_vm_id_wrapped = 0;
+static u64 avic_host_physical_id_mask;
static DEFINE_SPINLOCK(svm_vm_data_hash_lock);
/*
@@ -133,6 +135,20 @@ void avic_vm_destroy(struct kvm *kvm)
spin_unlock_irqrestore(&svm_vm_data_hash_lock, flags);
}
+static void avic_init_host_physical_apicid_mask(void)
+{
+ if (!x2apic_mode) {
Wonder why this is a exported global variable and not function.
Not the patch fault though.
+ /* If host is in xAPIC mode, default to only 8-bit mask. */
+ avic_host_physical_id_mask = 0xffULL;
+ } else {
+ u32 count = get_count_order(apic_get_max_phys_apicid());
+
+ avic_host_physical_id_mask = BIT(count) - 1;
I think that there were some complains about using this macro and instead encouraged
to use 1 << x directly, but I see it used already in other places in avic.c so I don't know.

And I think it should be BIT_ULL() since avic_host_physical_id_mask is a u64.

Thanks,
Tom