Re: [PATCH v6 4/9] KVM: VMX: Move MSR_IA32_VMX_BASIC bit defines to asm/vmx.h
From: Sean Christopherson
Date: Tue Apr 02 2024 - 10:28:27 EST
On Tue, Apr 02, 2024, Xin3 Li wrote:
> > On 3/9/2024 9:27 AM, Sean Christopherson wrote:
> > > From: Xin Li <xin3.li@xxxxxxxxx>
> > >
> > > Move the bit defines for MSR_IA32_VMX_BASIC from msr-index.h to vmx.h
> > > so that they are colocated with other VMX MSR bit defines, and with
> > > the helpers that extract specific information from an MSR_IA32_VMX_BASIC
> > value.
> >
> > My understanding of msr-index.h is, it contains the index of various MSRs and the
> > bit definitions of each MSRs.
>
> "index" in the name kind of tell what it wants to focus.
Heh, there are a lot of files with names that don't necessarily reflect the
entirety of what they contain, I wouldn't put too much stock in the name :-)
> > Put the definition of each bit or bits below the definition of MSR index instead of
> > dispersed in different headers looks more intact for me.
>
> You're right when there is no other proper header for a MSR field definition.
>
> While the Linux code is maintained in the manner of "divide and conquer",
> thus I would say the VMX fields definitions belong to the KVM community,
> and fortunately, there is such a vmx header.
>
> BTW, It looks to me that some perf MSRs and fields are not in msr-index.h,
> which avoids bothering the tip maintainers all the time.
Ya, there is no hard rule that MSR indices and bits/masks _must_ go in msr-index.h.
Like many things, it's a judgment call, in this case to balance between keeping
a single file maintainble, usable, and readable, and making information easy and
intuitive to find.
There are many more examples, usually for things that are extremely "platform"
specific, e.g. the perf MSRs (especially for uncore stuff), synthetic MSRs defined
by hypervisors, etc.
In this particular case, I agree with Xin that putting the bit and mask definitions
in vmx.h makes the most sense. Nothing outside of virtualization code is likely
to ever care about the bits of the VMX feature MSRs, and putting all of the info
and helpers in msr-index.h would add a fair bit of noise, and would make it more
annoying to tweak and add masks for KVM's usage.