From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 2A0E0221DB29A for ; Fri, 29 Dec 2017 02:23:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2017 02:28:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,475,1508828400"; d="scan'208";a="190633459" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 29 Dec 2017 02:28:03 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 29 Dec 2017 02:28:02 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 29 Dec 2017 02:28:01 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Fri, 29 Dec 2017 18:28:00 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" Thread-Topic: [PATCH] MdeModulePkg VarCheckHii: Make sure the bin at required alignment Thread-Index: AQHTgI5ljsUKVFRPS0mvOK29ylg2N6NaHj9Q Date: Fri, 29 Dec 2017 10:28:00 +0000 Message-ID: References: <1514542464-14676-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1514542464-14676-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjgwMjEzYzQtYjI1Mi00OTMzLWI4NjMtZGY2M2EyMWJmOGFjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJUTzhlVDYrTUNJUkZNbXQ0T1NjNnd1WXhqNE12YmJacWVUeUttZllMK2hFQkJqYnRuU1FwTlFlVVl4aDJBNmt3In0= 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 VarCheckHii: 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:23:06 -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:14 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Wang, Jian J ; > Yao, Jiewen > Subject: [PATCH] MdeModulePkg VarCheckHii: 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/VarCheckHiiLib/VarCheckHiiGen.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c > b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c > index c0efed450bfb..0db1383491f7 100644 > --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c > +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c > @@ -1518,6 +1518,10 @@ BuildVarCheckHiiBin ( > // > Data =3D AllocateRuntimeZeroPool (BinSize); > ASSERT (Data !=3D NULL); > + // > + // Make sure the allocated buffer for VarCheckHiiBin at required align= ment. > + // > + ASSERT ((((UINTN) Data) & (HEADER_ALIGNMENT - 1)) =3D=3D 0); > DEBUG ((DEBUG_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); >=20 > // > -- > 2.7.0.windows.1