]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Move the GHCB allocations into reserved memory
authorTom Lendacky <thomas.lendacky@amd.com>
Wed, 12 Aug 2020 20:21:42 +0000 (15:21 -0500)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 17 Aug 2020 02:46:39 +0000 (02:46 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198

After having transitioned from UEFI to the OS, the OS will need to boot
the APs. For an SEV-ES guest, the APs will have been parked by UEFI using
GHCB pages allocated by UEFI. The hypervisor will write to the GHCB
SW_EXITINFO2 field of the GHCB when the AP is booted. As a result, the
GHCB pages must be marked reserved so that the OS does not attempt to use
them and experience memory corruption because of the hypervisor write.

Change the GHCB allocation from the default boot services memory to
reserved memory.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/PlatformPei/AmdSev.c

index a2b38c5912363bff6eb6fc05023b7045fd9bb929..4a515a484720eca27aeed9e2e8102168b3a0dad8 100644 (file)
@@ -51,9 +51,11 @@ AmdSevEsInitialize (
 \r
   //\r
   // Allocate GHCB and per-CPU variable pages.\r
+  //   Since the pages must survive across the UEFI to OS transition\r
+  //   make them reserved.\r
   //\r
   GhcbPageCount = mMaxCpuCount * 2;\r
-  GhcbBase = AllocatePages (GhcbPageCount);\r
+  GhcbBase = AllocateReservedPages (GhcbPageCount);\r
   ASSERT (GhcbBase != NULL);\r
 \r
   GhcbBasePa = (PHYSICAL_ADDRESS)(UINTN) GhcbBase;\r