From 64706ef761273ba403f9cb3b7a986bfb804c0a87 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Tue, 31 May 2022 22:31:17 +0800 Subject: [PATCH] OvmfPkg: Search EFI_RESOURCE_MEMORY_UNACCEPTED for Fw hoblist In current TDVF implementation all unaccepted memory passed in Hoblist are tagged as EFI_RESOURCE_MEMORY_UNACCEPTED. They're all accepted before they can be accessed. After accepting memory region, the Hob ResourceType is unchanged (still be EFI_RESOURCE_MEMORY_UNACCEPTED). TDVF Config-B skip PEI phase and it tries to find a memory region which is the largest one below 4GB. Then this memory region will be used as the firmware hoblist. So we should walk thru the input hoblist and search for the memory region with the type of EFI_RESOURCE_MEMORY_UNACCEPTED. Because EFI_RESOURCE_MEMORY_UNACCEPTED has not been officially in PI spec. So it cannot be defined in MdePkg/Include/Pi/PiHob.h. As a temporary solution it is defined in Hob.c. There is a patch-set for lazy-accept very soon. In that patch-set EFI_RESOURCE_MEMORY_UNACCEPTED will be defined in MdeModulePkg. Config-B: https://edk2.groups.io/g/devel/message/76367 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Signed-off-by: Min Xu Reviewed-by: Jiewen Yao Acked-by: Gerd Hoffmann --- OvmfPkg/Library/PeilessStartupLib/Hob.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PeilessStartupLib/Hob.c b/OvmfPkg/Library/PeilessStartupLib/Hob.c index 3c544ca1f6..5fc84a8090 100644 --- a/OvmfPkg/Library/PeilessStartupLib/Hob.c +++ b/OvmfPkg/Library/PeilessStartupLib/Hob.c @@ -22,6 +22,8 @@ #include #include "PeilessStartupInternal.h" +#define EFI_RESOURCE_MEMORY_UNACCEPTED 7 + /** * Construct the HobList in SEC phase. * @@ -90,7 +92,7 @@ ConstructFwHobList ( // while (!END_OF_HOB_LIST (Hob)) { if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { - if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) { + if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_MEMORY_UNACCEPTED) { PhysicalEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength; ResourceLength = Hob.ResourceDescriptor->ResourceLength;