From nobody Sun Apr 28 18:47:17 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 1515562822728199.52129286666775; Tue, 9 Jan 2018 21:40:22 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 422BA2236BABC; Tue, 9 Jan 2018 21:35:09 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 EE964222A54D4 for ; Tue, 9 Jan 2018 21:35:07 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2018 21:40:19 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga006.fm.intel.com with ESMTP; 09 Jan 2018 21:40:18 -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=134.134.136.24; helo=mga09.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,338,1511856000"; d="scan'208";a="193748892" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 10 Jan 2018 13:40:14 +0800 Message-Id: <20180110054015.406612-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180110054015.406612-1-ruiyu.ni@intel.com> References: <20180110054015.406612-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/2] UefiCpuPkg/MtrrLib: Fix a MTRR calculation bug 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: 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" 80 A8 B0 B8 C0 +----------WB--------+-UC-+-WT-+-WB-+ For above memory settings, current code caused the final MTRR settings miss [A8, B0, UC] when default memory type is UC. The root cause is the code only checks the mandatory weight between A8 to B0, but skips to check the optional weight. The patch fixes this issue. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index fafa15fd63..768d4d5cff 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -47,7 +47,7 @@ typedef struct { UINT64 Address; UINT64 Alignment; UINT64 Length; - UINT8 Type : 7; + MTRR_MEMORY_CACHE_TYPE Type : 7; =20 // // Temprary use for calculating the best MTRR settings. @@ -1429,7 +1429,7 @@ MtrrLibCalculateSubtractivePath ( while (SubStart !=3D SubStop) { Status =3D MtrrLibAppendVariableMtrr ( Mtrrs, MtrrCapacity, MtrrCount, - Vertices[SubStart].Address, Vertices[SubStart].Length, (MTRR= _MEMORY_CACHE_TYPE) Vertices[SubStart].Type + Vertices[SubStart].Address, Vertices[SubStart].Length, Verti= ces[SubStart].Type ); if (RETURN_ERROR (Status)) { return Status; @@ -1450,10 +1450,11 @@ MtrrLibCalculateSubtractivePath ( Pre =3D Vertices[Cur].Previous; SubStop =3D Pre; =20 - if (Weight[M (Pre, Cur)] !=3D 0) { + if (Weight[M (Pre, Cur)] + Weight[O (Pre, Cur)] !=3D 0) { Status =3D MtrrLibAppendVariableMtrr ( Mtrrs, MtrrCapacity, MtrrCount, - Vertices[Pre].Address, Vertices[Cur].Address - Vertices[Pr= e].Address, LowestPrecedentType + Vertices[Pre].Address, Vertices[Cur].Address - Vertices[Pr= e].Address, + (Pre !=3D Cur - 1) ? LowestPrecedentType : Vertices[Pre].T= ype ); if (RETURN_ERROR (Status)) { return Status; --=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 Sun Apr 28 18:47:17 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 1515562825134879.626284548524; Tue, 9 Jan 2018 21:40:25 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A70D72236BAB5; Tue, 9 Jan 2018 21:35:11 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 E6AFD2236BAB9 for ; Tue, 9 Jan 2018 21:35:08 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2018 21:40:20 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga006.fm.intel.com with ESMTP; 09 Jan 2018 21:40:19 -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=134.134.136.24; helo=mga09.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,338,1511856000"; d="scan'208";a="193748899" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 10 Jan 2018 13:40:15 +0800 Message-Id: <20180110054015.406612-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180110054015.406612-1-ruiyu.ni@intel.com> References: <20180110054015.406612-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] UefiCpuPkg/MtrrLib: Fix an assertion bug 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" 0 40 f0 100 +---WT--+--UC--+--WT--+-----WB----+----UC----+ When calculating the shortest path from 0 to 100, the MtrrLibCalculateLeastMtrrs() is called to update the Vertices.Previous. When calculating the shortest path from 0 to 40, MtrrLibCalculateLeastMtrrs() is called recursively to update the Vertices.Previous. The second call corrupt the Previous value that will be used later. The patch removes the code that corrupts Previous. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Eric Dong Reviewed-by: Eric Dong --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index 768d4d5cff..30b0df030b 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -1171,7 +1171,6 @@ MtrrLibCalculateLeastMtrrs ( =20 for (Index =3D Start; Index <=3D Stop; Index++) { Vertices[Index].Visited =3D FALSE; - Vertices[Index].Previous =3D VertexCount; Mandatory =3D Weight[M(Start,Index)]; Vertices[Index].Weight =3D Mandatory; if (Mandatory !=3D MAX_WEIGHT) { --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel