From 8830216f0a0b35aac7761dedf21ccc426f651daf Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Thu, 19 Jun 2014 17:56:05 +0200 Subject: OvmfPkg: disable disk access in emulated (non-flash) varstore When the flash-based non-volatile variable store is unavailable, OVMF falls back to the EmuVariableFvbRuntimeDxe driver, which provides the variable store in normal RAM. When variables are updated, EmuVariableFvbRuntimeDxe sends notifications via the PlatformFvbLib library class. The upstream OVMF default is to provide a library implementation that calls back to a BDS hook, which in turn serializes variables to the EFI system partition (at boot time). OVMF-BDS EmuVariableFvbRuntimeDxe PlatformFvbLib NvVarsFileLib | | | | 1. setup------------------------------------------------->| | | | | 2. setup--------------------------------->| | | | | | 3. | varstore modified---------->| | | | | | callback<--------------------------------+ | | | | | +----------------------------------------------->disk write | | | | By resolving the PlatformFvbLib library class with a Null instance, such notifications have no effect. OVMF-BDS EmuVariableFvbRuntimeDxe PlatformFvbLib NvVarsFileLib | | | | 1. setup------------------------------------------------->| | | | | 2. setup--------------------------------->| | | | | | 3. | varstore modified---------->| | | | | | In addition, modify OVMF's BDS not to (attempt to) load variables from the ESP, nor to setup anything that would be required for the above callback and the ESP accesses in general. OVMF-BDS EmuVariableFvbRuntimeDxe PlatformFvbLib NvVarsFileLib | | | | 3. | varstore modified---------->| | | | | | Suggested-by: Paolo Bonzini --- OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c | 9 ++++----- OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c index 55f27cc..e6aac43 100644 --- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c @@ -965,6 +965,7 @@ EmuVariablesUpdatedCallback ( ) { DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n")); + ASSERT (FALSE); UpdateNvVarsOnFileSystem (); } @@ -984,6 +985,7 @@ VisitingFileSystemInstance ( return EFI_ALREADY_STARTED; } + ASSERT (FALSE); Status = ConnectNvVarsToFileSystem (Handle); if (EFI_ERROR (Status)) { return Status; @@ -1195,11 +1197,8 @@ Returns: DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars " "from disk since flash variables appear to be supported.\n")); } else { - // - // Try to restore variables from the hard disk early so - // they can be used for the other BDS connect operations. - // - PlatformBdsRestoreNvVarsFromHardDisk (); + DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: falling back to " + "non-persistent (memory-only) variable store\n")); } // diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 02d2d29..1eb8f9b 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -449,7 +449,7 @@ OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf + PlatformFvbLib|OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf } MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 7d60310..3470b23 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -456,7 +456,7 @@ OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf + PlatformFvbLib|OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf } MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 3643d11..74bd317 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -454,7 +454,7 @@ OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf { - PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf + PlatformFvbLib|OvmfPkg/Library/PlatformFvbLibNull/PlatformFvbLibNull.inf } MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf -- 1.8.3.1