From nobody Mon Dec 23 13:52:05 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 15153834458016.730088076162929; Sun, 7 Jan 2018 19:50:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9E397222A54D0; Sun, 7 Jan 2018 19:45:34 -0800 (PST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 65EF2222A54C2 for ; Sun, 7 Jan 2018 19:45:33 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2018 19:50:42 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga002.fm.intel.com with ESMTP; 07 Jan 2018 19:50:41 -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.120; helo=mga04.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,329,1511856000"; d="scan'208";a="8260558" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 8 Jan 2018 11:50:39 +0800 Message-Id: <20180108035039.334288-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [PATCH] 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 --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 66 +++++++++++++++++++++++---------= ---- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index f37b740fdf..5d44435459 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 /** --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel