On 11/07/13 19:07, Laszlo Ersek wrote:

> (2) 3.10-based host kernel, qemu v1.6.1, Xeon W3550 host CPU:
> [...]
> - my "personal" CSM build runs into an assert (triggered by one of the
> CSM patches) -- this would be needed for Windows 2008 R2.
> 
> [...]
> 
> The CSM patches I've been using are not official (they are not in the
> tree). I'll have to look what's wrong with them, when this series is
> applied, but they should certainly not block the series.

I "fixed" my CSM problem by keeping only the absolutely necessary
(out-of-tree) CSM patches:

- OvmfPkg: Don't build in QemuVideoDxe when we have CSM
- LegacyBios: Add UmbStart,UmbEnd fields to EFI_COMPATIBILITY16_TABLE
- add CSM build of SeaBIOS as "Csm16.bin"

This way I could boot Win2k8R2 too. That's a relevant test case because
it suggests that:
- the patchset doesn't break CSM,
- since Win2k8R2 massages variables at runtime, very early at OS
startup, the patchset seems to allocate stuff in runtime memory
correctly, and to convert pointers correctly.

> Therefore:
> 
> series
> Tested-by: Laszlo Ersek <[email protected]>

Reaffirmed.


> I also wanted to test secure boot (see if the enrolled keys survive a
> cold reboot), but I noticed that this series doesn't disable the "load
> variables from the NvVars file" functionality.
> 
> I added the attached patch on top of this series, and this way the
> enrolled keys seem to persist. I could fully secure-boot Fedora 19 on my
> SVM host with it, even after a full VM shutdown. Do you think the patch
> has merit?

Unfortunately, the patch that I attached earlier was buggy. I hadn't
realized that precisely one of
- QemuFlashFvbServicesRuntimeDxe and
- EmuVariableFvbRuntimeDxe
*will* set PcdFlashNvStorageVariableBase64. The former takes priority if
we have working flash, but even if we don't, the PCD gets set by the
second driver. Consequently, my patch broke NvVars loading even for
hosts that needed it.

I updated the patch by introducing yet another dynamic PCD (attached).
It's not elegant, just a proof of concept, and it works as expected. (I
tested it in all scenarios I could imagine.)


Finally, I've come up with the following hugely sophisticated way to
update a VM-specific flash file from a fresh OVMF build, without
disturbing the VM's variable store:

  dd if=OVMF.fd of=vm1.ovmf.flash bs=128K skip=1 seek=1

I sought to "double-check" the files with vbindiff.

Thanks,
Laszlo
From a7751e964b29c8a8a4a5cf5e7f7735ec29acee7a Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <[email protected]>
Date: Thu, 7 Nov 2013 18:18:43 +0100
Subject: [PATCH v2] OvmfPkg: don't restore NvVars from disk if we have working
 flash

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c              | 15 ++++++++++-----
 OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c   |  1 +
 OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf         |  1 +
 OvmfPkg/OvmfPkg.dec                                       |  1 +
 .../FvbServicesRuntimeDxe.inf                             |  1 +
 5 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c 
b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
index ba6af2c..ab9c93e 100644
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
@@ -1073,11 +1073,16 @@ Returns:
 
   ConnectRootBridge ();
 
-  //
-  // Try to restore variables from the hard disk early so
-  // they can be used for the other BDS connect operations.
-  //
-  PlatformBdsRestoreNvVarsFromHardDisk ();
+  if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
+    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 ();
+  }
 
   //
   // Init the time out value
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
index 1210337..0a70c42 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
@@ -1222,5 +1222,6 @@ Returns:
                   );
   ASSERT_EFI_ERROR (Status);
 
+  PcdSetBool (PcdOvmfFlashVariablesEnable, TRUE);
   return EFI_SUCCESS;
 }
diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf 
b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
index 7f7f473..a2b72ba 100644
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
@@ -57,6 +57,7 @@
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
 
 [Pcd.IA32, Pcd.X64]
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 01fe469..359383d 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -80,6 +80,7 @@
 
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0xff
 
 [PcdsFeatureFlag]
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf 
b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
index 81981f5..e3e7176 100644
--- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
@@ -77,6 +77,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
 
 
 [Depex]
-- 
1.8.3.1

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to