From nobody Tue Apr 30 03:47:19 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 1518273682539228.6397365159919; Sat, 10 Feb 2018 06:41:22 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0D4ED222DE14D; Sat, 10 Feb 2018 06:35:34 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 40272223DB78E for ; Sat, 10 Feb 2018 06:35:31 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2018 06:41:18 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.37]) by FMSMGA003.fm.intel.com with ESMTP; 10 Feb 2018 06:41:17 -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.93; helo=mga11.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,490,1511856000"; d="scan'208";a="26342564" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Sat, 10 Feb 2018 22:41:14 +0800 Message-Id: <20180210144115.432040-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180210144115.432040-1-ruiyu.ni@intel.com> References: <20180210144115.432040-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH v2 1/2] MdeModulePkg/GenericMemoryTest: Handle more reliable 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: Liming Gao , 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" Today's implementation converts the untested more reliable memory from reserved GCD type to system memory GCD type. Though it doesn't impact the return result of gBS->GetMemoryMap(). But it impacts the return result of gDS->GetMemorySpaceDescriptor(). The patch fixes the bug to convert the untested more reliable memory from reserved GCD type to more reliable memory GCD type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Liming Gao Reviewed-by: Liming Gao --- .../GenericMemoryTestDxe/LightMemoryTest.c | 75 ++++++++++++++----= ---- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMe= moryTest.c b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMe= moryTest.c index 477c914059..a7ade955c3 100644 --- a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTes= t.c +++ b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTes= t.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions @@ -106,7 +106,8 @@ ConstructBaseMemoryRange ( gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); =20 for (Index =3D 0; Index < NumberOfDescriptors; Index++) { - if (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeSystemM= emory) { + if ((MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeSystem= Memory) || + (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeMoreRe= liable)) { Private->BaseMemorySize +=3D MemorySpaceMap[Index].Length; } } @@ -138,6 +139,41 @@ DestroyLinkList ( } } =20 +/** + Convert the memory range to tested. + + @param BaseAddress Base address of the memory range. + @param Length Length of the memory range. + @param Capabilities Capabilities of the memory range. + + @retval EFI_SUCCESS The memory range is converted to tested. + @retval others Error happens. +**/ +EFI_STATUS +ConvertToTestedMemory ( + IN UINT64 BaseAddress, + IN UINT64 Length, + IN UINT64 Capabilities + ) +{ + EFI_STATUS Status; + Status =3D gDS->RemoveMemorySpace ( + BaseAddress, + Length + ); + if (!EFI_ERROR (Status)) { + Status =3D gDS->AddMemorySpace ( + ((Capabilities & EFI_MEMORY_MORE_RELIABLE) =3D=3D EFI_= MEMORY_MORE_RELIABLE) ? + EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemM= emory, + BaseAddress, + Length, + Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEM= ORY_TESTED | EFI_MEMORY_RUNTIME) + ); + } + return Status; +} + /** Add the extened memory to whole system memory map. =20 @@ -160,18 +196,12 @@ UpdateMemoryMap ( while (Link !=3D &Private->NonTestedMemRanList) { Range =3D NONTESTED_MEMORY_RANGE_FROM_LINK (Link); =20 - gDS->RemoveMemorySpace ( - Range->StartAddress, - Range->Length - ); - - gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - Range->StartAddress, - Range->Length, - Range->Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZ= ED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) - ); - + ConvertToTestedMemory ( + Range->StartAddress, + Range->Length, + Range->Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | E= FI_MEMORY_RUNTIME) + ); Link =3D Link->ForwardLink; } =20 @@ -215,17 +245,12 @@ DirectRangeTest ( // // Add the tested compatible memory to system memory using GCD service // - gDS->RemoveMemorySpace ( - StartAddress, - Length - ); - - gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - StartAddress, - Length, - Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_= MEMORY_TESTED | EFI_MEMORY_RUNTIME) - ); + ConvertToTestedMemory ( + StartAddress, + Length, + Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | E= FI_MEMORY_RUNTIME) + ); =20 return EFI_SUCCESS; } --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Tue Apr 30 03:47:19 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 1518273684408359.34003654272817; Sat, 10 Feb 2018 06:41:24 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6FC30222DE154; Sat, 10 Feb 2018 06:35:34 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 33F7B223DB789 for ; Sat, 10 Feb 2018 06:35:32 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2018 06:41:19 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.37]) by FMSMGA003.fm.intel.com with ESMTP; 10 Feb 2018 06:41: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=192.55.52.93; helo=mga11.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,490,1511856000"; d="scan'208";a="26342569" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Sat, 10 Feb 2018 22:41:15 +0800 Message-Id: <20180210144115.432040-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180210144115.432040-1-ruiyu.ni@intel.com> References: <20180210144115.432040-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH v2 2/2] MdeModulePkg/NullMemoryTest: Handle more reliable 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: Liming Gao , 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" Today's implementation converts the untested more reliable memory from reserved GCD type to system memory GCD type. Though it doesn't impact the return result of gBS->GetMemoryMap(). But it impacts the return result of gDS->GetMemorySpaceDescriptor(). The patch fixes the bug to convert the untested more reliable memory from reserved GCD type to more reliable memory GCD type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Liming Gao Reviewed-by: Liming Gao --- .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 75 +++++++++++++-----= ---- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemory= Test.c b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest= .c index 9c9849c776..11af8ea77f 100644 --- a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c +++ b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c @@ -1,7 +1,7 @@ /** @file Implementation of Generic Memory Test Protocol which does not perform re= al memory test. =20 -Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -58,6 +58,38 @@ GenericMemoryTestEntryPoint ( return EFI_SUCCESS; } =20 +/** + Convert the memory descriptor to tested. + + @param Descriptor Pointer to EFI_GCD_MEMORY_SPACE_DESCRIPTOR + + @retval EFI_SUCCESS The memory descriptor is converted to tested. + @retval others Error happens. +**/ +EFI_STATUS +ConvertToTestedMemory ( + IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor + ) +{ + EFI_STATUS Status; + Status =3D gDS->RemoveMemorySpace ( + Descriptor->BaseAddress, + Descriptor->Length + ); + if (!EFI_ERROR (Status)) { + Status =3D gDS->AddMemorySpace ( + ((Descriptor->Capabilities & EFI_MEMORY_MORE_RELIABLE)= =3D=3D EFI_MEMORY_MORE_RELIABLE) ? + EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemM= emory, + Descriptor->BaseAddress, + Descriptor->Length, + Descriptor->Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEM= ORY_TESTED | EFI_MEMORY_RUNTIME) + ); + } + return Status; +} + + /** Initialize the generic memory test. =20 @@ -83,6 +115,7 @@ InitializeMemoryTest ( OUT BOOLEAN *RequireSoftECCInit ) { + EFI_STATUS Status; UINTN NumberOfDescriptors; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; UINTN Index; @@ -96,22 +129,12 @@ InitializeMemoryTest ( // // For those reserved memory that have not been tested, simply promo= te to system memory. // - gDS->RemoveMemorySpace ( - MemorySpaceMap[Index].BaseAddress, - MemorySpaceMap[Index].Length - ); - - gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - MemorySpaceMap[Index].BaseAddress, - MemorySpaceMap[Index].Length, - MemorySpaceMap[Index].Capabilities &~ - (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TEST= ED | EFI_MEMORY_RUNTIME) - ); - + Status =3D ConvertToTestedMemory (&MemorySpaceMap[Index]); + ASSERT_EFI_ERROR (Status); mTestedSystemMemory +=3D MemorySpaceMap[Index].Length; mTotalSystemMemory +=3D MemorySpaceMap[Index].Length; - } else if (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryType= SystemMemory) { + } else if ((MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTyp= eSystemMemory) || + (MemorySpaceMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTyp= eMoreReliable)) { mTotalSystemMemory +=3D MemorySpaceMap[Index].Length; } } @@ -204,22 +227,16 @@ EFI_STATUS EFIAPI GenCompatibleRangeTest ( IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, - IN EFI_PHYSICAL_ADDRESS StartAddress, - IN UINT64 Length + IN EFI_PHYSICAL_ADDRESS StartAddress, + IN UINT64 Length ) { + EFI_STATUS Status; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; =20 - gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor); - - gDS->RemoveMemorySpace (StartAddress, Length); - - gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - StartAddress, - Length, - Descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIAL= IZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) - ); - - return EFI_SUCCESS; + Status =3D gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor); + if (!EFI_ERROR (Status)) { + Status =3D ConvertToTestedMemory (&Descriptor); + } + return Status; } --=20 2.16.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel