From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitaly Kuznetsov Subject: Re: [PATCH] x86/kvm/nVMX: tweak shadow fields Date: Mon, 12 Nov 2018 15:39:40 +0100 Message-ID: <87pnvas6kz.fsf@vitty.brq.redhat.com> References: <20181019141603.15995-1-vkuznets@redhat.com> <31279dfd-d0a1-3720-46a2-52395a124057@redhat.com> Mime-Version: 1.0 Content-Type: text/plain Cc: kvm list , Radim =?utf-8?B?S3LEjW3DocWZ?= , Liran Alon , LKML To: Jim Mattson , Paolo Bonzini Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org Jim Mattson writes: > I'm not convinced that the "one size fits all" and "context-free" > approaches to VMCS shadowing are terribly effective. > > For example, we never shadow VMX_INSTRUCTION_INFO, but if we just > reflected an exit to L1 for which that field is defined, there's > probably a good chance that L1 will use it. We always shadow > VM_EXIT_INTR_INFO, but if we didn't just reflect exit reason 0 to L1, > it's not likely to be read. If the L2 guest is in legacy mode or > compatibility mode, L1 is much more likely to be interested in the > contents of the descriptor cache than if the guest is in 64-bit mode. > > Some hypervisors write TSC_OFFSET quite frequently. Others rarely. > Last time I checked (it's been a while), VirtualBox was always > interested in everything. :-) Kvm, Hyper-V, VMware, VirtualBox, > Parallels...they all have different patterns, and they change from > release to release. > > Is it worth having a set of VMCS shadowing bitmaps per-vCPU, in order > to make better use of this feature? Per CPU or not, to improve the feature we'll probably need some sort of an 'adaptive' algorithm picking which fields to shadow. I haven't thought this through, especially read/write shadowing, but we can probably start with an empty bitmap and later shadow it when we get over some threshold of vmread/vmwrite exits we enabling shadowing. The question is when we un-shadow it. For example, we can un-shadow a field for writing every time we see it was not changed between two exits to L0 (so we're trying to write the same value to vmcs12). -- Vitaly