diff mbox

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

Message ID 1479147243-26864-1-git-send-email-jmattson@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jim Mattson Nov. 14, 2016, 6:14 p.m. UTC
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@google.com>
---
 x86/apic.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Radim Krčmář Nov. 22, 2016, 1:55 p.m. UTC | #1
2016-11-14 10:14-0800, Jim Mattson:
> 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@google.com>
> ---

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

Patch

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();