From owner-freebsd-usb@FreeBSD.ORG Thu Jul 25 06:10:03 2013 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A1CBFCCD for ; Thu, 25 Jul 2013 06:10:03 +0000 (UTC) (envelope-from hps@bitfrost.no) Received: from mta.bitpro.no (mta.bitpro.no [92.42.64.202]) by mx1.freebsd.org (Postfix) with ESMTP id 325712ED0 for ; Thu, 25 Jul 2013 06:10:03 +0000 (UTC) Received: from mail.lockless.no (mail.lockless.no [46.29.221.38]) by mta.bitpro.no (Postfix) with ESMTP id 4BD297A13D; Thu, 25 Jul 2013 08:10:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id 7CE4F8EFEB1; Thu, 25 Jul 2013 08:10:05 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at lockless.no Received: from mail.lockless.no ([127.0.0.1]) by localhost (mail.lockless.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FT-nldVygX7W; Thu, 25 Jul 2013 08:10:04 +0200 (CEST) Received: from laptop015.hselasky.homeunix.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) by mail.lockless.no (Postfix) with ESMTPSA id 8F9828EFEAF; Thu, 25 Jul 2013 08:10:04 +0200 (CEST) Message-ID: <51F0C193.4000104@bitfrost.no> Date: Thu, 25 Jul 2013 08:11:31 +0200 From: Hans Petter Selasky Organization: Bitfrost A/S User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130522 Thunderbird/17.0.6 MIME-Version: 1.0 To: Damjan Jovanovic Subject: Re: COMPAT_32BIT libusb ABI problem References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jul 2013 06:10:03 -0000 On 07/24/13 22:09, Damjan Jovanovic wrote: > Hi > > The ioctl: > #define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init) > when used by a COMPAT_32BIT libusb on amd64, fails (causing > libusb_open() to fail) due to: > > freebsd32_ioctl(0x6,0x800c55c3,0xffffc710,0x0,0x0,0x0) ERR#25 > 'Inappropriate ioctl for device' > but when hacked a bit: > freebsd32_ioctl(0x6,0x801055c3,0xffffc710,0x0,0x0,0x0) = 0 (0x0) > > because sizeof(struct usb_fs_init) is 12 bytes on i386, and 16 bytes on amd64. > > But the failure of even libusb_open() - a fundamental libusb function > - must mean that the COMPAT_32BIT libusb never worked. Can we please > take this opportunity to kill it and do a real 32 bit compatibility > layer in the kernel that will work from 32 bit chroots and statically > linked 32 bit binaries? I'll help. Hi, How did you compile it? Is the structure the same size, compiled with GCC and LLVM? The LIB32 for USB has been tested. I did a quick test and found on 9-stable: cc -m32 -I . -L /usr/lib32 -lusb usbconfig.c dump.c env LD_PRELOAD=/usr/lib32/libusb.so ./a.out ugen0.1: at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA) ugen1.1: at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA) ... Your approach requires much more code. It is not just about some structures, but also about code accessing those structures. Feel free to submit a patch however. I would rather fix this by adding the proper __aligned() to the structures in question. --HPS