From: "Wu, Jiaxin via groups.io" <jiaxin.wu=intel.com@groups.io>
To: "Zhou, Jianfeng" <jianfeng.zhou@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Ni, Ray" <ray.ni@intel.com>, Gerd Hoffmann <kraxel@redhat.com>,
"Liu, Zhiguang" <zhiguang.liu@intel.com>,
"Tan, Dun" <dun.tan@intel.com>,
"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
"Zeng, Star" <star.zeng@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Fix SMRAM memory leak during S3 resume
Date: Wed, 7 May 2025 06:32:25 +0000 [thread overview]
Message-ID: <MN0PR11MB6158D9156F199438F83CCB02FE88A@MN0PR11MB6158.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20250506125059.3343414-1-jianfeng.zhou@intel.com>
It looks good to me, Jianfeng, can you send the PR to the edk2 directly?
Thanks,
Jiaxin
> -----Original Message-----
> From: Zhou, Jianfeng <jianfeng.zhou@intel.com>
> Sent: Tuesday, May 6, 2025 8:51 PM
> To: devel@edk2.groups.io
> Cc: Zhou, Jianfeng <jianfeng.zhou@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Gerd Hoffmann <kraxel@redhat.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Liu,
> Zhiguang <zhiguang.liu@intel.com>; Tan, Dun <dun.tan@intel.com>; Kumar,
> Rahul R <rahul.r.kumar@intel.com>; Zeng, Star <star.zeng@intel.com>; Liming
> Gao <gaoliming@byosoft.com.cn>
> Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Fix SMRAM memory leak
> during S3 resume
>
> SyncContext of SMM_DISPATCHER_MP_SYNC_DATA was dynamically
> allocated from
> SMRAM. The memory was not freed before reallocation in S3 resume path.
> This could lead to:
> 1. Memory leak in SMRAM.
> 2. Potential S3 resume failure after repeated S3 tests due to SMRAM
> exhaustion.
>
> This change releases the SyncContext memory before reallocating it
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Dun Tan <dun.tan@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Zhou Jianfeng <jianfeng.zhou@intel.com>
>
> Signed-off-by: Zhou Jianfeng <jianfeng.zhou@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index b19906b610..7bc68087ad 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1868,6 +1868,10 @@ InitializeMpSyncData (
> UINTN CpuIndex;
>
> if (mSmmMpSyncData != NULL) {
> + if (mSmmMpSyncData->SyncContext != NULL) {
> + SmmCpuSyncContextDeinit (mSmmMpSyncData->SyncContext);
> + }
> +
> //
> // mSmmMpSyncDataSize includes one structure of
> SMM_DISPATCHER_MP_SYNC_DATA, one
> // CpuData array of SMM_CPU_DATA_BLOCK and one CandidateBsp array
> of BOOLEAN.
> @@ -1968,6 +1972,7 @@ InitializeMpServiceData (
> mSmmMpSyncData = (SMM_DISPATCHER_MP_SYNC_DATA *)AllocatePages
> (EFI_SIZE_TO_PAGES (mSmmMpSyncDataSize));
> ASSERT (mSmmMpSyncData != NULL);
>
> + ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize);
> RelaxedMode = FALSE;
> GetSmmCpuSyncConfigData (&RelaxedMode, NULL, NULL);
> mCpuSmmSyncMode = RelaxedMode ? MmCpuSyncModeRelaxedAp :
> MmCpuSyncModeTradition;
> --
> 2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121316): https://edk2.groups.io/g/devel/message/121316
Mute This Topic: https://groups.io/mt/112647890/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2025-05-07 6:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 12:50 [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Fix SMRAM memory leak during S3 resume Zhou Jianfeng via groups.io
2025-05-07 6:32 ` Wu, Jiaxin via groups.io [this message]
2025-05-07 6:35 ` Zhou Jianfeng via groups.io
-- strict thread matches above, loose matches on Subject: below --
2025-05-06 12:48 Zhou Jianfeng via groups.io
2025-05-06 12:42 Zhou Jianfeng via groups.io
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-list 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=MN0PR11MB6158D9156F199438F83CCB02FE88A@MN0PR11MB6158.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/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