From owner-svn-src-all@freebsd.org Fri Sep 22 08:12:10 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 69229E1DB9A; Fri, 22 Sep 2017 08:12:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 423418372C; Fri, 22 Sep 2017 08:12:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8M8C9tr019975; Fri, 22 Sep 2017 08:12:09 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8M8C9Vn019972; Fri, 22 Sep 2017 08:12:09 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201709220812.v8M8C9Vn019972@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 22 Sep 2017 08:12:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323910 - in head/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src sys X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys: compat/linuxkpi/common/include/linux compat/linuxkpi/common/src sys X-SVN-Commit-Revision: 323910 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 22 Sep 2017 08:12:10 -0000 Author: hselasky Date: Fri Sep 22 08:12:08 2017 New Revision: 323910 URL: https://svnweb.freebsd.org/changeset/base/323910 Log: Add support for 32-bit compatibility IOCTLs in the LinuxKPI. Bump the FreeBSD version to force recompilation of external kernel modules due to structure change. PR: 222504 Submitted by: Greg V MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h head/sys/compat/linuxkpi/common/src/linux_compat.c head/sys/sys/param.h Modified: head/sys/compat/linuxkpi/common/include/linux/fs.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/fs.h Fri Sep 22 07:44:36 2017 (r323909) +++ head/sys/compat/linuxkpi/common/include/linux/fs.h Fri Sep 22 08:12:08 2017 (r323910) @@ -137,6 +137,7 @@ struct file_operations { ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); unsigned int (*poll) (struct file *, struct poll_table_struct *); long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); + long (*compat_ioctl)(struct file *, unsigned int, unsigned long); int (*mmap)(struct file *, struct vm_area_struct *); int (*open)(struct inode *, struct file *); int (*release)(struct inode *, struct file *); @@ -157,7 +158,6 @@ struct file_operations { int (*readdir)(struct file *, void *, filldir_t); int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long); - long (*compat_ioctl)(struct file *, unsigned int, unsigned long); int (*flush)(struct file *, fl_owner_t id); int (*fsync)(struct file *, struct dentry *, int datasync); int (*aio_fsync)(struct kiocb *, int datasync); Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Fri Sep 22 07:44:36 2017 (r323909) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Fri Sep 22 08:12:08 2017 (r323910) @@ -906,7 +906,20 @@ linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t /* fetch user-space pointer */ data = *(void **)data; } - if (filp->f_op->unlocked_ioctl) +#if defined(__amd64__) + if (td->td_proc->p_elf_machine == EM_386) { + /* try the compat IOCTL handler first */ + if (filp->f_op->compat_ioctl != NULL) + error = -filp->f_op->compat_ioctl(filp, cmd, (u_long)data); + else + error = ENOTTY; + + /* fallback to the regular IOCTL handler, if any */ + if (error == ENOTTY && filp->f_op->unlocked_ioctl != NULL) + error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data); + } else +#endif + if (filp->f_op->unlocked_ioctl != NULL) error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data); else error = ENOTTY; Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Fri Sep 22 07:44:36 2017 (r323909) +++ head/sys/sys/param.h Fri Sep 22 08:12:08 2017 (r323910) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200045 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200046 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,