[RESEND PATCH 4/6] x86/traps: add external_interrupt() to dispatch external interrupts

Xin Li
2022-11-10T06:39:37Z

Add external_interrupt() to dispatch external interrupts to their
handlers. If an external interrupt is a system interrupt, dipatch
it through system_interrupt_handler_table, otherwise call into
common_interrupt().

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
---
arch/x86/kernel/traps.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 9c7826e588bc..c1eb3bd335ce 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -1507,6 +1507,27 @@ void __init install_system_interrupt_handler(unsigned int n, const void *asm_add
alloc_intr_gate(n, asm_addr);
}

+/*
+ * External interrupt dispatch function.
+ *
+ * Until/unless common_interrupt() can be taught to deal with the
+ * special system vectors, split the dispatch.
+ *
+ * Note: common_interrupt() already deals with IRQ_MOVE_CLEANUP_VECTOR.
+ */
+__visible noinstr void external_interrupt(struct pt_regs *regs,
+ unsigned int vector)
+{
+ unsigned int sysvec = vector - FIRST_SYSTEM_VECTOR;
+
+ BUG_ON(vector < FIRST_EXTERNAL_VECTOR);
+
+ if (sysvec < NR_SYSTEM_VECTORS)
+ return system_interrupt_handler_table[sysvec](regs, vector);
+
+ common_interrupt(regs, vector);
+}
+
void __init trap_init(void)
{
/* Init cpu_entry_area before IST entries are set up */
--
2.34.1