[PATCH kvm-unit-tests 4/4] x86: apic: cleanup

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

 



Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
 x86/apic.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/x86/apic.c b/x86/apic.c
index de19724..dfaea35 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -66,7 +66,7 @@ static bool do_write_apicbase(u64 data)
     jmp_buf jmpbuf;
     int ret;
     if (set_exception_jmpbuf(GP_VECTOR, jmpbuf) == 0) {
-        wrmsr(MSR_IA32_APICBASE, data);
+        wrmsr(MSR_IA32_APICBASE, APIC_DEFAULT_PHYS_BASE | APIC_BSP | data);
         ret = 0;
     } else {
         ret = 1;
@@ -77,36 +77,32 @@ static bool do_write_apicbase(u64 data)
 
 void test_enable_x2apic(void)
 {
-    u64 invalid_state = APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EXTD;
-    u64 apic_enabled = APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EN;
-    u64 x2apic_enabled =
-        APIC_DEFAULT_PHYS_BASE | APIC_BSP | APIC_EN | APIC_EXTD;
-
     if (enable_x2apic()) {
         printf("x2apic enabled\n");
 
         report("x2apic enabled to invalid state",
-               do_write_apicbase(invalid_state));
+               do_write_apicbase(APIC_EXTD));
         report("x2apic enabled to apic enabled",
-               do_write_apicbase(apic_enabled));
+               do_write_apicbase(APIC_EN));
 
-        wrmsr(MSR_IA32_APICBASE, APIC_DEFAULT_PHYS_BASE | APIC_BSP);
+        report("x2apic enabled to disabled state",
+               !do_write_apicbase(0));
         report("disabled to invalid state",
-               do_write_apicbase(invalid_state));
+               do_write_apicbase(APIC_EXTD));
         report("disabled to x2apic enabled",
-               do_write_apicbase(x2apic_enabled));
+               do_write_apicbase(APIC_EN | APIC_EXTD));
 
-        wrmsr(MSR_IA32_APICBASE, apic_enabled);
+        wrmsr(MSR_IA32_APICBASE, APIC_EN);
         report("apic enabled to invalid state",
-               do_write_apicbase(invalid_state));
+               do_write_apicbase(APIC_EXTD));
 
-        wrmsr(MSR_IA32_APICBASE, x2apic_enabled);
+        wrmsr(MSR_IA32_APICBASE, APIC_EN | APIC_EXTD);
         apic_write(APIC_SPIV, 0x1ff);
     } else {
         printf("x2apic not detected\n");
 
         report("enable unsupported x2apic",
-               do_write_apicbase(x2apic_enabled));
+               do_write_apicbase(APIC_EN | APIC_EXTD));
     }
 }
 
-- 
2.5.0

--
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