From owner-svn-src-all@FreeBSD.ORG Sat Oct 16 09:40:18 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6961A106564A; Sat, 16 Oct 2010 09:40:18 +0000 (UTC) (envelope-from hselasky@freebsd.org) Received: from swip.net (mailfe04.swip.net [212.247.154.97]) by mx1.freebsd.org (Postfix) with ESMTP id 5C46E8FC0C; Sat, 16 Oct 2010 09:40:16 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=gl0LPzB4YDQuuzpDoHYit7deEV0cOo++Sg28kyvF6vg= c=1 sm=1 a=JDvfM8UUrIYA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=6I5d2MoRAAAA:8 a=0lmskw69dS5j8ZysOG4A:9 a=bKm1Q0e_LByfRHvquksA:7 a=pcbShyqzeheGKVouiTlebcqnCLAA:4 a=PUjeQqilurYA:10 a=kRdFP4orv5aoMcEBSJwA:9 a=zkbzQjI9Bv3q3-CZc9UA:7 a=7z1EF6CxapNonKvoKVYfRoHaFMMA:4 a=wPNLvfGTeEIA:10 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe04.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 35905655; Sat, 16 Oct 2010 11:40:15 +0200 Received-SPF: softfail receiver=mailfe04.swip.net; client-ip=188.126.198.129; envelope-from=hselasky@freebsd.org From: Hans Petter Selasky To: Kostik Belousov Date: Sat, 16 Oct 2010 11:41:31 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.1-STABLE; KDE/4.4.5; amd64; ; ) References: <201010142038.o9EKcImV036360@svn.freebsd.org> <20101016081237.GR2392@deviant.kiev.zoral.com.ua> In-Reply-To: <20101016081237.GR2392@deviant.kiev.zoral.com.ua> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_MNXuMe5sUEJ+naY" Message-Id: <201010161141.32116.hselasky@freebsd.org> Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , Andrew Thompson Subject: Re: svn commit: r213852 - in head: lib/libusb sys/dev/usb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Oct 2010 09:40:18 -0000 --Boundary-00=_MNXuMe5sUEJ+naY Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit On Saturday 16 October 2010 10:12:37 Kostik Belousov wrote: > On Thu, Oct 14, 2010 at 08:38:18PM +0000, Hans Petter Selasky wrote: > > Author: hselasky > > Date: Thu Oct 14 20:38:18 2010 > > New Revision: 213852 > > URL: http://svn.freebsd.org/changeset/base/213852 > > > > Log: > > - Add support for LibUSB in 32-bit compatibility mode. > > > > Approved by: thompsa (mentor) > > > > Modified: > > head/lib/libusb/Makefile > > head/lib/libusb/libusb20.c > > head/lib/libusb/libusb20_int.h > > head/lib/libusb/libusb20_ugen20.c > > head/sys/dev/usb/usb_ioctl.h > > > > Modified: head/lib/libusb/Makefile > > ========================================================================= > > ===== --- head/lib/libusb/Makefile Thu Oct 14 20:31:07 2010 (r213851) > > +++ head/lib/libusb/Makefile Thu Oct 14 20:38:18 2010 (r213852) > > @@ -30,5 +30,9 @@ SRCS+= libusb10.c > > > > SRCS+= libusb10_desc.c > > SRCS+= libusb10_io.c > > > > +.if defined(COMPAT_32BIT) > > +CFLAGS+= -DCOMPAT_32BIT > > +.endif > > + > > > > .include > > The support is provided in a way that contradicts the established practice > of doing 32-bit compat. Very nice that the support is provided, thank you > for care about it. But, can it be changed so that the kernel emulates > 32-bit ABI instead of library conforming to the kernel ABI ? The short answer is yes, but it adds much more code than in the existing approach, with regard to USB. It is not all about IOCTL's it is also about shared memory layout. The existing approach means: You need to compile /usr/lib32/ and use that with the 32-bit binaries. I.E. I want to have the 32->64 bit conversion in user-space, hence as per implementation in the kernel, there are no pointer mappings involved. It is simply a matter of zero-extending the pointer variable from 32-bit to 64-bit. > > For COMPAT32, we aim in making the system where 32bit binaries and > libraries just work on the 64bit host. Your change does not allow to take > 32bit host into jail and run it on 64bit kernel, as example. USB has some shared memory structures which are used in both user-land and kernel, which are not part of IOCTLs. Your approach means that there are two sets of IOCTL's of all kinds, one for 32-bit and one for 64-bit? > > Please see numerous examples of ioctl translations under > #ifdef COMPAT_FREEBSD32 on how it is done. Please find attached a patch to fix libusbhid world breakage. Sorry about that. I will do some more checing and see if more is broken. I will commit this as soon as I get a go. --HPS --Boundary-00=_MNXuMe5sUEJ+naY Content-Type: text/plain; charset="ISO-8859-1"; name="050.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="050.txt" ==== Patch <050.txt> level 1 Source: [No source] Target: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f:/head/lib/libusbhid:208023 [mirrored] (svn+ssh://hselasky@svn.freebsd.org/base) Log: Fix worldbuild breakage. === Makefile ================================================================== --- Makefile (revision 208023) +++ Makefile (patch 050.txt level 1) @@ -19,4 +19,8 @@ INCS= usbhid.h +.if defined(COMPAT_32BIT) +CFLAGS+= -DCOMPAT_32BIT +.endif + .include === descr.c ================================================================== --- descr.c (revision 208023) +++ descr.c (patch 050.txt level 1) @@ -103,7 +103,7 @@ memset(&ugd, 0, sizeof(ugd)); /* get actual length first */ - ugd.ugd_data = NULL; + ugd.ugd_data = hid_pass_ptr(NULL); ugd.ugd_maxlen = 65535; if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { #ifdef HID_COMPAT7 @@ -124,7 +124,7 @@ return (NULL); /* fetch actual descriptor */ - ugd.ugd_data = data; + ugd.ugd_data = hid_pass_ptr(data); ugd.ugd_maxlen = ugd.ugd_actlen; if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { /* could not read descriptor */ @@ -133,7 +133,7 @@ } /* check END_COLLECTION */ - if (((unsigned char *)ugd.ugd_data)[ugd.ugd_actlen -1] != 0xC0) { + if (((unsigned char *)data)[ugd.ugd_actlen -1] != 0xC0) { /* invalid end byte */ free(data); return (NULL); === usbvar.h ================================================================== --- usbvar.h (revision 208023) +++ usbvar.h (patch 050.txt level 1) @@ -29,6 +29,9 @@ * */ +#ifndef _USBVAR_H_ +#define _USBVAR_H_ + struct report_desc { uint32_t size; uint8_t data[1]; @@ -41,3 +44,11 @@ int hid_get_report_id_compat7(int fd); report_desc_t hid_get_report_desc_compat7(int fd); #endif + +#ifdef COMPAT_32BIT +#define hid_pass_ptr(ptr) ((uint64_t)(uintptr_t)(ptr)) +#else +#define hid_pass_ptr(ptr) (ptr) +#endif + +#endif /* _USBVAR_H_ */ --Boundary-00=_MNXuMe5sUEJ+naY--