* [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
* Re: [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB
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
0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Bokun @ 2026-03-13 14:16 UTC (permalink / raw)
To: SHANMUGAM, SRINIVASAN, Koenig, Christian, Deucher, Alexander
Cc: amd-gfx@lists.freedesktop.org, Liu, Monk
[-- Attachment #1: Type: text/plain, Size: 3393 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Hey there,
Thank you for the change, but this header is already packed.
#pragma pack(push, 1) // PF2VF / VF2PF data areas are byte packed
...
#pragma pack(pop) // Restore previous packing option
Please check these 2 macros.
The header mush also match across platforms, so we prefer do not change it.
Thanks!
________________________________
From: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Sent: Thursday, March 12, 2026 8:51 AM
To: Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>; Zhang, Bokun <Bokun.Zhang@amd.com>; Liu, Monk <Monk.Liu@amd.com>
Subject: [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB
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
[-- Attachment #2: Type: text/html, Size: 7085 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB
2026-03-13 14:16 ` Zhang, Bokun
@ 2026-03-13 14:46 ` Lazar, Lijo
0 siblings, 0 replies; 3+ messages in thread
From: Lazar, Lijo @ 2026-03-13 14:46 UTC (permalink / raw)
To: Zhang, Bokun, SHANMUGAM, SRINIVASAN, Koenig, Christian,
Deucher, Alexander
Cc: amd-gfx@lists.freedesktop.org, Liu, Monk
On 13-Mar-26 7:46 PM, Zhang, Bokun wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> Hey there,
> Thank you for the change, but this header is already packed.
> *#pragma pack(push, 1) *// PF2VF / VF2PF data areas are byte packed
> ...
> *#pragma pack(pop) *// Restore previous packing option
> Please check these 2 macros.
> The header mush also match across platforms, so we prefer do not
> change it.
>
A related discussion -
https://lists.freedesktop.org/archives/amd-gfx/2023-June/094818.html
<quoted from related discussion>
https://lore.kernel.org/linux-sparse/CAHk-=wi7jGZ+bVbt-UfXOkpEQdHzF3Z2HBjkGdjh8q4dvPPGWQ@mail.gmail.com/
Thanks,
Lijo
> Thanks!
>
> ------------------------------------------------------------------------
> *From:* Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
> *Sent:* Thursday, March 12, 2026 8:51 AM
> *To:* Koenig, Christian <Christian.Koenig@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>
> *Cc:* amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>;
> SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>; Zhang, Bokun
> <Bokun.Zhang@amd.com>; Liu, Monk <Monk.Liu@amd.com>
> *Subject:* [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep
> struct size 1KB
>
> 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 [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