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

From: Suthikulpanit, Suravee
Date: Tue Nov 16 2021 - 05:30:10 EST




On 11/10/2021 11:48 AM, Sean Christopherson wrote:
Wed, Nov 10, 2021, Suravee Suthikulpanit wrote:
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 989685098b3e..0b066bb5149d 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1031,6 +1031,12 @@ static __init int svm_hardware_setup(void)
nrips = false;
}
+ if (avic) {
+ r = avic_init_host_physical_apicid_mask();
+ if (r)
+ avic = false;
+ }
Haven't yet dedicated any brain cells to the rest of the patch, but this can be
written as

if (avic && avic_init_host_physical_apicid_mask())
avic = false;

or

avic = avic && !avic_init_host_physical_apicid_mask();

But looking at the context below, combining everything would be preferable. I
would say split out the enable_apicv part to make it more obvious that enable_apicv
is merely a reflection of avic.

avic = avic && npt_enabled && boot_cpu_has(X86_FEATURE_AVIC) &&
!avic_init_host_physical_apicid_mask();
enable_apicv = avic;


Yes, we can do that. I'll update the logic in V2.

Thanks,
Suravee