From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 2/2] x86: Bail out on unemulated instructions Date: Sun, 15 Aug 2010 15:41:12 +0300 Message-ID: <20100815124112.GR10499@redhat.com> References: <1281801094-4515-1-git-send-email-m.gamal005@gmail.com> <1281801094-4515-2-git-send-email-m.gamal005@gmail.com> <20100815073236.GP10499@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx1.redhat.com ([209.132.183.28]:25097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932129Ab0HOQI2 convert rfc822-to-8bit (ORCPT ); Sun, 15 Aug 2010 12:08:28 -0400 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Aug 15, 2010 at 03:40:00PM +0300, Mohammed Gamal wrote: > On Sun, Aug 15, 2010 at 10:32 AM, Gleb Natapov wrot= e: > > On Sat, Aug 14, 2010 at 06:51:34PM +0300, Mohammed Gamal wrote: > >> If emulation fails due to the instruction being unemulated. Return= immediately > >> instead of restarting the instruction and infinitely trying to exe= cute it. > >> > > This is already handled correctly as far as I can see. Sometimes > > instruction should be retried and reexecute_instruction() checks > > for that case. If instruction emulation fails in big real mode > > re-executing instruction will be useless though, so what should be = done > > is to make reexecute_instruction() return false if vcpu is in big r= eal > > mode and cpu relies on emulation to handle it. > We don't have a separate mode for big real mode. The emulation modes > we have are real and vm86 >=20 That doesn't makes the patch right. So we will have to figure something out. > > > >> Signed-off-by: Mohammed Gamal > >> --- > >> =9Aarch/x86/kvm/x86.c | =9A =9A6 ++++++ > >> =9A1 files changed, 6 insertions(+), 0 deletions(-) > >> > >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > >> index 416aa0e..a31db44 100644 > >> --- a/arch/x86/kvm/x86.c > >> +++ b/arch/x86/kvm/x86.c > >> @@ -4036,6 +4036,9 @@ int emulate_instruction(struct kvm_vcpu *vcp= u, > >> =9A =9A =9A =9A =9A =9A =9A } > >> > >> =9A =9A =9A =9A =9A =9A =9A ++vcpu->stat.insn_emulation; > >> + =9A =9A =9A =9A =9A =9A if (r =3D=3D X86EMUL_UNHANDLEABLE) > >> + =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A return handle_emulation_= failure(vcpu); > >> + > >> =9A =9A =9A =9A =9A =9A =9A if (r) =9A{ > >> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A if (reexecute_instruct= ion(vcpu, cr2)) > >> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A return= EMULATE_DONE; > >> @@ -4057,6 +4060,9 @@ int emulate_instruction(struct kvm_vcpu *vcp= u, > >> =9Arestart: > >> =9A =9A =9A r =3D x86_emulate_insn(&vcpu->arch.emulate_ctxt); > >> > >> + =9A =9A if (r =3D=3D X86EMUL_UNHANDLEABLE) > >> + =9A =9A =9A =9A =9A =9A return handle_emulation_failure(vcpu); > >> + > >> =9A =9A =9A if (r) { /* emulation failed */ > >> =9A =9A =9A =9A =9A =9A =9A if (reexecute_instruction(vcpu, cr2)) > >> =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A return EMULATE_DONE; > >> -- > >> 1.7.0.4 > >> > >> -- > >> To unsubscribe from this list: send the line "unsubscribe kvm" in > >> the body of a message to majordomo@vger.kernel.org > >> More majordomo info at =9Ahttp://vger.kernel.org/majordomo-info.ht= ml > > > > -- > > =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9A =9AGleb. > > -- Gleb.