From 50058d32a2700352019baafb6046fec5980f104c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 9 Sep 2011 21:10:07 +0000 Subject: [PATCH] [HAL] Add a hack to work around a bug in VBox: The APIC emulation requires an iret instruction following closely after writing the EOI register. Since we return from kernel mode traps with a jmp (yes you can return from an interrupt with a jmp!) the EOI is never triggered, making VBox believe we are still serving the interrupt and keeping the PPR on high level, preventing following interrupts. A small asm stub now does the work of both writing the EOI and doing an iret. svn path=/trunk/; revision=53665 --- reactos/hal/halx86/apic/apic.c | 11 ++++++++--- reactos/hal/halx86/apic/apictrap.S | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/reactos/hal/halx86/apic/apic.c b/reactos/hal/halx86/apic/apic.c index 7b151be49ff..27f5e3de706 100644 --- a/reactos/hal/halx86/apic/apic.c +++ b/reactos/hal/halx86/apic/apic.c @@ -609,17 +609,22 @@ HalBeginSystemInterrupt( return TRUE; } +void HackEoi(void); + VOID NTAPI HalEndSystemInterrupt( IN KIRQL OldIrql, IN PKTRAP_FRAME TrapFrame) { + /* Write 0 to the EndOfInterruptRegister */ + //ApicWrite(APIC_EOI, 0); + + // HACK! + HackEoi(); + /* Restore the old IRQL */ ApicSetCurrentIrql(OldIrql); - - /* Write 0 to the EndOfInterruptRegister */ - ApicWrite(APIC_EOI, 0); } diff --git a/reactos/hal/halx86/apic/apictrap.S b/reactos/hal/halx86/apic/apictrap.S index 3a4c1cde641..2bf34d86315 100644 --- a/reactos/hal/halx86/apic/apictrap.S +++ b/reactos/hal/halx86/apic/apictrap.S @@ -27,6 +27,18 @@ PUBLIC _ApicSpuriousService TRAP_ENTRY HalpTrap0D, 0 TRAP_ENTRY HalpApcInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpDispatchInterrupt, KI_PUSH_FAKE_ERROR_CODE + +// VBox APIC needs an iret more or less directly following the EOI +PUBLIC _HackEoi +_HackEoi: + pushfd + push cs + push offset OnlyOnePersonKnowsHowToHackAroundVBoxBugsAndThatIsNotYou // !! + mov dword ptr ds:[HEX(0FFFE00B0)], 0 + iretd +OnlyOnePersonKnowsHowToHackAroundVBoxBugsAndThatIsNotYou: + ret + #endif TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE