From 3f3795df3ca7851042e9cbf2f2767ac6c425aa2f Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Mon, 24 Nov 2025 17:04:33 +0100 Subject: [PATCH] Fix stack alignment --- kernel/intr/intr0.S | 2 ++ kernel/proc/switch.S | 3 --- ulib/_start.S | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/intr/intr0.S b/kernel/intr/intr0.S index 9370e05..72f42cc 100644 --- a/kernel/intr/intr0.S +++ b/kernel/intr/intr0.S @@ -66,7 +66,9 @@ _push_regs cld movq %rsp, %rdi + sub $0x8, %rsp call intr_handleintr + add $0x8, %rsp _pop_regs add $0x10, %rsp iretq diff --git a/kernel/proc/switch.S b/kernel/proc/switch.S index d877ce1..4ed3afb 100644 --- a/kernel/proc/switch.S +++ b/kernel/proc/switch.S @@ -2,10 +2,7 @@ .global proc_switch proc_switch: - testq %rsi, %rsi - je 1f movq %rsi, %cr3 -1: mov %rdi, %rsp _pop_regs add $0x10, %rsp diff --git a/ulib/_start.S b/ulib/_start.S index 2a214d8..8a368b7 100644 --- a/ulib/_start.S +++ b/ulib/_start.S @@ -4,4 +4,9 @@ .global _start _start: + xor %rbp, %rbp + mov %rsp, %rbp + and $-0x10, %rsp + sub $0x8, %rsp + call _premain