From: Marcelo Tosatti Subject: Re: [PATCH 1/2] KVM: nVMX: Validate EFER values for VM_ENTRY/EXIT_LOAD_IA32_EFER Date: Wed, 17 Apr 2013 19:39:40 -0300 Message-ID: <20130417223934.GB31059@amt.cnet> References: <516A8879.6050202@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Gleb Natapov , kvm , Paolo Bonzini , "Nadav Har'El" To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32369 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257Ab3DQXhz (ORCPT ); Wed, 17 Apr 2013 19:37:55 -0400 Content-Disposition: inline In-Reply-To: <516A8879.6050202@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Apr 14, 2013 at 12:44:09PM +0200, Jan Kiszka wrote: > From: Jan Kiszka >=20 > As we may emulate the loading of EFER on VM-entry and VM-exit, implem= ent > the checks that VMX performs on the guest and host values on vmlaunch= / > vmresume. Factor out kvm_valid_efer for this purpose which checks for > set reserved bits. >=20 > Signed-off-by: Jan Kiszka > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/vmx.c | 38 +++++++++++++++++++++++++++++= +++++++++ > arch/x86/kvm/x86.c | 29 +++++++++++++++++++---------- > 3 files changed, 58 insertions(+), 10 deletions(-) >=20 > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/k= vm_host.h > index b2c7263..28a458f 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -805,6 +805,7 @@ static inline int emulate_instruction(struct kvm_= vcpu *vcpu, > } > =20 > void kvm_enable_efer_bits(u64); > +bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer); > int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data); > int kvm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr); > =20 > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index cc2ba55..0d13b29 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -7257,6 +7257,44 @@ static int nested_vmx_run(struct kvm_vcpu *vcp= u, bool launch) > } > =20 > /* > + * If the =E2=80=9Cload IA32_EFER=E2=80=9D VM-entry control is 1, t= he following checks > + * are performed on the field for the IA32_EFER MSR: > + * - Bits reserved in the IA32_EFER MSR must be 0. > + * - Bit 10 (corresponding to IA32_EFER.LMA) must equal the value o= f > + * the IA-32e mode guest VM-exit control. It must also be identic= al > + * to bit 8 (LME) if bit 31 in the CR0 field (corresponding to > + * CR0.PG) is 1.1 ^^^ Typo?