On 30.07.2024 12:33, Sergiy Kibrik wrote: > There're several places in common code, outside of arch/x86/hvm/vmx, > where cpu_has_vmx_* get accessed without checking whether VMX supported first. > These macros rely on global variables defined in vmx code, so when VMX support > is disabled accesses to these variables turn into build failures. > > To overcome these failures, build-time check is done before accessing global > variables, so that DCE would remove these variables. > > Signed-off-by: Sergiy Kibrik <sergiy_kib...@epam.com> > Acked-by: Paul Durrant <p...@xen.org> > CC: Andrew Cooper <andrew.coop...@citrix.com> > CC: Jan Beulich <jbeul...@suse.com> > --- > changes in v5: > - change kconfig option name VMX -> INTEL_VMX > - do not change .c files, only modify macros in vmcs.h
Better, yet still not going far enough, as indicated earlier: > --- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h > +++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h > @@ -300,13 +300,15 @@ extern u64 vmx_ept_vpid_cap; > #define cpu_has_wbinvd_exiting \ > (vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING) > #define cpu_has_vmx_virtualize_apic_accesses \ > - (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) > + (IS_ENABLED(CONFIG_INTEL_VMX) && \ > + vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) Why does this change but the earlier cpu_has_wbinvd_exiting or ... > #define cpu_has_vmx_tpr_shadow \ > (vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW) > #define cpu_has_vmx_vnmi \ > (vmx_pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS) ... these two (and several more elsewhere) don't? Jan