From: Oliver Upton <oupton@google.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Oliver Upton <oupton@google.com>,
Jim Mattson <jmattson@google.com>
Subject: [kvm-unit-tests PATCH] x86: VMX: test MTF VM-exit event injection
Date: Tue, 14 Apr 2020 21:46:36 +0000 [thread overview]
Message-ID: <20200414214634.126508-2-oupton@google.com> (raw)
In-Reply-To: <20200414214634.126508-1-oupton@google.com>
SDM 26.6.2 describes how the VM-entry interruption-information field
may be configured to inject an MTF VM-exit upon VM-entry. Ensure that an
MTF VM-exit occurs when the VM-entry interruption-information field is
configured appropriately by the host.
Signed-off-by: Oliver Upton <oupton@google.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
---
Parent commit: b16df9e ("arch-run: Add reserved variables to the default environ")
x86/vmx_tests.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 1f97fe3..a91715f 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4964,6 +4964,7 @@ static void test_vmx_preemption_timer(void)
extern unsigned char test_mtf1;
extern unsigned char test_mtf2;
extern unsigned char test_mtf3;
+extern unsigned char test_mtf4;
static void test_mtf_guest(void)
{
@@ -4992,7 +4993,10 @@ static void test_mtf_guest(void)
* documented, don't rely on assemblers enumerating the
* instruction. Resort to hand assembly.
*/
- ".byte 0xf1;\n\t");
+ ".byte 0xf1;\n\t"
+ "vmcall;\n\t"
+ "test_mtf4:\n\t"
+ "mov $0, %eax;\n\t");
}
static void test_mtf_gp_handler(struct ex_regs *regs)
@@ -5037,7 +5041,7 @@ static void report_mtf(const char *insn_name, unsigned long exp_rip)
unsigned long rip = vmcs_read(GUEST_RIP);
assert_exit_reason(VMX_MTF);
- report(rip == exp_rip, "MTF VM-exit after %s instruction. RIP: 0x%lx (expected 0x%lx)",
+ report(rip == exp_rip, "MTF VM-exit after %s. RIP: 0x%lx (expected 0x%lx)",
insn_name, rip, exp_rip);
}
@@ -5114,7 +5118,12 @@ static void vmx_mtf_test(void)
disable_mtf();
enter_guest();
+ skip_exit_vmcall();
handle_exception(DB_VECTOR, old_db);
+ vmcs_write(ENT_INTR_INFO, INTR_INFO_VALID_MASK | INTR_TYPE_OTHER_EVENT);
+ enter_guest();
+ report_mtf("injected MTF", (unsigned long) &test_mtf4);
+ enter_guest();
}
/*
--
2.26.0.110.g2183baf09c-goog
next prev parent reply other threads:[~2020-04-14 21:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 21:46 [PATCH] kvm: nVMX: reflect MTF VM-exits if injected by L1 Oliver Upton
2020-04-14 21:46 ` Oliver Upton [this message]
2020-04-14 22:05 ` [kvm-unit-tests PATCH] x86: VMX: test MTF VM-exit event injection Peter Shier
2020-04-16 18:22 ` Oliver Upton
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=20200414214634.126508-2-oupton@google.com \
--to=oupton@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.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