Re: [PATCH v4 11/19] x86/cpu: Print VMX flags in /proc/cpuinfo using VMX_FEATURES_*

From: Borislav Petkov
Date: Thu Dec 12 2019 - 07:26:55 EST


On Wed, Nov 27, 2019 at 05:40:08PM -0800, Sean Christopherson wrote:
> Add support for generating VMX feature names in capflags.c and use the
> resulting x86_vmx_flags to print the VMX flags in /proc/cpuinfo. Don't
> print VMX flags if no bits are set in word 0, which holds Pin Controls.
> Pin Control's INTR and NMI exiting are fundamental pillars of VMX, if
> they are not supported then the CPU is broken, it does not actually
> support VMX, or the kernel wasn't built with support for the target CPU.
>
> Print the features in a dedicated "vmx flags" line to avoid polluting
> the common "flags" and to avoid having to prefix all flags with "vmx_",
> which results in horrendously long names.
>
> Keep synthetic VMX flags in cpufeatures to preserve /proc/cpuinfo's ABI
> for those flags. This means that "flags" and "vmx flags" will have
> duplicate entries for tpr_shadow (virtual_tpr), vnmi (virtual_nmis),
> ept, flexpriority, vpid and ept_ad, but caps the pollution of "flags" at
> those six VMX features. The vendor specific code that populates the
> synthetic flags will be consolidated in a future patch to futher
^

further

> +#ifdef CONFIG_X86_VMX_FEATURE_NAMES
> + if (cpu_has(c, X86_FEATURE_VMX) && c->vmx_capability[0]) {
> + seq_puts(m, "\nvmx flags\t:");
> + for (i = 0; i < 32*NVMXINTS; i++) {
> + if (test_bit(i, (unsigned long *)c->vmx_capability) &&
> + x86_vmx_flags[i] != NULL)
> + seq_printf(m, " %s", x86_vmx_flags[i]);
> + }
> + }
> +#endif

Oh well, some could be shorter:

vmx flags : virtual_nmis preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offsetting virtual_tpr mtf virt_apic_accesses ept vpid unrestricted_guest ple shadow_vmcs pml mode_based_ept_exec

virtual_nmis -> vnmis
preemption_timer -> preempt_tmr
flexpriority -> flexprio
tsc_offsetting -> tsc_ofs
virtual_tpr -> vtpr
virt_apic_accesses -> vapic
unrestricted_guest -> unres_guest

and so on. Those are just my examples - I betcha the SDM is more
creative here with abbreviations. But you guys are going to grep for
them. If it were me, I'd save on typing. :-)

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette