* [PATCH v2 1/2] MdeModulePkg/GenericMemoryTest: Handle more reliable memory
2018-02-10 14:41 [PATCH v2 0/2] Update memory test driver to handle more reliable memory Ruiyu Ni
@ 2018-02-10 14:41 ` Ruiyu Ni
2018-02-10 14:41 ` [PATCH v2 2/2] MdeModulePkg/NullMemoryTest: " Ruiyu Ni
2018-02-27 5:15 ` [PATCH v2 0/2] Update memory test driver to handle " Gao, Liming
2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2018-02-10 14:41 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Liming Gao
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 <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
.../GenericMemoryTestDxe/LightMemoryTest.c | 75 ++++++++++++++--------
1 file changed, 50 insertions(+), 25 deletions(-)
diff --git a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c
index 477c914059..a7ade955c3 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.<BR>
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
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);
for (Index = 0; Index < NumberOfDescriptors; Index++) {
- if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
+ if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
+ (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) {
Private->BaseMemorySize += MemorySpaceMap[Index].Length;
}
}
@@ -138,6 +139,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 +196,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 +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 | EFI_MEMORY_RUNTIME)
+ );
return EFI_SUCCESS;
}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] MdeModulePkg/NullMemoryTest: Handle more reliable memory
2018-02-10 14:41 [PATCH v2 0/2] Update memory test driver to handle more reliable memory Ruiyu Ni
2018-02-10 14:41 ` [PATCH v2 1/2] MdeModulePkg/GenericMemoryTest: Handle " Ruiyu Ni
@ 2018-02-10 14:41 ` Ruiyu Ni
2018-02-27 5:15 ` [PATCH v2 0/2] Update memory test driver to handle " Gao, Liming
2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2018-02-10 14:41 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Liming Gao
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 <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
.../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 75 +++++++++++++---------
1 file changed, 46 insertions(+), 29 deletions(-)
diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.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 real memory test.
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
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;
}
+/**
+ 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 = gDS->RemoveMemorySpace (
+ Descriptor->BaseAddress,
+ Descriptor->Length
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gDS->AddMemorySpace (
+ ((Descriptor->Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE) ?
+ EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,
+ Descriptor->BaseAddress,
+ Descriptor->Length,
+ Descriptor->Capabilities &~
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
+ );
+ }
+ return Status;
+}
+
+
/**
Initialize the generic memory test.
@@ -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 promote 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_TESTED | EFI_MEMORY_RUNTIME)
- );
-
+ Status = ConvertToTestedMemory (&MemorySpaceMap[Index]);
+ ASSERT_EFI_ERROR (Status);
mTestedSystemMemory += MemorySpaceMap[Index].Length;
mTotalSystemMemory += MemorySpaceMap[Index].Length;
- } else if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
+ } else if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
+ (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) {
mTotalSystemMemory += 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;
- gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);
-
- gDS->RemoveMemorySpace (StartAddress, Length);
-
- gDS->AddMemorySpace (
- EfiGcdMemoryTypeSystemMemory,
- StartAddress,
- Length,
- Descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
- );
-
- return EFI_SUCCESS;
+ Status = gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);
+ if (!EFI_ERROR (Status)) {
+ Status = ConvertToTestedMemory (&Descriptor);
+ }
+ return Status;
}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] Update memory test driver to handle more reliable memory
2018-02-10 14:41 [PATCH v2 0/2] Update memory test driver to handle more reliable memory Ruiyu Ni
2018-02-10 14:41 ` [PATCH v2 1/2] MdeModulePkg/GenericMemoryTest: Handle " Ruiyu Ni
2018-02-10 14:41 ` [PATCH v2 2/2] MdeModulePkg/NullMemoryTest: " Ruiyu Ni
@ 2018-02-27 5:15 ` Gao, Liming
2 siblings, 0 replies; 4+ messages in thread
From: Gao, Liming @ 2018-02-27 5:15 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
Please add the bugzilar link in commit log.
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Ruiyu Ni
>Sent: Saturday, February 10, 2018 10:41 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [PATCH v2 0/2] Update memory test driver to handle more
>reliable memory
>
>v2: Fix GenericMemoryTest to count more reliable memory into total memory.
>
>Ruiyu Ni (2):
> MdeModulePkg/GenericMemoryTest: Handle more reliable memory
> MdeModulePkg/NullMemoryTest: Handle more reliable memory
>
> .../GenericMemoryTestDxe/LightMemoryTest.c | 75 ++++++++++++++--
>------
> .../MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 75
>+++++++++++++---------
> 2 files changed, 96 insertions(+), 54 deletions(-)
>
>--
>2.16.1.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread