amd64: simplify entry path
move all IRQs and exceptions into smaller stubs, that then jmp into `irq_common` or `exception_common`. handle swap GS on userspace-kernel interrupt switches Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
3ca26e6068
commit
bc39293c83
1 changed files with 48 additions and 16 deletions
|
|
@ -40,34 +40,66 @@
|
||||||
.macro exception nr
|
.macro exception nr
|
||||||
.global _exception_\nr
|
.global _exception_\nr
|
||||||
_exception_\nr:
|
_exception_\nr:
|
||||||
push_all
|
push 0
|
||||||
mov rdi, \nr
|
push \nr
|
||||||
call exception_handler
|
jmp exception_common
|
||||||
pop_all
|
|
||||||
iretq
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro exception_err nr
|
.macro exception_err nr
|
||||||
.global _exception_\nr
|
.global _exception_\nr
|
||||||
_exception_\nr:
|
_exception_\nr:
|
||||||
pop rsi
|
push \nr
|
||||||
push_all
|
jmp exception_common
|
||||||
mov rdi, \nr
|
|
||||||
call exception_handler
|
|
||||||
pop_all
|
|
||||||
iretq
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro irq nr
|
.macro irq nr
|
||||||
.global _irq_\nr
|
.global _irq_\nr
|
||||||
_irq_\nr:
|
_irq_\nr:
|
||||||
push_all
|
push \nr
|
||||||
mov rdi, \nr
|
jmp irq_common
|
||||||
call irq_handler
|
|
||||||
pop_all
|
|
||||||
iretq
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
exception_common:
|
||||||
|
test qword ptr [rsp + 24], 3 /* is this from userspace? */
|
||||||
|
jz 1f
|
||||||
|
swapgs
|
||||||
|
1:
|
||||||
|
push_all /* pushes 15 registers */
|
||||||
|
mov rdi, [rsp + 120] /* vector: 15 regs up = 120 */
|
||||||
|
mov rsi, [rsp + 128] /* error code we pushed in the macro */
|
||||||
|
|
||||||
|
/* we skip storing the user stack in these interrupt entries because
|
||||||
|
* the iretq frame stores it
|
||||||
|
*/
|
||||||
|
|
||||||
|
call exception_handler
|
||||||
|
pop_all
|
||||||
|
test qword ptr [rsp + 24], 3 /* from userspace? */
|
||||||
|
jz 2f
|
||||||
|
swapgs
|
||||||
|
2:
|
||||||
|
add rsp, 16 /* the two pushed items, from the macro */
|
||||||
|
iretq
|
||||||
|
|
||||||
|
/* same as exception_common, but we don't get the error code */
|
||||||
|
irq_common:
|
||||||
|
test qword ptr [rsp + 24], 3 /* is this from userspace? */
|
||||||
|
jz 1f
|
||||||
|
swapgs
|
||||||
|
1:
|
||||||
|
push_all /* pushes 15 registers */
|
||||||
|
mov rdi, [rsp + 120] /* irq no */
|
||||||
|
|
||||||
|
call irq_handler
|
||||||
|
pop_all
|
||||||
|
test qword ptr [rsp + 24], 3 /* from userspace? */
|
||||||
|
jz 2f
|
||||||
|
swapgs
|
||||||
|
2:
|
||||||
|
add rsp, 8
|
||||||
|
iretq
|
||||||
|
|
||||||
|
|
||||||
.global _syscall_enter
|
.global _syscall_enter
|
||||||
_syscall_enter:
|
_syscall_enter:
|
||||||
swapgs
|
swapgs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue