Reviewed-by: Star Zeng <[email protected]>

Thanks,
Star
-----Original Message-----
From: Brijesh Singh [mailto:[email protected]] 
Sent: Wednesday, July 4, 2018 10:02 AM
To: [email protected]
Cc: Tom Lendacky <[email protected]>; Brijesh Singh 
<[email protected]>; Dong, Eric <[email protected]>; Justen, Jordan L 
<[email protected]>; Zeng, Star <[email protected]>; Laszlo Ersek 
<[email protected]>
Subject: [PATCH v2 1/1] MdeModulePkg/Variable: Check EFI_MEMORY_RUNTIME 
attribute before setting it

Set the EFI_MEMORY_RUNTIME attribute in FtwNotificationEvent() only if the 
attribute is not already present. This will ensure that the attributes set by 
the platform drivers (e.g Ovmf pflash) is not lost.

Cc: Dong Eric <[email protected]>
Cc: Justen Jordan L <[email protected]>
Cc: Zeng Star <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Star Zeng <[email protected]>
Signed-off-by: Brijesh Singh <[email protected]>
---

Change since v1:
 - fix coding style

 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 6b04f4f7b394..23186176be75 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -412,13 +412,15 @@ FtwNotificationEvent (
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_WARN, "Variable driver failed to get flash memory 
attribute.\n"));
   } else {
-    Status = gDS->SetMemorySpaceAttributes (
-                    BaseAddress,
-                    Length,
-                    GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
-                    );
-    if (EFI_ERROR (Status)) {
-      DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME 
attribute to Flash.\n"));
+    if ((GcdDescriptor.Attributes & EFI_MEMORY_RUNTIME) == 0) {
+      Status = gDS->SetMemorySpaceAttributes (
+                      BaseAddress,
+                      Length,
+                      GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME
+                      );
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_WARN, "Variable driver failed to add EFI_MEMORY_RUNTIME 
attribute to Flash.\n"));
+      }
     }
   }
 
--
2.7.4

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to