From: Paolo Bonzini Subject: Re: [PATCH] kvm/x86/vmx: switch MSR_MISC_FEATURES_ENABLES between host and guest Date: Thu, 14 Mar 2019 15:44:39 +0100 Message-ID: <476deae9-05ca-5f3d-2178-66333674b57d@redhat.com> References: <20190314063858.18292-1-xiaoyao.li@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Kyle Huey , Chao Gao , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Xiaoyao Li Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 14/03/19 13:37, Xiaoyao Li wrote: >> Adding a RDMSR for this to each vmentry is too heavy. Since we emulate >> MSR_MISC_FEATURES_ENABLES, you can just clear the MSR on vcpu_load and >> restore it on vcpu_put. > One question here. Just clear the MSR on vcpu_load instead of writing the > emulated value to MSR? > > I think writing the emulated value to MSR is better. As I mentioned in case 3, > if hardware has cpuid faulting feature. Using hardware capability is more > efficient than emulation that the emulation solution needs VM exit to inject > #GP. You can do that too, yes. You can add it to vmx_msr_index and it will be handled like that. However, that wouldn't work on AMD (which doesn't use the kvm_define_shared_msr infrastructure) and also on hosts that don't have MSR_MISC_FEATURES_ENABLES, so my suggestion is to add this optimization as a separate patch. Paolo