iommufd: Explicitize struct iommu_hwpt_pgfault padding
PATCH 1/1 iommufd: Explicitize struct iommu_hwpt_pgfault padding
Though the padding could be done by the compiler, add a 32-bit padding explicitly. Also, change the __u64 to __aligned_u64.
pahole result, before:
struct iommu_hwpt_pgfault {
__u32 flags; /* 0 4 */
__u32 dev_id; /* 4 4 */
__u32 pasid; /* 8 4 */
__u32 grpid; /* 12 4 */
__u32 perm; /* 16 4 */ /* XXX 4 bytes hole, try to pack */
__u64 addr; /* 24 8 */
__u32 length; /* 32 4 */
__u32 cookie; /* 36 4 */
/* size: 40, cachelines: 1, members: 8 */
/* sum members: 36, holes: 1, sum holes: 4 */
/* last cacheline: 40 bytes */
};pahole result, after:
struct iommu_hwpt_pgfault {
__u32 flags; /* 0 4 */
__u32 dev_id; /* 4 4 */
__u32 pasid; /* 8 4 */
__u32 grpid; /* 12 4 */
__u32 perm; /* 16 4 */
__u32 __reserved; /* 20 4 */
__u64 addr __attribute__((__aligned__(8))); /* 24 8 */
__u32 length; /* 32 4 */
__u32 cookie; /* 36 4 */ /* size: 40, cachelines: 1, members: 9 */
/* forced alignments: 1 */
/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));--- include/uapi/linux/iommufd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/iommufd.h +3 -1
@@ -868,6 +868,7 @@ enum iommu_hwpt_pgfault_perm {* @pasid: Process Address Space ID * @grpid: Page Request Group Index * @perm: Combination of enum iommu_hwpt_pgfault_perm +* @__reserved: Must be 0. * @addr: Fault address * @length: a hint of how much data the requestor is expecting to fetch. For * example, if the PRI initiator knows it is going to do a 10MB
@@ -883,7 +884,8 @@ struct iommu_hwpt_pgfault {__u32 pasid;__u32 grpid;__u32 perm; -__u64 addr; +__u32 __reserved; +__aligned_u64 addr;__u32 length;__u32 cookie; };
Signature · 1 line
2.34.1
Tian, Kevin
maintainerinclude/uapi/linux/iommufd.h enum iommu_hwpt_pgfault_perm { · line 871
Quoted 8 lines
From: Nicolin Chen <[email protected]>
Sent: Saturday, January 18, 2025 10:37 AMinclude/uapi/linux/iommufd.h +1
-0@@ -868,6 +868,7 @@ enum iommu_hwpt_pgfault_perm {* @pasid: Process Address Space ID * @grpid: Page Request Group Index * @perm: Combination of enum iommu_hwpt_pgfault_perm +* @__reserved: Must be 0.
iommufd_fault_fops_read() doesn't follow this statement as hwpt_fault is on stack with that field uninitialized.
Quoted 11 lines · Kevin
include/uapi/linux/iommufd.h enum iommu_hwpt_pgfault_perm { · line 871
Quoted 8 lines
From: Nicolin Chen <[email protected]>
Sent: Saturday, January 18, 2025 10:37 AMinclude/uapi/linux/iommufd.h +1
-0@@ -868,6 +868,7 @@ enum iommu_hwpt_pgfault_perm {* @pasid: Process Address Space ID * @grpid: Page Request Group Index * @perm: Combination of enum iommu_hwpt_pgfault_perm +* @__reserved: Must be 0.
iommufd_fault_fops_read()doesn't follow this statement ashwpt_faultis on stack with that field uninitialized.
OK. I guess I should update the iommufd_fault_fops_read too.
Thanks
Nic