From: Paolo Bonzini <pbonzini@redhat.com>
To: Nadav Amit <namit@cs.technion.ac.il>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH kvm-unit-tests] x86: Test illegal movbe
Date: Wed, 26 Nov 2014 14:57:22 +0100 [thread overview]
Message-ID: <5475DC42.6000201@redhat.com> (raw)
In-Reply-To: <1417009731-7354-1-git-send-email-namit@cs.technion.ac.il>
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 <namit@cs.technion.ac.il>
> ---
> 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 <pbonzini@redhat.com>
Thanks,
Paolo
next prev parent reply other threads:[~2014-11-26 13:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 13:47 [PATCH] KVM: x86: Generate #UD when memory operand is required Nadav Amit
2014-11-26 13:48 ` [PATCH kvm-unit-tests] x86: Test illegal movbe Nadav Amit
2014-11-26 13:57 ` Paolo Bonzini [this message]
2014-11-26 21:42 ` [PATCH kvm-unit-tests v2] " Nadav Amit
2014-11-26 13:50 ` [PATCH] KVM: x86: Generate #UD when memory operand is required Paolo Bonzini
2014-11-27 14:58 ` Radim Krčmář
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=5475DC42.6000201@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=namit@cs.technion.ac.il \
/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.