From owner-freebsd-arch@FreeBSD.ORG Thu Oct 7 16:13:44 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAC1A1065673; Thu, 7 Oct 2010 16:13:43 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6293B8FC20; Thu, 7 Oct 2010 16:13:42 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o97GDcjI057941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Oct 2010 19:13:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o97GDcEj089508; Thu, 7 Oct 2010 19:13:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o97GDc00089507; Thu, 7 Oct 2010 19:13:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 7 Oct 2010 19:13:38 +0300 From: Kostik Belousov To: mdf@freebsd.org Message-ID: <20101007161338.GK2392@deviant.kiev.zoral.com.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZccQPJAL46kky/Sq" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: FreeBSD Arch Subject: Re: freebsd32_ioctl.c X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2010 16:13:44 -0000 --ZccQPJAL46kky/Sq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 07, 2010 at 09:05:49AM -0700, mdf@freebsd.org wrote: > I added some more ioctls to those translated by freebsd32_ioctl in my > local tree, and then I started thinking. If we support all the > various drivers as loadable modules, but the ioctl translation is in > the base kernel, that's a lot of code to have for COMPAT_IA32 that may > never get run. It would be nice to keep the ioctl argument munging in > the driver, but while it's not hard to check in the driver's ioctl > function if p_sysent is freebsd32_sysent, the code isn't as clean as a > passthrough function like freebsd32_ioctl(). >=20 > So I was wondering if that would be considered an issue. Should we > just be adding ioctl argument munging as we go along and not worry > about the size? Or is there simple way to keep the munging inside the > driver? Perhaps my making the driver's ioctl look something like: I think that in-driver variant is the best. >=20 > #ifdef COMPAT_IA32 > static int > xxx_ioctl32(struct cdev *dev, u_long com32, caddr_t arg, int flag, > struct thread *td) > { > struct xxx_32 *cmd32 =3D (void *)arg; > struct xxx cmd; > u_long com; > int error; >=20 > CP(*cmd32, cmd, field1); > /* ... */ > error =3D xxx_ioctl(dev, com, &cmd, flag, td); > if (error =3D=3D 0 && (com & IOC_OUT) !=3D 0) { > CP(cmd, *cmd32, field1); > /* ... */ > } > return (error); > } > #endif /* COMPAT_IA32 */ >=20 > static int > xxx_ioctl_devsw(struct cdev *dev, u_long com, caddr_t arg, int flag, > struct thread *td) > { > #ifdef COMPAT_IA32 > if (td->td_proc->p_sysent =3D=3D &ia32_freebsd_sysvec) > return (xxx_ioctl32(dev, com, arg, flag, td)); > #endif > return (xxx_ioctl(dev, com, arg, flag, td); > } >=20 > ... and the check for p_sysent =3D=3D &ia32_freebsd_sysvec should probably > be a more-correct macro. if (SV_CURPROC_FLAG(SV_ILP32)) --ZccQPJAL46kky/Sq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkyt8bEACgkQC3+MBN1Mb4gU0ACeOIZs5hjj+7kK5TwHQrYNAaG/ GMoAoJ7qeI2y9KGHOClUMBopyo93ImrC =mL3O -----END PGP SIGNATURE----- --ZccQPJAL46kky/Sq--