summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug
diff options
context:
space:
mode:
Diffstat (limited to 'SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug')
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c9
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c17
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h7
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c11
4 files changed, 29 insertions, 15 deletions
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c
index b2d4c37a9..ccf3fb184 100644
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c
+++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c
@@ -18,6 +18,7 @@
Read IDT entry to check if IDT entries are setup by Debug Agent.
@param[in] IdtDescriptor Pointer to IDT Descriptor.
+ @param[in] InterruptType Interrupt type.
@retval TRUE IDT entries were setup by Debug Agent.
@retval FALSE IDT entries were not setuo by Debug Agent.
@@ -25,7 +26,8 @@
**/
BOOLEAN
CheckDebugAgentHandler (
- IN IA32_DESCRIPTOR *IdtDescriptor
+ IN IA32_DESCRIPTOR *IdtDescriptor,
+ IN UINTN InterruptType
)
{
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
@@ -36,8 +38,9 @@ CheckDebugAgentHandler (
return FALSE;
}
- InterruptHandler = IdtEntry[0].Bits.OffsetLow + (IdtEntry[0].Bits.OffsetHigh << 16);
- if (InterruptHandler >= 4 && *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {
+ InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
+ (IdtEntry[InterruptType].Bits.OffsetHigh << 16);
+ if (InterruptHandler >= sizeof (UINT32) && *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {
return TRUE;
} else {
return FALSE;
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
index c28d7930a..9bf76bfb2 100644
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
+++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
@@ -80,18 +80,21 @@ PeCoffLoaderExtraActionCommon (
IdtEntryHooked = FALSE;
LoadImageMethod = PcdGet8 (PcdDebugLoadImageMethod);
AsmReadIdtr (&IdtDescriptor);
- if (!CheckDebugAgentHandler (&IdtDescriptor)) {
- if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
+ if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
+ if (!CheckDebugAgentHandler (&IdtDescriptor, SOFT_INT_VECTOR_NUM)) {
//
// Do not trigger INT3 if Debug Agent did not setup IDT entries.
//
return;
}
- //
- // Save and update IDT entry for INT1
- //
- SaveAndUpdateIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);
- IdtEntryHooked = TRUE;
+ } else {
+ if (!CheckDebugAgentHandler (&IdtDescriptor, IO_HW_BREAKPOINT_VECTOR_NUM)) {
+ //
+ // Save and update IDT entry for INT1
+ //
+ SaveAndUpdateIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);
+ IdtEntryHooked = TRUE;
+ }
}
//
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h
index 36aebf16d..3f919287e 100644
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h
+++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h
@@ -28,12 +28,16 @@
#define DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT 1
#define DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3 2
+#define IO_HW_BREAKPOINT_VECTOR_NUM 1
+#define SOFT_INT_VECTOR_NUM 3
+
extern UINTN AsmInterruptHandle;
/**
Read IDT entry to check if IDT entries are setup by Debug Agent.
@param[in] IdtDescriptor Pointer to IDT Descriptor.
+ @param[in] InterruptType Interrupt type.
@retval TRUE IDT entries were setup by Debug Agent.
@retval FALSE IDT entries were not setuo by Debug Agent.
@@ -41,7 +45,8 @@ extern UINTN AsmInterruptHandle;
**/
BOOLEAN
CheckDebugAgentHandler (
- IN IA32_DESCRIPTOR *IdtDescriptor
+ IN IA32_DESCRIPTOR *IdtDescriptor,
+ IN UINTN InterruptType
);
/**
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c
index c9041de76..5431187d0 100644
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c
+++ b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c
@@ -18,6 +18,7 @@
Read IDT entry to check if IDT entries are setup by Debug Agent.
@param[in] IdtDescriptor Pointer to IDT Descriptor.
+ @param[in] InterruptType Interrupt type.
@retval TRUE IDT entries were setup by Debug Agent.
@retval FALSE IDT entries were not setuo by Debug Agent.
@@ -25,7 +26,8 @@
**/
BOOLEAN
CheckDebugAgentHandler (
- IN IA32_DESCRIPTOR *IdtDescriptor
+ IN IA32_DESCRIPTOR *IdtDescriptor,
+ IN UINTN InterruptType
)
{
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
@@ -36,9 +38,10 @@ CheckDebugAgentHandler (
return FALSE;
}
- InterruptHandler = IdtEntry[0].Bits.OffsetLow + (((UINTN)IdtEntry[0].Bits.OffsetHigh) << 16) +
- (((UINTN)IdtEntry[0].Bits.OffsetUpper) << 32);
- if (InterruptHandler >= 4 && *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {
+ InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
+ (((UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) +
+ (((UINTN)IdtEntry[InterruptType].Bits.OffsetUpper) << 32);
+ if (InterruptHandler >= sizeof (UINT32) && *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {
return TRUE;
} else {
return FALSE;