public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V1 1/1] OvmfPkg/PlatformPei: Skip PlatformInitEmuVariableNvStore in SEV guest
@ 2023-03-29  5:23 Min Xu
  2023-03-30  7:50 ` Gerd Hoffmann
  0 siblings, 1 reply; 28+ messages in thread
From: Min Xu @ 2023-03-29  5:23 UTC (permalink / raw)
  To: devel
  Cc: Min M Xu, Erdem Aktas, James Bottomley, Jiewen Yao, Tom Lendacky,
	Michael Roth, Gerd Hoffmann, Joey Lee

From: Min M Xu <min.m.xu@intel.com>

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

PlatformInitEmuVariableNvStore is called to initialize the
EmuVariableNvStore with the content pointed by
PcdOvmfFlashNvStorageVariableBase. This is because when OVMF is launched
with -bios parameter, UEFI variables will be partially emulated, and
non-volatile variables may lose their contents after a reboot. This makes
the secure boot feature not working.

But in SEV guest, this design doesn't work. Because at this point the
variable store mapping is still private/encrypted, OVMF will see
ciphertext. So we skip the call of PlatformInitEmuVariableNvStore in
SEV guest.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reported-by: Joey Lee <jlee@suse.com>
Tested-by: Joey Lee <jlee@suse.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
---
 OvmfPkg/PlatformPei/Platform.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 148240342b4b..be9ba3e00124 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -223,7 +223,20 @@ ReserveEmuVariableNvStore (
   PcdStatus     = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
 
  #ifdef SECURE_BOOT_FEATURE_ENABLED
-  PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
+  //
+  // PlatformInitEmuVariableNvStore is called to initialize the EmuVariableNvStore
+  // with the content pointed by PcdOvmfFlashNvStorageVariableBase. This is because
+  // when OVMF is launched with -bios parameter, UEFI variables will be partially emulated,
+  // and non-volatile variables may lose their contents after a reboot. This makes the secure
+  // boot feature not working.
+  // But in SEV guest, this design doesn't work. Because at this point the variable store
+  // mapping is still private/encrypted, OVMF will see ciphertext. So we skip the call
+  // of PlatformInitEmuVariableNvStore in SEV guest.
+  //
+  if (!MemEncryptSevIsEnabled ()) {
+    PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
+  }
+
  #endif
 
   ASSERT_RETURN_ERROR (PcdStatus);
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-05-01 19:06 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-29  5:23 [PATCH V1 1/1] OvmfPkg/PlatformPei: Skip PlatformInitEmuVariableNvStore in SEV guest Min Xu
2023-03-30  7:50 ` Gerd Hoffmann
2023-03-31  7:59   ` joeyli
2023-03-31  8:25     ` Gerd Hoffmann
2023-03-31 14:48       ` joeyli
2023-04-03  0:21         ` Min Xu
2023-04-03 11:20           ` Gerd Hoffmann
2023-04-06  1:42             ` Min Xu
2023-04-06 20:28               ` Lendacky, Thomas
2023-04-07  1:56                 ` Min Xu
2023-04-07 14:49                   ` [edk2-devel] " joeyli
2023-04-07 17:00                   ` Lendacky, Thomas
2023-04-11 10:04                     ` Gerd Hoffmann
2023-04-11 18:03                       ` Lendacky, Thomas
2023-04-12  7:24                         ` Gerd Hoffmann
2023-04-12 15:23                           ` Lendacky, Thomas
2023-04-13  6:05                             ` Gerd Hoffmann
2023-04-13 13:58                               ` Lendacky, Thomas
2023-04-14 10:20                                 ` Gerd Hoffmann
2023-04-20 15:16                                   ` Lendacky, Thomas
2023-04-21  9:18                                     ` Gerd Hoffmann
2023-04-21 20:49                                       ` Lendacky, Thomas
2023-04-24  9:45                                         ` Gerd Hoffmann
2023-04-26 20:43                                           ` Lendacky, Thomas
2023-04-28  8:41                                             ` Gerd Hoffmann
2023-05-01 19:06                                               ` Lendacky, Thomas
2023-04-07  9:41           ` joeyli
2023-04-07 11:54             ` Min Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox