public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Wu, Hao A" <hao.a.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned
Date: Tue, 18 Apr 2017 06:52:23 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A92DACB@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170418023652.21128-2-hao.a.wu@intel.com>

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



  reply	other threads:[~2017-04-18  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-04-18  7:56     ` Zeng, Star

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=74D8A39837DF1E4DA445A8C0B3885C503A92DACB@shsmsx102.ccr.corp.intel.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