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

[Xen-devel] [PATCH v10 13/20] 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 17e957d..cea0306 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -707,7 +707,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_valid)
+               lapic_disable();
 
        /* signal our startup to the BSP. */
        mp_naps++;
@@ -733,7 +734,7 @@ init_secondary(void)
 
        /* A quick check from sanity claus */
        cpuid = PCPU_GET(cpuid);
-       if (PCPU_GET(apic_id) != lapic_id()) {
+       if (lapic_valid && (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));
@@ -749,7 +750,8 @@ init_secondary(void)
        mtx_lock_spin(&ap_boot_mtx);
 
        /* Init local apic for irq's */
-       lapic_setup(1);
+       if (lapic_valid)
+               lapic_setup(1);
 
        /* Set memory range attributes for this CPU to match the BSP */
        mem_range_AP_init();
@@ -764,7 +766,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_valid && 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..c04a238 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_valid;
 
 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..ea8a3c3 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_valid;
 
 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..25b9cfc 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_valid = false;
        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..fddf1fb 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_valid = true;
 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_valid)
+               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 22fd6a6..6ea1e2a 100644
--- a/sys/x86/xen/pv.c
+++ b/sys/x86/xen/pv.c
@@ -53,6 +53,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/hypervisor.h>
@@ -315,4 +316,6 @@ xen_pv_set_init_ops(void)
 {
        /* Init ops for Xen PV */
        init_ops = xen_init_ops;
+       /* Disable lapic */
+       lapic_valid = false;
 }
-- 
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®.