svn commit: r199253 - in head/sys/amd64: amd64 include

Konstantin Belousov kib at FreeBSD.org
Fri Nov 13 13:07:02 UTC 2009


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 <freebsd levsha org ua>
  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);


More information about the svn-src-all mailing list