Re: [PATCH v2 3/5] KVM: x86: Use common 'enable_apicv' variable for both APICv and AVIC

From: Sean Christopherson
Date: Tue May 18 2021 - 16:40:02 EST


On Tue, May 18, 2021, Vitaly Kuznetsov wrote:
> Unify VMX and SVM code by moving APICv/AVIC enablement tracking to common
> 'enable_apicv' variable. Note: unlike APICv, AVIC is disabled by default.
>
> No functional change intended.
>
> Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
> ---

...

> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 8c3918a11826..0d6ec34d1e4b 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -185,6 +185,10 @@ module_param(vls, int, 0444);
> static int vgif = true;
> module_param(vgif, int, 0444);
>
> +/* enable / disable AVIC */
> +static int avic;
> +module_param(avic, int, 0444);

We should opportunistically make avic a "bool".

> +
> bool __read_mostly dump_invalid_vmcb;
> module_param(dump_invalid_vmcb, bool, 0644);
>
> @@ -1009,14 +1013,15 @@ static __init int svm_hardware_setup(void)
> nrips = false;
> }
>
> - if (avic) {
> - if (!npt_enabled || !boot_cpu_has(X86_FEATURE_AVIC)) {
> - avic = false;
> - } else {
> - pr_info("AVIC enabled\n");
> + if (!npt_enabled || !boot_cpu_has(X86_FEATURE_AVIC))
> + avic = false;
>
> - amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier);
> - }
> + /* 'enable_apicv' is common between VMX/SVM but the defaults differ */

-1 for not throwing Jim under the bus :-)

Nits aside,

Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>