AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB
@ 2026-03-12 12:51 Srinivasan Shanmugam
  2026-03-13 14:16 ` Zhang, Bokun
  0 siblings, 1 reply; 3+ messages in thread
From: Srinivasan Shanmugam @ 2026-03-12 12:51 UTC (permalink / raw)
  To: Christian König, Alex Deucher
  Cc: amd-gfx, Srinivasan Shanmugam, Bokun Zhang, Monk Liu

The VF2PF mailbox structure must be exactly 1KB, which is enforced by
a compile-time static assertion.

The ucode_info array currently uses a small struct containing:

  uint8_t id
  uint32_t version

Without explicit packing, the compiler may insert padding after the
uint8_t field so that the uint32_t field starts at a 4-byte aligned
address. For example, the layout may become:

  id (1 byte) + 3 bytes padding + version (4 bytes)

which makes the struct 8 bytes instead of the expected 5 bytes.

Since the structure contains multiple ucode_info entries, this padding
can increase the total structure size beyond 1024 bytes and cause the
1KB size check to fail.

Define the ucode_info entry as a packed struct to ensure each entry
remains 5 bytes and the VF2PF mailbox structure stays exactly 1KB.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h:510:49: error: static assertion failed: "amd_sriov_msg_vf2pf_info must be 1 KB"

Fixes: 1721bc1b2afa ("drm/amdgpu: Update VF2PF interface")
Cc: Bokun Zhang <Bokun.Zhang@amd.com>
Cc: Monk Liu <monk.liu@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
index 847cfd1fd004..31fc54111519 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
@@ -328,6 +328,11 @@ struct amd_sriov_msg_vf2pf_info_header {
 	uint32_t reserved[2];
 };
 
+struct amd_sriov_msg_ucode_info {
+	u8 id;
+	u32 version;
+} __packed;
+
 #define AMD_SRIOV_MSG_VF2PF_INFO_FILLED_SIZE (73)
 struct amd_sriov_msg_vf2pf_info {
 	/* header contains size and version */
@@ -367,10 +372,7 @@ struct amd_sriov_msg_vf2pf_info {
 	uint32_t fb_vis_size;
 	uint32_t fb_size;
 	/* guest ucode data, each one is 1.25 Dword */
-	struct {
-		uint8_t id;
-		uint32_t version;
-	} ucode_info[AMD_SRIOV_MSG_RESERVE_UCODE];
+	struct amd_sriov_msg_ucode_info ucode_info[AMD_SRIOV_MSG_RESERVE_UCODE];
 	uint64_t dummy_page_addr;
 	/* FB allocated for guest MES to record UQ info */
 	uint64_t mes_info_addr;
-- 
2.34.1


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

end of thread, other threads:[~2026-03-13 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 12:51 [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB Srinivasan Shanmugam
2026-03-13 14:16 ` Zhang, Bokun
2026-03-13 14:46   ` Lazar, Lijo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox