From owner-freebsd-usb@FreeBSD.ORG Thu Jul 25 19:01:13 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 BED76E13 for ; Thu, 25 Jul 2013 19:01:13 +0000 (UTC) (envelope-from hans.petter.selasky@bitfrost.no) Received: from mta.bitpro.no (mta.bitpro.no [92.42.64.202]) by mx1.freebsd.org (Postfix) with ESMTP id 2CF3D2A0F for ; Thu, 25 Jul 2013 19:01:13 +0000 (UTC) Received: from mail.lockless.no (mail.lockless.no [46.29.221.38]) by mta.bitpro.no (Postfix) with ESMTP id B1B9E7A1E5; Thu, 25 Jul 2013 21:01:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id 049D08F0091; Thu, 25 Jul 2013 21:01:15 +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 jwOa7KrISQuI; Thu, 25 Jul 2013 21:01:14 +0200 (CEST) Received: from mail.lockless.no (localhost [127.0.0.1]) by mail.lockless.no (Postfix) with ESMTP id F2B5C8F008F; Thu, 25 Jul 2013 21:01:13 +0200 (CEST) Subject: RE: COMPAT_32BIT libusb ABI problem From: =?utf-8?Q?Hans_Petter_Selasky?= To: =?utf-8?Q?Damjan_Jovanovic?= Date: Thu, 25 Jul 2013 21:01:13 +0200 Mime-Version: 1.0 In-Reply-To: References: X-Priority: 3 (Normal) X-Mailer: Zarafa 7.1.4-41394 Message-Id: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: =?utf-8?Q?freebsd-usb=40freebsd=2Eorg?= 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 19:01:13 -0000 Hi,=0D=0A=0D=0ALibUSB 32-bit is compiled using -m32 in a 64-bit environme= nt. What happens when you pass -m32 to the compiler=3F=0D=0A=0D=0AThank y= ou for your report.=0D=0A=0D=0AAnother alternative is to use __packed att= ribute, but that has some implications too.=0D=0A=0D=0A--HPS=0D=0A=20=0D=0A= -----Original message-----=0D=0A> From:Damjan Jovanovic >=0D=0A> Sent: Thursday 25th July 20= 13 20:55=0D=0A> To: Hans Petter Selasky >=0D=0A> Cc: freebsd-usb@freebsd= =2Eorg =20=0D=0A> Subject: Re: COMPAT_32B= IT libusb ABI problem=0D=0A>=20=0D=0A> On Thu, Jul 25, 2013 at 6:11 AM, H= ans Petter Selasky > wrote:=0D=0A= > > On 07/24/13 22:09, Damjan Jovanovic wrote:=0D=0A> >>=0D=0A> >> Hi=0D=0A= > >>=0D=0A> >> The ioctl:=0D=0A> >> #define USB_FS_INIT _IOW = ('U', 195, struct usb_fs_init)=0D=0A> >> when used by a COMPAT_32BIT libu= sb on amd64, fails (causing=0D=0A> >> libusb_open() to fail) due to:=0D=0A= > >>=0D=0A> >> freebsd32_ioctl(0x6,0x800c55c3,0xffffc710,0x0,0x0,0x0) ERR= #25=0D=0A> >> 'Inappropriate ioctl for device'=0D=0A> >> but when hacked = a bit:=0D=0A> >> freebsd32_ioctl(0x6,0x801055c3,0xffffc710,0x0,0x0,0x0) =3D= 0 (0x0)=0D=0A> >>=0D=0A> >> because sizeof(struct usb_fs_init) is 12 byt= es on i386, and 16 bytes on=0D=0A> >> amd64.=0D=0A> >>=0D=0A> >> But the = failure of even libusb_open() - a fundamental libusb function=0D=0A> >> -= must mean that the COMPAT_32BIT libusb never worked. Can we please=0D=0A= > >> take this opportunity to kill it and do a real 32 bit compatibility=0D= =0A> >> layer in the kernel that will work from 32 bit chroots and static= ally=0D=0A> >> linked 32 bit binaries=3F I'll help.=0D=0A> >=0D=0A> >=0D=0A= > > Hi,=0D=0A> >=0D=0A> > How did you compile it=3F Is the structure the = same size, compiled with GCC=0D=0A> > and LLVM=3F=0D=0A>=20=0D=0A> GCC 4.= 2.1=0D=0A> "gcc file.c -o file -lusb" in a 32 bit chroot =3D 12 bytes=0D=0A= > "gcc file.c -o file -lusb" 64 bit =3D 16 bytes=0D=0A>=20=0D=0A> Clang 3= =2E1=0D=0A> "clang file.c -o file -lusb" in a 32 bit chroot =3D 12 bytes=0D= =0A> "clang file.c -o file -lusb" 64 bit =3D 16 bytes=0D=0A>=20=0D=0A> Th= e "uint8_t ep_index_max" field at the end of struct usb_fs_init must=0D=0A= > be getting padded to a 4 byte boundary on 32 bit, and 8 byte boundary=0D= =0A> on 64 bit.=0D=0A>=20=0D=0A> > The LIB32 for USB has been tested. I d= id a quick test and found on 9-stable:=0D=0A> >=0D=0A> > cc -m32 -I . -L = /usr/lib32 -lusb usbconfig.c dump.c=0D=0A> > env LD_PRELOAD=3D/usr/lib32/= libusb.so ./a.out=0D=0A> > ugen0.1: at usbus0, cfg=3D= 0 md=3DHOST spd=3DFULL (12Mbps)=0D=0A> > pwr=3DSAVE (0mA)=0D=0A> > ugen1.= 1: at usbus1, cfg=3D0 md=3DHOST spd=3DFULL (12Mbps)= =0D=0A> > pwr=3DSAVE (0mA)=0D=0A> >=0D=0A> > ...=0D=0A>=20=0D=0A> But usb= config uses the libusb20 API and never seems to get to that broken ioctl.= =0D=0A>=20=0D=0A> > Your approach requires much more code. It is not just= about some structures,=0D=0A> > but also about code accessing those stru= ctures. Feel free to submit a patch=0D=0A> > however.=0D=0A>=20=0D=0A> I'= ll see what I can do.=0D=0A>=20=0D=0A> > I would rather fix this by addin= g the proper __aligned() to the structures=0D=0A> > in question.=0D=0A>=20= =0D=0A> Do that in the meanwhile=3F=0D=0A>=20=0D=0A> > --HPS=0D=0A> >=0D=0A= >=20=0D=0A> Damjan=0D=0A>=20=0D=0A=0D=0A From owner-freebsd-usb@FreeBSD.ORG Fri Jul 26 02:03:11 2013 Return-Path: Delivered-To: freebsd-usb@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 14292360; Fri, 26 Jul 2013 02:03:11 +0000 (UTC) (envelope-from linimon@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DAEDE2BDF; Fri, 26 Jul 2013 02:03:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r6Q23AU3089500; Fri, 26 Jul 2013 02:03:10 GMT (envelope-from linimon@freefall.freebsd.org) Received: (from linimon@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r6Q23Axa089499; Fri, 26 Jul 2013 02:03:10 GMT (envelope-from linimon) Date: Fri, 26 Jul 2013 02:03:10 GMT Message-Id: <201307260203.r6Q23Axa089499@freefall.freebsd.org> To: linimon@FreeBSD.org, freebsd-bugs@FreeBSD.org, freebsd-usb@FreeBSD.org From: linimon@FreeBSD.org Subject: Re: usb/180837: [scsi_da] [patch] Kingston DT 101 G2 usb stick quirk (scsi_da quirk) 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: Fri, 26 Jul 2013 02:03:11 -0000 Old Synopsis: QUIRK: Kingston DT 101 G2 usb stick (scsi_da quirk) New Synopsis: [scsi_da] [patch] Kingston DT 101 G2 usb stick quirk (scsi_da quirk) Responsible-Changed-From-To: freebsd-bugs->freebsd-usb Responsible-Changed-By: linimon Responsible-Changed-When: Fri Jul 26 02:02:33 UTC 2013 Responsible-Changed-Why: Over to maintainer(s). http://www.freebsd.org/cgi/query-pr.cgi?pr=180837