diff mbox series

[kvm-unit-tests,2/2] x86: VMX: Verify do not lose pending interrupt queued before entering halted guest

Message ID 20180904093731.28473-3-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show
Series : x86: VMX: Verify do not lose pending interrupt queued before entering guest | expand

Commit Message

Liran Alon Sept. 4, 2018, 9:37 a.m. UTC
Add test similar to previous patch ("x86: VMX: Verify do not lose
pending interrupt queued before entering guest") but when guest
is configured with HLT activity-state.

Reviewed-by: Nikita Leshchenko <nikita.leshchenko@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
 x86/unittests.cfg |  6 ++++++
 x86/vmx_tests.c   | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 8d1c7db1cf6f..0774ddbafa52 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -560,6 +560,12 @@  extra_params = -cpu host,+vmx -m 2560 -append vmx_pending_event_test
 arch = x86_64
 groups = vmx
 
+[vmx_pending_event_hlt_test]
+file = vmx.flat
+extra_params = -cpu host,+vmx -m 2560 -append vmx_pending_event_hlt_test
+arch = x86_64
+groups = vmx
+
 [vmx_eoi_bitmap_ioapic_scan]
 file = vmx.flat
 smp = 2
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 21b474db012b..e27c8f3a6c9b 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4467,10 +4467,11 @@  static void vmx_pending_event_ipi_isr(isr_regs_t *regs)
 bool vmx_pending_event_guest_run;
 static void vmx_pending_event_guest(void)
 {
+	vmcall();
 	vmx_pending_event_guest_run = true;
 }
 
-static void vmx_pending_event_test(void)
+static void vmx_pending_event_test_core(bool guest_hlt)
 {
 	int ipi_vector = 0xf1;
 
@@ -4482,6 +4483,12 @@  static void vmx_pending_event_test(void)
 
 	vmcs_set_bits(PIN_CONTROLS, PIN_EXTINT);
 
+	enter_guest();
+	skip_exit_vmcall();
+
+	if (guest_hlt)
+		vmcs_write(GUEST_ACTV_STATE, ACTV_HLT);
+
 	irq_disable();
 	apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL |
 				   APIC_DM_FIXED | ipi_vector,
@@ -4499,11 +4506,24 @@  static void vmx_pending_event_test(void)
 	report("Got pending interrupt after IRQ enabled",
 		   vmx_pending_event_ipi_fired);
 
+	if (guest_hlt)
+		vmcs_write(GUEST_ACTV_STATE, ACTV_ACTIVE);
+
 	enter_guest();
 	report("Guest finished running when no interrupt",
 		   vmx_pending_event_guest_run);
 }
 
+static void vmx_pending_event_test(void)
+{
+	vmx_pending_event_test_core(false);
+}
+
+static void vmx_pending_event_hlt_test(void)
+{
+	vmx_pending_event_test_core(true);
+}
+
 static bool cpu_has_apicv(void)
 {
 	return ((ctrl_cpu_rev[1].clr & CPU_APIC_REG_VIRT) &&
@@ -5064,6 +5084,7 @@  struct vmx_test vmx_tests[] = {
 	/* Regression tests */
 	TEST(vmx_cr_load_test),
 	TEST(vmx_pending_event_test),
+	TEST(vmx_pending_event_hlt_test),
 	/* EPT access tests. */
 	TEST(ept_access_test_not_present),
 	TEST(ept_access_test_read_only),