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

From: Xin Li
Date: Thu Oct 26 2023 - 13:40:39 EST


On 10/26/2023 10:25 AM, Xin Li (Intel) wrote:
From: Xin Li <xin3.li@xxxxxxxxx>

Define VMX basic information fields with BIT_ULL()/GENMASK_ULL(), and
replace hardcoded VMX basic numbers with these macros.

Per Sean's ask, read MSR_IA32_VMX_BASIC into an u64 to get rid of the
hi/lo crud.

Tested-by: Shan Kang <shan.kang@xxxxxxxxx>
Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
---

Changes since v1:
* Don't add field shift macros unless it's really needed, extra layer
of indirect makes it harder to read (Sean Christopherson).
* Add a static_assert() to ensure that VMX_BASIC_FEATURES_MASK doesn't
overlap with VMX_BASIC_RESERVED_BITS (Sean Christopherson).
* read MSR_IA32_VMX_BASIC into an u64 rather than 2 u32 (Sean
Christopherson).
* Add 2 new functions for extracting fields from VMX basic (Sean
Christopherson).
* Drop the tools header update (Sean Christopherson).
* Move VMX basic field macros to arch/x86/include/asm/vmx.h.
---
arch/x86/include/asm/msr-index.h | 9 ---------
arch/x86/include/asm/vmx.h | 16 ++++++++++++++++
arch/x86/kvm/vmx/nested.c | 25 ++++++++++++++++++-------
arch/x86/kvm/vmx/vmx.c | 22 ++++++++++------------
4 files changed, 44 insertions(+), 28 deletions(-)

Sigh, forgot to add "--base=HEAD~2".

This is based on commit c076acf10c78c0d7e1aa50670e9cc4c91e8d59b4 of the 'next' branch in the kvm-x86 tree.

Thanks!
Xin