Skip to content

Commit 4e3b456

Browse files
GuillaumeDIDIERphil-opp
authored andcommitted
Change the way the kernel entry point is called to honor alignement ABI (#81)
Compilers expect functions to be called with the stack containing the return address making the rsp be 8 mod 16. jmp caused rsp to be 0 mod 16 (aka 16 bytes aligned), which then caused compiler to meke the stack misaligned everywhere.
1 parent 4190d67 commit 4e3b456

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ global_asm!(include_str!("video_mode/vga_320x200.s"));
4444
global_asm!(include_str!("video_mode/vga_text_80x25.s"));
4545

4646
unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! {
47-
asm!("jmp $1; ${:private}.spin.${:uid}: jmp ${:private}.spin.${:uid}" ::
47+
asm!("call $1; ${:private}.spin.${:uid}: jmp ${:private}.spin.${:uid}" ::
4848
"{rsp}"(stack_pointer), "r"(entry_point), "{rdi}"(boot_info) :: "intel");
4949
::core::hint::unreachable_unchecked()
5050
}

0 commit comments

Comments
 (0)