OvmfPkg/SerializeVariablesLib: Relax check for the read-only variable
authorGary Lin <glin@suse.com>
Thu, 26 May 2016 10:24:14 +0000 (18:24 +0800)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 26 May 2016 11:21:36 +0000 (13:21 +0200)
When OVMF tried to restore the variables from the file-based NvVars, it
failed to set the read-only variable and aborted the restoration with
this message:

Variable Check ReadOnly variable fail Write Protected - 04B37FE8-F6AE-480B-BDD5-37D98C5E89AA:VarErrorFlag

Since it's a read-only variable maintained by the firmware, it's
pointless to restore the previous value, so the check can be
relaxed to allow EFI_WRITE_PROTECTED returned from SetVariable.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c

index 3a24edcd48f47a074b4623ee3d8dc5f7ba3ba0bc..a1a3d188f2ee35e4b064234ae4fe91df1bdcbb57 100644 (file)
@@ -302,6 +302,11 @@ IterateVariablesCallbackSetSystemVariable (
             "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__,\r
             VariableName));\r
     Status = EFI_SUCCESS;\r
+  } else if (Status == EFI_WRITE_PROTECTED) {\r
+    DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" "\r
+            "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__,\r
+            VariableName));\r
+    Status = EFI_SUCCESS;\r
   }\r
   return Status;\r
 }\r