vfio-mdev: fix non-standard ioctl return val causing i386 build fail
Subsystems (2)
PATCH 1/1 vfio-mdev: fix non-standard ioctl return val causing i386 build fail
What appears to be a copy and paste error from the line above gets the ioctl a ssize_t return value instead of the traditional "int".
The associated sample code used "long" which meant it would compile for x86-64 but not i386, with the latter failing as follows:
CC [M] samples/vfio-mdev/mtty.osamples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl = mtty_ioctl,
^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errors
Use the standard "int" ioctl return value in both the header and the sample code to fix the issue.
--- include/linux/mdev.h | 2 +- samples/vfio-mdev/mtty.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/mdev.h +1 -1
@@ -78,7 +78,7 @@ struct mdev_parent_ops { size_t count, loff_t *ppos);ssize_t (*write)(struct mdev_device *mdev,const char __user *buf,size_t count,loff_t *ppos); -ssize_t (*ioctl)(struct mdev_device *mdev,unsigned int cmd, +int (*ioctl)(struct mdev_device *mdev,unsigned int cmd,unsigned long arg);int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };
samples/vfio-mdev/mtty.c +1 -1
@@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,return 0 ; } -static long mtty_ioctl (struct mdev_device *mdev,unsigned int cmd, +static int mtty_ioctl (struct mdev_device *mdev,unsigned int cmd,unsigned long arg) {int ret =0 ;
Signature · 1 line
2.11.0
Kirti Wankhede
maintainerThanks Paul for catching this.
In that case we should go with 'long' since mdev_parent_ops->ioctl() is called from vfio_device_ops->ioctl() for which the return type is 'long'.
Thanks,
Kirti
Quoted 54 lines · Paul Gortmaker
What appears to be a copy and paste error from the line above gets the ioctl a
ssize_treturn value instead of the traditional "int".The associated sample code used "long" which meant it would compile for x86-64 but not i386, with the latter failing as follows:
CC [M]
samples/vfio-mdev/mtty.osamples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl =mtty_ioctl,^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errorsUse the standard "int" ioctl return value in both the header and the sample code to fix the issue.
Fixes 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")Cc Kirti Wankhede <[email protected]>Cc Neo Jia <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- include/linux/mdev.h | 2 +- samples/vfio-mdev/mtty.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/linux/mdev.h +1
-1@@ -78,7 +78,7 @@ struct mdev_parent_ops { size_t count, loff_t *ppos);ssize_t (*write)(struct mdev_device *mdev,const char __user *buf,size_t count,loff_t *ppos); -ssize_t (*ioctl)(struct mdev_device *mdev,unsigned int cmd, +int (*ioctl)(struct mdev_device *mdev,unsigned int cmd,unsigned long arg);int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };samples/vfio-mdev/mtty.c +1
-1@@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,return 0 ; } -static long mtty_ioctl (struct mdev_device *mdev,unsigned int cmd, +static int mtty_ioctl (struct mdev_device *mdev,unsigned int cmd,unsigned long arg) {int ret =0 ;
Quoted 4 lines · On Wed, 4 Jan 2017 18:06:57 +0530 Kirti Wankhede <[email protected]> wrote:
Thanks Paul for catching this.
In that case we should go with 'long' since
mdev_parent_ops->ioctl()is called fromvfio_device_ops->ioctl()for which the return type is 'long'.
Agreed, we're mirroring the struct file_operations definition of ioctl, so the return should be a long. Thanks,
Alex
Quoted 55 lines · Paul Gortmaker
Quoted 54 lines
What appears to be a copy and paste error from the line above gets the ioctl a
ssize_treturn value instead of the traditional "int".The associated sample code used "long" which meant it would compile for x86-64 but not i386, with the latter failing as follows:
CC [M]
samples/vfio-mdev/mtty.osamples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl =mtty_ioctl,^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errorsUse the standard "int" ioctl return value in both the header and the sample code to fix the issue.
Fixes 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")Cc Kirti Wankhede <[email protected]>Cc Neo Jia <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>--- include/linux/mdev.h | 2 +- samples/vfio-mdev/mtty.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)include/linux/mdev.h +1
-1@@ -78,7 +78,7 @@ struct mdev_parent_ops { size_t count, loff_t *ppos);ssize_t (*write)(struct mdev_device *mdev,const char __user *buf,size_t count,loff_t *ppos); -ssize_t (*ioctl)(struct mdev_device *mdev,unsigned int cmd, +int (*ioctl)(struct mdev_device *mdev,unsigned int cmd,unsigned long arg);int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };samples/vfio-mdev/mtty.c +1
-1@@ -1147,7 +1147,7 @@ int mtty_get_device_info(struct mdev_device *mdev,return 0 ; } -static long mtty_ioctl (struct mdev_device *mdev,unsigned int cmd, +static int mtty_ioctl (struct mdev_device *mdev,unsigned int cmd,unsigned long arg) {int ret =0 ;
PATCH v2 1/1 vfio-mdev: fix non-standard ioctl return val causing i386 build fail
What appears to be a copy and paste error from the line above gets the ioctl a ssize_t return value instead of the traditional "int".
The associated sample code used "long" which meant it would compile for x86-64 but not i386, with the latter failing as follows:
CC [M] samples/vfio-mdev/mtty.osamples/vfio-mdev/mtty.c:1418:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.ioctl = mtty_ioctl,
^
samples/vfio-mdev/mtty.c:1418:20: note: (near initialization for ‘mdev_fops.ioctl’)
cc1: some warnings being treated as errors
Since in this case, vfio is working with struct file_operations; as such:
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);...and so here we just standardize on long vs. the normal int that user space typically sees and documents as per "man ioctl" and similar.
---
[v1 --> v2: promote ioctl return from int to long to align with the
struct file_operations as per requests in review comments. ]
include/linux/mdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mdev.h +1 -1
@@ -78,7 +78,7 @@ struct mdev_parent_ops { size_t count, loff_t *ppos);ssize_t (*write)(struct mdev_device *mdev,const char __user *buf,size_t count,loff_t *ppos); -ssize_t (*ioctl)(struct mdev_device *mdev,unsigned int cmd, +long (*ioctl)(struct mdev_device *mdev,unsigned int cmd,unsigned long arg);int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };
Signature · 1 line
2.11.0