]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted
authorDionna Glaze <dionnaglaze@google.com>
Thu, 26 Jan 2023 21:17:40 +0000 (21:17 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 26 Jan 2023 23:00:51 +0000 (23:00 +0000)
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 <ardb@kernel.org>
Cc: "Min M. Xu" <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/PlatformPei/AmdSev.c

index e4e7b72e67926a55442d35e4cf17c80f6b73f98a..e6b602d79a05173fe5472865902765dc095374ce 100644 (file)
@@ -16,6 +16,7 @@
 #include <Library/MemEncryptSevLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Pi/PrePiHob.h>\r
 #include <PiPei.h>\r
 #include <Register/Amd/Msr.h>\r
 #include <Register/Intel/SmramSaveStateMap.h>\r
@@ -65,6 +66,11 @@ AmdSevSnpInitialize (
       ResourceHob = Hob.ResourceDescriptor;\r
 \r
       if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
+        if (ResourceHob->PhysicalStart >= SIZE_4GB) {\r
+          ResourceHob->ResourceType = BZ3937_EFI_RESOURCE_MEMORY_UNACCEPTED;\r
+          continue;\r
+        }\r
+\r
         MemEncryptSevSnpPreValidateSystemRam (\r
           ResourceHob->PhysicalStart,\r
           EFI_SIZE_TO_PAGES ((UINTN)ResourceHob->ResourceLength)\r