From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 F2B4A222DE13D for ; Sat, 10 Feb 2018 06:18:45 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2018 06:24:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,489,1511856000"; d="scan'208";a="16777560" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.37]) by fmsmga007.fm.intel.com with ESMTP; 10 Feb 2018 06:24:31 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Star Zeng , Liming Gao Date: Sat, 10 Feb 2018 22:24:26 +0800 Message-Id: <20180210142427.426736-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: <20180210142427.426736-1-ruiyu.ni@intel.com> References: <20180210142427.426736-1-ruiyu.ni@intel.com> Subject: [PATCH 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: , X-List-Received-Date: Sat, 10 Feb 2018 14:18:46 -0000 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 --- .../GenericMemoryTestDxe/LightMemoryTest.c | 72 ++++++++++++++-------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c index 477c914059..512515ef38 100644 --- a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c +++ b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2006 - 2010, 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 @@ -138,6 +138,41 @@ DestroyLinkList ( } } +/** + 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 = gDS->RemoveMemorySpace ( + BaseAddress, + Length + ); + if (!EFI_ERROR (Status)) { + Status = gDS->AddMemorySpace ( + ((Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE) ? + EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory, + BaseAddress, + Length, + Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) + ); + } + return Status; +} + /** Add the extened memory to whole system memory map. @@ -160,18 +195,12 @@ UpdateMemoryMap ( while (Link != &Private->NonTestedMemRanList) { Range = NONTESTED_MEMORY_RANGE_FROM_LINK (Link); - gDS->RemoveMemorySpace ( - Range->StartAddress, - Range->Length - ); - - gDS->AddMemorySpace ( - EfiGcdMemoryTypeSystemMemory, - Range->StartAddress, - Range->Length, - Range->Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) - ); - + ConvertToTestedMemory ( + Range->StartAddress, + Range->Length, + Range->Capabilities &~ + (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) + ); Link = Link->ForwardLink; } @@ -215,17 +244,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 | EFI_MEMORY_RUNTIME) + ); return EFI_SUCCESS; } -- 2.16.1.windows.1