From 6c227820a80fb18c9c04b588aa1cb7aa23fbc4ac Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Tue, 31 Oct 2023 14:28:15 +0100 Subject: Kernel: Remove all O0 optimizations on functions. The kernel can now fully compile under O3 without any noticable problems :) --- kernel/arch/i386/mmu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'kernel/arch') diff --git a/kernel/arch/i386/mmu.c b/kernel/arch/i386/mmu.c index f4246d4..6b2f704 100644 --- a/kernel/arch/i386/mmu.c +++ b/kernel/arch/i386/mmu.c @@ -430,18 +430,15 @@ void *virtual_to_physical(void *address, PageDirectory *directory) { } extern uint32_t inital_esp; -void __attribute__((optimize("O0"))) +void move_stack(uint32_t new_stack_address, uint32_t size) { - mmu_allocate_region((void *)(new_stack_address - size), size, - MMU_FLAG_KERNEL, NULL); + mmu_allocate_region((void *)(new_stack_address - size), size, MMU_FLAG_KERNEL, + NULL); uint32_t old_stack_pointer, old_base_pointer; - register uint32_t eax asm("eax"); - asm volatile("mov %esp, %eax"); - old_stack_pointer = eax; - asm volatile("mov %ebp, %eax"); - old_base_pointer = eax; + asm volatile("mov %%esp, %0" : "=r"(old_stack_pointer)); + asm volatile("mov %%ebp, %0" : "=r"(old_base_pointer)); uint32_t new_stack_pointer = old_stack_pointer + ((uint32_t)new_stack_address - inital_esp); @@ -463,10 +460,8 @@ move_stack(uint32_t new_stack_address, uint32_t size) { inital_esp = new_stack_pointer; // Actually change the stack - eax = new_stack_pointer; - asm volatile("mov %eax, %esp"); - eax = new_base_pointer; - asm volatile("mov %eax, %ebp"); + asm volatile("mov %0, %%esp" ::"irm"(new_stack_pointer)); + asm volatile("mov %0, %%ebp" ::"irm"(new_base_pointer)); } // C strings have a unknown length so it does not makes sense to check -- cgit v1.2.3