-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
td-exception: use global asm to replace naked interrupt handler
An interrupt handler table is used to handle all 256 interrupts. They share common handler that saves the interrupt vector and context. If the interrupt is not an error, a zero is pushed to the stack to align with the error one. Function `generic_interrupt_handler` is called to find and call the corresponding callback in the `CALLBACK_TABLE`. For virtualization exception, when the CET shadow stack is enabled, we need to update the LIP value in the shadow stack. As shadow stack saves the latest two return address after interrupt entry and the SSP, the position of saved LIP value is the top address of shadow stack minus 0x18 bytes. Signed-off-by: Jiaqi Gao <[email protected]>
- Loading branch information
Showing
6 changed files
with
228 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (c) 2024 Intel Corporation | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
|
||
.section .text | ||
interrupt_handler_entry: | ||
push rax | ||
push rcx | ||
push rdx | ||
push rdi | ||
push rsi | ||
push r8 | ||
push r9 | ||
push r10 | ||
push r11 | ||
push rbx | ||
push rbp | ||
push r12 | ||
push r13 | ||
push r14 | ||
push r15 | ||
|
||
mov rdi, rsp | ||
call generic_interrupt_handler | ||
|
||
pop r15 | ||
pop r14 | ||
pop r13 | ||
pop r12 | ||
pop rbp | ||
pop rbx | ||
pop r11 | ||
pop r10 | ||
pop r9 | ||
pop r8 | ||
pop rsi | ||
pop rdi | ||
pop rdx | ||
pop rcx | ||
pop rax | ||
|
||
# vector number and error code | ||
add rsp, 16 | ||
|
||
iretq | ||
|
||
.align 32 | ||
.global interrupt_handler_table | ||
interrupt_handler_table: | ||
i = 0 | ||
.rept 256 | ||
.align 32 | ||
.if ((0x20027d00 >> i) & 1) == 0 | ||
push 0 | ||
.endif | ||
push i | ||
jmp interrupt_handler_entry | ||
i = i + 1 | ||
.endr | ||
|
||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use core::arch::global_asm; | ||
|
||
global_asm!(include_str!("handler.asm")); | ||
|
||
extern "C" { | ||
pub(crate) static interrupt_handler_table: u8; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.