From 0d129ef7c3a95d64f2f2cab4f8302318775f9933 Mon Sep 17 00:00:00 2001 From: Dionna Glaze Date: Thu, 26 Jan 2023 21:17:40 +0000 Subject: [PATCH] OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted Instead of eagerly accepting all memory in PEI, only accept memory under the 4GB address. This allows a loaded image to use the MEMORY_ACCEPTANCE_PROTOCOL to disable the accept behavior and indicate that it can interpret the memory type accordingly. This classification is safe since ExitBootServices will accept and reclassify the memory as conventional if the disable protocol is not used. Cc: Ard Biescheuvel Cc: "Min M. Xu" Cc: Gerd Hoffmann Cc: James Bottomley Cc: Tom Lendacky Cc: Jiewen Yao Cc: Erdem Aktas Signed-off-by: Dionna Glaze Reviewed-by: Ard Biesheuvel --- OvmfPkg/PlatformPei/AmdSev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index e4e7b72e67..e6b602d79a 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,11 @@ AmdSevSnpInitialize ( ResourceHob = Hob.ResourceDescriptor; if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) { + if (ResourceHob->PhysicalStart >= SIZE_4GB) { + ResourceHob->ResourceType = BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED; + continue; + } + MemEncryptSevSnpPreValidateSystemRam ( ResourceHob->PhysicalStart, EFI_SIZE_TO_PAGES ((UINTN)ResourceHob->ResourceLength)