From owner-freebsd-emulation@FreeBSD.ORG Mon Oct 24 12:27:52 2011 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4793B106566B; Mon, 24 Oct 2011 12:27:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1E7578FC08; Mon, 24 Oct 2011 12:27:52 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id B5CF446B0D; Mon, 24 Oct 2011 08:27:51 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 52A0B8A02E; Mon, 24 Oct 2011 08:27:51 -0400 (EDT) From: John Baldwin To: freebsd-amd64@freebsd.org Date: Mon, 24 Oct 2011 07:42:10 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110617; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201110240742.10896.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 24 Oct 2011 08:27:51 -0400 (EDT) Cc: freebsd-emulation@freebsd.org Subject: Re: 32-bit binaries (e.g. wine) and 64-bit kernel structures 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: Mon, 24 Oct 2011 12:27:52 -0000 On Sunday, October 23, 2011 7:04:51 pm Li-Lun "Leland" Wang wrote: > Hi, > > Although I only encounter this kind of problem when running wine > (because it is one of the few ports that need to compile into 32-bit), > it is a problem of i386 binaries on x64 FreeBSD in general. > > The problem that I'm running into recently is > http://bugs.winehq.org/show_bug.cgi?id=28857 . > In short, wine recently implemented GetUdpTable() for Mac OS and BSD. > It uses sysctlbyname() to get net.inet.udp.pcblist, and parses it into > xinpgen structures. However, the size of xinpgen is different on i386 > and x64. As a result, when I run applications that call > GetUdpTable(), the kernel supplies wine with 64-bit structures, while > wine expects 32-bit structures, and crashes. They decided that this > is a FreeBSD bug rather than a wine bug, and that the kernel or LD > should know a 32-bit binary is being run and return proper structures, > as is done in Mac OS. > > xinpgen is not the only structure of wrong sizes for 32-bit binaries > on x64. A while ago I was trying to make my usb gamepad work on wine > using the ugen device. libusbhid uses ioctl to get the > usb_gen_descriptor structure, which is also of different sizes on i386 > and x64. I had to manually "pad" the pointers to 64-bit and build a > custom libusbhid for it to work. > > As it stands, they will probably not fix GetUdpTable() on wine side, > and any windows applications that uses GetUdpTable() will not run > properly in wine on FreeBSD x64. Do we have plans to fix this kind of > problems in general? Although wine port on FreeBSD is only supported > for ARCH=i386, could there be workarounds? Fixing this problem generically is very hard. Instead, we have patched individual sysctls and ioctls on a case-by-case basis. I do think newer interfaces often opt to use fixed-size types so that the structure is the same for both 32-bit and 64-bit, but that will not work for existing interfaces. -- John Baldwin