From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1213B21954060 for ; Tue, 18 Apr 2017 00:57:33 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 18 Apr 2017 00:57:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,218,1488873600"; d="scan'208";a="78372452" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 18 Apr 2017 00:57:32 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Apr 2017 00:57:31 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Apr 2017 00:57:31 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Tue, 18 Apr 2017 15:56:46 +0800 From: "Zeng, Star" To: "Yao, Jiewen" , "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned Thread-Index: AQHSuBBgJxkiV7b2pkuly3AKWRJRnqHKwGjg Date: Tue, 18 Apr 2017 07:56:46 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B87BA40@shsmsx102.ccr.corp.intel.com> References: <20170418023652.21128-1-hao.a.wu@intel.com> <20170418023652.21128-2-hao.a.wu@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A92DACB@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A92DACB@shsmsx102.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be 8-byte aligned X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2017 07:57:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Good comments. I plan to send the patch for https://bugzilla.tianocore.org/show_bug.cgi?id= =3D407 this week. Since the patch for https://bugzilla.tianocore.org/show_bug.cgi?id=3D407 ca= n 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 ; 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 t= o catch buffer overflow https://bugzilla.tianocore.org/show_bug.cgi?id=3D40= 7 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 ; Yao, Jiewen > Subject: [PATCH v2 1/1] MdeModulePkg/PiSmmCore: Pad POOL_HEADER to be=20 > 8-byte aligned >=20 > According to the PI spec (Vol 4, Section 3.2 SmmAllocatePool()): > The SmmAllocatePool() function ... All allocations are eight-byte aligned= . >=20 > The commit adds a padding field in structure 'POOL_HEADER' to ensure=20 > the above requirement is met. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 8 ++++++++ > 1 file changed, 8 insertions(+) >=20 > 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=20 > + should // be 8-byte aligned. Here, the pad bytes make sure that the=20 > + structure // is 8-byte aligned: > + // For IA32, sizeof (POOL_HEADER) is 16. > + // For X64, sizeof (POOL_HEADER) is 24. > + // > + UINT32 Padding; > } POOL_HEADER; >=20 > typedef struct { > -- > 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel