diff options
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r-- | UefiCpuPkg/CpuDxe/CpuDxe.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 454659150f..369fe65aa6 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -1014,11 +1014,12 @@ InitInterruptDescriptorTable ( VOID
)
{
- EFI_STATUS Status;
- VOID *IdtPtrAlignmentBuffer;
- IA32_DESCRIPTOR *IdtPtr;
- UINTN Index;
- UINTN CurrentHandler;
+ EFI_STATUS Status;
+ VOID *IdtPtrAlignmentBuffer;
+ IA32_DESCRIPTOR *IdtPtr;
+ UINTN Index;
+ UINTN CurrentHandler;
+ IA32_DESCRIPTOR Idtr;
SetMem (ExternalVectorTable, sizeof(ExternalVectorTable), 0);
@@ -1028,7 +1029,6 @@ InitInterruptDescriptorTable ( CurrentHandler = (UINTN)AsmIdtVector00;
for (Index = 0; Index < INTERRUPT_VECTOR_NUMBER; Index ++, CurrentHandler += 0x08) {
gIdtTable[Index].Bits.OffsetLow = (UINT16)CurrentHandler;
- gIdtTable[Index].Bits.Selector = AsmReadCs();
gIdtTable[Index].Bits.Reserved_0 = 0;
gIdtTable[Index].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
gIdtTable[Index].Bits.OffsetHigh = (UINT16)(CurrentHandler >> 16);
@@ -1039,6 +1039,23 @@ InitInterruptDescriptorTable ( }
//
+ // Get original IDT address and size.
+ //
+ AsmReadIdtr ((IA32_DESCRIPTOR *) &Idtr);
+
+ //
+ // Copy original IDT entry.
+ //
+ CopyMem (&gIdtTable[0], (VOID *) Idtr.Base, Idtr.Limit + 1);
+
+ //
+ // Update all IDT enties to use cuurent CS value
+ //
+ for (Index = 0; Index < INTERRUPT_VECTOR_NUMBER; Index ++, CurrentHandler += 0x08) {
+ gIdtTable[Index].Bits.Selector = AsmReadCs();
+ }
+
+ //
// Load IDT Pointer
//
IdtPtrAlignmentBuffer = AllocatePool (sizeof (*IdtPtr) + 16);
|