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 16:55:33 -0300 Message-ID: <20100728195533.GA29917@amt.cnet> References: <1280309941-13571-1-git-send-email-m.gamal005@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Mohammed Gamal Return-path: Received: from mx1.redhat.com ([209.132.183.28]:17649 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754748Ab0G1UZU (ORCPT ); Wed, 28 Jul 2010 16:25:20 -0400 Content-Disposition: inline In-Reply-To: <1280309941-13571-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 instruction > > Signed-off-by: Mohammed Gamal > > --- > Changes from v1: > - Added test for 16-bit iret > - Added tests for returned eflags > --- > kvm/test/x86/realmode.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 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() > print_serial("Pusha/Popa Test2: PASS\n"); > } > > +void test_iret() > +{ > + struct regs inregs = { 0 }, outregs; > + > + MK_INSN(iret32, "pushf\n\t" > + "pushl %cs\n\t" > + "call 1f\n\t" /* a near call will push eip onto the stack */ > + "jmp 2f\n\t" > + "1: iret\n\t" > + "2:\n\t" > + ); > + > + MK_INSN(iret16, "pushfw\n\t" > + "pushw %cs\n\t" > + "callw 1f\n\t" > + "jmp 2f\n\t" > + "1: iretw\n\t" > + "2:\n\t"); Unless iret causes a task switch, it will not cause an exit.