]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuDxe.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuDxe.c
index 00f3cb09572cfcb2308d0fef50ab269b74fe90cb..a6a91507f6066fbce11911530b083abe9904a658 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU DXE Module to produce CPU ARCH Protocol.\r
 \r
-  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -10,6 +10,8 @@
 #include "CpuMp.h"\r
 #include "CpuPageTable.h"\r
 \r
+#define CPU_INTERRUPT_NUM  256\r
+\r
 //\r
 // Global Variables\r
 //\r
@@ -924,9 +926,12 @@ InitInterruptDescriptorTable (
   VOID\r
   )\r
 {\r
-  EFI_STATUS               Status;\r
-  EFI_VECTOR_HANDOFF_INFO  *VectorInfoList;\r
-  EFI_VECTOR_HANDOFF_INFO  *VectorInfo;\r
+  EFI_STATUS                Status;\r
+  EFI_VECTOR_HANDOFF_INFO   *VectorInfoList;\r
+  EFI_VECTOR_HANDOFF_INFO   *VectorInfo;\r
+  IA32_IDT_GATE_DESCRIPTOR  *IdtTable;\r
+  IA32_DESCRIPTOR           IdtDescriptor;\r
+  UINTN                     IdtEntryCount;\r
 \r
   VectorInfo = NULL;\r
   Status     = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);\r
@@ -934,7 +939,25 @@ InitInterruptDescriptorTable (
     VectorInfo = VectorInfoList;\r
   }\r
 \r
-  Status = InitializeCpuInterruptHandlers (VectorInfo);\r
+  AsmReadIdtr (&IdtDescriptor);\r
+  IdtEntryCount = (IdtDescriptor.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR);\r
+  if (IdtEntryCount < CPU_INTERRUPT_NUM) {\r
+    //\r
+    // Increase Interrupt Descriptor Table and Copy the old IDT table in\r
+    //\r
+    IdtTable = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM);\r
+    ASSERT (IdtTable != NULL);\r
+    CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount);\r
+\r
+    //\r
+    // Load Interrupt Descriptor Table\r
+    //\r
+    IdtDescriptor.Base  = (UINTN)IdtTable;\r
+    IdtDescriptor.Limit = (UINT16)(sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM - 1);\r
+    AsmWriteIdtr (&IdtDescriptor);\r
+  }\r
+\r
+  Status = InitializeCpuExceptionHandlers (VectorInfo);\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r