Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SYSENTER/SYSEXIT vs INT 0x80

Old linux versions use "int 0x80" instruction to implement system call, the later versions use "SYSENTER/SYSEXIT" instructions to do so.

After transfer to ring 0 via "int 0x80", cpu is in interrupt context and interrupt is disabled. But "SYSENTER/SYSEXIT" will not produce "interrupt context" and interrupt is not disabled.

Will this difference cause problems for system call?

like image 372
Gary Yin Avatar asked Mar 07 '14 15:03

Gary Yin


1 Answers

Whoever gets the call is clear what is going on, and has to cope. Remember that interrupts are the way to alert the system that something requiring urgent attention has come up, it better be handled ASAP. Disabling interrupts degrades performance, as event handling gets delayed. The new instructions SYSENTER/SYSEXIT instructions were added by intel not too long ago to offer faster/simpler system call handling, Linux started using them almost immediately.

For a bit of historical perspective, computers used to have one CPU. Disabling interrupts on them was a (brutal) way of ensuring mutual exclusion: As long as interrupts were disabled, nothing (with little exception) could interfere, because nothing else could be happening. So forcing an interrupt was a simple way to get system calls done, with the extra benefit of ensuring no interference. With multi-CPU machines (even cell phones!), disabling interrupts on the CPU getting to handle the call buys very little, others can go ahead and trample on your work. Disabling interrupts system-wide is costly to do, and just halting the whole system just to ensure mutual exclusion is madness. Current versions of Linux use sophisticated synchronization techniques to avoid such heavy-handed methods if at all possible. So the protection against interrupts isn't so important anymore.

like image 60
vonbrand Avatar answered Oct 05 '22 12:10

vonbrand