summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJian J Wang <jian.j.wang@intel.com>2018-01-15 09:45:59 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-01-18 17:03:23 +0800
commitfceafda5185af0445d83f8c819b65417b981c485 (patch)
treeed16c11964f7ca7789aac437514572be61f664f0
parentf32bfe6d061420a15bac6083063d227c567e6388 (diff)
downloadedk2-fceafda5185af0445d83f8c819b65417b981c485.tar.gz
edk2-fceafda5185af0445d83f8c819b65417b981c485.tar.bz2
edk2-fceafda5185af0445d83f8c819b65417b981c485.zip
UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers
If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory of EfiBootServicesData, EfiConventionalMemory, the BIOS will reset after timer initialized and started. The root cause is that the memory used to hold the exception and interrupt handler is allocated with type of EfiBootServicesData and marked as non-executable due to NX feature enabled. This patch fixes it by allocating EfiBootServicesCode type of memory for those handlers instead. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
-rw-r--r--UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
index 9a72b37e77..6d1b54d31d 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c
@@ -16,6 +16,7 @@
#include "CpuExceptionCommon.h"
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
CONST UINTN mDoFarReturnFlag = 0;
@@ -106,8 +107,12 @@ InitializeCpuInterruptHandlers (
RESERVED_VECTORS_DATA *ReservedVectors;
EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
- ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM);
- ASSERT (ReservedVectors != NULL);
+ Status = gBS->AllocatePool (
+ EfiBootServicesCode,
+ sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM,
+ (VOID **)&ReservedVectors
+ );
+ ASSERT (!EFI_ERROR (Status) && ReservedVectors != NULL);
SetMem ((VOID *) ReservedVectors, sizeof (RESERVED_VECTORS_DATA) * CPU_INTERRUPT_NUM, 0xff);
if (VectorInfo != NULL) {
Status = ReadAndVerifyVectorInfo (VectorInfo, ReservedVectors, CPU_INTERRUPT_NUM);
@@ -137,8 +142,13 @@ InitializeCpuInterruptHandlers (
AsmGetTemplateAddressMap (&TemplateMap);
ASSERT (TemplateMap.ExceptionStubHeaderSize <= HOOKAFTER_STUB_SIZE);
- InterruptEntryCode = AllocatePool (TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM);
- ASSERT (InterruptEntryCode != NULL);
+
+ Status = gBS->AllocatePool (
+ EfiBootServicesCode,
+ TemplateMap.ExceptionStubHeaderSize * CPU_INTERRUPT_NUM,
+ (VOID **)&InterruptEntryCode
+ );
+ ASSERT (!EFI_ERROR (Status) && InterruptEntryCode != NULL);
InterruptEntry = (UINTN) InterruptEntryCode;
for (Index = 0; Index < CPU_INTERRUPT_NUM; Index ++) {