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 <eric.dong@intel.com>
Cc: Justen Jordan L <jordan.l.justen@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Star Zeng <star.zeng@intel.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
This commit is contained in:
Brijesh Singh 2018-07-04 10:02:16 +08:00 committed by Star Zeng
parent dd3907f221
commit f88290964f
1 changed files with 9 additions and 7 deletions

View File

@ -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"));
}
}
}