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