Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 2017 08:12:09 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
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
Message-ID:  <201709220812.v8M8C9Vn019972@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <greg@unrelenting.technology>
  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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709220812.v8M8C9Vn019972>