From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Kyle Huey <me@kylehuey.com>
Cc: kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] x86: Test single stepping with emulated instructions
Date: Wed, 30 Nov 2016 19:17:35 +0100 [thread overview]
Message-ID: <20161130181735.GE1682@potion> (raw)
In-Reply-To: <20161128041932.11671-1-khuey@kylehuey.com>
2016-11-27 20:19-0800, Kyle Huey:
> This test checks that single stepping through CPUID and RDMSR works.
> Both instructions trigger VM exits and are emulated by the hypervisor.
>
> Signed-off-by: Kyle Huey <khuey@kylehuey.com>
> ---
> diff --git a/x86/debug.c b/x86/debug.c
> @@ -107,16 +107,47 @@ hw_bp2:
> "popf\n\t"
> : "=g" (start) : : "rax");
> report("single step",
> n == 3 &&
> bp_addr[0] == start+1+6 && dr6[0] == 0xffff4ff0 &&
> bp_addr[1] == start+1+6+1 && dr6[1] == 0xffff4ff0 &&
> bp_addr[2] == start+1+6+1+1 && dr6[2] == 0xffff4ff0);
>
> + /*
> + * cpuid and rdmsr (among others) trigger VM exits and are then
> + * emulated. Test that single stepping works on emulated instructions.
> + */
> + n = 0;
> + set_dr6(0);
> + asm volatile(
> + "pushf\n\t"
> + "pop %%rax\n\t"
> + "or $(1<<8),%%rax\n\t"
> + "push %%rax\n\t"
> + "lea (%%rip),%0\n\t"
> + "popf\n\t"
> + "and $~(1<<8),%%rax\n\t"
> + "push %%rax\n\t"
> + "xor %%rax,%%rax\n\t"
> + "cpuid\n\t"
> + "movl $0x1a0,%%ecx\n\t"
> + "rdmsr\n\t"
> + "popf\n\t"
> + : "=g" (start) : : "rax", "ebx", "ecx", "edx");
> + report("single step emulated instructions",
> + n == 7 &&
> + bp_addr[0] == start+1+6 && dr6[0] == 0xffff4ff0 &&
> + bp_addr[1] == start+1+6+1 && dr6[1] == 0xffff4ff0 &&
> + bp_addr[2] == start+1+6+1+3 && dr6[2] == 0xffff4ff0 &&
> + bp_addr[3] == start+1+6+1+3+2 && dr6[3] == 0xffff4ff0 &&
> + bp_addr[4] == start+1+6+1+3+2+5 && dr6[4] == 0xffff4ff0 &&
> + bp_addr[5] == start+1+6+1+3+2+5+2 && dr6[4] == 0xffff4ff0 &&
> + bp_addr[6] == start+1+6+1+3+2+5+2+1 && dr6[4] == 0xffff4ff0);
You probably wanted to check dr6[5] and dr6[6] too, I will fix that
while applying.
Thanks.
prev parent reply other threads:[~2016-11-30 18:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 4:19 [kvm-unit-tests PATCH] x86: Test single stepping with emulated instructions Kyle Huey
2016-11-30 18:17 ` Radim Krčmář [this message]
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=20161130181735.GE1682@potion \
--to=rkrcmar@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=me@kylehuey.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox