From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: linux-4.4: qemu starting VM emits vmwrite error Date: Tue, 12 Jan 2016 11:42:09 +0100 Message-ID: <5694D881.1090709@redhat.com> References: <5693F235.5010309@gmail.com> <1452587122.4846.3.camel@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: "Han, Huaitong" , "zkaspar82@gmail.com" , "kvm@vger.kernel.org" Return-path: Received: from mail-wm0-f53.google.com ([74.125.82.53]:37051 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbcALKmO (ORCPT ); Tue, 12 Jan 2016 05:42:14 -0500 Received: by mail-wm0-f53.google.com with SMTP id f206so312905492wmf.0 for ; Tue, 12 Jan 2016 02:42:13 -0800 (PST) In-Reply-To: <1452587122.4846.3.camel@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 12/01/2016 09:25, Han, Huaitong wrote: > I don't have a old machine to test it, please patch it and give me > feedback. Thanks a lot. > > From f06a85c76db210ce7145be6c704c44a9cef70ee3 Mon Sep 17 00:00:00 2001 > From: Huaitong Han > Date: Tue, 12 Jan 2016 16:04:20 +0800 > Subject: [PATCH] kvm: x86: Fix vmwrite to SECONDARY_VM_EXEC_CONTROL > > SECONDARY_VM_EXEC_CONTROL vmcs will be updated with vmx_cpuid_update, > but it > will vmwrite error on the older CPU because the code is written without > CPU_BASED_ACTIVATE_SECONDARY_CONTROLS check. > > This will get rid of the following trace: > > vmwrite error: reg 401e value 10 (err 12) > Call Trace: > [] ? dump_stack+0x40/0x57 > [] ?vmx_cpuid_update+0x5d/0x150 [kvm_intel] > [] ?kvm_vcpu_ioctl_set_cpuid2+0x4c/0x70 [kvm] > [] ?kvm_arch_vcpu_ioctl+0x903/0xfa0 [kvm] > > Signen-off-by: Huaitong Han > --- > arch/x86/kvm/vmx.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 44976a5..80f21d3 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -8904,7 +8904,7 @@ static void vmx_cpuid_update(struct kvm_vcpu > *vcpu) > { > struct kvm_cpuid_entry2 *best; > struct vcpu_vmx *vmx = to_vmx(vcpu); > - u32 secondary_exec_ctl = vmx_secondary_exec_control(vmx); > + u32 secondary_exec_ctl = -1; > > if (vmx_rdtscp_supported()) { > bool rdtscp_enabled = guest_cpuid_has_rdtscp(vcpu); > @@ -8932,7 +8932,10 @@ static void vmx_cpuid_update(struct kvm_vcpu > *vcpu) > best->ebx &= ~bit(X86_FEATURE_INVPCID); > } > > - vmcs_set_secondary_exec_control(secondary_exec_ctl); > + if (cpu_has_secondary_exec_ctrls()) { > + secondary_exec_ctl &= vmx_secondary_exec_control(vmx); > + vmcs_set_secondary_exec_control(secondary_exec_ctl); > + } > > if (static_cpu_has(X86_FEATURE_PCOMMIT) && nested) { > if (guest_cpuid_has_pcommit(vcpu)) > Looks good, thanks! Paolo