emulators/linux-wine: Help in porting to FreeBSD

Jung-uk Kim jkim at FreeBSD.org
Fri Mar 9 22:46:11 UTC 2007


On Friday 09 March 2007 03:51 pm, Scot Hetzel wrote:
> On 3/9/07, Tijl Coosemans <tijl at ulyssis.org> 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


More information about the freebsd-emulation mailing list