summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/CpuDxe/CpuDxe.c
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2017-02-21 10:35:47 +0800
committerJeff Fan <jeff.fan@intel.com>2017-02-22 14:50:11 +0800
commit14f92ded906d22274730a92f7801f0ffd84e6193 (patch)
treed87d715d85f451c84e17551307d1e0277f0afaff /UefiCpuPkg/CpuDxe/CpuDxe.c
parent410590f149149f6170a9a72458f78913d00572de (diff)
downloadedk2-14f92ded906d22274730a92f7801f0ffd84e6193.tar.gz
edk2-14f92ded906d22274730a92f7801f0ffd84e6193.tar.bz2
edk2-14f92ded906d22274730a92f7801f0ffd84e6193.zip
UefiCpuPkg/CpuDxe: Add Local APIC memory mapped space in GCD
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>
Diffstat (limited to 'UefiCpuPkg/CpuDxe/CpuDxe.c')
-rw-r--r--UefiCpuPkg/CpuDxe/CpuDxe.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index bd0aedc7fb..c5be1ff124 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -1038,6 +1038,36 @@ FreeMemorySpaceMap:
}
/**
+ Add and allocate CPU local APIC memory mapped space.
+
+ @param[in]ImageHandle Image handle this driver.
+
+**/
+VOID
+AddLocalApicMemorySpace (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+
+ BaseAddress = (EFI_PHYSICAL_ADDRESS) GetLocalApicBaseAddress();
+ Status = AddMemoryMappedIoSpace (BaseAddress, SIZE_4KB, EFI_MEMORY_UC);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gDS->AllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ EfiGcdMemoryTypeMemoryMappedIo,
+ 0,
+ SIZE_4KB,
+ &BaseAddress,
+ ImageHandle,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
Initialize the state information for the CPU Architectural Protocol.
@param ImageHandle Image handle this driver.
@@ -1098,6 +1128,11 @@ InitializeCpu (
RefreshGcdMemoryAttributes ();
//
+ // Add and allocate local APIC memory mapped space
+ //
+ AddLocalApicMemorySpace (ImageHandle);
+
+ //
// Setup a callback for idle events
//
Status = gBS->CreateEventEx (