Re: [PATCH v4 1/2] KVM: VMX: Cleanup VMX basic information defines and usages

From: Huang, Kai
Date: Mon Jan 15 2024 - 06:46:44 EST


On Fri, 2024-01-12 at 01:34 -0800, Li, Xin3 wrote:
> Define VMX basic information fields with BIT_ULL()/GENMASK_ULL(), and
> replace hardcoded VMX basic numbers with these field macros.
>
> Per Sean's ask, save the full/raw value of MSR_IA32_VMX_BASIC in the
> global vmcs_config as type u64 to get rid of the hi/lo crud, and then
> use VMX_BASIC helpers to extract info as needed.

For the sake of wanting a single 'u64 vmx_basic', feel free to add:

Acked-by: Kai Huang <kai.huang@xxxxxxxxx>

Although I still don't like splitting ...

[...]


> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -120,6 +120,14 @@
>
...

> +/* VMX_BASIC bits and bitmasks */
> +#define VMX_BASIC_32BIT_PHYS_ADDR_ONLY BIT_ULL(48)
> +#define VMX_BASIC_INOUT BIT_ULL(54)
> +
>
...

> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -1226,23 +1226,32 @@ static bool is_bitwise_subset(u64 superset, u64 subset, u64 mask)
> return (superset | subset) == superset;
> }
>
> +#define VMX_BASIC_DUAL_MONITOR_TREATMENT BIT_ULL(49)
> +#define VMX_BASIC_TRUE_CTLS BIT_ULL(55)

... these VMX_BASIC bit definitions across multiple files.

[...]


> +#define VMX_BASIC_MEM_TYPE_WB (MEM_TYPE_WB << 50);

Also, please fix this one.