From nobody Mon Dec 23 14:15:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151546895927520.398779135621226; Mon, 8 Jan 2018 19:35:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4065521F833AC; Mon, 8 Jan 2018 19:30:47 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 896182035D329 for ; Mon, 8 Jan 2018 19:30:44 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 19:35:55 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 19:35:54 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,334,1511856000"; d="scan'208";a="19407605" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 11:35:49 +0800 Message-Id: <20180109033552.378192-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com> References: <20180109033552.378192-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/4] UefiCpuPkg/MtrrLib: Refine the debug messages 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: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" MtrrSetMemoryAttributesInMtrrSettings() missed the debug messages of memory attribute request and status. The patch moves all debug messages from MtrrSetMemoryAttributeInMtrrSettings() to MtrrSetMemoryAttributesInMtrrSettings() and refines the debug message to carry more information. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Eric Dong Cc: Star Zeng Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 83 +++++++++++++++++++++++---------= ---- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index f37b740fdf..b83d768c5f 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -5,7 +5,7 @@ Most of services in this library instance are suggested to be invoked = by BSP only, except for MtrrSetAllMtrrs() which is used to sync BSP's MTRR setting = to APs. =20 - Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2018, 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 @@ -1570,7 +1570,7 @@ MtrrLibCalculateMtrrs ( // VectorCount =3D VectorIndex + 1; DEBUG (( - DEBUG_CACHE, "VectorCount (%016lx - %016lx) =3D %d\n",=20 + DEBUG_CACHE, " VectorCount (%016lx - %016lx) =3D %d\n", Ranges[0].BaseAddress, Ranges[RangeCount - 1].BaseAddress + Ranges[Ran= geCount - 1].Length, VectorCount )); ASSERT (VectorCount < MAX_UINT16); @@ -2209,6 +2209,7 @@ MtrrSetMemoryAttributesInMtrrSettings ( MTRR_CONTEXT MtrrContext; BOOLEAN MtrrContextValid; =20 + Status =3D RETURN_SUCCESS; MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); =20 // @@ -2226,24 +2227,48 @@ MtrrSetMemoryAttributesInMtrrSettings ( Above1MbExist =3D FALSE; OriginalVariableMtrrCount =3D 0; =20 + // + // 0. Dump the requests. + // + DEBUG_CODE ( + DEBUG ((DEBUG_CACHE, "Mtrr: Set Mem Attribute to %a, ScratchSize =3D %= x%a", + (MtrrSetting =3D=3D NULL) ? "Hardware" : "Buffer", ScratchSize, + (RangeCount <=3D 1) ? "," : "\n" + )); + for (Index =3D 0; Index < RangeCount; Index++) { + DEBUG ((DEBUG_CACHE, " %a: [%016lx, %016lx)\n", + mMtrrMemoryCacheTypeShortName[MIN (Ranges[Index].Type, Cache= Invalid)], + Ranges[Index].BaseAddress, Ranges[Index].BaseAddress + Range= s[Index].Length + )); + } + ); + // // 1. Validate the parameters. // + if (!IsMtrrSupported ()) { + Status =3D RETURN_UNSUPPORTED; + goto Exit; + } + for (Index =3D 0; Index < RangeCount; Index++) { if (Ranges[Index].Length =3D=3D 0) { - return RETURN_INVALID_PARAMETER; + Status =3D RETURN_INVALID_PARAMETER; + goto Exit; } if (((Ranges[Index].BaseAddress & ~MtrrValidAddressMask) !=3D 0) || ((Ranges[Index].Length & ~MtrrValidAddressMask) !=3D 0) ) { - return RETURN_UNSUPPORTED; + Status =3D RETURN_UNSUPPORTED; + goto Exit; } if ((Ranges[Index].Type !=3D CacheUncacheable) && (Ranges[Index].Type !=3D CacheWriteCombining) && (Ranges[Index].Type !=3D CacheWriteThrough) && (Ranges[Index].Type !=3D CacheWriteProtected) && (Ranges[Index].Type !=3D CacheWriteBack)) { - return RETURN_INVALID_PARAMETER; + Status =3D RETURN_INVALID_PARAMETER; + goto Exit; } if (Ranges[Index].BaseAddress + Ranges[Index].Length > BASE_1MB) { Above1MbExist =3D TRUE; @@ -2309,7 +2334,7 @@ MtrrSetMemoryAttributesInMtrrSettings ( if (Status =3D=3D RETURN_ALREADY_STARTED) { Status =3D RETURN_SUCCESS; } else if (Status =3D=3D RETURN_OUT_OF_RESOURCES) { - return Status; + goto Exit; } else { ASSERT_RETURN_ERROR (Status); Modified =3D TRUE; @@ -2327,7 +2352,7 @@ MtrrSetMemoryAttributesInMtrrSettings ( WorkingVariableMtrr, FirmwareVariableMtrrCount + 1, &Work= ingVariableMtrrCount ); if (RETURN_ERROR (Status)) { - return Status; + goto Exit; } =20 // @@ -2346,7 +2371,8 @@ MtrrSetMemoryAttributesInMtrrSettings ( } =20 if (WorkingVariableMtrrCount > FirmwareVariableMtrrCount) { - return RETURN_OUT_OF_RESOURCES; + Status =3D RETURN_OUT_OF_RESOURCES; + goto Exit; } =20 // @@ -2375,7 +2401,7 @@ MtrrSetMemoryAttributesInMtrrSettings ( Ranges[Index].BaseAddress, Ranges[Index].Length, Ranges[Ind= ex].Type ); if (RETURN_ERROR (Status)) { - return Status; + goto Exit; } } =20 @@ -2441,7 +2467,12 @@ MtrrSetMemoryAttributesInMtrrSettings ( } } =20 - return RETURN_SUCCESS; +Exit: + DEBUG ((DEBUG_CACHE, " Result =3D %r\n", Status)); + if (!RETURN_ERROR (Status)) { + MtrrDebugPrintAllMtrrsWorker (MtrrSetting); + } + return Status; } =20 /** @@ -2475,28 +2506,15 @@ MtrrSetMemoryAttributeInMtrrSettings ( IN MTRR_MEMORY_CACHE_TYPE Attribute ) { - RETURN_STATUS Status; UINT8 Scratch[SCRATCH_BUFFER_SIZE]; UINTN ScratchSize; MTRR_MEMORY_RANGE Range; =20 - if (!IsMtrrSupported ()) { - return RETURN_UNSUPPORTED; - } - Range.BaseAddress =3D BaseAddress; Range.Length =3D Length; Range.Type =3D Attribute; ScratchSize =3D sizeof (Scratch); - Status =3D MtrrSetMemoryAttributesInMtrrSettings (MtrrSetting, Scratch, = &ScratchSize, &Range, 1); - DEBUG ((DEBUG_CACHE, "MtrrSetMemoryAttribute(MtrrSettings =3D %p) %a: [%= 016lx, %016lx) - %r\n", - MtrrSetting, - mMtrrMemoryCacheTypeShortName[Attribute], BaseAddress, BaseAddre= ss + Length, Status)); - - if (!RETURN_ERROR (Status)) { - MtrrDebugPrintAllMtrrsWorker (MtrrSetting); - } - return Status; + return MtrrSetMemoryAttributesInMtrrSettings (MtrrSetting, Scratch, &Scr= atchSize, &Range, 1); } =20 /** @@ -2788,6 +2806,7 @@ MtrrDebugPrintAllMtrrsWorker ( UINT64 MtrrValidBitsMask; UINT64 MtrrValidAddressMask; UINT32 VariableMtrrCount; + BOOLEAN ContainVariableMtrr; MTRR_MEMORY_RANGE Ranges[ ARRAY_SIZE (mMtrrLibFixedMtrrTable) * sizeof (UINT64) + 2 * ARRAY_SI= ZE (Mtrrs->Variables.Mtrr) + 1 ]; @@ -2809,13 +2828,13 @@ MtrrDebugPrintAllMtrrsWorker ( // // Dump RAW MTRR contents // - DEBUG((DEBUG_CACHE, "MTRR Settings\n")); - DEBUG((DEBUG_CACHE, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n")); - DEBUG((DEBUG_CACHE, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType)= ); + DEBUG ((DEBUG_CACHE, "MTRR Settings:\n")); + DEBUG ((DEBUG_CACHE, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n")); + DEBUG ((DEBUG_CACHE, "MTRR Default Type: %016lx\n", Mtrrs->MtrrDefType= )); for (Index =3D 0; Index < ARRAY_SIZE (mMtrrLibFixedMtrrTable); Index++= ) { - DEBUG((DEBUG_CACHE, "Fixed MTRR[%02d] : %016lx\n", Index, Mtrrs->F= ixed.Mtrr[Index])); + DEBUG ((DEBUG_CACHE, "Fixed MTRR[%02d] : %016lx\n", Index, Mtrrs->= Fixed.Mtrr[Index])); } - + ContainVariableMtrr =3D FALSE; for (Index =3D 0; Index < VariableMtrrCount; Index++) { if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *)&Mtrrs->Variables.Mtrr[Index= ].Mask)->Bits.V =3D=3D 0) { // @@ -2823,18 +2842,22 @@ MtrrDebugPrintAllMtrrsWorker ( // continue; } + ContainVariableMtrr =3D TRUE; DEBUG ((DEBUG_CACHE, "Variable MTRR[%02d]: Base=3D%016lx Mask=3D%016= lx\n", Index, Mtrrs->Variables.Mtrr[Index].Base, Mtrrs->Variables.Mtrr[Index].Mask )); } + if (!ContainVariableMtrr) { + DEBUG ((DEBUG_CACHE, "Variable MTRR : None.\n")); + } DEBUG((DEBUG_CACHE, "\n")); =20 // // Dump MTRR setting in ranges // - DEBUG((DEBUG_CACHE, "MTRR Ranges\n")); + DEBUG((DEBUG_CACHE, "Memory Ranges:\n")); DEBUG((DEBUG_CACHE, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n")); MtrrLibInitializeMtrrMask (&MtrrValidBitsMask, &MtrrValidAddressMask); Ranges[0].BaseAddress =3D 0; --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 14:15:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515468961891439.4445039500399; Mon, 8 Jan 2018 19:36:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9CC332222758A; Mon, 8 Jan 2018 19:30:48 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 9F78E21F833AA for ; Mon, 8 Jan 2018 19:30:46 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 19:35:56 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 19:35:55 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,334,1511856000"; d="scan'208";a="19407609" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 11:35:50 +0800 Message-Id: <20180109033552.378192-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com> References: <20180109033552.378192-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/4] UefiCpuPkg/MtrrLib: Fix bug that may calculate wrong MTRR result 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: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Code forgot to initialize the optional weight between adjacent vertices. It caused wrong MTRR result was calculated for some memory settings. The logic was incorrectly removed when converting from POC code. The patch adds back the initialization. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Eric Dong Cc: Star Zeng Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 37 ++++++++++++++++++++++++--------= ---- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index b83d768c5f..566a4cb67b 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -1583,20 +1583,33 @@ MtrrLibCalculateMtrrs ( Vector[VectorCount - 1].Address =3D Base1; =20 Weight =3D (UINT8 *) &Vector[VectorCount]; - // - // Set mandatory weight between any vector to max - // Set optional weight and between any vector and self->self to 0 - // E.g.: - // 00 FF FF FF - // 00 00 FF FF - // 00 00 00 FF - // 00 00 00 00 - // for (VectorIndex =3D 0; VectorIndex < VectorCount; VectorIndex++) { + // + // Set optional weight between vertices and self->self to 0 + // SetMem (&Weight[M(VectorIndex, 0)], VectorIndex + 1, 0); - if (VectorIndex !=3D VectorCount - 1) { - Weight[M (VectorIndex, VectorIndex + 1)] =3D (DefaultType =3D=3D Vec= tor[VectorIndex].Type) ? 0 : 1; - SetMem (&Weight[M (VectorIndex, VectorIndex + 2)], VectorCount - Vec= torIndex - 2, MAX_WEIGHT); + // + // Set mandatory weight between vectors to MAX_WEIGHT + // + SetMem (&Weight[M (VectorIndex, VectorIndex + 1)], VectorCount - Vecto= rIndex - 1, MAX_WEIGHT); + + // Final result looks like: + // 00 FF FF FF + // 00 00 FF FF + // 00 00 00 FF + // 00 00 00 00 + } + + // + // Set mandatory weight and optional weight for adjacent vertices + // + for (VectorIndex =3D 0; VectorIndex < VectorCount - 1; VectorIndex++) { + if (Vector[VectorIndex].Type !=3D DefaultType) { + Weight[M (VectorIndex, VectorIndex + 1)] =3D 1; + Weight[O (VectorIndex, VectorIndex + 1)] =3D 0; + } else { + Weight[M (VectorIndex, VectorIndex + 1)] =3D 0; + Weight[O (VectorIndex, VectorIndex + 1)] =3D 1; } } =20 --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 14:15:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151546896437874.15311082858148; Mon, 8 Jan 2018 19:36:04 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 06388222275A8; Mon, 8 Jan 2018 19:30:49 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 46F6521F833B9 for ; Mon, 8 Jan 2018 19:30:47 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 19:35:57 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 19:35:56 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,334,1511856000"; d="scan'208";a="19407613" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 11:35:51 +0800 Message-Id: <20180109033552.378192-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com> References: <20180109033552.378192-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 3/4] UefiCpuPkg/MtrrLib: Handle one setting request covering all memory 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: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" *SetMemoryAttribute*() API cannot handle the setting request that looks like <0, MAX_ADDRESS, Type>. The buggy parameter checking logic returns Unsupported for this case. The patch fixes the checking logic to handle such case. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Eric Dong Cc: Star Zeng Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index 566a4cb67b..54f703606b 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -2270,8 +2270,13 @@ MtrrSetMemoryAttributesInMtrrSettings ( goto Exit; } if (((Ranges[Index].BaseAddress & ~MtrrValidAddressMask) !=3D 0) || - ((Ranges[Index].Length & ~MtrrValidAddressMask) !=3D 0) + ((((Ranges[Index].BaseAddress + Ranges[Index].Length) & ~MtrrValid= AddressMask) !=3D 0) && + (Ranges[Index].BaseAddress + Ranges[Index].Length) !=3D MtrrVali= dBitsMask + 1) ) { + // + // Either the BaseAddress or the Limit doesn't follow the alignment = requirement. + // Note: It's still valid if Limit doesn't follow the alignment requ= irement but equals to MAX Address. + // Status =3D RETURN_UNSUPPORTED; goto Exit; } --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 14:15:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515468967136945.8398816340308; Mon, 8 Jan 2018 19:36:07 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 69CB721F833DD; Mon, 8 Jan 2018 19:30:50 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 1C37B2035D329 for ; Mon, 8 Jan 2018 19:30:48 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 19:35:58 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 19:35:57 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,334,1511856000"; d="scan'208";a="19407622" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 11:35:52 +0800 Message-Id: <20180109033552.378192-5-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com> References: <20180109033552.378192-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 4/4] UefiCpuPkg/MtrrLib: Correct typo to change vector to vertex 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: , Cc: Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch only change the comments and variable name so doesn't impact the functionality. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Eric Dong Cc: Star Zeng Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 190 +++++++++++++++++--------------= ---- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index 54f703606b..eb46861163 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -1,7 +1,7 @@ /** @file MTRR setting library =20 - @par Note:=20 + @par Note: Most of services in this library instance are suggested to be invoked = by BSP only, except for MtrrSetAllMtrrs() which is used to sync BSP's MTRR setting = to APs. =20 @@ -32,8 +32,8 @@ #define SCRATCH_BUFFER_SIZE (4 * SIZE_4KB) #define MTRR_LIB_ASSERT_ALIGNED(B, L) ASSERT ((B & ~(L - 1)) =3D=3D B); =20 -#define M(x,y) ((x) * VectorCount + (y)) -#define O(x,y) ((y) * VectorCount + (x)) +#define M(x,y) ((x) * VertexCount + (y)) +#define O(x,y) ((y) * VertexCount + (x)) =20 // // Context to save and restore when MTRRs are programmed @@ -1142,21 +1142,21 @@ MtrrLibGetNumberOfTypes ( } =20 /** - Calculate the least MTRR number from vector Start to Stop and update - the Previous of all vectors from Start to Stop is updated to reflect + Calculate the least MTRR number from vertex Start to Stop and update + the Previous of all vertices from Start to Stop is updated to reflect how the memory range is covered by MTRR. =20 - @param VectorCount The count of vectors in the graph. - @param Vector Array holding all vectors. - @param Weight 2-dimention array holding weights between vectors. - @param Start Start vector. - @param Stop Stop vector. + @param VertexCount The count of vertices in the graph. + @param Vertices Array holding all vertices. + @param Weight 2-dimention array holding weights between vertice= s. + @param Start Start vertex. + @param Stop Stop vertex. @param IncludeOptional TRUE to count the optional weight. **/ VOID MtrrLibCalculateLeastMtrrs ( - IN UINT16 VectorCount, - IN MTRR_LIB_ADDRESS *Vector, + IN UINT16 VertexCount, + IN MTRR_LIB_ADDRESS *Vertices, IN OUT CONST UINT8 *Weight, IN UINT16 Start, IN UINT16 Stop, @@ -1170,52 +1170,52 @@ MtrrLibCalculateLeastMtrrs ( UINT8 Optional; =20 for (Index =3D Start; Index <=3D Stop; Index++) { - Vector[Index].Visited =3D FALSE; - Vector[Index].Previous =3D VectorCount; + Vertices[Index].Visited =3D FALSE; + Vertices[Index].Previous =3D VertexCount; Mandatory =3D Weight[M(Start,Index)]; - Vector[Index].Weight =3D Mandatory; + Vertices[Index].Weight =3D Mandatory; if (Mandatory !=3D MAX_WEIGHT) { Optional =3D IncludeOptional ? Weight[O(Start, Index)] : 0; - Vector[Index].Weight +=3D Optional; - ASSERT (Vector[Index].Weight >=3D Optional); + Vertices[Index].Weight +=3D Optional; + ASSERT (Vertices[Index].Weight >=3D Optional); } } =20 MinI =3D Start; MinWeight =3D 0; - while (!Vector[Stop].Visited) { + while (!Vertices[Stop].Visited) { // - // Update the weight from the shortest vector to other unvisited vecto= rs + // Update the weight from the shortest vertex to other unvisited verti= ces // for (Index =3D Start + 1; Index <=3D Stop; Index++) { - if (!Vector[Index].Visited) { + if (!Vertices[Index].Visited) { Mandatory =3D Weight[M(MinI, Index)]; if (Mandatory !=3D MAX_WEIGHT) { Optional =3D IncludeOptional ? Weight[O(MinI, Index)] : 0; - if (MinWeight + Mandatory + Optional <=3D Vector[Index].Weight) { - Vector[Index].Weight =3D MinWeight + Mandatory + Optional; - Vector[Index].Previous =3D MinI; // Previous is Start based. + if (MinWeight + Mandatory + Optional <=3D Vertices[Index].Weight= ) { + Vertices[Index].Weight =3D MinWeight + Mandatory + Optional; + Vertices[Index].Previous =3D MinI; // Previous is Start based. } } } } =20 // - // Find the shortest vector from Start + // Find the shortest vertex from Start // - MinI =3D VectorCount; + MinI =3D VertexCount; MinWeight =3D MAX_WEIGHT; for (Index =3D Start + 1; Index <=3D Stop; Index++) { - if (!Vector[Index].Visited && MinWeight > Vector[Index].Weight) { + if (!Vertices[Index].Visited && MinWeight > Vertices[Index].Weight) { MinI =3D Index; - MinWeight =3D Vector[Index].Weight; + MinWeight =3D Vertices[Index].Weight; } } =20 // - // Mark the shortest vector from Start as visited + // Mark the shortest vertex from Start as visited // - Vector[MinI].Visited =3D TRUE; + Vertices[MinI].Visited =3D TRUE; } } =20 @@ -1288,17 +1288,17 @@ MtrrLibIsPowerOfTwo ( } =20 /** - Calculate the subtractive path from vector Start to Stop. + Calculate the subtractive path from vertex Start to Stop. =20 @param DefaultType Default memory type. @param A0 Alignment to use when base address is 0. @param Ranges Array holding memory type settings for all memory re= gions. @param RangeCount The count of memory ranges the array holds. - @param VectorCount The count of vectors in the graph. - @param Vector Array holding all vectors. - @param Weight 2-dimention array holding weights between vectors. - @param Start Start vector. - @param Stop Stop vector. + @param VertexCount The count of vertices in the graph. + @param Vertices Array holding all vertices. + @param Weight 2-dimention array holding weights between vertices. + @param Start Start vertex. + @param Stop Stop vertex. @param Types Type bit mask of memory range from Start to Stop. @param TypeCount Number of different memory types from Start to Stop. @param Mtrrs Array holding all MTRR settings. @@ -1315,8 +1315,8 @@ MtrrLibCalculateSubtractivePath ( IN UINT64 A0, IN CONST MTRR_MEMORY_RANGE *Ranges, IN UINTN RangeCount, - IN UINT16 VectorCount, - IN MTRR_LIB_ADDRESS *Vector, + IN UINT16 VertexCount, + IN MTRR_LIB_ADDRESS *Vertices, IN OUT UINT8 *Weight, IN UINT16 Start, IN UINT16 Stop, @@ -1342,8 +1342,8 @@ MtrrLibCalculateSubtractivePath ( MTRR_MEMORY_CACHE_TYPE LowestType; MTRR_MEMORY_CACHE_TYPE LowestPrecedentType; =20 - Base =3D Vector[Start].Address; - Length =3D Vector[Stop].Address - Base; + Base =3D Vertices[Start].Address; + Length =3D Vertices[Stop].Address - Base; =20 LowestType =3D MtrrLibLowestType (Types); =20 @@ -1404,18 +1404,18 @@ MtrrLibCalculateSubtractivePath ( // We might use positive or subtractive, depending on which way uses= less MTRR // for (SubStart =3D Start; SubStart <=3D Stop; SubStart++) { - if (Vector[SubStart].Address =3D=3D HBase) { + if (Vertices[SubStart].Address =3D=3D HBase) { break; } } =20 for (SubStop =3D SubStart; SubStop <=3D Stop; SubStop++) { - if (Vector[SubStop].Address =3D=3D HBase + HLength) { + if (Vertices[SubStop].Address =3D=3D HBase + HLength) { break; } } - ASSERT (Vector[SubStart].Address =3D=3D HBase); - ASSERT (Vector[SubStop].Address =3D=3D HBase + HLength); + ASSERT (Vertices[SubStart].Address =3D=3D HBase); + ASSERT (Vertices[SubStop].Address =3D=3D HBase + HLength); =20 if ((TypeCount =3D=3D 2) || (SubStart =3D=3D SubStop - 1)) { // @@ -1429,7 +1429,7 @@ MtrrLibCalculateSubtractivePath ( while (SubStart !=3D SubStop) { Status =3D MtrrLibAppendVariableMtrr ( Mtrrs, MtrrCapacity, MtrrCount, - Vector[SubStart].Address, Vector[SubStart].Length, (MTRR_MEM= ORY_CACHE_TYPE) Vector[SubStart].Type + Vertices[SubStart].Address, Vertices[SubStart].Length, (MTRR= _MEMORY_CACHE_TYPE) Vertices[SubStart].Type ); if (RETURN_ERROR (Status)) { return Status; @@ -1439,21 +1439,21 @@ MtrrLibCalculateSubtractivePath ( } } else { ASSERT (TypeCount =3D=3D 3); - MtrrLibCalculateLeastMtrrs (VectorCount, Vector, Weight, SubStart,= SubStop, TRUE); + MtrrLibCalculateLeastMtrrs (VertexCount, Vertices, Weight, SubStar= t, SubStop, TRUE); =20 if (Mtrrs =3D=3D NULL) { - Weight[M (Start, Stop)] +=3D Vector[SubStop].Weight; + Weight[M (Start, Stop)] +=3D Vertices[SubStop].Weight; } else { // When we need to collect the optimal path from SubStart to Sub= Stop while (SubStop !=3D SubStart) { Cur =3D SubStop; - Pre =3D Vector[Cur].Previous; + Pre =3D Vertices[Cur].Previous; SubStop =3D Pre; =20 if (Weight[M (Pre, Cur)] !=3D 0) { Status =3D MtrrLibAppendVariableMtrr ( Mtrrs, MtrrCapacity, MtrrCount, - Vector[Pre].Address, Vector[Cur].Address - Vector[Pre].Add= ress, LowestPrecedentType + Vertices[Pre].Address, Vertices[Cur].Address - Vertices[Pr= e].Address, LowestPrecedentType ); if (RETURN_ERROR (Status)) { return Status; @@ -1463,7 +1463,7 @@ MtrrLibCalculateSubtractivePath ( Status =3D MtrrLibCalculateSubtractivePath ( DefaultType, A0, Ranges, RangeCount, - VectorCount, Vector, Weight, + VertexCount, Vertices, Weight, Pre, Cur, PrecedentTypes, 2, Mtrrs, MtrrCapacity, MtrrCount ); @@ -1526,10 +1526,10 @@ MtrrLibCalculateMtrrs ( UINT64 Length; UINT64 Alignment; UINT64 SubLength; - MTRR_LIB_ADDRESS *Vector; + MTRR_LIB_ADDRESS *Vectices; UINT8 *Weight; - UINT32 VectorIndex; - UINT32 VectorCount; + UINT32 VertexIndex; + UINT32 VertexCount; UINTN RequiredScratchSize; UINT8 TypeCount; UINT16 Start; @@ -1542,10 +1542,10 @@ MtrrLibCalculateMtrrs ( MTRR_LIB_ASSERT_ALIGNED (Base0, Base1 - Base0); =20 // - // Count the number of vectors. + // Count the number of vertices. // - Vector =3D (MTRR_LIB_ADDRESS*)Scratch; - for (VectorIndex =3D 0, Index =3D 0; Index < RangeCount; Index++) { + Vectices =3D (MTRR_LIB_ADDRESS*)Scratch; + for (VertexIndex =3D 0, Index =3D 0; Index < RangeCount; Index++) { Base =3D Ranges[Index].BaseAddress; Length =3D Ranges[Index].Length; while (Length !=3D 0) { @@ -1554,44 +1554,44 @@ MtrrLibCalculateMtrrs ( if (SubLength > Length) { SubLength =3D GetPowerOfTwo64 (Length); } - if (VectorIndex < *ScratchSize / sizeof (*Vector)) { - Vector[VectorIndex].Address =3D Base; - Vector[VectorIndex].Alignment =3D Alignment; - Vector[VectorIndex].Type =3D Ranges[Index].Type; - Vector[VectorIndex].Length =3D SubLength; + if (VertexIndex < *ScratchSize / sizeof (*Vectices)) { + Vectices[VertexIndex].Address =3D Base; + Vectices[VertexIndex].Alignment =3D Alignment; + Vectices[VertexIndex].Type =3D Ranges[Index].Type; + Vectices[VertexIndex].Length =3D SubLength; } Base +=3D SubLength; Length -=3D SubLength; - VectorIndex++; + VertexIndex++; } } // - // Vector[VectorIndex] =3D Base1, so whole vector count is (VectorIndex = + 1). + // Vertices[VertexIndex] =3D Base1, so whole vertex count is (VertexInde= x + 1). // - VectorCount =3D VectorIndex + 1; + VertexCount =3D VertexIndex + 1; DEBUG (( - DEBUG_CACHE, " VectorCount (%016lx - %016lx) =3D %d\n", - Ranges[0].BaseAddress, Ranges[RangeCount - 1].BaseAddress + Ranges[Ran= geCount - 1].Length, VectorCount + DEBUG_CACHE, " Count of vertices (%016llx - %016llx) =3D %d\n", + Ranges[0].BaseAddress, Ranges[RangeCount - 1].BaseAddress + Ranges[Ran= geCount - 1].Length, VertexCount )); - ASSERT (VectorCount < MAX_UINT16); + ASSERT (VertexCount < MAX_UINT16); =20 - RequiredScratchSize =3D VectorCount * sizeof (*Vector) + VectorCount * V= ectorCount * sizeof (*Weight); + RequiredScratchSize =3D VertexCount * sizeof (*Vectices) + VertexCount *= VertexCount * sizeof (*Weight); if (*ScratchSize < RequiredScratchSize) { *ScratchSize =3D RequiredScratchSize; return RETURN_BUFFER_TOO_SMALL; } - Vector[VectorCount - 1].Address =3D Base1; + Vectices[VertexCount - 1].Address =3D Base1; =20 - Weight =3D (UINT8 *) &Vector[VectorCount]; - for (VectorIndex =3D 0; VectorIndex < VectorCount; VectorIndex++) { + Weight =3D (UINT8 *) &Vectices[VertexCount]; + for (VertexIndex =3D 0; VertexIndex < VertexCount; VertexIndex++) { // // Set optional weight between vertices and self->self to 0 // - SetMem (&Weight[M(VectorIndex, 0)], VectorIndex + 1, 0); + SetMem (&Weight[M(VertexIndex, 0)], VertexIndex + 1, 0); // - // Set mandatory weight between vectors to MAX_WEIGHT + // Set mandatory weight between vertices to MAX_WEIGHT // - SetMem (&Weight[M (VectorIndex, VectorIndex + 1)], VectorCount - Vecto= rIndex - 1, MAX_WEIGHT); + SetMem (&Weight[M (VertexIndex, VertexIndex + 1)], VertexCount - Verte= xIndex - 1, MAX_WEIGHT); =20 // Final result looks like: // 00 FF FF FF @@ -1603,22 +1603,22 @@ MtrrLibCalculateMtrrs ( // // Set mandatory weight and optional weight for adjacent vertices // - for (VectorIndex =3D 0; VectorIndex < VectorCount - 1; VectorIndex++) { - if (Vector[VectorIndex].Type !=3D DefaultType) { - Weight[M (VectorIndex, VectorIndex + 1)] =3D 1; - Weight[O (VectorIndex, VectorIndex + 1)] =3D 0; + for (VertexIndex =3D 0; VertexIndex < VertexCount - 1; VertexIndex++) { + if (Vectices[VertexIndex].Type !=3D DefaultType) { + Weight[M (VertexIndex, VertexIndex + 1)] =3D 1; + Weight[O (VertexIndex, VertexIndex + 1)] =3D 0; } else { - Weight[M (VectorIndex, VectorIndex + 1)] =3D 0; - Weight[O (VectorIndex, VectorIndex + 1)] =3D 1; + Weight[M (VertexIndex, VertexIndex + 1)] =3D 0; + Weight[O (VertexIndex, VertexIndex + 1)] =3D 1; } } =20 for (TypeCount =3D 2; TypeCount <=3D 3; TypeCount++) { - for (Start =3D 0; Start < VectorCount; Start++) { - for (Stop =3D Start + 2; Stop < VectorCount; Stop++) { - ASSERT (Vector[Stop].Address > Vector[Start].Address); - Length =3D Vector[Stop].Address - Vector[Start].Address; - if (Length > Vector[Start].Alignment) { + for (Start =3D 0; Start < VertexCount; Start++) { + for (Stop =3D Start + 2; Stop < VertexCount; Stop++) { + ASSERT (Vectices[Stop].Address > Vectices[Start].Address); + Length =3D Vectices[Stop].Address - Vectices[Start].Address; + if (Length > Vectices[Start].Alignment) { // // Pickup a new Start when [Start, Stop) cannot be described by = one MTRR. // @@ -1626,7 +1626,7 @@ MtrrLibCalculateMtrrs ( } if ((Weight[M(Start, Stop)] =3D=3D MAX_WEIGHT) && MtrrLibIsPowerOf= Two (Length)) { if (MtrrLibGetNumberOfTypes ( - Ranges, RangeCount, Vector[Start].Address, Vector[Stop].Ad= dress - Vector[Start].Address, &Type + Ranges, RangeCount, Vectices[Start].Address, Vectices[Stop= ].Address - Vectices[Start].Address, &Type ) =3D=3D TypeCount) { // // Update the Weight[Start, Stop] using subtractive path. @@ -1634,7 +1634,7 @@ MtrrLibCalculateMtrrs ( MtrrLibCalculateSubtractivePath ( DefaultType, A0, Ranges, RangeCount, - (UINT16)VectorCount, Vector, Weight, + (UINT16)VertexCount, Vectices, Weight, Start, Stop, Type, TypeCount, NULL, 0, NULL ); @@ -1651,17 +1651,17 @@ MtrrLibCalculateMtrrs ( } =20 Status =3D RETURN_SUCCESS; - MtrrLibCalculateLeastMtrrs ((UINT16) VectorCount, Vector, Weight, 0, (UI= NT16) VectorCount - 1, FALSE); - Stop =3D (UINT16) VectorCount - 1; + MtrrLibCalculateLeastMtrrs ((UINT16) VertexCount, Vectices, Weight, 0, (= UINT16) VertexCount - 1, FALSE); + Stop =3D (UINT16) VertexCount - 1; while (Stop !=3D 0) { - Start =3D Vector[Stop].Previous; + Start =3D Vectices[Stop].Previous; TypeCount =3D MAX_UINT8; Type =3D 0; if (Weight[M(Start, Stop)] !=3D 0) { - TypeCount =3D MtrrLibGetNumberOfTypes (Ranges, RangeCount, Vector[St= art].Address, Vector[Stop].Address - Vector[Start].Address, &Type); + TypeCount =3D MtrrLibGetNumberOfTypes (Ranges, RangeCount, Vectices[= Start].Address, Vectices[Stop].Address - Vectices[Start].Address, &Type); Status =3D MtrrLibAppendVariableMtrr ( Mtrrs, MtrrCapacity, MtrrCount, - Vector[Start].Address, Vector[Stop].Address - Vector[Start].Addres= s,=20 + Vectices[Start].Address, Vectices[Stop].Address - Vectices[Start].= Address, MtrrLibLowestType (Type) ); if (RETURN_ERROR (Status)) { @@ -1675,13 +1675,13 @@ MtrrLibCalculateMtrrs ( // if (TypeCount =3D=3D MAX_UINT8) { TypeCount =3D MtrrLibGetNumberOfTypes ( - Ranges, RangeCount, Vector[Start].Address, Vector[St= op].Address - Vector[Start].Address, &Type + Ranges, RangeCount, Vectices[Start].Address, Vectice= s[Stop].Address - Vectices[Start].Address, &Type ); } Status =3D MtrrLibCalculateSubtractivePath ( DefaultType, A0, Ranges, RangeCount, - (UINT16) VectorCount, Vector, Weight, Start, Stop, + (UINT16) VertexCount, Vectices, Weight, Start, Stop, Type, TypeCount, Mtrrs, MtrrCapacity, MtrrCount ); @@ -1788,7 +1788,7 @@ MtrrLibApplyVariableMtrrs ( // 2. Set other types than WB or UC // for (Index =3D 0; Index < VariableMtrrCount; Index++) { - if ((VariableMtrr[Index].Length !=3D 0) &&=20 + if ((VariableMtrr[Index].Length !=3D 0) && (VariableMtrr[Index].Type !=3D CacheWriteBack) && (VariableMtrr[In= dex].Type !=3D CacheUncacheable)) { Status =3D MtrrLibSetMemoryType ( Ranges, RangeCapacity, RangeCount, @@ -1981,7 +1981,7 @@ MtrrLibSetMemoryRanges ( UINTN BiggestScratchSize; =20 *VariableMtrrCount =3D 0; - =20 + // // Since the whole ranges need multiple calls of MtrrLibCalculateMtrrs(). // Each call needs different scratch buffer size. --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel