-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[interrupt-handlers] adds exception handling to the hyperlight guest #250
base: main
Are you sure you want to change the base?
Conversation
…n handler - interrupt handler entry stubs = -- added macros to save/restore register context -- added defintions for different exceptions (_do_excp0-20+30), which save context, set params per SysV ABI, call handler, restore context, then iretq via macros. - added an exception handler that are used by the _do_excp* fxns. Note: this code is specific for x86_64 Signed-off-by: danbugs <[email protected]>
- added IdtEntry structure, - created IDT static mut array, and - made fxns to init_idt and set_idt_entry. Signed-off-by: danbugs <[email protected]>
- made Idtr structure (+ its static mut global var) to house the IDT, and - made load_idt fxn that uses global_asm's lidt to load the IDT. Signed-off-by: danbugs <[email protected]>
- added GdtEntry struct for GDT static mut global var, - added null, kernel code, and kernel data segments to GDT, - added code to load the GDT, and - added calls to init_idt, load_idt, and load_gdt to entrypoint. Signed-off-by: danbugs <[email protected]>
- added new guest fxn to simpleguest that triggers an invalid opcode exception - added test in guest_dispatch that calls the new guest fxn to test exception handling Signed-off-by: danbugs <[email protected]>
f441a46
to
918bc74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
generate_excp!(11), | ||
generate_excp!(12), | ||
generate_excp!(13), | ||
generate_excp!(14, pagefault), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe more exception types than pagefault take additional parameters
@@ -86,6 +89,14 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_ | |||
let peb_ptr = P_PEB.unwrap(); | |||
__security_cookie = peb_address ^ seed; | |||
|
|||
// Set up GDT/IDT | |||
load_gdt(); | |||
init_idt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: does it make sense to distinguish init_idt
from load_idt
?
This PR introduces exception handling to the Hyperlight guest by setting up and loading a Global Descriptor Table (GDT) and an Interrupt Descriptor Table (IDT) onto the CPU.
GDT Setup & Loading
lgdt
.IDT Setup & Exception Handlers
iretq
.context_save
andcontext_restore
to properly preserve CPU state.lidt
.This PR closes #228.