From owner-freebsd-current@FreeBSD.ORG Tue Jan 14 15:25:53 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 224F7BC1; Tue, 14 Jan 2014 15:25:53 +0000 (UTC) Received: from SMTP.CITRIX.COM (smtp.citrix.com [66.165.176.89]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9E53910B4; Tue, 14 Jan 2014 15:25:51 +0000 (UTC) X-IronPort-AV: E=Sophos;i="4.95,658,1384300800"; d="scan'208";a="92709294" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 14 Jan 2014 15:25:49 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Tue, 14 Jan 2014 10:25:48 -0500 Received: from gateway-cbg.eng.citrite.net ([10.80.16.17] helo=localhost.localdomain) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W35T6-0006J6-3l; Tue, 14 Jan 2014 14:59:52 +0000 From: Roger Pau Monne To: , , , , , , Subject: [PATCH v10 13/20] xen: introduce flag to disable the local apic Date: Tue, 14 Jan 2014 15:59:35 +0100 Message-ID: <1389711582-66908-14-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.7.7.5 (Apple Git-26) In-Reply-To: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> References: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain X-DLP: MIA2 Cc: Roger Pau Monne X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2014 15:25:53 -0000 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 #include #include +#include @@ -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 #include #include +#include #include #include @@ -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)