From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Zhang, Bokun" <Bokun.Zhang@amd.com>,
"SHANMUGAM, SRINIVASAN" <SRINIVASAN.SHANMUGAM@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Liu, Monk" <Monk.Liu@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Pack VF2PF ucode_info entries to keep struct size 1KB
Date: Fri, 13 Mar 2026 20:16:39 +0530 [thread overview]
Message-ID: <b82116ff-6354-44bf-9a20-e56265eefcda@amd.com> (raw)
In-Reply-To: <DS0PR12MB8813F2DF9593AD35A2D7F03FF445A@DS0PR12MB8813.namprd12.prod.outlook.com>
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
>
prev parent reply other threads:[~2026-03-13 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b82116ff-6354-44bf-9a20-e56265eefcda@amd.com \
--to=lijo.lazar@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Bokun.Zhang@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Monk.Liu@amd.com \
--cc=SRINIVASAN.SHANMUGAM@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox