From owner-freebsd-emulation Tue Apr 27 22: 5:36 1999 Delivered-To: freebsd-emulation@freebsd.org Received: from m4.c2.telstra-mm.net.au (m4.c2.telstra-mm.net.au [24.192.3.19]) by hub.freebsd.org (Postfix) with ESMTP id 51CFF14E89 for ; Tue, 27 Apr 1999 22:05:32 -0700 (PDT) (envelope-from andrew@lake.com.au) Received: from m5.c2.telstra-mm.net.au (m5.c2.telstra-mm.net.au [24.192.3.20]) by m4.c2.telstra-mm.net.au (8.8.6 (PHNE_14041)/8.8.6) with ESMTP id PAA17110 for ; Wed, 28 Apr 1999 15:05:29 +1000 (EST) X-BPC-Relay-Envelope-From: andrew@lake.com.au X-BPC-Relay-Envelope-To: X-BPC-Relay-Sender-Host: m5.c2.telstra-mm.net.au [24.192.3.20] X-BPC-Relay-Info: Message delivered directly. Received: from areilly.bpc-users.org (CPE-24-192-51-95.nsw.bigpond.net.au [24.192.51.95]) by m5.c2.telstra-mm.net.au (8.8.6 (PHNE_14041)/8.8.6) with SMTP id PAA10507 for ; Wed, 28 Apr 1999 15:05:28 +1000 (EST) Received: (qmail 26750 invoked by uid 1000); 28 Apr 1999 05:05:29 -0000 From: "Andrew Reilly" Date: Wed, 28 Apr 1999 15:05:29 +1000 To: Luoqi Chen Cc: andrew@lake.com.au, nox@jelal.kn-bremen.de, freebsd-emulation@FreeBSD.ORG Subject: Re: Wine, Win32 stripped executables vs FreeBSD mmap() Message-ID: <19990428150529.A26340@gurney.reilly.home> References: <199904280141.VAA29678@lor.watermarkgroup.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <199904280141.VAA29678@lor.watermarkgroup.com>; from Luoqi Chen on Tue, Apr 27, 1999 at 09:41:22PM -0400 Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tue, Apr 27, 1999 at 09:41:22PM -0400, Luoqi Chen wrote: > > As a simultaneous expert in Wine and FreeBSD, do you have any > > thoughts on the problem I reported last week: I found that Wine > > could not execute any of my Win32 programs, because the FreeBSD mmap > > system call refused to allocate a block of VM at 0x4000000 for > > the executable. I poked around in /proc a little, and it didn't > > nothing appeared to use virtual addresses lower than 0x8048000. > > Is there some architectural reason for that space to be off > > limmits in FreeBSD? > > > You should be able to mmap at any address in user space (currently address > <0xc0000000). I wrote a test program to map one anonymous page at 0x4000000 > and it worked. What's the errno from the mmap() call? How big is the block > wine tried to allocate? What's the flag argument passed to mmap()? I've done some poking around of my own, with ktrace this time, and found some interesting things. First, to answer your questions: Errno: 0: mmap doesn't think it's failing, it just isn't returning a block with the address we've requested. How big? 0x6b000. The whole call was: mmap(0x400000,0x6b000,7,0x1002,-1,0) which produced the result: 0x28a70000 Those flags are MAP_ANON and MAP_PRIVATE, as I'm sure you know. The poking I did this morning was to try adding MAP_FIXED to the flags, so that at least we'd see an error from the failure. Well, now the map works and I get the address 0x400000 returned. I've added a one-line patch to wine to include this flag: --- work/wine-990214/files/file.c.orig Wed Apr 28 15:00:48 1999 +++ work/wine-990214/files/file.c Wed Apr 28 13:54:08 1999 @@ -1604,6 +1604,7 @@ #ifdef MAP_PRIVATE flags |= MAP_PRIVATE; #endif +/*AR:TRIAL:*/if (start) flags |= MAP_FIXED; /* see if this helps */ } else fd = unix_handle; Well, that has done the trick for me. I can now execute the Win32 assemblers and simulators that I was using before the upgrade, so I'm a happy camper. I'll send the patch to the Wine folk, to see if they want to try it, but if you have any thoughts about why mmap was ignoring my address "hint", I'd be keen to hear them. -- Andrew To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message