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.115; helo=mga14.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 6A2122238B59C for ; Thu, 25 Jan 2018 19:57:50 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 20:03:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,415,1511856000"; d="scan'208";a="169253228" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 25 Jan 2018 20:03:19 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Jan 2018 20:03:19 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Jan 2018 20:03:18 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Fri, 26 Jan 2018 12:01:51 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be multiples of 1KB Thread-Index: AQHTlli8mU18RZ+SVEaoIyAwN3MMJ6OFiAsA Date: Fri, 26 Jan 2018 04:01:50 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AA97C23@shsmsx102.ccr.corp.intel.com> References: <1516938591-9856-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1516938591-9856-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWYxZGUwMDctMmU3MS00NTcyLTkwZjQtZGJmZTg1YTBkNDYyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJjNFgwN3hkMVk3YjQ2RGV4YjRnU0FTcFlQRlwvVFY0eFZnUVJqa3VXS0xXN3pBOWZtVUVXUGZHdTJwWENuSmhwKyJ9 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] IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be multiples of 1KB 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, 26 Jan 2018 03:57:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Zeng, Star > Sent: Friday, January 26, 2018 11:50 AM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Yao, Jiewen ; > Chaganty, Rangasai V > Subject: [PATCH] IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be > multiples of 1KB >=20 > TotalSize must be multiples of 1024 bytes (1 KBytes) according to SDM. >=20 > Also enhance the debug message for DataSize that must be > multiples of DWORDs. >=20 > Cc: Jiewen Yao > Cc: Rangasai V Chaganty > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c | 19 > +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) >=20 > diff --git > a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c > b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c > index 11a51106fdd2..46b55088285f 100644 > --- a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.= c > +++ > b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c > @@ -8,7 +8,7 @@ >=20 > MicrocodeWrite() and VerifyMicrocode() will receive untrusted input an= d do > basic validation. >=20 > - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > @@ -421,7 +421,7 @@ VerifyMicrocode ( > return EFI_INCOMPATIBLE_VERSION; > } > // > - // Check Size > + // Check TotalSize > // > if (MicrocodeEntryPoint->DataSize =3D=3D 0) { > TotalSize =3D 2048; > @@ -436,6 +436,14 @@ VerifyMicrocode ( > } > return EFI_VOLUME_CORRUPTED; > } > + if ((TotalSize & (SIZE_1KB - 1)) !=3D 0) { > + DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize is not multiples of > 1024 bytes (1 KBytes)\n")); > + *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; > + if (AbortReason !=3D NULL) { > + *AbortReason =3D AllocateCopyPool(sizeof(L"InvalidTotalSize"), > L"InvalidTotalSize"); > + } > + return EFI_VOLUME_CORRUPTED; > + } > if (TotalSize !=3D ImageSize) { > DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n")); > *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; > @@ -445,7 +453,7 @@ VerifyMicrocode ( > return EFI_VOLUME_CORRUPTED; > } > // > - // Check CheckSum32 > + // Check DataSize > // > if (MicrocodeEntryPoint->DataSize =3D=3D 0) { > DataSize =3D 2048 - sizeof(CPU_MICROCODE_HEADER); > @@ -461,13 +469,16 @@ VerifyMicrocode ( > return EFI_VOLUME_CORRUPTED; > } > if ((DataSize & 0x3) !=3D 0) { > - DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize not aligned\n")); > + DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize is not multiples of > DWORDs\n")); > *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; > if (AbortReason !=3D NULL) { > *AbortReason =3D AllocateCopyPool(sizeof(L"InvalidDataSize"), > L"InvalidDataSize"); > } > return EFI_VOLUME_CORRUPTED; > } > + // > + // Check CheckSum32 > + // > CheckSum32 =3D CalculateSum32((UINT32 *)MicrocodeEntryPoint, DataSize = + > sizeof(CPU_MICROCODE_HEADER)); > if (CheckSum32 !=3D 0) { > DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CheckSum32\n")); > -- > 2.7.0.windows.1