Re: [PATCH] KVM: nVMX: Dynamically compute max VMCS index for vmcs12

From: Sean Christopherson
Date: Thu Jul 22 2021 - 11:04:39 EST


On Thu, Jul 22, 2021, Maxim Levitsky wrote:
> On Fri, 2021-06-18 at 14:46 -0700, Sean Christopherson wrote:
> > Calculate the max VMCS index for vmcs12 by walking the array to find the
> > actual max index. Hardcoding the index is prone to bitrot, and the
> > calculation is only done on KVM bringup (albeit on every CPU, but there
> > aren't _that_ many null entries in the array).
> >
> > Fixes: 3c0f99366e34 ("KVM: nVMX: Add a TSC multiplier field in VMCS12")
> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
>
> Could you give me an example on how this fails in the KVM unit tests?
> I have a bug report here and it might be related so I want to save some
> time triaging it.

FAIL: VMX_VMCS_ENUM.MAX_INDEX expected: 19, actual: 17

FWIW, unless a kernel/hypervisor is sanity checking VMREAD/VMWRITE or doing something
clever with the MAX_INDEX, I wouldn't expect this to cause any real world failures.