From: Paolo Bonzini Subject: Re: [PATCH v6 06/13] KVM: nVMX: optimize prepare_vmcs02{,_full} for Enlightened VMCS case Date: Wed, 17 Oct 2018 19:17:32 +0200 Message-ID: <173cc977-58fd-9431-6199-c2eb8e898f7c@redhat.com> References: <20181016165011.6607-1-vkuznets@redhat.com> <20181016165011.6607-7-vkuznets@redhat.com> <2064be05-4286-e3d5-cd22-13fd957b7003@redhat.com> <8736t4sk8w.fsf@vitty.brq.redhat.com> <0ff3acb0-1d20-cbb0-5f40-887d9db93d9e@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Vitaly Kuznetsov , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Roman Kagan , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , LKML , Liran Alon , kvm list To: Jim Mattson Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 17/10/2018 19:08, Jim Mattson wrote: > I believe that ESXi reads GUEST_CS_AR_BYTES on every VM-exit to > determine code size. Which makes me wonder, maybe we should add GUEST_SS_AR_BYTES which is where the CPL lives. But then your tests from last year didn't find it. Paolo > On Wed, Oct 17, 2018 at 10:02 AM, Paolo Bonzini wrote: >> On 17/10/2018 16:47, Vitaly Kuznetsov wrote: >>>>> + if (!hv_evmcs || !(hv_evmcs->hv_clean_fields & >>>>> + HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP2)) { >>>>> + vmcs_write16(GUEST_CS_SELECTOR, vmcs12->guest_cs_selector); >>>>> + vmcs_write32(GUEST_CS_LIMIT, vmcs12->guest_cs_limit); >>>>> + vmcs_write32(GUEST_CS_AR_BYTES, vmcs12->guest_cs_ar_bytes); >>>>> + vmcs_writel(GUEST_ES_BASE, vmcs12->guest_es_base); >>>>> + vmcs_writel(GUEST_CS_BASE, vmcs12->guest_cs_base); >>>>> + } >>>> For what it's worth, I suspect that these can be moved to >>>> prepare_vmcs02_full. The initial implementation of shadow VMCS did not >>>> expose "unrestricted guest" to the L1 hypervisor, and emulation does a >>>> lot of accesses to CS (of course). Not sure how ES base ended up in >>>> there and not DS base, though... >>> I tried unshadowing all these fields and at least Hyper-V on KVM >>> (without using eVMCS of course) experiences a 1200-1300 cpu cycles >>> regression during tight cpuid loop test. I checked and this happens >>> because it likes vmreading GUEST_CS_AR_BYTES a lot. >> >> Go figure. :) Liran, do you happen to know if ESX does something >> similar with CS descriptor cache fields? >> >> Paolo