From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web09.1307.1578035655737142176 for ; Thu, 02 Jan 2020 23:14:15 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: siyuan.fu@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2020 23:14:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,389,1571727600"; d="scan'208";a="419943694" Received: from shwdeopenpsi787.ccr.corp.intel.com ([10.239.158.56]) by fmsmga005.fm.intel.com with ESMTP; 02 Jan 2020 23:14:12 -0800 From: "Siyuan, Fu" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Hao A Wu Subject: [Patch 1/1] UefiCpuPkg: Remove redundant alignment check when calculate microcode patch size. Date: Fri, 3 Jan 2020 15:14:11 +0800 Message-Id: <20200103071411.10760-1-siyuan.fu@intel.com> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch removes the unnecessary alignment check on microcode patch TotalSize introduced by commit d786a172. The TotalSize has already been checked with 1K alignment and MAX_ADDRESS in previous code as below: if ( (UINTN)MicrocodeEntryPoint > (MAX_ADDRESS - TotalSize) || ((UINTN)MicrocodeEntryPoint + TotalSize) > MicrocodeEnd || (DataSize & 0x3) != 0 || (TotalSize & (SIZE_1KB - 1)) != 0 || TotalSize < DataSize ) { Cc: Eric Dong Cc: Ray Ni Cc: Hao A Wu Signed-off-by: Siyuan Fu --- UefiCpuPkg/Library/MpInitLib/Microcode.c | 24 +++++------------------- UefiCpuPkg/Library/MpInitLib/MpLib.h | 3 +-- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c b/UefiCpuPkg/Library/MpInitLib/Microcode.c index 3da5bfb9cf2f..a9d06dd4099a 100644 --- a/UefiCpuPkg/Library/MpInitLib/Microcode.c +++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c @@ -1,7 +1,7 @@ /** @file Implementation of loading microcode on processors. - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -397,16 +397,7 @@ LoadMicrocodePatchWorker ( Patches[Index].Size ); - // - // Zero-fill the padding area - // Please note that AlignedSize will be no less than Size - // - ZeroMem ( - Walker + Patches[Index].Size, - Patches[Index].AlignedSize - Patches[Index].Size - ); - - Walker += Patches[Index].AlignedSize; + Walker += Patches[Index].Size; } // @@ -578,14 +569,9 @@ LoadMicrocodePatch ( // // Store the information of this microcode patch // - if (TotalSize > ALIGN_VALUE (TotalSize, SIZE_1KB) || - ALIGN_VALUE (TotalSize, SIZE_1KB) > MAX_UINTN - TotalLoadSize) { - goto OnExit; - } - PatchInfoBuffer[PatchCount - 1].Address = (UINTN) MicrocodeEntryPoint; - PatchInfoBuffer[PatchCount - 1].Size = TotalSize; - PatchInfoBuffer[PatchCount - 1].AlignedSize = ALIGN_VALUE (TotalSize, SIZE_1KB); - TotalLoadSize += PatchInfoBuffer[PatchCount - 1].AlignedSize; + PatchInfoBuffer[PatchCount - 1].Address = (UINTN) MicrocodeEntryPoint; + PatchInfoBuffer[PatchCount - 1].Size = TotalSize; + TotalLoadSize += TotalSize; } // diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h index 6609c958ce8a..b6e5a1afab00 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -1,7 +1,7 @@ /** @file Common header file for MP Initialize Library. - Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -54,7 +54,6 @@ typedef struct { UINTN Address; UINTN Size; - UINTN AlignedSize; } MICROCODE_PATCH_INFO; // -- 2.19.1.windows.1