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 <[email protected]>
Cc: Monk Liu <[email protected]>
Cc: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
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