[edk2-devel] [RFC PATCH v2 10/44] OvmfPkg: A per-CPU variable area for #VC usage

Lendacky, Thomas thomas.lendacky at amd.com
Thu Sep 19 19:52:35 UTC 2019


From: Tom Lendacky <thomas.lendacky at amd.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198

A per-CPU implementation for holding values specific to a CPU when
running as an SEV-ES guest, specifically to hold the Debug Register
value. Allocate an extra page immediately after the GHCB page for each
AP.

Using the page after the GHCB ensures that it is unique per AP. But,
it also ends up being marked shared/unencrypted when it doesn't need to
be. It is possible during PEI to mark only the GHCB pages as shared (and
that is done), but DXE is not as easy. There needs to be a way to change
the pagetables created for DXE using CreateIdentityMappingPageTables()
before switching to them.

Cc: Jordan Justen <jordan.l.justen at intel.com>
Cc: Laszlo Ersek <lersek at redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Signed-off-by: Tom Lendacky <thomas.lendacky at amd.com>
---
 OvmfPkg/OvmfPkgX64.fdf                | 2 +-
 OvmfPkg/PlatformPei/AmdSev.c          | 2 +-
 OvmfPkg/ResetVector/ResetVector.nasmb | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index a567131a0591..84716952052d 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -79,7 +79,7 @@ [FD.MEMFD]
 0x008000|0x001000
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbPageTableBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbPageTableSize
 
-0x009000|0x001000
+0x009000|0x002000
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecGhcbSize
 
 0x010000|0x010000
diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
index 30c0e4af7252..699bb8b11557 100644
--- a/OvmfPkg/PlatformPei/AmdSev.c
+++ b/OvmfPkg/PlatformPei/AmdSev.c
@@ -48,7 +48,7 @@ AmdSevEsInitialize (
   //
   // Allocate GHCB pages.
   //
-  GhcbPageCount = mMaxCpuCount;
+  GhcbPageCount = mMaxCpuCount * 2;
   GhcbBase = AllocatePages (GhcbPageCount);
   ASSERT (GhcbBase);
 
diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb b/OvmfPkg/ResetVector/ResetVector.nasmb
index 8909fc9313f4..d7c0ab3ada00 100644
--- a/OvmfPkg/ResetVector/ResetVector.nasmb
+++ b/OvmfPkg/ResetVector/ResetVector.nasmb
@@ -57,7 +57,7 @@
     %error "This implementation inherently depends on PcdOvmfSecGhcbPageTableSize"
   %endif
 
-  %if (FixedPcdGet32 (PcdOvmfSecGhcbSize) != 0x1000)
+  %if (FixedPcdGet32 (PcdOvmfSecGhcbSize) != 0x2000)
     %error "This implementation inherently depends on PcdOvmfSecGhcbSize"
   %endif
 
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#47644): https://edk2.groups.io/g/devel/message/47644
Mute This Topic: https://groups.io/mt/34203546/1813853
Mute #vc: https://groups.io/mk?hashtag=vc&subid=3943202
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list