Skip to content

Commit 0252b0c

Browse files
committed
x86/idtentry: Add a macro to create IDT entry stubs
The symbols irq_entries_start and spurious_entries_start are tables of IDT entry stubs that are subsequently used to populate the interrupt descriptor table. The code for both stubs tables is identical. Wrap it in a macro. Signed-off-by: Ricardo Neri <[email protected]> --- Changes since v1: * None
1 parent 0901382 commit 0252b0c

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

arch/x86/include/asm/idtentry.h

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -547,36 +547,43 @@ static inline void fred_install_sysvec(unsigned int vector, const idtentry_t fun
547547
* point is to mask off the bits above bit 7 because the push is sign
548548
* extending.
549549
*/
550+
.macro __idtentry_stubs name, vector_nr_start, vector_nr, isr
550551
.align IDT_ALIGN
551-
SYM_CODE_START(irq_entries_start)
552-
vector=FIRST_EXTERNAL_VECTOR
553-
.rept NR_EXTERNAL_VECTORS
552+
SYM_CODE_START(\name)
553+
vector=\vector_nr_start
554+
.rept (\vector_nr)
554555
UNWIND_HINT_IRET_REGS
555556
0 :
556557
ENDBR
557558
.byte 0x6a, vector
558-
jmp asm_common_interrupt
559+
jmp asm_\isr
559560
/* Ensure that the above is IDT_ALIGN bytes max */
560561
.fill 0b + IDT_ALIGN - ., 1, 0xcc
561562
vector = vector+1
563+
562564
.endr
563-
SYM_CODE_END(irq_entries_start)
565+
566+
SYM_CODE_END(\name)
567+
.endm
568+
569+
/**
570+
* DEFINE_IDTENTRY_STUBS - DECLARE_IDTENTRY_DF - Define a block of IDT entries
571+
* @name: Name of the entry point
572+
* @vector_nr_start: First vector number
573+
* @vector_nr: Number of vectors to emit
574+
* @isr: Name of the C handler called from ASM entry point
575+
*
576+
* Emit a block of @vector_nr IDT entry stubs packed into IDT_ALIGN bytes.
577+
*/
578+
#define DEFINE_IDTENTRY_STUBS(name, vector_nr_start, vector_nr, isr) \
579+
__idtentry_stubs name, (vector_nr_start), (vector_nr), isr
580+
581+
DEFINE_IDTENTRY_STUBS(irq_entries_start, FIRST_EXTERNAL_VECTOR,
582+
NR_EXTERNAL_VECTORS, common_interrupt)
564583

565584
#ifdef CONFIG_X86_LOCAL_APIC
566-
.align IDT_ALIGN
567-
SYM_CODE_START(spurious_entries_start)
568-
vector=FIRST_SYSTEM_VECTOR
569-
.rept NR_SYSTEM_VECTORS
570-
UNWIND_HINT_IRET_REGS
571-
0 :
572-
ENDBR
573-
.byte 0x6a, vector
574-
jmp asm_spurious_interrupt
575-
/* Ensure that the above is IDT_ALIGN bytes max */
576-
.fill 0b + IDT_ALIGN - ., 1, 0xcc
577-
vector = vector+1
578-
.endr
579-
SYM_CODE_END(spurious_entries_start)
585+
DEFINE_IDTENTRY_STUBS(spurious_entries_start, FIRST_SYSTEM_VECTOR,
586+
NR_SYSTEM_VECTORS, spurious_interrupt)
580587
#endif
581588

582589
#endif /* __ASSEMBLY__ */

0 commit comments

Comments
 (0)