From: Daniel Wagner Date: Mon, 31 Jan 2022 08:17:50 +0000 (+0100) Subject: ioctl: Fix struct nvme_get_log_args memberm alignment X-Git-Tag: v1.0-rc2~3^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f1af770aa33e2dcce122d2b5903b5fce35b2f6d4;p=users%2Fsagi%2Flibnvme.git ioctl: Fix struct nvme_get_log_args memberm alignment Commit 781b9105cc43 ("nvme: Add Media Unit Status log page(LID: 0x10)") placed the domid member between two u8 members. The access domid member would not be 16 bit aligned which is caused problems on certain architectures. Let's fix the aligemnt by moving domid before lsp. This give us following layout struct nvme_get_log_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ enum nvme_cmd_get_log_lid lid; /* 20 4 */ __u64 lpo; /* 24 8 */ void * log; /* 32 8 */ __u32 len; /* 40 4 */ __u32 nsid; /* 44 4 */ enum nvme_csi csi; /* 48 4 */ __u16 lsi; /* 52 2 */ __u16 domid; /* 54 2 */ __u8 lsp; /* 56 1 */ __u8 uuidx; /* 57 1 */ _Bool rae; /* 58 1 */ _Bool ot; /* 59 1 */ /* size: 64, cachelines: 1, members: 16 */ /* padding: 4 */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner --- diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 0dca0e3b..f0ad3db6 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -1122,9 +1122,9 @@ static inline int nvme_zns_identify_ctrl(int fd, struct nvme_zns_id_ctrl *id) * @len: Length of provided user buffer to hold the log data in bytes * @nsid: Namespace identifier, if applicable * @csi: Command set identifier, see &enum nvme_csi for known values - * @lsp: Log specific field * @lsi: Endurance group information * @domid: Domain Identifier selection, if supported + * @lsp: Log specific field * @uuidx: UUID selection, if supported * @rae: Retain asynchronous events * @ot: Offset Type; if set @lpo specifies the index into the list @@ -1143,8 +1143,8 @@ struct nvme_get_log_args { __u32 nsid; enum nvme_csi csi; __u16 lsi; - __u8 lsp; __u16 domid; + __u8 lsp; __u8 uuidx; bool rae; bool ot; @@ -1175,8 +1175,8 @@ static inline int nvme_get_nsid_log(int fd, bool rae, .nsid = nsid, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1318,8 +1318,8 @@ static inline int nvme_get_log_cmd_effects(int fd, enum nvme_csi csi, .nsid = NVME_NSID_ALL, .csi = csi, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1365,8 +1365,8 @@ static inline int nvme_get_log_create_telemetry_host(int fd, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_TELEM_HOST_LSP_CREATE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_TELEM_HOST_LSP_CREATE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1402,8 +1402,8 @@ static inline int nvme_get_log_telemetry_host(int fd, __u64 offset, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_TELEM_HOST_LSP_RETAIN, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_TELEM_HOST_LSP_RETAIN, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1434,8 +1434,8 @@ static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1474,8 +1474,8 @@ static inline int nvme_get_log_endurance_group(int fd, __u16 endgid, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = endgid, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1506,8 +1506,8 @@ static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = nvmsetid, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1535,8 +1535,8 @@ static inline int nvme_get_log_predictable_lat_event(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1576,8 +1576,8 @@ static int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = lsp, .domid = NVME_DOMID_NONE, + .lsp = lsp, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1619,8 +1619,8 @@ static inline int nvme_get_log_lba_status(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1648,8 +1648,8 @@ static inline int nvme_get_log_endurance_grp_evt(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1699,8 +1699,8 @@ static inline int nvme_get_log_boot_partition(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1737,8 +1737,8 @@ static inline int nvme_get_log_discovery(int fd, bool rae, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1769,8 +1769,8 @@ static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = domid, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1836,8 +1836,8 @@ static inline int nvme_get_log_zns_changed_zones(int fd, __u32 nsid, bool rae, .nsid = nsid, .csi = NVME_CSI_ZNS, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = rae, .ot = false, @@ -1868,8 +1868,8 @@ static inline int nvme_get_log_persistent_event(int fd, .nsid = NVME_NSID_ALL, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_LSP_NONE, .domid = NVME_DOMID_NONE, + .lsp = NVME_LOG_LSP_NONE, .uuidx = NVME_UUID_NONE, .rae = false, .ot = false,