Subject: kern/12440: [rkb] UBC winsize -> winshift change confuses MIPS PMAPs
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rafal@mediaone.net>
List: netbsd-bugs
Date: 03/20/2001 14:11:38
>Number:         12440
>Category:       kern
>Synopsis:       MIPS PMAPs mis-size kernel map, can't map UBC window(s)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 20 11:13:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        -current of 3/19/01 CVS updated ~ 7pm EST
>Organization:
Highly unlikely
>Environment:
System: NetBSD cyclops.metatel.office 1.5S NetBSD 1.5S (CYCLOPS.4MB) #20: Mon Mar 12 01:58:37 EST 2001 rafal@cyclops.metatel.office:/extra/src-current/sys/arch/i386/compile/CYCLOPS.4MB i386

Builder Architecture: i386
Builder Machine: i386

Target Architecture: mips
Target Machine: sgimips

>Description:
It seems this is related to the change from `ubc_winsize' to `ubc_winshift'.
The MIPS pmap module sizes the virtual space (in pmap_bootstrap()) as 
follows:

        start = VM_MIN_KERNEL_ADDRESS;
        end   = VM_MIN_KERNEL_ADDRESS + Sysmapsize * NBPG;

    where:
        Sysmapsize = (VM_PHYS_SIZE + ubc_nwins * ubc_winsize + 
                nbuf * MAXBSIZE + 16 * NCARGS + PAGER_MAP_SIZE) / NBPG + 
                (maxproc * UPAGES) + nkmempages;

*However*, when Sysmapsize is calculated, `ucb_winsize' has still not been
initialized (and hence is still zero), as it's not set until ubc_init(), 
which runs much, much later.

>How-To-Repeat:
Boot a (SGI)MIPS kernel, watch it complain about not being able to map the 
UBC window.

>Fix:
I imagine the easiest thing is to just initialize ubc_winsize from 
ubc_winshift in uvm_bio.c... Was this not done for some reason other
than forgetting to do it or overlooking it?

While we're at it, we should probably export ubc_winshift as well as
ubc_winsize to UVM's consumers.  The first patch is the critical bit,
the second is icing on the cake.

Index: uvm_bio.c
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_bio.c,v
retrieving revision 1.11
diff -b -u -r1.11 uvm_bio.c
--- uvm_bio.c	2001/03/19 00:29:04	1.11
+++ uvm_bio.c	2001/03/20 19:03:25
@@ -106,7 +106,7 @@
 
 int ubc_nwins = UBC_NWINS;
 int ubc_winshift = UBC_WINSHIFT;
-int ubc_winsize;
+int ubc_winsize = 1 << UBC_WINSHIFT;
 #ifdef PMAP_PREFER
 int ubc_nqueues;
 boolean_t ubc_release_unmap = FALSE;
Index: uvm_param.h
===================================================================
RCS file: /cvsroot/syssrc/sys/uvm/uvm_param.h,v
retrieving revision 1.6
diff -b -u -r1.6 uvm_param.h
--- uvm_param.h	2001/03/15 06:10:58	1.6
+++ uvm_param.h	2001/03/20 19:03:25
@@ -146,6 +146,7 @@
 extern psize_t		mem_size;	/* size of physical memory (bytes) */
 extern int		ubc_nwins;	/* number of UBC mapping windows */
 extern int		ubc_winsize;	/* size of a UBC mapping window */
+extern int		ubc_winshift;	/* size of a UBC mapping window */
 
 #else
 /* out-of-kernel versions of round_page and trunc_page */
>Release-Note:
>Audit-Trail:
>Unformatted: