From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH kvm-unit-tests] x86: Test illegal movbe Date: Wed, 26 Nov 2014 14:57:22 +0100 Message-ID: <5475DC42.6000201@redhat.com> References: <1417009638-7260-1-git-send-email-namit@cs.technion.ac.il> <1417009731-7354-1-git-send-email-namit@cs.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Nadav Amit Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35853 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbaKZN53 (ORCPT ); Wed, 26 Nov 2014 08:57:29 -0500 In-Reply-To: <1417009731-7354-1-git-send-email-namit@cs.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: On 26/11/2014 14:48, Nadav Amit wrote: > Previously KVM ignored the mod field of MOVBE instruction, so MOVBE from > register to register succeeds, although it should fail (cause a #UD exception). > This test check that a #UD is indeed delivered upon such MOVBE. > > The test would not work if MOVBE is unsupported. > > Signed-off-by: Nadav Amit > --- > x86/emulator.c | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/x86/emulator.c b/x86/emulator.c > index 5aa4dbf..709978b 100644 > --- a/x86/emulator.c > +++ b/x86/emulator.c > @@ -1051,6 +1051,27 @@ static void test_simplealu(u32 *mem) > report("test", *mem == 0x8400); > } > > +static void illegal_movbe_handler(struct ex_regs *regs) > +{ > + extern char bad_movbe_cont; > + > + ++exceptions; > + regs->rip = (ulong)&bad_movbe_cont; > +} > + > +static void test_illegal_movbe(void) > +{ > + if (!(cpuid(1).c & (1 << 22))) > + printf("SKIP: illegal movbe\n"); > + > + exceptions = 0; > + handle_exception(UD_VECTOR, illegal_movbe_handler); > + asm volatile(".byte 0x0f; .byte 0x38; .byte 0xf0; .byte 0xc0;\n\t" > + " bad_movbe_cont:" : : : "rax"); > + report("illegal movbe", exceptions == 1); > + handle_exception(UD_VECTOR, 0); > +} > + > int main() > { > void *mem; > @@ -1119,6 +1140,7 @@ int main() > test_string_io_mmio(mem); > > test_jmp_noncanonical(mem); > + test_illegal_movbe(); > > return report_summary(); > } > Reviewed-by: Paolo Bonzini Thanks, Paolo