From: Gleb Natapov <gleb@redhat.com>
To: Arthur Chunqi Li <yzt356@gmail.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, jan.kiszka@web.de
Subject: Re: [PATCH 3/3] emulator: Add spl/bpl/sil/dil access via modrm
Date: Tue, 25 Jun 2013 14:35:12 +0300 [thread overview]
Message-ID: <20130625113512.GQ18508@redhat.com> (raw)
In-Reply-To: <1372150291-31096-3-git-send-email-yzt356@gmail.com>
On Tue, Jun 25, 2013 at 04:51:31PM +0800, Arthur Chunqi Li wrote:
> Add test case of accessing spl/bpl/sil/dil via modrm in emulator.
>
> Signed-off-by: Arthur Chunqi Li <yzt356@gmail.com>
> ---
> x86/emulator.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/x86/emulator.c b/x86/emulator.c
> index bd02d5c..bea9513 100755
> --- a/x86/emulator.c
> +++ b/x86/emulator.c
> @@ -840,6 +840,31 @@ static void test_nopl(uint64_t *mem, void *alt_insn_page)
> report("nopl", 1);
> }
>
> +static void test_modrm(uint64_t *mem, void *alt_insn_page)
> +{
> +
> + MK_INSN(modrm_spl,"mov %al, %spl\n\t");
> + MK_INSN(modrm_bpl,"mov %cl, %bpl\n\t");
> + MK_INSN(modrm_sil,"mov %dl, %sil\n\t");
> + MK_INSN(modrm_dil,"mov %bl, %dil\n\t");
> +
The test can be compiled for 64 bit only so we need to put it in an
#ifdef. Previous patches that introduced testing infrastructure are
64 bit specific too, so now emulator.c can be compiled for 64bit only,
we should fix that one day.
> + inregs = (struct regs){ .rax = 0x1234 };
> + trap_emulator(mem, alt_insn_page, &insn_modrm_spl);
> + report("access spl via modr/m", outregs.rax == 0x1234);
I'd prefer to write report variant like the one in realmode.c that
checks all registers for consistency. Then the report would be like
that:
report("access spl via modr/m", R_SP, outregs.rsp == 0x34);
> +
> + inregs = (struct regs){ .rcx = 0x1234 };
> + trap_emulator(mem, alt_insn_page, &insn_modrm_bpl);
> + report("access bpl via modr/m", outregs.rcx == 0x1234);
> +
> + inregs = (struct regs){ .rdx = 0x1234 };
> + trap_emulator(mem, alt_insn_page, &insn_modrm_sil);
> + report("access sil via modr/m", outregs.rdx == 0x1234);
> +
> + inregs = (struct regs){ .rbx = 0x1234 };
> + trap_emulator(mem, alt_insn_page, &insn_modrm_dil);
> + report("access dil via modr/m", outregs.rbx == 0x1234);
> +}
> +
> static void test_crosspage_mmio(volatile uint8_t *mem)
> {
> volatile uint16_t w, *pw;
> @@ -1037,6 +1062,7 @@ int main()
> test_mmx_movq_mf(mem, alt_insn_page);
> test_movabs(mem, alt_insn_page);
> test_nopl(mem, alt_insn_page);
> + test_modrm(mem, alt_insn_page);
>
> test_crosspage_mmio(mem);
>
> --
> 1.7.9.5
--
Gleb.
next prev parent reply other threads:[~2013-06-25 11:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 8:51 [PATCH 1/3] emulator: fix confused param list Arthur Chunqi Li
2013-06-25 8:51 ` [PATCH 2/3] emulator: Add multibyte nopl test case Arthur Chunqi Li
2013-06-25 8:51 ` [PATCH 3/3] emulator: Add spl/bpl/sil/dil access via modrm Arthur Chunqi Li
2013-06-25 11:35 ` Gleb Natapov [this message]
2013-06-25 8:53 ` [PATCH 1/3] emulator: fix confused param list Arthur Chunqi Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130625113512.GQ18508@redhat.com \
--to=gleb@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yzt356@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.