[kvm-unit-tests PATCH 4/9] x86/apic: Assert that vCPU0's APIC is enabled at the start of the test

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

 



Assert that vCPU's APIC is fully enabled at the start of the apic test.
The boot code is supposed to do that, but nothing ever actually verifies
the APIC got setup correctly.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 x86/apic.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/x86/apic.c b/x86/apic.c
index 650c1d0..6c555ce 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -15,6 +15,11 @@ static bool is_apic_hw_enabled(void)
 	return rdmsr(MSR_IA32_APICBASE) & APIC_EN;
 }
 
+static bool is_apic_sw_enabled(void)
+{
+	return apic_read(APIC_SPIV) & APIC_SPIV_APIC_ENABLED;
+}
+
 static bool is_x2apic_enabled(void)
 {
 	return (rdmsr(MSR_IA32_APICBASE) & (APIC_EN | APIC_EXTD)) == (APIC_EN | APIC_EXTD);
@@ -691,6 +696,9 @@ static void test_pv_ipi(void)
 
 int main(void)
 {
+	assert_msg(is_apic_hw_enabled() && is_apic_sw_enabled(),
+		   "APIC should be fully enabled by startup code.");
+
 	setup_vm();
 
 	test_lapic_existence();
-- 
2.38.0.rc1.362.ged0d419d3c-goog




[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