[HAL] Eliminate tail calls from HalpDispatchInterrupt[2]. CORE-14076

This commit is contained in:
Thomas Faber 2018-02-18 12:50:54 +01:00
parent ade345427f
commit b4453242f7
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
3 changed files with 30 additions and 4 deletions

View file

@ -576,7 +576,7 @@ HalpEnableInterruptHandler(IN UCHAR Flags,
VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts);
VOID __cdecl HalpApcInterrupt(VOID);
VOID __cdecl HalpDispatchInterrupt(VOID);
VOID __cdecl HalpDispatchInterrupt2(VOID);
PHAL_SW_INTERRUPT_HANDLER __cdecl HalpDispatchInterrupt2(VOID);
DECLSPEC_NORETURN VOID FASTCALL HalpApcInterrupt2ndEntry(IN PKTRAP_FRAME TrapFrame);
DECLSPEC_NORETURN VOID FASTCALL HalpDispatchInterrupt2ndEntry(IN PKTRAP_FRAME TrapFrame);

View file

@ -48,8 +48,32 @@ WrapperName&_CallIntHandler:
.ENDP
ENDM
MACRO(DEFINE_INTERRUPT_WRAPPER, WrapperName, HandlerName)
EXTERN _&HandlerName:PROC
PUBLIC _&WrapperName
.PROC _&WrapperName
FPO 0, 0, 0, 0, 0, FRAME_FPO
/* Call the C function */
call _&HandlerName
/* Check if we got a pointer back */
test eax, eax
jnz WrapperName&_CallIntHandler
/* No? Just return */
ret
WrapperName&_CallIntHandler:
/* Optimize the tail call to avoid stack overflow */
jmp eax
.ENDP
ENDM
DEFINE_END_INTERRUPT_WRAPPER HalpEndSoftwareInterrupt, HalpEndSoftwareInterrupt2
DEFINE_END_INTERRUPT_WRAPPER HalEndSystemInterrupt, HalEndSystemInterrupt2
DEFINE_INTERRUPT_WRAPPER HalpDispatchInterrupt, HalpDispatchInterrupt2
END

View file

@ -382,7 +382,7 @@ PHAL_SW_INTERRUPT_HANDLER SWInterruptHandlerTable[20] =
{
(PHAL_SW_INTERRUPT_HANDLER)KiUnexpectedInterrupt,
HalpApcInterrupt,
HalpDispatchInterrupt2,
HalpDispatchInterrupt,
(PHAL_SW_INTERRUPT_HANDLER)KiUnexpectedInterrupt,
HalpHardwareInterrupt0,
HalpHardwareInterrupt1,
@ -1297,7 +1297,7 @@ HalpDispatchInterrupt2ndEntry(IN PKTRAP_FRAME TrapFrame)
KiEoiHelper(TrapFrame);
}
VOID
PHAL_SW_INTERRUPT_HANDLER
__cdecl
HalpDispatchInterrupt2(VOID)
{
@ -1330,8 +1330,10 @@ HalpDispatchInterrupt2(VOID)
}
/* Now handle pending interrupt */
SWInterruptHandlerTable[PendingIrql]();
return SWInterruptHandlerTable[PendingIrql];
}
return NULL;
}
#else