LEA with a register-direct source operand is illegal. Verify that the emulator raises #UD.
Suggested-by: Sean Christopherson seanjc@google.com Signed-off-by: Michal Luczaj mhal@rbox.co --- v1 -> v2: Use ASM_TRY_FEP()
x86/emulator.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/x86/emulator.c b/x86/emulator.c index 0eb7c1a..dc91ce3 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -897,6 +897,20 @@ static void test_mov_dr(uint64_t *mem) report(rax == DR6_ACTIVE_LOW, "mov_dr6"); }
+static void test_illegal_lea(void) +{ + unsigned int vector; + + asm volatile (ASM_TRY_FEP("1f") + ".byte 0x8d; .byte 0xc0\n\t" + "1:" + : : : "memory", "eax"); + + vector = exception_vector(); + report(vector == UD_VECTOR, + "Wanted #UD on LEA with /reg, got vector = %u", vector); +} + static void test_push16(uint64_t *mem) { uint64_t rsp1, rsp2; @@ -1188,6 +1202,7 @@ int main(void) test_smsw_reg(mem); test_nop(mem); test_mov_dr(mem); + test_illegal_lea(); } else { report_skip("skipping register-only tests, " "use kvm.force_emulation_prefix=1 to enable");