From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] test: Add emulator test for iret instruction Date: Wed, 28 Jul 2010 17:32:18 -0300 Message-ID: <20100728203218.GA30659@amt.cnet> References: <1280309941-13571-1-git-send-email-m.gamal005@gmail.com> <20100728195533.GA29917@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: avi@redhat.com, kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9334 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754999Ab0G1Uc4 (ORCPT ); Wed, 28 Jul 2010 16:32:56 -0400 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jul 28, 2010 at 11:28:05PM +0300, Mohammed Gamal wrote: > On Wed, Jul 28, 2010 at 10:55 PM, Marcelo Tosatti wrote: > > On Wed, Jul 28, 2010 at 12:39:01PM +0300, Mohammed Gamal wrote: > >> This adds a unit test for real mode emulation of the iret instruct= ion > >> > >> Signed-off-by: Mohammed Gamal > >> > >> --- > >> Changes from v1: > >> - Added test for 16-bit iret > >> - Added tests for returned eflags > >> --- > >> =A0kvm/test/x86/realmode.c | =A0 79 ++++++++++++++++++++++++++++++= +++++++++++++++++ > >> =A01 files changed, 79 insertions(+), 0 deletions(-) > >> > >> diff --git a/kvm/test/x86/realmode.c b/kvm/test/x86/realmode.c > >> index bd79348..74456c3 100644 > >> --- a/kvm/test/x86/realmode.c > >> +++ b/kvm/test/x86/realmode.c > >> @@ -865,6 +865,84 @@ void test_pusha_popa() > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 print_serial("Pusha/Popa Test2: PASS\n= "); > >> =A0} > >> > >> +void test_iret() > >> +{ > >> + =A0 =A0 struct regs inregs =3D { 0 }, outregs; > >> + > >> + =A0 =A0 MK_INSN(iret32, "pushf\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "pushl %cs\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "call 1f\n\t" /* a near = call will push eip onto the stack */ > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "jmp 2f\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "1: iret\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "2:\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0); > >> + > >> + =A0 =A0 MK_INSN(iret16, "pushfw\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "pushw %cs\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "callw 1f\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "jmp 2f\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "1: iretw\n\t" > >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "2:\n\t"); > > > > Unless iret causes a task switch, it will not cause an exit. > > > > > The test covers only the real mode case, we won't have a task switch = there, no? No. And there is no vmexit for iret, so it does not go through the emulator.