]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: Add Local APIC memory mapped space in GCD
authorJeff Fan <jeff.fan@intel.com>
Tue, 21 Feb 2017 02:35:47 +0000 (10:35 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 22 Feb 2017 06:50:11 +0000 (14:50 +0800)
Local APIC memory mapped space should be added into GCD and be allocated.
Otherwise, UEFI firmware cannot get correct memory map for it. For example,
SMM profile feature needs to get the completed MMIO map to protect them.

v2:
  Consume AddMemoryMappedIoSpace() to handle the case that Local APIC
  memory space has already been added before.

https://bugzilla.tianocore.org/show_bug.cgi?id=390

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/CpuDxe/CpuDxe.c

index bd0aedc7fb457d27fba9bea44630aa97498ce7c3..c5be1ff124bb5fd49e0f60d3b029b4f993b72791 100644 (file)
@@ -1037,6 +1037,36 @@ FreeMemorySpaceMap:
   return Status;\r
 }\r
 \r
+/**\r
+  Add and allocate CPU local APIC memory mapped space. \r
+\r
+  @param[in]ImageHandle     Image handle this driver.\r
+\r
+**/\r
+VOID\r
+AddLocalApicMemorySpace (\r
+  IN EFI_HANDLE               ImageHandle\r
+  )\r
+{\r
+  EFI_STATUS              Status;\r
+  EFI_PHYSICAL_ADDRESS    BaseAddress;\r
+\r
+  BaseAddress = (EFI_PHYSICAL_ADDRESS) GetLocalApicBaseAddress();\r
+  Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gDS->AllocateMemorySpace (\r
+                  EfiGcdAllocateAddress,\r
+                  EfiGcdMemoryTypeMemoryMappedIo,\r
+                  0,\r
+                  SIZE_4KB,\r
+                  &BaseAddress,\r
+                  ImageHandle,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
 /**\r
   Initialize the state information for the CPU Architectural Protocol.\r
 \r
@@ -1097,6 +1127,11 @@ InitializeCpu (
   //\r
   RefreshGcdMemoryAttributes ();\r
 \r
+  //\r
+  // Add and allocate local APIC memory mapped space\r
+  //\r
+  AddLocalApicMemorySpace (ImageHandle);\r
+\r
   //\r
   // Setup a callback for idle events\r
   //\r