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

From: Suthikulpanit, Suravee
Date: Tue Feb 01 2022 - 09:57:14 EST


Sean,

On 12/31/2021 12:21 AM, Sean Christopherson wrote:
On Mon, Dec 13, 2021, Suravee Suthikulpanit wrote:
The AVIC physical APIC ID table entry contains the host physical
APIC ID field, which the hardware uses to keep track of where each
vCPU is running. Originally, the field is an 8-bit value, which can
only support physical APIC ID up to 255.

To support system with larger APIC ID, the AVIC hardware extends
this field to support up to the largest possible physical APIC ID
available on the system.

Therefore, replace the hard-coded mask value with the value
calculated from the maximum possible physical APIC ID in the system.

...

+static void avic_init_host_physical_apicid_mask(void)
+{
+ if (!x2apic_mode) {
+ /* If host is in xAPIC mode, default to only 8-bit mask. */
+ avic_host_physical_id_mask = 0xffULL;

Use GENMASK(7:0) instead of open coding the equivalent. Oh, and
avic_host_physical_id_mask doesn't need to be a u64, it's hard capped at 12 bits
and so can be a simple int.


Actually, shouldn't it be u16 since the value returned from kvm_cpu_get_apicid()
would typically be 16-bit value (despite it has int as a return type).

Regards,
Suravee