From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] x86: nVMX: Dynamically calculate and check max VMCS field encoding index
Date: Wed, 15 May 2019 09:45:36 -0700 [thread overview]
Message-ID: <20190515164536.GC5875@linux.intel.com> (raw)
In-Reply-To: <04F148C8-5E44-4195-97E7-35A428E36983@gmail.com>
On Mon, May 13, 2019 at 03:43:18PM -0700, Nadav Amit wrote:
> > On Apr 15, 2019, at 6:38 PM, Sean Christopherson <sean.j.christopherson@intel.com> wrote:
> >
> > Per Intel's SDM:
> >
> > IA32_VMX_VMCS_ENUM indicates to software the highest index value used
> > in the encoding of any field supported by the processor:
> > - Bits 9:1 contain the highest index value used for any VMCS encoding.
> > - Bit 0 and bits 63:10 are reserved and are read as 0
> >
> > KVM correctly emulates this behavior, in no small part due to the VMX
> > preemption timer being unconditionally emulated *and* having the highest
> > index of any field supported in vmcs12. Given that the maximum control
> > field index is already above the VMX preemption timer (0x32 vs 0x2E),
> > odds are good that the max index supported in vmcs12 will change in the
> > not-too-distant future.
> >
> > Unfortunately, the only unit test coverage for IA32_VMX_VMCS_ENUM is in
> > test_vmx_caps(), which simply checks that the max index is >= 0x2a, i.e.
> > won't catch any future breakage of KVM's IA32_VMX_VMCS_ENUM emulation,
> > especially if the max index depends on underlying hardware support.
> >
> > Instead of playing whack-a-mole with a hardcoded max index test,
> > piggyback the exhaustive VMWRITE/VMREAD test and dynamically calculate
> > the max index based on which fields can be VMREAD. Leave the existing
> > hardcoded check in place as it won't hurt anything and test_vmx_caps()
> > is a better location for checking the reserved bits of the MSR.
>
> [ Yes, I know this patch was already accepted. ]
>
> This patch causes me problems.
>
> I think that probing using the known VMCS fields gives you a minimum for the
> maximum index. There might be VMCS fields that the test does not know about.
> Otherwise it would require to update kvm-unit-tests for every fields that is
> added to kvm.
>
> One option is just to change the max index, as determined by the probing to
> be required to smaller or equal to IA32_VMX_VMCS_ENUM.MAX_INDEX. A second
> option is to run additional probing, using IA32_VMX_VMCS_ENUM.MAX_INDEX and
> see if it is supported.
>
> What do you say?
Argh, I thought the test I was piggybacking was exhaustively probing all
theoretically possible fields, but that's the VMCS shadowing test. That
was my intent: probe all possible fields to find the max index and compare
it against IA32_VMX_VMCS_ENUM.MAX_INDEX.
To fix the immediate issue, going with the "smaller or equal" check makes
sense. To get the coverage I originally intended, I'll work on a test to
find the max non-failing field and compare it against MAX_INDEX.
next prev parent reply other threads:[~2019-05-15 16:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190416013832.11697-1-sean.j.christopherson@intel.com>
2019-05-13 22:43 ` [kvm-unit-tests PATCH] x86: nVMX: Dynamically calculate and check max VMCS field encoding index Nadav Amit
2019-05-15 16:45 ` Sean Christopherson [this message]
2019-05-17 23:03 ` Nadav Amit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190515164536.GC5875@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=kvm@vger.kernel.org \
--cc=nadav.amit@gmail.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox