Subject: port-sparc/13241: mmap problem on Sparcstation 2
To: None <>
From: None <>
List: netbsd-bugs
Date: 06/18/2001 14:35:31
>Number:         13241
>Category:       port-sparc
>Synopsis:       mmap returns no error, when not mapping on a Sparcstation 2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 18 14:29:00 PDT 2001
>Originator:     Cliff Wright
>Release:        NetBSD 1.5
System: NetBSD clone 1.5 NetBSD 1.5 (GENERIC) #1: Wed Nov 29 00:29:52 MET 2000 root@flambard:/usr/src/sys/arch/sparc/compile/GENERIC sparc

	Mozilla .9 was seg faulting on my Sparcstation 2.
	This was due to mmap being used with a large supplied virtual address
	hint, rather than 0 for auto select virtual address,
	and returning success when it did not useably mmap.
	Code that produces the error follows.
	I was told that on the sun4c architecture the MMU's can not access
	addresses in the range 0x1fffffff through 0xe0000000.
	However then I believe mmap should either select a useable address,
	as the supplied address is only a hint, or should return
	an error. Returning a successful mmap when it was not successful
	seems wrong to me.

	Test code that duplicates Mozilla error:

#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/mman.h>

    int fdz;
    void *rv;
    int prot;
    char *vaddr = (char*) 0x50000000;

    fdz = open("/dev/zero",O_RDWR , 0);
    rv = mmap(vaddr, 65536L, prot, MAP_PRIVATE, fdz, 0);

    printf("rv = 0x%0x\n", rv);

    memset(rv, 0, 216);

	I fixed the Mozilla problem by changing
	_PR_STACK_VMBASE 0x50000000 to
	_PR_STACK_VMBASE 0 (i.e. auto select virtual address) in