Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jul 2013 21:01:13 +0200
From:      =?utf-8?Q?Hans_Petter_Selasky?= <hans.petter.selasky@bitfrost.no>
To:        =?utf-8?Q?Damjan_Jovanovic?= <damjan.jov@gmail.com>
Cc:        =?utf-8?Q?freebsd-usb=40freebsd=2Eorg?= <freebsd-usb@freebsd.org>
Subject:   RE: COMPAT_32BIT libusb ABI problem
Message-ID:  <zarafa.51f175f9.25d7.1ecfc86c5d6b39b6@mail.lockless.no>
In-Reply-To: <CAJm2B-nBTKUw42U_6OkLoYEZg8Fwd9J1zeVwZvgEj5Z_gLscrg@mail.gmail.com>
References:  <CAJm2B-mfidBre0tCwJg=6OirBtdgvxCTrGGVX-3kqQ8vYf1kFw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <damjan.jov@gmail=
=2Ecom <mailto:damjan.jov@gmail.com> >=0D=0A> Sent: Thursday 25th July 20=
13 20:55=0D=0A> To: Hans Petter Selasky <hans.petter.selasky@bitfrost.no =
<mailto:hans.petter.selasky@bitfrost.no> >=0D=0A> Cc: freebsd-usb@freebsd=
=2Eorg <mailto:freebsd-usb@freebsd.org>=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 <hps@bitfrost.no <mailto:hps@bitfrost.no> > 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: <UHCI root HUB Intel> at usbus0, cfg=3D=
0 md=3DHOST spd=3DFULL (12Mbps)=0D=0A> > pwr=3DSAVE (0mA)=0D=0A> > ugen1.=
1: <UHCI root HUB Intel> 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: <owner-freebsd-usb@FreeBSD.ORG>
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 <freebsd-usb.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-usb>,
 <mailto:freebsd-usb-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-usb>;
List-Post: <mailto:freebsd-usb@freebsd.org>
List-Help: <mailto:freebsd-usb-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-usb>,
 <mailto:freebsd-usb-request@freebsd.org?subject=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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?zarafa.51f175f9.25d7.1ecfc86c5d6b39b6>