From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 4/4] kvm: Emulate MOVBE Date: Tue, 16 Jul 2013 09:04:09 +0300 Message-ID: <20130716060409.GF11772@redhat.com> References: <20130702105758.GF4535@pd.tnic> <20130702115122.GA28872@redhat.com> <20130702131910.GG4535@pd.tnic> <20130702141606.GB18489@redhat.com> <20130706122739.GB7149@pd.tnic> <20130707093552.GV5113@redhat.com> <20130707100023.GB27168@pd.tnic> <20130707101826.GW5113@redhat.com> <20130715223930.GD14503@pd.tnic> <20130715224115.GE14503@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: KVM , Paolo Bonzini , Andre Przywara , "H. Peter Anvin" , X86 ML , Borislav Petkov To: Borislav Petkov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46602 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901Ab3GPGEZ (ORCPT ); Tue, 16 Jul 2013 02:04:25 -0400 Content-Disposition: inline In-Reply-To: <20130715224115.GE14503@pd.tnic> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jul 16, 2013 at 12:41:15AM +0200, Borislav Petkov wrote: > Fix kvm ML already. > > On Tue, Jul 16, 2013 at 12:39:30AM +0200, Borislav Petkov wrote: > > On Sun, Jul 07, 2013 at 01:18:27PM +0300, Gleb Natapov wrote: > > > KVM does not enables emulation because QEMU called > > > KVM_GET_EMULATED_CPUID. KVM enables emulation because QEMU sets > > > MOVBE bit in a guest visible cpuid using KVM_SET_CPUID2. QEMU does > > > that either because host and cpu model QEMU uses both have it, or > > > because user asked for it specifically and KVM reports that it can > > > be emulated. Why emulator should care what is the reason MOVBE is > > > enabled? > > > > Ok, I think I know what you mean: > > > > diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > > index 6fe5a838116a..c963ff8e43dd 100644 > > --- a/arch/x86/kvm/emulate.c > > +++ b/arch/x86/kvm/emulate.c > > @@ -3147,10 +3147,18 @@ static int em_mov(struct x86_emulate_ctxt *ctxt) > > return X86EMUL_CONTINUE; > > } > > > > +#undef F > > +#define F(x) bit(X86_FEATURE_##x) > > + > > static int em_movbe(struct x86_emulate_ctxt *ctxt) > > { > > + u32 ebx, ecx, edx, eax = 1; > > u16 tmp; > > > > + ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx); > > + if (!(ecx & F(MOVBE))) > > + return X86EMUL_PROPAGATE_FAULT; > > + > > switch (ctxt->op_bytes) { > > case 2: > > /* > > --- > > > > Right? > Right, just replace return X86EMUL_PROPAGATE_FAULT; with return emulate_ud(ctxt); -- Gleb.