summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-16 04:36:24 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-16 04:36:24 +0000
commitf4a25e813f7ffa624b4868eb19fe13a34c4778ce (patch)
tree2cde91db065fc9402936d13b26510a6d6d2c46ec /MdeModulePkg
parent54e27ada3e63b559e2e18c44d3cb8c69a5f5a561 (diff)
downloadedk2-platforms-f4a25e813f7ffa624b4868eb19fe13a34c4778ce.tar.xz
Add validation on ACPI_S3_CONTEXT.S3DebugBufferAddress, moreover only debug tip could override IDT entry for INT3.
Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13640 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c25
-rw-r--r--MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c29
2 files changed, 33 insertions, 21 deletions
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c
index 9f04959cd9..fbdf32b60b 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c
@@ -50,14 +50,25 @@ SetIdtEntry (
// Restore IDT for debug
//
IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);
- IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
- S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
+ AsmWriteIdtr (IdtDescriptor);
- IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;
- IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
- IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
- IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
+ //
+ // Setup the default CPU exception handlers
+ //
+ SetupCpuExceptionHandlers ();
- AsmWriteIdtr (IdtDescriptor);
+ DEBUG_CODE (
+ //
+ // Update IDT entry INT3 if the instruction is valid in it
+ //
+ S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
+ if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
+ IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
+ IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;
+ IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();;
+ IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
+ IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
+ }
+ );
}
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
index 8c34993587..40c27e4f67 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
@@ -126,23 +126,24 @@ SetIdtEntry (
//
SetupCpuExceptionHandlers ();
- //
- // Update IDT entry INT3
- //
- IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
- S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
-
- IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;
- IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
- IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
- IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);
- IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);
- IdtEntry->Reserved = 0;
+ DEBUG_CODE (
+ //
+ // Update IDT entry INT3 if the instruction is valid in it
+ //
+ S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
+ if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
+ IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
+ IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;
+ IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
+ IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
+ IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);
+ IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);
+ IdtEntry->Reserved = 0;
+ }
+ );
IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (14 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
HookPageFaultHandler (IdtEntry);
-
- AsmWriteIdtr (IdtDescriptor);
}
/**