Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c9b5265 authored by Matthew Wilcox's avatar Matthew Wilcox
Browse files

NVMe: Fix endian-related problems in user I/O submission path



When constructing the command, dsmgmt needs to be treated as a 32-bit
value, not a 16-bit value.  reftag, apptag and appmask all need to be
converted from native-endian to little-endian.  Again, sparse's bitwise
warnings caught this problem.  Thanks to Keith for pointing out the
correct way to fix the reftag.

Signed-off-by: default avatarMatthew Wilcox <matthew.r.wilcox@intel.com>
Acked-by: default avatarKeith Busch <keith.busch@intel.com>
parent af2d9ca7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1166,10 +1166,10 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
	c.rw.slba = cpu_to_le64(io.slba);
	c.rw.length = cpu_to_le16(io.nblocks);
	c.rw.control = cpu_to_le16(io.control);
	c.rw.dsmgmt = cpu_to_le16(io.dsmgmt);
	c.rw.reftag = io.reftag;
	c.rw.apptag = io.apptag;
	c.rw.appmask = io.appmask;
	c.rw.dsmgmt = cpu_to_le32(io.dsmgmt);
	c.rw.reftag = cpu_to_le32(io.reftag);
	c.rw.apptag = cpu_to_le16(io.apptag);
	c.rw.appmask = cpu_to_le16(io.appmask);
	/* XXX: metadata */
	length = nvme_setup_prps(dev, &c.common, iod, length, GFP_KERNEL);

+2 −2
Original line number Diff line number Diff line
@@ -207,11 +207,11 @@ struct nvme_common_command {
	__u8			flags;
	__u16			command_id;
	__le32			nsid;
	__u32			cdw2[2];
	__le32			cdw2[2];
	__le64			metadata;
	__le64			prp1;
	__le64			prp2;
	__u32			cdw10[6];
	__le32			cdw10[6];
};

struct nvme_rw_command {