]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add validation on ACPI_S3_CONTEXT.S3DebugBufferAddress, moreover only debug tip could...
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Aug 2012 04:36:24 +0000 (04:36 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Aug 2012 04:36:24 +0000 (04:36 +0000)
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

IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3Save.c
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c

index 4e36c8ae64b45ea9fcc857e20fe2c7a89296b074..5a021d2caaa09c3485d0dd5aa3ab5ef161b1b084 100644 (file)
@@ -2,7 +2,7 @@
   This is an implementation of the ACPI S3 Save protocol.  This is defined in\r
   S3 boot path specification 0.9.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -453,9 +453,10 @@ S3Ready (
   ASSERT (AcpiS3Context->BootScriptStackBase != 0);\r
 \r
   //\r
-  // Allocate a code buffer < 4G for S3 debug to load external code\r
+  // Allocate a code buffer < 4G for S3 debug to load external code, set invalid code instructions in it.\r
   //\r
   AcpiS3Context->S3DebugBufferAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateAcpiNvsMemoryBelow4G (EFI_PAGE_SIZE);\r
+  SetMem ((VOID *)(UINTN)AcpiS3Context->S3DebugBufferAddress, EFI_PAGE_SIZE, 0xff);\r
 \r
   DEBUG((EFI_D_INFO, "AcpiS3Context: AcpiFacsTable is 0x%8x\n", AcpiS3Context->AcpiFacsTable));\r
   DEBUG((EFI_D_INFO, "AcpiS3Context: IdtrProfile is 0x%8x\n", AcpiS3Context->IdtrProfile));\r
index 9f04959cd98404751e5164c9003b1f13c1698c9d..fbdf32b60b02db00059f25a2c14d0f533fc57b57 100644 (file)
@@ -50,14 +50,25 @@ SetIdtEntry (
   // Restore IDT for debug\r
   //\r
   IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);\r
-  IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
-  S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+  AsmWriteIdtr (IdtDescriptor);\r
 \r
-  IdtEntry->OffsetLow       = (UINT16)S3DebugBuffer;\r
-  IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
-  IdtEntry->Attributes      = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
-  IdtEntry->OffsetHigh      = (UINT16)(S3DebugBuffer >> 16);\r
+  //\r
+  // Setup the default CPU exception handlers\r
+  //\r
+  SetupCpuExceptionHandlers ();\r
 \r
-  AsmWriteIdtr (IdtDescriptor);\r
+  DEBUG_CODE (\r
+    //\r
+    // Update IDT entry INT3 if the instruction is valid in it\r
+    //\r
+    S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+    if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {\r
+      IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
+      IdtEntry->OffsetLow       = (UINT16)S3DebugBuffer;\r
+      IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();;\r
+      IdtEntry->Attributes      = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
+      IdtEntry->OffsetHigh      = (UINT16)(S3DebugBuffer >> 16);\r
+    }\r
+  );\r
 }\r
 \r
index 8c34993587507e872bbfc0ddedbc822d509ece32..40c27e4f678a4d646c3612f9ba1357919c9a4c31 100644 (file)
@@ -126,23 +126,24 @@ SetIdtEntry (
   //\r
   SetupCpuExceptionHandlers ();\r
 \r
-  //\r
-  // Update IDT entry INT3\r
-  //\r
-  IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
-  S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
-\r
-  IdtEntry->Offset15To0     = (UINT16)S3DebugBuffer;\r
-  IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
-  IdtEntry->Attributes      = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
-  IdtEntry->Offset31To16    = (UINT16)(S3DebugBuffer >> 16);\r
-  IdtEntry->Offset63To32    = (UINT32)(S3DebugBuffer >> 32);\r
-  IdtEntry->Reserved        = 0;\r
+  DEBUG_CODE (\r
+    //\r
+    // Update IDT entry INT3 if the instruction is valid in it\r
+    //\r
+    S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+    if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {\r
+      IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
+      IdtEntry->Offset15To0     = (UINT16)S3DebugBuffer;\r
+      IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
+      IdtEntry->Attributes      = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
+      IdtEntry->Offset31To16    = (UINT16)(S3DebugBuffer >> 16);\r
+      IdtEntry->Offset63To32    = (UINT32)(S3DebugBuffer >> 32);\r
+      IdtEntry->Reserved        = 0;\r
+    }\r
+  );\r
 \r
   IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (14 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
   HookPageFaultHandler (IdtEntry);\r
-\r
-  AsmWriteIdtr (IdtDescriptor);\r
 }\r
 \r
 /**\r