From 362c84a08a1b8f1eb7f9c1c37c6ed7cece348ee4 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 10 Aug 2023 19:18:43 +0200 Subject: Acknowledge IRQ *before* calling the handler 5da1aea7ab3c ("Acknoledge interrupt after handler call") moved the IRQ ack to after calling the handler because of overflows. But that was because the interrupts were getting enabled at some point. Now that all spl levels above 0 just disable interrupts, once we have called spl7 we are safe until splx_cli is called (and even that doesn't release interrupts, only the eventual iret will). And if the handler triggers another IRQ, it will be lost, so we do want to ack the IRQ before handling it. --- x86_64/interrupt.S | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'x86_64') diff --git a/x86_64/interrupt.S b/x86_64/interrupt.S index 845e0d1a..c73b31e8 100644 --- a/x86_64/interrupt.S +++ b/x86_64/interrupt.S @@ -41,7 +41,9 @@ ENTRY(interrupt) #ifdef APIC cmpl $255,%eax /* was this a spurious intr? */ - je _no_eoi /* if so, just return */ + jne 1f + ret /* if so, just return */ +1: #endif cmpl $CALL_SINGLE_FUNCTION_BASE,%eax /* was this a SMP call single function request? */ je _call_single @@ -52,26 +54,6 @@ ENTRY(interrupt) call spl7 /* set ipl */ movl %eax,S_IPL /* save previous ipl */ - ; - movq S_IPL,S_ARG1 /* previous ipl as 2nd arg */ - - ; - movq S_RET,S_ARG2 /* return address as 3th arg */ - - ; - movq S_REGS,S_ARG3 /* address of interrupted registers as 4th arg */ - - movl S_IRQ,%eax /* copy irq number */ - shll $2,%eax /* irq * 4 */ - movl EXT(iunit)(%rax),%edi /* get device unit number as 1st arg */ - - shll $1,%eax /* irq * 8 */ - call *EXT(ivect)(%rax) /* call interrupt handler */ - - movl S_IPL,%edi /* restore previous ipl */ - call splx_cli /* restore previous ipl */ - cli /* XXX no more nested interrupts */ - movl S_IRQ,%ecx /* restore irq number */ #ifndef APIC @@ -113,12 +95,31 @@ ENTRY(interrupt) #else cmpl $16,%ecx /* was this a low ISA intr? */ jge _no_eoi /* no, must be PCI (let irq_ack handle EOI) */ -_isa_eoi: movl %ecx,%edi /* load irq number as 1st arg */ call EXT(ioapic_irq_eoi) /* ioapic irq specific EOI */ +_no_eoi: #endif + + ; + movq S_IPL,S_ARG1 /* previous ipl as 2nd arg */ + + ; + movq S_RET,S_ARG2 /* return address as 3th arg */ + + ; + movq S_REGS,S_ARG3 /* address of interrupted registers as 4th arg */ + + movl S_IRQ,%eax /* copy irq number */ + shll $2,%eax /* irq * 4 */ + movl EXT(iunit)(%rax),%edi /* get device unit number as 1st arg */ + + shll $1,%eax /* irq * 8 */ + call *EXT(ivect)(%rax) /* call interrupt handler */ + + movl S_IPL,%edi /* restore previous ipl */ + call splx_cli /* restore previous ipl */ + addq $16,%rsp /* pop local variables */ -_no_eoi: ret _call_single: -- cgit v1.2.3