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

[Xen-devel] [PATCH v7 13/19] xen: introduce flag to disable the local apic



PVH guests don't have an emulated lapic.
---
 sys/amd64/amd64/mp_machdep.c |   10 ++++++----
 sys/amd64/include/apicvar.h  |    1 +
 sys/i386/include/apicvar.h   |    1 +
 sys/i386/xen/xen_machdep.c   |    2 ++
 sys/x86/x86/local_apic.c     |    8 +++++---
 sys/x86/xen/pv.c             |    3 +++
 6 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index e302886..0296a92 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -709,7 +709,8 @@ init_secondary(void)
        wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
 
        /* Disable local APIC just to be sure. */
-       lapic_disable();
+       if (!lapic_disabled)
+               lapic_disable();
 
        /* signal our startup to the BSP. */
        mp_naps++;
@@ -735,7 +736,7 @@ init_secondary(void)
 
        /* A quick check from sanity claus */
        cpuid = PCPU_GET(cpuid);
-       if (PCPU_GET(apic_id) != lapic_id()) {
+       if (!lapic_disabled && (PCPU_GET(apic_id) != lapic_id())) {
                printf("SMP: cpuid = %d\n", cpuid);
                printf("SMP: actual apic_id = %d\n", lapic_id());
                printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id));
@@ -751,7 +752,8 @@ init_secondary(void)
        mtx_lock_spin(&ap_boot_mtx);
 
        /* Init local apic for irq's */
-       lapic_setup(1);
+       if (!lapic_disabled)
+               lapic_setup(1);
 
        /* Set memory range attributes for this CPU to match the BSP */
        mem_range_AP_init();
@@ -766,7 +768,7 @@ init_secondary(void)
        if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0)
                CPU_SET(cpuid, &logical_cpus_mask);
 
-       if (bootverbose)
+       if (!lapic_disabled && bootverbose)
                lapic_dump("AP");
 
        if (smp_cpus == mp_ncpus) {
diff --git a/sys/amd64/include/apicvar.h b/sys/amd64/include/apicvar.h
index e7423a3..84e01d4 100644
--- a/sys/amd64/include/apicvar.h
+++ b/sys/amd64/include/apicvar.h
@@ -169,6 +169,7 @@ inthand_t
 
 extern vm_paddr_t lapic_paddr;
 extern int apic_cpuids[];
+extern bool lapic_disabled;
 
 u_int  apic_alloc_vector(u_int apic_id, u_int irq);
 u_int  apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count,
diff --git a/sys/i386/include/apicvar.h b/sys/i386/include/apicvar.h
index df99ebe..24c99f0 100644
--- a/sys/i386/include/apicvar.h
+++ b/sys/i386/include/apicvar.h
@@ -168,6 +168,7 @@ inthand_t
 
 extern vm_paddr_t lapic_paddr;
 extern int apic_cpuids[];
+extern bool lapic_disabled;
 
 u_int  apic_alloc_vector(u_int apic_id, u_int irq);
 u_int  apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count,
diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c
index 09c01f1..7039b4a 100644
--- a/sys/i386/xen/xen_machdep.c
+++ b/sys/i386/xen/xen_machdep.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/intr_machdep.h>
 #include <machine/md_var.h>
 #include <machine/asmacros.h>
+#include <machine/apicvar.h>
 
 
 
@@ -912,6 +913,7 @@ initvalues(start_info_t *startinfo)
 #endif 
        xen_start_info = startinfo;
        HYPERVISOR_start_info = startinfo;
+       lapic_disabled = true;
        xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list;
 
        IdlePTD = (pd_entry_t *)((uint8_t *)startinfo->pt_base + PAGE_SIZE);
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 41bd602..85736c8 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -156,6 +156,7 @@ extern inthand_t IDTVEC(rsvd);
 
 volatile lapic_t *lapic;
 vm_paddr_t lapic_paddr;
+bool lapic_disabled;
 static u_long lapic_timer_divisor;
 static struct eventtimer lapic_et;
 
@@ -1367,9 +1368,10 @@ apic_setup_io(void *dummy __unused)
        if (retval != 0)
                printf("%s: Failed to setup I/O APICs: returned %d\n",
                    best_enum->apic_name, retval);
-#ifdef XEN
-       return;
-#endif
+
+       if (lapic_disabled)
+               return;
+
        /*
         * Finish setting up the local APIC on the BSP once we know how to
         * properly program the LINT pins.
diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c
index 7e45a83..e783bb8 100644
--- a/sys/x86/xen/pv.c
+++ b/sys/x86/xen/pv.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/clock.h>
 #include <machine/pc/bios.h>
 #include <machine/smp.h>
+#include <machine/apicvar.h>
 
 #include <xen/xen-os.h>
 #include <xen/pv.h>
@@ -230,4 +231,6 @@ xen_pv_set_init_ops(void)
 {
        /* Init ops for Xen PV */
        init_ops = xen_init_ops;
+       /* Disable lapic */
+       lapic_disabled = true;
 }
-- 
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.