mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
fix interrupt entry stack alignment
This commit is contained in:
@@ -28,11 +28,11 @@ void gdt_setup() {
|
||||
gdt_tss.unused = 0;
|
||||
gdt_tss.gran = 0;
|
||||
gdt_tss.base_high = (tss_base >> 24) & 0xFFFFFFFFFF;
|
||||
|
||||
tss_entry.ist1 = ((uintptr_t) int_stack + INT_STACK_SIZE - 1) & (~0xFULL);
|
||||
if ((tss_entry.ist1 & 0xFULL) != 0) _hcf();
|
||||
tss_entry.rsp0 = ((uintptr_t) rsp_stack + RSP_STACK_SIZE - 1) & (~0xFULL);
|
||||
if ((tss_entry.rsp0 & 0xFULL) != 0) _hcf();
|
||||
|
||||
tss_entry.ist1 = (((uintptr_t) int_stack + (INT_STACK_SIZE - 9) - 1) & (~0xFULL)) + 8;
|
||||
if ((tss_entry.ist1 & 0xFULL) != 8) _hcf();
|
||||
tss_entry.rsp0 = (((uintptr_t) rsp_stack + (RSP_STACK_SIZE - 9) - 1) & (~0xFULL)) + 8;
|
||||
if ((tss_entry.rsp0 & 0xFULL) != 8) _hcf();
|
||||
|
||||
barrier();// The asm function might clobber registers
|
||||
_gdt_setup();
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef struct {
|
||||
// Assuming the compiler understands that this is pushed on the stack in the correct order
|
||||
struct task_frame {
|
||||
uint64_t guard;
|
||||
uint64_t guard2;// To keep stack aligned after pushaq
|
||||
|
||||
uint64_t r15;
|
||||
uint64_t r14;
|
||||
|
||||
@@ -29,10 +29,11 @@ extern temp_fxsave
|
||||
|
||||
mov rdi, 0xdeadbe3fdeadb3ef ; IDT_GUARD
|
||||
push rdi ; IDT_GUARD
|
||||
push rdi ; IDT_GUARD2 for alignment
|
||||
|
||||
%endmacro
|
||||
%macro popaq 0
|
||||
add rsp, 8 ; remove IDT_GUARD
|
||||
add rsp, 16 ; remove IDT_GUARD
|
||||
|
||||
fxrstor64 [temp_fxsave]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user