From owner-freebsd-emulation@FreeBSD.ORG Fri Mar 9 22:46:10 2007 Return-Path: X-Original-To: freebsd-emulation@FreeBSD.org Delivered-To: freebsd-emulation@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF98516A405; Fri, 9 Mar 2007 22:46:10 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from anuket.mj.niksun.com (gwnew.niksun.com [65.115.46.162]) by mx1.freebsd.org (Postfix) with ESMTP id 7AA5E13C4A7; Fri, 9 Mar 2007 22:46:10 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from niksun.com (anuket [10.70.0.5]) by anuket.mj.niksun.com (8.13.6/8.13.6) with ESMTP id l29Mk923041326; Fri, 9 Mar 2007 17:46:09 -0500 (EST) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-emulation@FreeBSD.org Date: Fri, 9 Mar 2007 17:46:04 -0500 User-Agent: KMail/1.6.2 References: <790a9fff0610132255k5c3b08fcrb550fa308d31752d@mail.gmail.com> <200703092024.23577.tijl@ulyssis.org> <790a9fff0703091251w6b664efbs55a0d608b7c2f441@mail.gmail.com> In-Reply-To: <790a9fff0703091251w6b664efbs55a0d608b7c2f441@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200703091746.06515.jkim@FreeBSD.org> X-Virus-Scanned: ClamAV 0.88.6/2788/Fri Mar 9 13:27:23 2007 on anuket.mj.niksun.com X-Virus-Status: Clean Cc: Scot Hetzel , gerald@FreeBSD.org, Alexander Leidinger Subject: Re: emulators/linux-wine: Help in porting to FreeBSD X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2007 22:46:11 -0000 On Friday 09 March 2007 03:51 pm, Scot Hetzel wrote: > On 3/9/07, Tijl Coosemans wrote: > > This is a problem with the FreeBSD mmap. > > > > * The wine executable is loaded at 0x7bf00000. > > * It reserves 0x00000000-0x60000000 and 0x80000000-(stack). > > * Then a couple dlls are dlopen'ed (ntdll,kernel32,...). > > * This fails because the freebsd mmap, when called without > > MAP_FIXED and NULL for the addr argument, looks for free space > > after the executable + maximum possible data segment (to preserve > > space for brk(2) style allocations). The default maximum data > > segment size is 512MiB, so mmap is looking for free space well > > beyond 0x80000000 which isn't there. > > > > In current you could work around this by setting > > kern.maxdsiz="8M" or so in /boot/loader.conf, but that probably > > causes problems for programs that use brk(2). A better solutions > > would be to create a wrapper program that reduces the data > > segment size with setrlimit(2) and then runs wine with execv(3). > > Thanks for the hint, I didn't find kern.maxdsiz in the sysctl tree, > but I did find 2 other maxdsiz settings. > > hp010# sysctl -a | grep maxdsiz > compat.ia32.maxdsiz: 536870912 > compat.linux32.maxdsiz: 536870912 > > hp010# /compat/linux/usr/bin/wineprefixcreate > wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to > map segment from shared object: Cannot allocate memory > > hp010# /compat/linux/usr/bin/wine --version > wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to > map segment from shared object: Cannot allocate memory > > Changing only compat.linux32.maxdsiz to 8M, allowed > wineprefixcreate to run without giving the above error, but instead > resulted in a core dump. ---- CUT!!! --- Segmentation. Wine seems to (ab)use set_thread_area() (to set up special GDT entry), %fs, and %gs to emulate Windows kernel. I am sorry to tell you this but there is no way that we can get that fixed unless we give up performance, i.e., for every context switch, we have to save and restore three segment registers, their corresponding base addresses and GDT entries. I have implemented set_thread_area() for amd64 but that is just not enough to support Wine. Jung-uk Kim