Nik Novák
Nik Novák

Reputation: 589

Interrupts and system calls dispatching in Linux

Are hardware interrupts and system calls/exceptions dispatched by the same dispatcher procedure in Linux? If you see Linux source, you will notice that hardware interrupts (on x86 arch) on their interrupt vectors doesn't contain more instructions that PUSH interrupt vector number on the stack and JUMP to common_interrupt.

My question: Are every interrupt in Linux (exceptions (include SysCall), interrupts) dispatched by the same way until reach some point to branch? (in the reason of their type)

Sorry for my English.

Upvotes: 2

Views: 1593

Answers (1)

0xAX
0xAX

Reputation: 21817

Are hardware interrupts and system calls/exceptions dispatched by the same dispatcher procedure in Linux?

No. Exceptions, system calls and hardware interrupts are dispatched in a different way. If you will look in the arch/x86/entry/entry_64.S, you will find there all of them. First is the idtentry macro:

.macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
ENTRY(\sym)
...
...
...
END(\sym)
.endm

which provides preparation for an exception handling (stores registers, calls of an exception handler and etc....). Also definition of exceptions handlers with the idtentry macro:

idtentry divide_error           do_divide_error         has_error_code=0
idtentry overflow           do_overflow         has_error_code=0
idtentry bounds             do_bounds           has_error_code=0

Most of exceptions handlers are in the arch/x86/kernel/trap.c

Entry point of hardware interrupts is irq_entries_start. And the system call handling is starts at the entry_SYSCALL_64.

My question: Are every interrupt in Linux (exceptions (include SysCall), interrupts) dispatched by the same way until reach some point to branch? (in the reason of their type)

No. They are similar, but not the same. For example, system call preparation routine (entry_SYSCALL_64) checks the type of system call (64-bit or 32-bit emulation), has each time the same state of registers before execution (depends on ABI) and etc..., but for example an exception handler first of all check the type of exception to select correct stack from IST and etc.

More info you can find in the Intel® 64 and IA-32 Architectures Software Developer’s Manual 3A

Upvotes: 4

Related Questions