Skip to content

Commit

Permalink
Change the way the kernel entry point is called to honor alignement A…
Browse files Browse the repository at this point in the history
…BI (#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.
  • Loading branch information
GuillaumeDIDIER authored and phil-opp committed Oct 8, 2019
1 parent 4190d67 commit 4e3b456
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ global_asm!(include_str!("video_mode/vga_320x200.s"));
global_asm!(include_str!("video_mode/vga_text_80x25.s"));

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

0 comments on commit 4e3b456

Please sign in to comment.