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 <na...@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 <pbonz...@redhat.com>

Thanks,

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to