From: Arthur Chunqi Li Subject: [PATCH 2/3] emulator: Add multibyte nopl test case Date: Tue, 25 Jun 2013 16:51:30 +0800 Message-ID: <1372150291-31096-2-git-send-email-yzt356@gmail.com> References: <1372150291-31096-1-git-send-email-yzt356@gmail.com> Cc: gleb@redhat.com, pbonzini@redhat.com, jan.kiszka@web.de, Arthur Chunqi Li To: kvm@vger.kernel.org Return-path: Received: from mail-pa0-f41.google.com ([209.85.220.41]:54876 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752693Ab3FYIvv (ORCPT ); Tue, 25 Jun 2013 04:51:51 -0400 Received: by mail-pa0-f41.google.com with SMTP id bj3so12330395pad.0 for ; Tue, 25 Jun 2013 01:51:50 -0700 (PDT) In-Reply-To: <1372150291-31096-1-git-send-email-yzt356@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Test multiple byte nopl (from 1-byte nopl to 9-byte nopl) in 64-bit mode. Signed-off-by: Arthur Chunqi Li --- x86/emulator.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index 6972334..bd02d5c 100755 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -816,6 +816,30 @@ static void test_movabs(uint64_t *mem, uint8_t *alt_insn_page) report("64-bit mov imm2", outregs.rcx == 0x9090909090909090); } +static void test_nopl(uint64_t *mem, void *alt_insn_page) +{ + MK_INSN(nopl1, ".byte 0x90\n\r"); /* 1 byte nop */ + MK_INSN(nopl2, ".byte 0x66, 0x90\n\r"); /* 2 byte nop */ + MK_INSN(nopl3, ".byte 0x0f, 0x1f, 0x00\n\r"); /* 3 byte nop */ + MK_INSN(nopl4, ".byte 0x0f, 0x1f, 0x40, 0x00\n\r"); /* 4 byte nop */ + MK_INSN(nopl5, ".byte 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); /* 5 byte nop */ + MK_INSN(nopl6, ".byte 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00\n\r"); /* 6 byte nop */ + MK_INSN(nopl7, ".byte 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00\n\r"); /* 7 byte nop */ + MK_INSN(nopl8, ".byte 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); /* 8 byte nop */ + MK_INSN(nopl9, ".byte 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00\n\r"); /* 9 byte nop */ + + trap_emulator(mem, alt_insn_page, &insn_nopl1); + trap_emulator(mem, alt_insn_page, &insn_nopl2); + trap_emulator(mem, alt_insn_page, &insn_nopl3); + trap_emulator(mem, alt_insn_page, &insn_nopl4); + trap_emulator(mem, alt_insn_page, &insn_nopl5); + trap_emulator(mem, alt_insn_page, &insn_nopl6); + trap_emulator(mem, alt_insn_page, &insn_nopl7); + trap_emulator(mem, alt_insn_page, &insn_nopl8); + trap_emulator(mem, alt_insn_page, &insn_nopl9); + report("nopl", 1); +} + static void test_crosspage_mmio(volatile uint8_t *mem) { volatile uint16_t w, *pw; @@ -1012,6 +1036,7 @@ int main() test_mmx_movq_mf(mem, alt_insn_page); test_movabs(mem, alt_insn_page); + test_nopl(mem, alt_insn_page); test_crosspage_mmio(mem); -- 1.7.9.5