[kvm-unit-tests PATCH] x86: Test disabled local APIC

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

 



This test disables and re-enables the local APIC and ensures that
CPUID.1H:EDX.APIC[bit 9] mirrors IA32_APIC_BASE[11].

Signed-off-by: Jim Mattson <jmattson@xxxxxxxxxx>
---
 x86/apic.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/x86/apic.c b/x86/apic.c
index eff9a11..39c7fd1 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -104,6 +104,28 @@ void test_enable_x2apic(void)
     }
 }
 
+static void test_apic_disable(void)
+{
+    u64 orig_apicbase = rdmsr(MSR_IA32_APICBASE);
+
+    report_prefix_push("apic_disable");
+
+    report("Local apic enabled", orig_apicbase & APIC_EN);
+    report("CPUID.1H:EDX.APIC[bit 9] is set", cpuid(1).d & (1 << 9));
+
+    wrmsr(MSR_IA32_APICBASE, orig_apicbase & ~(APIC_EN | APIC_EXTD));
+    report("Local apic disabled", !(rdmsr(MSR_IA32_APICBASE) & APIC_EN));
+    report("CPUID.1H:EDX.APIC[bit 9] is clear", !(cpuid(1).d & (1 << 9)));
+
+    wrmsr(MSR_IA32_APICBASE, orig_apicbase & ~APIC_EXTD);
+    wrmsr(MSR_IA32_APICBASE, orig_apicbase);
+    apic_write(APIC_SPIV, 0x1ff);
+    report("Local apic enabled", rdmsr(MSR_IA32_APICBASE) & APIC_EN);
+    report("CPUID.1H:EDX.APIC[bit 9] is set", cpuid(1).d & (1 << 9));
+
+    report_prefix_pop();
+}
+
 #define ALTERNATE_APIC_BASE	0x42000000
 
 static void test_apicbase(void)
@@ -398,6 +420,7 @@ int main()
 
     mask_pic_interrupts();
     test_apic_id();
+    test_apic_disable();
     test_enable_x2apic();
     test_apicbase();
 
-- 
2.8.0.rc3.226.g39d4020

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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