From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 B1CA6221DB29A for ; Fri, 29 Dec 2017 02:22:53 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2017 02:27:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,475,1508828400"; d="scan'208";a="16380556" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 29 Dec 2017 02:27:50 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 29 Dec 2017 02:27:50 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 29 Dec 2017 02:27:50 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Fri, 29 Dec 2017 18:27:48 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH] MdeModulePkg VarCheckPcd: Make sure the bin at required alignment Thread-Index: AQHTgI5zRKLzOpw9CUSsm0fID5x4eaNaHi1g Date: Fri, 29 Dec 2017 10:27:48 +0000 Message-ID: References: <1514542726-12116-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1514542726-12116-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTRhMDdmYmYtNzc5OC00MzJiLTgwMjYtOWFhMDcyMjFlY2M4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ0UEhCTTMxVzhQOERxOUVHZW1HZ3BHK0hleXVzdXpSMkN5YmNzN0lFV29UNVpZTGczbkV3RlkxbHJzTlFiWU9HIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg VarCheckPcd: Make sure the bin at required alignment X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Dec 2017 10:22:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----Original Message----- > From: Zeng, Star > Sent: Friday, December 29, 2017 6:19 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Wang, Jian J ; > Yao, Jiewen > Subject: [PATCH] MdeModulePkg VarCheckPcd: Make sure the bin at required > alignment >=20 > According to UEFI/PI spec, the AllocateXXXPool() interfaces should > return eight-byte aligned buffer that satisfies the required > HEADER_ALIGNMENT which is 4. >=20 > This patch adds ASSERT to make sure the bin at required alignment, > that can help catch the issue earlier about incorrect aligned buffer > returned from AllocateXXXPool(). >=20 > Cc: Jian J Wang > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.= c > b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c > index 72b0363b1979..d24ee966a44c 100644 > --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c > +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c > @@ -1,7 +1,7 @@ > /** @file > Var Check PCD handler. >=20 > -Copyright (c) 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -435,6 +435,10 @@ LocateVarCheckPcdBin ( > // > mVarCheckPcdBin =3D AllocateRuntimeCopyPool (VarCheckPcdBinSize, > VarCheckPcdBin); > ASSERT (mVarCheckPcdBin !=3D NULL); > + // > + // Make sure the allocated buffer for VarCheckPcdBin at required ali= gnment. > + // > + ASSERT ((((UINTN) mVarCheckPcdBin) & (HEADER_ALIGNMENT - 1)) =3D=3D = 0); > mVarCheckPcdBinSize =3D VarCheckPcdBinSize; > FreePool (VarCheckPcdBin); >=20 > -- > 2.7.0.windows.1