From 65d2d83a7b4fdcfc30fd0c3bb92e84d433544627 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 13 Jan 2022 15:49:10 +0100 Subject: [PATCH] ioctl: Rearrange members in nvme_lockdown_args Avoid any holes in the struct by rearranging the members. Also add the attribute packed to struct definition to reduce ABI breakage. struct nvme_lockdown_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u8 scp; /* 20 1 */ __u8 prhbt; /* 21 1 */ __u8 ifc; /* 22 1 */ __u8 ofi; /* 23 1 */ __u8 uuidx; /* 24 1 */ /* size: 32, cachelines: 1, members: 8 */ /* padding: 1 */ /* last cacheline: 32 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner --- src/nvme/ioctl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index c4481702..18142e79 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -3323,7 +3323,7 @@ struct nvme_capacity_mgmt_args { __u32 cdw12; __u16 element_id; __u8 op; -} __attribute__((__packed__)); +} __attribute__((packed, aligned(__alignof__(__u32*)))); /** * nvme_capacity_mgmt() - @@ -3337,25 +3337,25 @@ int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args); /** * nvme_lockdown_args - Arguments for the NVME Lockdown command * @fd: File descriptor of nvme device + * @result: The command completion result from CQE dword0 + * @timeout: Timeout in ms (0 for default timeout) * @scp: Scope of the command * @prhbt: Prohibit or allow the command opcode or Set Features command * @ifc: Affected interface * @ofi: Opcode or Feature Identifier * @uuid: UUID Index if controller supports this id selection method - * @timeout: Timeout in ms (0 for default timeout) - * @result: The command completion result from CQE dword0 */ struct nvme_lockdown_args { int args_size; int fd; + __u32 *result; + __u32 timeout; __u8 scp; __u8 prhbt; __u8 ifc; __u8 ofi; __u8 uuidx; - __u32 timeout; - __u32 *result; -}; +} __attribute__((__packed__)); /** * nvme_lockdown() - Issue lockdown command -- 2.50.1