NVMe: compat SG_IO ioctl
Subsystems (2)
PATCH v2 1/1 NVMe: compat SG_IO ioctl
For 32-bit versions of sg3-utils running on a 64-bit system. This is mostly a copy from the relevent portions of fs/compat_ioctl.c, with slight modifications for going through block_device_operations.
---v1->v2:
Added the copying the status back into the 32-bit user structure at the end. I missed this when copying from the original implmenetation.
drivers/block/nvme-core.c | 14 ++++- drivers/block/nvme-scsi.c | 146 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/nvme.h | 1 + 3 files changed, 160 insertions(+), 1 deletion(-)
drivers/block/nvme-core.c +13 -1
@@ -1569,10 +1569,22 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, } } +static int nvme_compat_ioctl (struct block_device *bdev,fmode_t mode, +unsigned int cmd,unsigned long arg) +{ +struct nvme_ns *ns = bdev->bd_disk->private_data; + +switch (cmd) { +case SG_IO : +return nvme_sg_io32 (ns, arg); + } +return nvme_ioctl (bdev, mode, cmd, arg); +} +static const struct block_device_operations nvme_fops = { .owner =THIS_MODULE , .ioctl = nvme_ioctl, - .compat_ioctl = nvme_ioctl, + .compat_ioctl = nvme_compat_ioctl, };static void nvme_resubmit_bios (struct nvme_queue *nvmeq)
drivers/block/nvme-scsi.c +146 -0
164 lines not on this page · raw message
include/linux/nvme.h +1 -0
@@ -165,6 +165,7 @@ int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,struct sg_io_hdr ;int nvme_sg_io (struct nvme_ns *ns,struct sg_io_hdr __user *u_hdr); +int nvme_sg_io32 (struct nvme_ns *ns,unsigned long arg);int nvme_sg_get_version_num (int __user *ip);#endif /* _LINUX_NVME_H */
Signature · 1 line
1.7.10.4
PATCH v2 1/1 NVMe: compat SG_IO ioctl
Quoted 8 lines · Keith Busch
For 32-bit versions of sg3-utils running on a 64-bit system. This is mostly a copy from the relevent portions of
fs/compat_ioctl.c, with slight modifications for going throughblock_device_operations.Signed-off-by Keith Busch <keith.busch at intel.com>---
v1->v2:
Quoted 8 lines
Added the copying the status back into the 32-bit user structure at the end. I missed this when copying from the original implmenetation.
drivers/block/nvme-core.c | 14 ++++- drivers/block/nvme-scsi.c | 146 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/nvme.h | 1 + 3 files changed, 160 insertions(+), 1 deletion(-)
PATCH v2 1/1 NVMe: compat SG_IO ioctl
In reply to Keith BuschQuoted 10 lines · Keith Busch
For 32-bit versions of sg3-utils running on a 64-bit system. This is mostly a copy from the relevent portions of
fs/compat_ioctl.c, with slight modifications for going throughblock_device_operations.Signed-off-by Keith Busch <keith.busch at intel.com>---
v1->v2:Added the copying the status back into the 32-bit user structure at the end. I missed this when copying from the original implmenetation.
Thanks to Fengguang's automated tester, I ended up fixing the !CONFIG_COMPAT case like this:
drivers/block/nvme-core.c +4 -0
@@ -1696,6 +1696,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, } } +#ifdef CONFIG_COMPAT static int nvme_compat_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long arg) {
@@ -1707,6 +1708,9 @@ static int nvme_compat_ioctl(struct block_device *bdev, fmode_t mode, }return nvme_ioctl (bdev, mode, cmd, arg); } +#else +#define nvme_compat_ioctl NULL +#endif static const struct block_device_operations nvme_fops = { .owner =THIS_MODULE ,
drivers/block/nvme-scsi.c +2 -1
@@ -47,7 +47,6 @@#include <linux/types.h> #include <scsi/sg.h> #include <scsi/scsi.h> -#include <asm/compat.h> static int sg_version_num =30534 ;/* 2 digits for each component */
@@ -3040,6 +3039,7 @@ int nvme_sg_io(struct nvme_ns *ns, struct sg_io_hdr __user *u_hdr)return retcode; } +#ifdef CONFIG_COMPAT typedef struct sg_io_hdr32 { compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ compat_int_t dxfer_direction; /* [i] data transfer direction */
@@ -3183,6 +3183,7 @@ int nvme_sg_io32(struct nvme_ns *ns, unsigned long arg) return err; } +#endif int nvme_sg_get_version_num (int __user *ip) {