From owner-freebsd-arch@FreeBSD.ORG Thu Oct 7 16:05:52 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 36912106566B for ; Thu, 7 Oct 2010 16:05:52 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id E7A318FC25 for ; Thu, 7 Oct 2010 16:05:51 +0000 (UTC) Received: by gxk8 with SMTP id 8so4824gxk.13 for ; Thu, 07 Oct 2010 09:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=RKk85lpFkIqeHIqm6sXquHEQL29SasW30Tm8rZEwm40=; b=V+xuCXuVv+b+mhf0Lgwn0OS4nKk+iZCpOj+eqB3VxP1iqRnFYAYmvQol9Kv7yCDrLS 4GpNNfPzFF3RgScOJ0lKYMm4LyG/w8oQZWD6InHbKIVxKYgTy5nZQK6dyHnr8FbhyMSz QhPXV9XnxZ6pqDbCiGcnZqwGB3NF87RAQr1i4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=VayxxdBeHiPJxxSLLdkBSZUHSze39DtIkFxM57d1fpzM2HIC5+96ZzwsOkxu4k2FE0 2v4mFbMKbe4+vV0LzATHtmPc/YQp1eJ0L02uqqjIeM8nkkfs0mvybFuMAV0D1znHgYJG hIiQiY4Q+EuZVHbNCsRjJlBCOkgajUL3MA9dU= MIME-Version: 1.0 Received: by 10.231.170.21 with SMTP id b21mr1055132ibz.122.1286467549725; Thu, 07 Oct 2010 09:05:49 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.231.142.76 with HTTP; Thu, 7 Oct 2010 09:05:49 -0700 (PDT) Date: Thu, 7 Oct 2010 09:05:49 -0700 X-Google-Sender-Auth: W0cxDvvSpn2AVW3eIs3ipvqMqls Message-ID: From: mdf@FreeBSD.org To: FreeBSD Arch Content-Type: text/plain; charset=ISO-8859-1 Subject: 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:05:52 -0000 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(). 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: #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 = (void *)arg; struct xxx cmd; u_long com; int error; CP(*cmd32, cmd, field1); /* ... */ error = xxx_ioctl(dev, com, &cmd, flag, td); if (error == 0 && (com & IOC_OUT) != 0) { CP(cmd, *cmd32, field1); /* ... */ } return (error); } #endif /* COMPAT_IA32 */ 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 == &ia32_freebsd_sysvec) return (xxx_ioctl32(dev, com, arg, flag, td)); #endif return (xxx_ioctl(dev, com, arg, flag, td); } ... and the check for p_sysent == &ia32_freebsd_sysvec should probably be a more-correct macro. Thanks, matthew