From owner-svn-src-head@FreeBSD.ORG Fri Nov 13 13:07:02 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 676DE106566B; Fri, 13 Nov 2009 13:07:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 548FF8FC0C; Fri, 13 Nov 2009 13:07:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nADD72CY066977; Fri, 13 Nov 2009 13:07:02 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nADD72Gi066975; Fri, 13 Nov 2009 13:07:02 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200911131307.nADD72Gi066975@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 13 Nov 2009 13:07:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199253 - in head/sys/amd64: amd64 include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Nov 2009 13:07:02 -0000 Author: kib Date: Fri Nov 13 13:07:01 2009 New Revision: 199253 URL: http://svn.freebsd.org/changeset/base/199253 Log: Amd64 init_secondary() calls initializecpu() while curthread is still not properly set up. r199067 added the call to TUNABLE_INT_FETCH() to initializecpu() that results in hang because AP are started when kernel environment is already dynamic and thus needs to acquire mutex, that is too early in AP start sequence to work. Extract the code that should be executed only once, because it sets up global variables, from initializecpu() to initializecpucache(), and call the later only from hammer_time() executed on BSP. Now, TUNABLE_INT_FETCH() is done only once at BSP at the early boot stage. In collaboration with: Mykola Dzham Reviewed by: jhb Tested by: ed, battlez Modified: head/sys/amd64/amd64/initcpu.c head/sys/amd64/amd64/machdep.c head/sys/amd64/include/md_var.h Modified: head/sys/amd64/amd64/initcpu.c ============================================================================== --- head/sys/amd64/amd64/initcpu.c Fri Nov 13 11:54:52 2009 (r199252) +++ head/sys/amd64/amd64/initcpu.c Fri Nov 13 13:07:01 2009 (r199253) @@ -163,6 +163,11 @@ initializecpu(void) CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) >= 0xf) init_via(); +} + +void +initializecpucache() +{ /* * CPUID with %eax = 1, %ebx returns Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Fri Nov 13 11:54:52 2009 (r199252) +++ head/sys/amd64/amd64/machdep.c Fri Nov 13 13:07:01 2009 (r199253) @@ -1663,6 +1663,7 @@ hammer_time(u_int64_t modulep, u_int64_t identify_cpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ + initializecpucache(); /* make an initial tss so cpu can get interrupt stack on syscall! */ common_tss[0].tss_rsp0 = thread0.td_kstack + \ Modified: head/sys/amd64/include/md_var.h ============================================================================== --- head/sys/amd64/include/md_var.h Fri Nov 13 11:54:52 2009 (r199252) +++ head/sys/amd64/include/md_var.h Fri Nov 13 13:07:01 2009 (r199253) @@ -89,6 +89,7 @@ void gs_load_fault(void) __asm(__STRING( void dump_add_page(vm_paddr_t); void dump_drop_page(vm_paddr_t); void initializecpu(void); +void initializecpucache(void); void fillw(int /*u_short*/ pat, void *base, size_t cnt); void fpstate_drop(struct thread *td); int is_physical_memory(vm_paddr_t addr);