]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeCore: Filter out all paging capabilities
authorJian J Wang <jian.j.wang@intel.com>
Thu, 23 Nov 2017 01:48:33 +0000 (09:48 +0800)
committerStar Zeng <star.zeng@intel.com>
Fri, 24 Nov 2017 01:43:10 +0000 (09:43 +0800)
Some OSs will treat EFI_MEMORY_DESCRIPTOR.Attribute as really
set attributes and change memory paging attribute accordingly.
But current EFI_MEMORY_DESCRIPTOR.Attribute is assigned by
value from Capabilities in GCD memory map. This might cause
boot problems. Clearing all paging related capabilities can
workaround it. The code added in this patch is supposed to
be removed once the usage of EFI_MEMORY_DESCRIPTOR.Attribute
is clarified in UEFI spec and adopted by both EDK-II Core and
all supported OSs.

Laszlo did a thorough test on OVMF emulated platform. The details
can be found at
    https://bugzilla.tianocore.org/show_bug.cgi?id=753#c10

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
MdeModulePkg/Core/Dxe/Mem/Page.c

index 2034b64cd72d0d4e3c9af9372fa06cfc7f2a5fa1..962ae90d3dd68e48708761bff4610750a20ee9bd 100644 (file)
@@ -1687,6 +1687,7 @@ CoreGetMemoryMap (
   EFI_GCD_MAP_ENTRY                 MergeGcdMapEntry;\r
   EFI_MEMORY_TYPE                   Type;\r
   EFI_MEMORY_DESCRIPTOR             *MemoryMapStart;\r
+  EFI_MEMORY_DESCRIPTOR             *MemoryMapEnd;\r
 \r
   //\r
   // Make sure the parameters are valid\r
@@ -1896,6 +1897,25 @@ CoreGetMemoryMap (
   //\r
   BufferSize = ((UINT8 *)MemoryMap - (UINT8 *)MemoryMapStart);\r
 \r
+  //\r
+  // Note: Some OSs will treat EFI_MEMORY_DESCRIPTOR.Attribute as really\r
+  //       set attributes and change memory paging attribute accordingly.\r
+  //       But current EFI_MEMORY_DESCRIPTOR.Attribute is assigned by\r
+  //       value from Capabilities in GCD memory map. This might cause\r
+  //       boot problems. Clearing all paging related capabilities can\r
+  //       workaround it. Following code is supposed to be removed once\r
+  //       the usage of EFI_MEMORY_DESCRIPTOR.Attribute is clarified in\r
+  //       UEFI spec and adopted by both EDK-II Core and all supported\r
+  //       OSs.\r
+  //\r
+  MemoryMapEnd = MemoryMap;\r
+  MemoryMap = MemoryMapStart;\r
+  while (MemoryMap < MemoryMapEnd) {\r
+    MemoryMap->Attribute &= ~(UINT64)(EFI_MEMORY_RP | EFI_MEMORY_RO |\r
+                                      EFI_MEMORY_XP);\r
+    MemoryMap = NEXT_MEMORY_DESCRIPTOR (MemoryMap, Size);\r
+  }\r
+\r
   Status = EFI_SUCCESS;\r
 \r
 Done:\r