linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* nvme_passthru_cmd64 has a 4 byte hole
@ 2019-10-30  4:43 Charles Machalow
  2019-10-30  6:32 ` Keith Busch
  0 siblings, 1 reply; 4+ messages in thread
From: Charles Machalow @ 2019-10-30  4:43 UTC (permalink / raw)
  To: linux-nvme

Hey all,

I noticed (via some debug) that nvme_passthru_cmd64 seems to have a 4
byte hole that isn't currently accounted for in the struct:
From pahole:

struct nvme_passthru_cmd64 {
        __u8                       opcode;               /*     0     1 */
        __u8                       flags;                /*     1     1 */
        __u16                      rsvd1;                /*     2     2 */
        __u32                      nsid;                 /*     4     4 */
        __u32                      cdw2;                 /*     8     4 */
        __u32                      cdw3;                 /*    12     4 */
        __u64                      metadata;             /*    16     8 */
        __u64                      addr;                 /*    24     8 */
        __u32                      metadata_len;         /*    32     4 */
        __u32                      data_len;             /*    36     4 */
        __u32                      cdw10;                /*    40     4 */
        __u32                      cdw11;                /*    44     4 */
        __u32                      cdw12;                /*    48     4 */
        __u32                      cdw13;                /*    52     4 */
        __u32                      cdw14;                /*    56     4 */
        __u32                      cdw15;                /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        __u32                      timeout_ms;           /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        __u64                      result;               /*    72     8 */

        /* size: 80, cachelines: 2, members: 18 */
        /* sum members: 76, holes: 1, sum holes: 4 */
        /* last cacheline: 16 bytes */
};

(Since I doubt we can functionally change the structure at this
point...) can we add a second rsvd field to mark that hole? ...
something like this:

struct nvme_passthru_cmd64 {
__u8 opcode;
__u8 flags;
__u16 rsvd1;
__u32 nsid;
__u32 cdw2;
__u32 cdw3;
__u64 metadata;
__u64 addr;
__u32 metadata_len;
__u32 data_len;
__u32 cdw10;
__u32 cdw11;
__u32 cdw12;
__u32 cdw13;
__u32 cdw14;
__u32 cdw15;
__u32 timeout_ms;
__u32 rsvd2;
__u64 result;
};

I believe this is binary compatible with the current
nvme_passthru_cmd64, but may help people avoid nonobvious issues in
working with both nvme_passthru_cmd and nvme_passthru_cmd64 in the
same code base. (Since I originally thought I could just use the cmd64
struct for both the old/new ioctls, and then for the old ioctls just
take 32 bits of the result... not realizing there is an extra 32 bits
of implicit padding)

If this makes sense, I'd be happy to do a formal patch request. Just
trying to feel the waters first.

- Charlie Scott Machalow

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-31  2:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30  4:43 nvme_passthru_cmd64 has a 4 byte hole Charles Machalow
2019-10-30  6:32 ` Keith Busch
2019-10-30 14:08   ` Charles Machalow
2019-10-31  2:56     ` Charles Machalow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).