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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Reviewed-by: Darren Kenny <darren.kenny@xxxxxxxxxx>
Signed-off-by: Liran Alon <liran.alon@xxxxxxxxxx>
---
 x86/unittests.cfg |  6 ++++++
 x86/vmx_tests.c   | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

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),
-- 
2.16.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux