mirror of https://github.com/acidanthera/audk.git
Allocate memory in DebugSupport beforehand, in order to avoid calling memory allocation services in high TPL level.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2556 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
7e9f4e1d8e
commit
735561c27f
|
@ -55,7 +55,7 @@ ASM_PFX(WriteInterruptFlag):
|
|||
and $0x200,%eax
|
||||
shr $0x9,%eax
|
||||
mov 0x8(%ebp),%ecx
|
||||
or %ecx,%ecx
|
||||
or %cl,%cl
|
||||
jne ASM_PFX(WriteInterruptFlag+0x17)
|
||||
cli
|
||||
jmp ASM_PFX(WriteInterruptFlag+0x18)
|
||||
|
|
|
@ -164,7 +164,7 @@ WriteInterruptFlag PROC C PUBLIC State:DWORD
|
|||
and eax, 200h
|
||||
shr eax, 9
|
||||
mov ecx, State
|
||||
.IF ecx == 0
|
||||
.IF cl == 0
|
||||
cli
|
||||
.ELSE
|
||||
sti
|
||||
|
|
|
@ -46,16 +46,10 @@ Returns:
|
|||
{
|
||||
UINT8 *StubCopy;
|
||||
|
||||
//
|
||||
// First, allocate a new buffer and copy the stub code into it
|
||||
//
|
||||
*Stub = AllocatePool (StubSize);
|
||||
if (*Stub != NULL) {
|
||||
StubCopy = *Stub;
|
||||
CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
|
||||
//
|
||||
// Next fixup the stub code for this vector
|
||||
// Fixup the stub code for this vector
|
||||
//
|
||||
|
||||
// The stub code looks like this:
|
||||
|
@ -80,9 +74,6 @@ Returns:
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
HookEntry (
|
||||
|
@ -151,8 +142,6 @@ Returns:
|
|||
|
||||
OldIntFlagState = WriteInterruptFlag (0);
|
||||
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||
FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
|
||||
WriteInterruptFlag (OldIntFlagState);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -362,16 +351,37 @@ Returns:
|
|||
|
||||
--*/
|
||||
{
|
||||
EFI_EXCEPTION_TYPE ExceptionType;
|
||||
|
||||
if (!FxStorSupport ()) {
|
||||
return EFI_UNSUPPORTED;
|
||||
} else {
|
||||
}
|
||||
|
||||
IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
|
||||
if (IdtEntryTable != NULL) {
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
if (IdtEntryTable == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
|
||||
IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);
|
||||
if (IdtEntryTable[ExceptionType].StubEntry == NULL) {
|
||||
goto ErrorCleanup;
|
||||
}
|
||||
|
||||
CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ErrorCleanup:
|
||||
|
||||
for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
|
||||
if (IdtEntryTable[ExceptionType].StubEntry != NULL) {
|
||||
FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);
|
||||
}
|
||||
}
|
||||
FreePool (IdtEntryTable);
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
|
|
|
@ -28,11 +28,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
typedef UINT64 DESCRIPTOR;
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*DEBUG_PROC) (
|
||||
VOID
|
||||
)
|
||||
;
|
||||
|
||||
typedef struct {
|
||||
DESCRIPTOR OrigDesc;
|
||||
VOID (*OrigVector) (VOID);
|
||||
DEBUG_PROC OrigVector;
|
||||
DESCRIPTOR NewDesc;
|
||||
VOID (*StubEntry) (VOID);
|
||||
DEBUG_PROC StubEntry;
|
||||
VOID (*RegisteredCallback) ();
|
||||
} IDT_ENTRY;
|
||||
|
||||
|
|
|
@ -156,9 +156,8 @@ GetIdtr PROC PUBLIC
|
|||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
sub rsp, 8h
|
||||
sidt QWORD PTR [rbp - 6]
|
||||
mov rax, QWORD PTR [rbp - 4]
|
||||
sidt QWORD PTR [rbp - 0ah]
|
||||
mov rax, QWORD PTR [rbp - 8h]
|
||||
|
||||
mov rsp, rbp
|
||||
pop rbp
|
||||
|
|
|
@ -46,16 +46,10 @@ Returns:
|
|||
{
|
||||
UINT8 *StubCopy;
|
||||
|
||||
//
|
||||
// First, allocate a new buffer and copy the stub code into it
|
||||
//
|
||||
*Stub = AllocatePool (StubSize);
|
||||
if (*Stub != NULL) {
|
||||
StubCopy = *Stub;
|
||||
CopyMem (StubCopy, InterruptEntryStub, StubSize);
|
||||
|
||||
//
|
||||
// Next fixup the stub code for this vector
|
||||
// Fixup the stub code for this vector
|
||||
//
|
||||
|
||||
// The stub code looks like this:
|
||||
|
@ -78,9 +72,6 @@ Returns:
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
HookEntry (
|
||||
|
@ -150,8 +141,6 @@ Returns:
|
|||
|
||||
OldIntFlagState = WriteInterruptFlag (0);
|
||||
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
|
||||
FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
|
||||
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
|
||||
WriteInterruptFlag (OldIntFlagState);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -359,16 +348,37 @@ Returns:
|
|||
|
||||
--*/
|
||||
{
|
||||
EFI_EXCEPTION_TYPE ExceptionType;
|
||||
|
||||
if (!FxStorSupport ()) {
|
||||
return EFI_UNSUPPORTED;
|
||||
} else {
|
||||
}
|
||||
|
||||
IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
|
||||
if (IdtEntryTable != NULL) {
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
if (IdtEntryTable == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
|
||||
IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);
|
||||
if (IdtEntryTable[ExceptionType].StubEntry == NULL) {
|
||||
goto ErrorCleanup;
|
||||
}
|
||||
|
||||
CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ErrorCleanup:
|
||||
|
||||
for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
|
||||
if (IdtEntryTable[ExceptionType].StubEntry != NULL) {
|
||||
FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);
|
||||
}
|
||||
}
|
||||
FreePool (IdtEntryTable);
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
|
|
|
@ -31,11 +31,18 @@ typedef struct {
|
|||
UINT64 High;
|
||||
} DESCRIPTOR;
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(*DEBUG_PROC) (
|
||||
VOID
|
||||
)
|
||||
;
|
||||
|
||||
typedef struct {
|
||||
DESCRIPTOR OrigDesc;
|
||||
VOID (*OrigVector) (VOID);
|
||||
DEBUG_PROC OrigVector;
|
||||
DESCRIPTOR NewDesc;
|
||||
VOID (*StubEntry) (VOID);
|
||||
DEBUG_PROC StubEntry;
|
||||
VOID (*RegisteredCallback) ();
|
||||
} IDT_ENTRY;
|
||||
|
||||
|
|
Loading…
Reference in New Issue