Re: [edk2-devel] [PATCH V2 5/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore

2022-06-28 Thread Min Xu
On June 27, 2022 5:14 PM, Gerd Hoffmann wrote:
> > + #ifdef SECURE_BOOT_FEATURE_ENABLED
> > +  PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> > + #endif
> 
> OvmfPkg/Library/NvVarsFileLib/ allows loading variables into emulated
> varstore from a on-disk NvVars file.  We can't allow that when secure boot is
> active.  I think we need a simliar check there.  Shortcutting the
> ConnectNvVarsToFileSystem() function with a
> 
> #ifdef SECURE_BOOT_FEATURE_ENABLED
>   return EFI_NOT_SUPPORTED;
> #endif
> 
> should do the trick I think.
> 
A good suggestion. It will be updated in the next version.

Thanks
Min


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90831): https://edk2.groups.io/g/devel/message/90831
Mute This Topic: https://groups.io/mt/91995192/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 5/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore

2022-06-27 Thread Gerd Hoffmann
  Hi,

> + #ifdef SECURE_BOOT_FEATURE_ENABLED
> +  PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> + #endif

OvmfPkg/Library/NvVarsFileLib/ allows loading variables into emulated
varstore from a on-disk NvVars file.  We can't allow that when secure
boot is active.  I think we need a simliar check there.  Shortcutting
the ConnectNvVarsToFileSystem() function with a

#ifdef SECURE_BOOT_FEATURE_ENABLED
return EFI_NOT_SUPPORTED;
#endif

should do the trick I think.

thanks,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90790): https://edk2.groups.io/g/devel/message/90790
Mute This Topic: https://groups.io/mt/91995192/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V2 5/8] OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore

2022-06-25 Thread Min Xu
From: Min M Xu 

ReserveEmuVariableNvStore is updated with below 2 functions defined in
PlatformInitLib:
 - PlatformReserveEmuVariableNvStore
 - PlatformInitEmuVariableNvStore

PlatformInitEmuVariableNvStore works when secure boot feature is enabled.
This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc)
and EmuVariableNvStore is cleared when OVMF is launched with -bios
parameter.

Cc: Erdem Aktas 
Cc: James Bottomley  [jejb]
Cc: Jiewen Yao  [jyao1]
Cc: Tom Lendacky  [tlendacky]
Cc: Gerd Hoffmann 
Signed-off-by: Min Xu 
---
 OvmfPkg/PlatformPei/Platform.c | 25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 009db67ee60a..b1f8140d6041 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -220,24 +220,13 @@ ReserveEmuVariableNvStore (
   EFI_PHYSICAL_ADDRESS  VariableStore;
   RETURN_STATUS PcdStatus;
 
-  //
-  // Allocate storage for NV variables early on so it will be
-  // at a consistent address.  Since VM memory is preserved
-  // across reboots, this allows the NV variable storage to survive
-  // a VM reboot.
-  //
-  VariableStore =
-(EFI_PHYSICAL_ADDRESS)(UINTN)
-AllocateRuntimePages (
-  EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
-  );
-  DEBUG ((
-DEBUG_INFO,
-"Reserved variable store memory: 0x%lX; size: %dkb\n",
-VariableStore,
-(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
-));
-  PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
+  VariableStore = 
(EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
+  PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
+
+ #ifdef SECURE_BOOT_FEATURE_ENABLED
+  PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
+ #endif
+
   ASSERT_RETURN_ERROR (PcdStatus);
 }
 
-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90757): https://edk2.groups.io/g/devel/message/90757
Mute This Topic: https://groups.io/mt/91995192/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-