* [PATCH v2 0/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned @ 2017-04-18 2:36 Hao Wu 2017-04-18 2:36 ` [PATCH v2 1/1] " Hao Wu 0 siblings, 1 reply; 4+ messages in thread From: Hao Wu @ 2017-04-18 2:36 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Jiewen Yao V2 changes: Add comments for the purpose of the newly added 'Padding' field in structure 'POOL_HEADER'. Cc: Jiewen Yao <jiewen.yao@intel.com> Hao Wu (1): MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned 2017-04-18 2:36 [PATCH v2 0/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned Hao Wu @ 2017-04-18 2:36 ` Hao Wu 2017-04-18 6:52 ` Yao, Jiewen 0 siblings, 1 reply; 4+ messages in thread From: Hao Wu @ 2017-04-18 2:36 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Jiewen Yao According to the PI spec (Vol 4, Section 3.2 SmmAllocatePool()): The SmmAllocatePool() function ... All allocations are eight-byte aligned. The commit adds a padding field in structure 'POOL_HEADER' to ensure the above requirement is met. Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> --- MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h index c12805a2dd..0692661114 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h @@ -1200,6 +1200,14 @@ typedef struct { UINTN Size; BOOLEAN Available; EFI_MEMORY_TYPE Type; + // + // According to the PI spec, buffers allocated by SmmAllocatePool should + // be 8-byte aligned. Here, the pad bytes make sure that the structure + // is 8-byte aligned: + // For IA32, sizeof (POOL_HEADER) is 16. + // For X64, sizeof (POOL_HEADER) is 24. + // + UINT32 Padding; } POOL_HEADER; typedef struct { -- 2.12.0.windows.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned 2017-04-18 2:36 ` [PATCH v2 1/1] " Hao Wu @ 2017-04-18 6:52 ` Yao, Jiewen 2017-04-18 7:56 ` Zeng, Star 0 siblings, 1 reply; 4+ messages in thread From: Yao, Jiewen @ 2017-04-18 6:52 UTC (permalink / raw) To: Wu, Hao A, edk2-devel@lists.01.org Thanks, this is better. I recall that I have submitted a bugzillar before to enhance Smm FreePool to catch buffer overflow https://bugzilla.tianocore.org/show_bug.cgi?id=407 Maybe we can use below structure, then we do not need PAD. typedef struct { // Proposal for SMM core UINT32 Signature; BOOLEAN Available; EFI_MEMORY_TYPE Type; UINTN Size; } POOL_HEADER; This is also similar to DXE version: typedef struct { // Current DXE core UINT32 Signature; UINT32 Reserved; EFI_MEMORY_TYPE Type; UINTN Size; CHAR8 Data[1]; } POOL_HEAD; Thank you Yao Jiewen > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, April 18, 2017 10:37 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be > 8-byte aligned > > According to the PI spec (Vol 4, Section 3.2 SmmAllocatePool()): > The SmmAllocatePool() function ... All allocations are eight-byte aligned. > > The commit adds a padding field in structure 'POOL_HEADER' to ensure the > above requirement is met. > > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > index c12805a2dd..0692661114 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > @@ -1200,6 +1200,14 @@ typedef struct { > UINTN Size; > BOOLEAN Available; > EFI_MEMORY_TYPE Type; > + // > + // According to the PI spec, buffers allocated by SmmAllocatePool should > + // be 8-byte aligned. Here, the pad bytes make sure that the structure > + // is 8-byte aligned: > + // For IA32, sizeof (POOL_HEADER) is 16. > + // For X64, sizeof (POOL_HEADER) is 24. > + // > + UINT32 Padding; > } POOL_HEADER; > > typedef struct { > -- > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned 2017-04-18 6:52 ` Yao, Jiewen @ 2017-04-18 7:56 ` Zeng, Star 0 siblings, 0 replies; 4+ messages in thread From: Zeng, Star @ 2017-04-18 7:56 UTC (permalink / raw) To: Yao, Jiewen, Wu, Hao A, edk2-devel@lists.01.org; +Cc: Zeng, Star Good comments. I plan to send the patch for https://bugzilla.tianocore.org/show_bug.cgi?id=407 this week. Since the patch for https://bugzilla.tianocore.org/show_bug.cgi?id=407 can naturally fix the alignment issue, so we can skip this patch. Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yao, Jiewen Sent: Tuesday, April 18, 2017 2:52 PM To: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org Subject: Re: [edk2] [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned Thanks, this is better. I recall that I have submitted a bugzillar before to enhance Smm FreePool to catch buffer overflow https://bugzilla.tianocore.org/show_bug.cgi?id=407 Maybe we can use below structure, then we do not need PAD. typedef struct { // Proposal for SMM core UINT32 Signature; BOOLEAN Available; EFI_MEMORY_TYPE Type; UINTN Size; } POOL_HEADER; This is also similar to DXE version: typedef struct { // Current DXE core UINT32 Signature; UINT32 Reserved; EFI_MEMORY_TYPE Type; UINTN Size; CHAR8 Data[1]; } POOL_HEAD; Thank you Yao Jiewen > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, April 18, 2017 10:37 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be > 8-byte aligned > > According to the PI spec (Vol 4, Section 3.2 SmmAllocatePool()): > The SmmAllocatePool() function ... All allocations are eight-byte aligned. > > The commit adds a padding field in structure 'POOL_HEADER' to ensure > the above requirement is met. > > Cc: Jiewen Yao <jiewen.yao@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu <hao.a.wu@intel.com> > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > index c12805a2dd..0692661114 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > @@ -1200,6 +1200,14 @@ typedef struct { > UINTN Size; > BOOLEAN Available; > EFI_MEMORY_TYPE Type; > + // > + // According to the PI spec, buffers allocated by SmmAllocatePool > + should // be 8-byte aligned. Here, the pad bytes make sure that the > + structure // is 8-byte aligned: > + // For IA32, sizeof (POOL_HEADER) is 16. > + // For X64, sizeof (POOL_HEADER) is 24. > + // > + UINT32 Padding; > } POOL_HEADER; > > typedef struct { > -- > 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-18 7:57 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-04-18 2:36 [PATCH v2 0/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned Hao Wu 2017-04-18 2:36 ` [PATCH v2 1/1] " Hao Wu 2017-04-18 6:52 ` Yao, Jiewen 2017-04-18 7:56 ` Zeng, Star
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox