]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Library/ArmExceptionLib/AArch64/AArch64Exception.c
ArmPkg/ArmExceptionLib: use static buffer for sp_el0
[mirror_edk2.git] / ArmPkg / Library / ArmExceptionLib / AArch64 / AArch64Exception.c
index 3d6eb4974d7469f780b5daebced8d2e220a2aaea..514f80a2d47afa0686395c597b398df0b98e7d39 100644 (file)
@@ -3,20 +3,14 @@
 *\r
 *  Copyright (c) 2016 HP Development Company, L.P.\r
 *\r
-*  This program and the accompanying materials\r
-*  are licensed and made available under the terms and conditions of the BSD License\r
-*  which accompanies this distribution.  The full text of the license may be found at\r
-*  http://opensource.org/licenses/bsd-license.php\r
-*\r
-*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 *\r
 **/\r
 \r
 #include <Uefi.h>\r
 \r
 #include <Chipset/AArch64.h>\r
-\r
+#include <Library/MemoryAllocationLib.h>\r
 #include <Protocol/DebugSupport.h> // for MAX_AARCH64_EXCEPTION\r
 \r
 UINTN                   gMaxExceptionNumber = MAX_AARCH64_EXCEPTION;\r
@@ -25,12 +19,25 @@ EFI_EXCEPTION_CALLBACK  gDebuggerExceptionHandlers[MAX_AARCH64_EXCEPTION + 1] =
 PHYSICAL_ADDRESS        gExceptionVectorAlignmentMask = ARM_VECTOR_TABLE_ALIGNMENT;\r
 UINTN                   gDebuggerNoHandlerValue = 0; // todo: define for AArch64\r
 \r
+#define EL0_STACK_SIZE  EFI_PAGES_TO_SIZE(2)\r
+STATIC UINTN mNewStackBase[EL0_STACK_SIZE / sizeof (UINTN)];\r
+\r
+VOID\r
+RegisterEl0Stack (\r
+  IN  VOID    *Stack\r
+  );\r
+\r
 RETURN_STATUS ArchVectorConfig(\r
   IN  UINTN       VectorBaseAddress\r
   )\r
 {\r
   UINTN             HcrReg;\r
 \r
+  // Round down sp by 16 bytes alignment\r
+  RegisterEl0Stack (\r
+    (VOID *)(((UINTN)mNewStackBase + EL0_STACK_SIZE) & ~0xFUL)\r
+    );\r
+\r
   if (ArmReadCurrentEL() == AARCH64_EL2) {\r
     HcrReg = ArmReadHcr();\r
 \r