From ef907825e861b63726952bb34b425a98f34ed412 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 24 Jul 2025 13:52:42 +0000 Subject: x86_64: provide a clean slate on entry to long mode --- arch/x86_64/src/boot/boot32.S | 4 ++++ arch/x86_64/src/boot/entry64.s | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/src/boot/boot32.S b/arch/x86_64/src/boot/boot32.S index 3039f38..27eed4d 100644 --- a/arch/x86_64/src/boot/boot32.S +++ b/arch/x86_64/src/boot/boot32.S @@ -27,8 +27,12 @@ page_maps_size = page_maps_end - page_maps_start .section .boot_stack, "aw", @nobits .align 16 +.global stack_size +.global stack_bottom + stack_bottom: .skip 1 << 20 stack_top: +stack_size = stack_top - stack_bottom /** * @brief Constants for the bootstrapping process. diff --git a/arch/x86_64/src/boot/entry64.s b/arch/x86_64/src/boot/entry64.s index 110ced8..c5df5db 100644 --- a/arch/x86_64/src/boot/entry64.s +++ b/arch/x86_64/src/boot/entry64.s @@ -10,10 +10,20 @@ _entry64: mov %rax, %fs mov %rax, %gs - xor %rax, %rax - call invoke_global_constructors + xor %rax, %rax + mov %rax, %rbp + mov %rax, %rdx + mov %rax, %rsi + + mov $stack_size, %rcx + shr $3, %rcx + lea (stack_bottom), %rdi + rep stosq + + mov %rax, %rdi + call main 1: -- cgit v1.2.3