From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
Michal Luczaj <mhal@rbox.co>
Subject: [kvm-unit-tests PATCH v3 6/7] x86: Test emulator's handling of LEA with /reg
Date: Mon, 8 Aug 2022 16:47:06 +0000 [thread overview]
Message-ID: <20220808164707.537067-7-seanjc@google.com> (raw)
In-Reply-To: <20220808164707.537067-1-seanjc@google.com>
From: Michal Luczaj <mhal@rbox.co>
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>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/emulator.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/x86/emulator.c b/x86/emulator.c
index cc20440..7d97774 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -893,6 +893,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;
@@ -1179,6 +1193,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");
--
2.37.1.559.g78731f0fdb-goog
next prev parent reply other threads:[~2022-08-08 16:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 16:47 [kvm-unit-tests PATCH v3 0/7] x86: Illegal LEA test and FEP cleanups Sean Christopherson
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 1/7] x86: emulator.c: Save and restore exception handlers Sean Christopherson
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 2/7] x86: Dedup 32-bit vs. 64-bit ASM_TRY() by stealing kernel's __ASM_SEL() Sean Christopherson
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 3/7] x86: Introduce ASM_TRY_FEP() to handle exceptions on forced emulation Sean Christopherson
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 4/7] x86: Add helper to detect if forced emulation prefix is available Sean Christopherson
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 5/7] x86: emulator.c: Use ASM_TRY() for the UD_VECTOR cases Sean Christopherson
2022-08-08 16:47 ` Sean Christopherson [this message]
2022-08-08 16:47 ` [kvm-unit-tests PATCH v3 7/7] x86/pmu: Run the "emulation" test iff forced emulation is available Sean Christopherson
2022-08-10 19:06 ` [kvm-unit-tests PATCH v3 0/7] x86: Illegal LEA test and FEP cleanups Paolo Bonzini
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=20220808164707.537067-7-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=pbonzini@redhat.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;
as well as URLs for NNTP newsgroup(s).