From owner-freebsd-emulation@FreeBSD.ORG Sat Mar 10 09:38:41 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 D5FD316A406; Sat, 10 Mar 2007 09:38:41 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.176.14]) by mx1.freebsd.org (Postfix) with ESMTP id 77EE313C441; Sat, 10 Mar 2007 09:38:41 +0000 (UTC) (envelope-from xdivac02@stud.fit.vutbr.cz) Received: from eva.fit.vutbr.cz (localhost [127.0.0.1]) by eva.fit.vutbr.cz (envelope-from xdivac02@eva.fit.vutbr.cz) (8.13.8/8.13.7) with ESMTP id l2A9ceog046074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 10 Mar 2007 10:38:40 +0100 (CET) Received: (from xdivac02@localhost) by eva.fit.vutbr.cz (8.13.8/8.13.3/Submit) id l2A9ced2046073; Sat, 10 Mar 2007 10:38:40 +0100 (CET) Date: Sat, 10 Mar 2007 10:38:40 +0100 From: Divacky Roman To: Jung-uk Kim Message-ID: <20070310093840.GA45813@stud.fit.vutbr.cz> References: <790a9fff0610132255k5c3b08fcrb550fa308d31752d@mail.gmail.com> <200703092024.23577.tijl@ulyssis.org> <790a9fff0703091251w6b664efbs55a0d608b7c2f441@mail.gmail.com> <200703091746.06515.jkim@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200703091746.06515.jkim@FreeBSD.org> User-Agent: Mutt/1.4.2.2i X-Scanned-By: MIMEDefang 2.57 on 147.229.176.14 Cc: Alexander Leidinger , freebsd-emulation@freebsd.org, Scot Hetzel , gerald@freebsd.org 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: Sat, 10 Mar 2007 09:38:41 -0000 On Fri, Mar 09, 2007 at 05:46:04PM -0500, Jung-uk Kim wrote: > 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. yes... linux supports 3 GDT entries for TLS we support just 1. And I dont think we will ever be willing to pay the performance price for the ability to run just 1 (one!!!) program more... but as there is native fbsd version of wine I think we'd better spend our time on fixing/improving the native version my two cents roman