Subject: Re: Netscape - the plot thickens
To: None <port-sparc@NetBSD.ORG>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: port-sparc
Date: 11/15/1995 21:06:55
>> netscape-2.0beta2[pid 212]: T_RWRET read_rw failed: pc=3a44fc npc=3a4500
>> 	psr=90001081<EF,S>
> 
> This points at a bogus stack pointer.  In fact, ktrace'ing reveals that the
> thing wants to mmap(2) a region of memory at 0x50000000, which is an illegal
> address on small SPARCs but which the VM system does nothing about (this
> has come up before not too long ago).

[If I was really clever, I'd insert a "manydohs.au" audio attachment here]

Doh!!!

When I fixed the beta 1 binary, I only had to change the mmap() flags from
0x12 to 0x2 for SunOS, but I *also* had to change the addr to 0x0 for NetBSD.

When I saw that the beta 2 binary worked on SunOS 4.1.x, I naturally assumed
that they'd fixed the mmap() for good (geez, I *did* tell them about it ... ).
Sigh.  Little did I suspect ...

> The following adb one-liner makes the Illegal instruction go away:
> 
> 	sunos% adb netscape
> 	$W
> 	450628?We0000000
> 	^D

Just out of curiosity; why 0xE0000000 instead of 0x0?  Would this break if it
was on a sun4m?

(I was gonna ask why not just do a "clr %o0" before the mmap(), but of course
 having looked at it your solution of where to make the change is much better.)

Oh ... should probably note that this 0x450628 address is for the DNS-enabled
SunOS Netscape (i.e., "netscape_dns") binary ... the address for the plain
Netscape (i.e., "netscape") binary is 0x44e330.

> We must soup-up the VM system to do the right thing.

How hard would it be to change the VM such that on a SPARC, if it was passed
an address in the VM hole - but without MAP_FIXED set - the code would just
either grab any old address (e.g., like as if 0x0 was passed as the address)
or use this Mysterious 0xE0000000 Magic Address that's not in the hole?

I smell potential "#ifdef sun4c" kludges in vm_mmap.c::mmap(), but maybe
that's why there's a "There should really be a pmap call to determine a 
reasonable location." comment in there already?  :-)

Well, I feel a lot better knowing that Netscape is still merely abusing their
use of mmap() as opposed to having discovered a way to framboozle the register
windows.

Thanks Paul!!!  I owe ya a beer ... or three

	- Greg