From luoqi@luoqi.watermarkgroup.com  Thu Jan  8 01:27:10 1998
Received: from luoqi.watermarkgroup.com (luoqi.watermarkgroup.com [207.202.73.170])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id BAA26047
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 8 Jan 1998 01:27:03 -0800 (PST)
          (envelope-from luoqi@luoqi.watermarkgroup.com)
Received: (from luoqi@localhost)
	by luoqi.watermarkgroup.com (8.8.8/8.8.8) id EAA04228;
	Thu, 8 Jan 1998 04:26:52 GMT
	(envelope-from luoqi)
Message-Id: <199801080426.EAA04228@luoqi.watermarkgroup.com>
Date: Thu, 8 Jan 1998 04:26:52 GMT
From: Luoqi Chen <luoqi@luoqi.watermarkgroup.com>
Reply-To: luoqi@luoqi.watermarkgroup.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: page fault during proc0 init & fix
X-Send-Pr-Version: 3.2

>Number:         5458
>Category:       kern
>Synopsis:       page fault in proc0_init() & fix
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan  8 14:33:17 PST 1998
>Closed-Date:    Sat Apr 11 10:24:17 PDT 1998
>Last-Modified:  Sat Apr 11 10:24:34 PDT 1998
>Originator:     Luoqi Chen
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
The Watermark Group
>Environment:

	UP kernel cvsupped as of 1/7/1998

>Description:

	When pmap_pinit0() allocates a page for proc0's page
	directory, kernal page table may need to be extended.
	But while growing the kernel page table (pmap_growkernel()),
	newly allocated kernel page table pages are entered into
	every process' page directory. For proc0, the page
	directory is not allocated yet, and results in a page fault.
	Eventually, the machine panics with "lockmgr: not holding
	exclusive lock".

>How-To-Repeat:

	Not sure.

>Fix:
	
	In init_main.c:proc0_init(), move the call to pmap_pinit0()
	two lines up, right before proc0->p_vmspace is set. Because
	vmspace is not set, proc0 will be skipped when growing
	kernel page table.

Index: init_main.c
===================================================================
RCS file: /fun/cvs/src/sys/kern/init_main.c,v
retrieving revision 1.79
diff -u -r1.79 init_main.c
--- init_main.c	1997/12/14 02:10:12	1.79
+++ init_main.c	1998/01/08 07:14:29
@@ -399,9 +399,9 @@
 	limit0.p_refcnt = 1;
 
 	/* Allocate a prototype map so we have something to fork. */
+	pmap_pinit0(&vmspace0.vm_pmap);
 	p->p_vmspace = &vmspace0;
 	vmspace0.vm_refcnt = 1;
-	pmap_pinit0(&vmspace0.vm_pmap);
 	vm_map_init(&vmspace0.vm_map, round_page(VM_MIN_ADDRESS),
 	    trunc_page(VM_MAXUSER_ADDRESS), TRUE);
 	vmspace0.vm_map.pmap = &vmspace0.vm_pmap;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sat Apr 11 10:24:17 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
