From: Paolo Bonzini Subject: Re: [PATCH] kvm/x86/vmx: Make the emulation of MSR_IA32_ARCH_CAPABILITIES only for vmx Date: Thu, 7 Mar 2019 19:15:44 +0100 Message-ID: <55caabc3-e075-3282-a000-88356ddb15c2@redhat.com> References: <20190307093143.77182-1-xiaoyao.li@linux.intel.com> <20190307173744.GB4986@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: =?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: Sean Christopherson , Xiaoyao Li Return-path: In-Reply-To: <20190307173744.GB4986@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/03/19 18:37, Sean Christopherson wrote: > On Thu, Mar 07, 2019 at 05:31:43PM +0800, Xiaoyao Li wrote: >> At present, we report F(ARCH_CAPABILITIES) for x86 arch(both vmx and svm) >> unconditionally, but we only emulate this MSR in vmx. It will cause #GP >> while guest kernel rdmsr(MSR_IA32_ARCH_CAPABILITIES) in an AMD host. >> >> Since MSR IA32_ARCH_CAPABILITIES is an intel-specific MSR, it makes no >> sense to emulate it in svm. Thus this patch chooses to only emulate it >> for vmx, and moves the related handling to vmx related files. > > What about emulating the MSR on an AMD host for testing purpsoes? It > might be a useful way for someone without Intel hardware to test spectre > related flows. > > In other words, an alternative to restricting emulation of the MSR to > Intel CPUS would be to move MSR_IA32_ARCH_CAPABILITIES handling into > kvm_{get,set}_msr_common(). Guest access to MSR_IA32_ARCH_CAPABILITIES > is gated by X86_FEATURE_ARCH_CAPABILITIES in the guest's CPUID, e.g. > RDMSR will naturally #GP fault if userspace passes through the host's > CPUID on a non-Intel system. This is also better because it wouldn't change the guest ABI for AMD processors. Dropping CPUID flags is generally not a good idea. Paolo