Skip to content

Commit faf06a2

Browse files
committed
KVM: selftests: Skip ICR.BUSY test in xapic_state_test if x2APIC is enabled
Don't test the ICR BUSY bit when x2APIC is enabled as AMD and Intel have different behavior (AMD #GPs, Intel ignores), and the fact that the CPU performs the reserved bit checks when IPI virtualization is enabled makes it impossible for KVM to precisely emulate one or the other. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent f2e91e8 commit faf06a2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tools/testing/selftests/kvm/x86_64/xapic_state_test.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ static void ____test_icr(struct xapic_vcpu *x, uint64_t val)
7070
vcpu_ioctl(vcpu, KVM_GET_LAPIC, &xapic);
7171
icr = (u64)(*((u32 *)&xapic.regs[APIC_ICR])) |
7272
(u64)(*((u32 *)&xapic.regs[APIC_ICR2])) << 32;
73-
if (!x->is_x2apic) {
73+
if (!x->is_x2apic)
7474
val &= (-1u | (0xffull << (32 + 24)));
75-
TEST_ASSERT_EQ(icr, val & ~APIC_ICR_BUSY);
76-
} else {
77-
TEST_ASSERT_EQ(icr & ~APIC_ICR_BUSY, val & ~APIC_ICR_BUSY);
78-
}
75+
76+
TEST_ASSERT_EQ(icr, val & ~APIC_ICR_BUSY);
7977
}
8078

8179
#define X2APIC_RSVED_BITS_MASK (GENMASK_ULL(31,20) | \
@@ -91,7 +89,15 @@ static void __test_icr(struct xapic_vcpu *x, uint64_t val)
9189
*/
9290
val &= ~X2APIC_RSVED_BITS_MASK;
9391
}
94-
____test_icr(x, val | APIC_ICR_BUSY);
92+
93+
/*
94+
* The BUSY bit is reserved on both AMD and Intel, but only AMD treats
95+
* it is as _must_ be zero. Intel simply ignores the bit. Don't test
96+
* the BUSY bit for x2APIC, as there is no single correct behavior.
97+
*/
98+
if (!x->is_x2apic)
99+
____test_icr(x, val | APIC_ICR_BUSY);
100+
95101
____test_icr(x, val & ~(u64)APIC_ICR_BUSY);
96102
}
97103

0 commit comments

Comments
 (0)