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.126; helo=mga18.intel.com; envelope-from=ray.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 2B8C7211CFFC2 for ; Wed, 27 Feb 2019 22:18:04 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 22:18:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,422,1544515200"; d="scan'208";a="127849144" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 27 Feb 2019 22:18:03 -0800 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 27 Feb 2019 22:18:03 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 27 Feb 2019 22:18:03 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.74]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.158]) with mapi id 14.03.0415.000; Thu, 28 Feb 2019 14:18:01 +0800 From: "Ni, Ray" To: "Chen, Chen A" , "edk2-devel@lists.01.org" CC: "Dong, Eric" Thread-Topic: [edk2] [PATCH 1/2] UefiCpuPkg/Microcode: Fix InComplete CheckSum32 issue Thread-Index: AQHUzytQHt6JvdWERU2a++imROQvV6X0vB5w Date: Thu, 28 Feb 2019 06:14:25 +0000 Deferred-Delivery: Thu, 28 Feb 2019 06:18:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C04FB9E@SHSMSX104.ccr.corp.intel.com> References: <20190228060252.23944-1-chen.a.chen@intel.com> <20190228060252.23944-2-chen.a.chen@intel.com> In-Reply-To: <20190228060252.23944-2-chen.a.chen@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/2] UefiCpuPkg/Microcode: Fix InComplete CheckSum32 issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2019 06:18:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: edk2-devel On Behalf Of Chen A > Chen > Sent: Thursday, February 28, 2019 2:03 PM > To: edk2-devel@lists.01.org > Cc: Dong, Eric > Subject: [edk2] [PATCH 1/2] UefiCpuPkg/Microcode: Fix InComplete > CheckSum32 issue >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1020 >=20 > The Microcode region indicated by MicrocodePatchAddress PCD may contain > more than one Microcode entry. We should save InCompleteCheckSum32 > value for each payload. Move the logic for calculate InCompleteCheckSum32 > from the outsize of the do-while loop to the inside. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Chen A Chen > Cc: Ray Ni > Cc: Eric Dong > --- > UefiCpuPkg/Library/MpInitLib/Microcode.c | 37 ++++++++++++++++--------- > ------- > 1 file changed, 19 insertions(+), 18 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c > b/UefiCpuPkg/Library/MpInitLib/Microcode.c > index e1f661d6b1..5f9ae22794 100644 > --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c > +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c > @@ -159,30 +159,31 @@ MicrocodeDetect ( > MicrocodeEnd =3D (UINTN) (CpuMpData->MicrocodePatchAddress + > CpuMpData->MicrocodePatchRegionSize); > MicrocodeEntryPoint =3D (CPU_MICROCODE_HEADER *) (UINTN) > CpuMpData->MicrocodePatchAddress; >=20 > - // > - // Save an in-complete CheckSum32 from CheckSum Part1 for common > parts. > - // > - if (MicrocodeEntryPoint->DataSize =3D=3D 0) { > - InCompleteCheckSum32 =3D CalculateSum32 ( > - (UINT32 *) MicrocodeEntryPoint, > - sizeof (CPU_MICROCODE_HEADER) + 2000 > - ); > - } else { > - InCompleteCheckSum32 =3D CalculateSum32 ( > - (UINT32 *) MicrocodeEntryPoint, > - sizeof (CPU_MICROCODE_HEADER) + MicrocodeEn= tryPoint- > >DataSize > - ); > - } > - InCompleteCheckSum32 -=3D MicrocodeEntryPoint- > >ProcessorSignature.Uint32; > - InCompleteCheckSum32 -=3D MicrocodeEntryPoint->ProcessorFlags; > - InCompleteCheckSum32 -=3D MicrocodeEntryPoint->Checksum; > - > do { > // > // Check if the microcode is for the Cpu and the version is newer > // and the update can be processed on the platform > // > CorrectMicrocode =3D FALSE; > + > + // > + // Save an in-complete CheckSum32 from CheckSum Part1 for common > parts. > + // > + if (MicrocodeEntryPoint->DataSize =3D=3D 0) { > + InCompleteCheckSum32 =3D CalculateSum32 ( > + (UINT32 *) MicrocodeEntryPoint, > + sizeof (CPU_MICROCODE_HEADER) + 2000 > + ); > + } else { > + InCompleteCheckSum32 =3D CalculateSum32 ( > + (UINT32 *) MicrocodeEntryPoint, > + sizeof (CPU_MICROCODE_HEADER) + Microcode= EntryPoint- > >DataSize > + ); > + } > + InCompleteCheckSum32 -=3D MicrocodeEntryPoint- > >ProcessorSignature.Uint32; > + InCompleteCheckSum32 -=3D MicrocodeEntryPoint->ProcessorFlags; > + InCompleteCheckSum32 -=3D MicrocodeEntryPoint->Checksum; > + > if (MicrocodeEntryPoint->HeaderVersion =3D=3D 0x1) { > // > // It is the microcode header. It is not the padding data between > microcode patches > -- > 2.16.2.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel