diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c index ebf7aac2b6..345f261679 100644 --- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c +++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c @@ -273,6 +273,10 @@ CommonCExceptionHandler ( IN OUT EFI_SYSTEM_CONTEXT SystemContext ) { + if (ArmHasPan ()) { + ArmClearPan (); + } + if (ExceptionType <= gMaxExceptionNumber) { if (gExceptionHandlers[ExceptionType]) { gExceptionHandlers[ExceptionType](ExceptionType, SystemContext); diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 6f881af12a..6855633e6c 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -256,8 +256,6 @@ DefaultExceptionHandler ( DEBUG ((DEBUG_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR)); } - ArmClearPan (); - if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) { Idx = 0; diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c index 0ab3d85e38..2ede70de1b 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c @@ -76,14 +76,14 @@ SysCallBootService ( (RING3_STACK *)(UINTN)Physical ); + CoreFreePages (Physical, EFI_SIZE_TO_PAGES (9 * sizeof (UINTN))); + SetUefiImageMemoryAttributes ( gUartBaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_XP | EFI_MEMORY_USER ); - CoreFreePages (Physical, EFI_SIZE_TO_PAGES (9 * sizeof (UINTN))); - return Status; } diff --git a/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c index d208c9e0fe..4e8c690116 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c +++ b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c @@ -79,14 +79,14 @@ SysCallBootService ( (RING3_STACK *)(UINTN)Physical ); + CoreFreePages (Physical, EFI_SIZE_TO_PAGES (9 * sizeof (UINTN))); + SetUefiImageMemoryAttributes ( gUartBaseAddress, EFI_PAGE_SIZE, EFI_MEMORY_XP | EFI_MEMORY_USER ); - CoreFreePages (Physical, EFI_SIZE_TO_PAGES (9 * sizeof (UINTN))); - return Status; } diff --git a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c index 4da58f9839..52fb93ff81 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c +++ b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c @@ -94,12 +94,7 @@ GoToRing3 ( ); } #elif defined (MDE_CPU_AARCH64) || defined (MDE_CPU_ARM) - // - // Problem 2: Uart memory maped page is not allocated at the very beginnig - // and can be used for translation table later. - // AllowSupervisorAccessToUserMemory (); - SetUefiImageMemoryAttributes ( gUartBaseAddress, EFI_PAGE_SIZE,