Skip to content

Commit 17e44b8

Browse files
devsnekkennystrawnmusic
authored andcommitted
zero rbp
1 parent eda35ae commit 17e44b8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

common/src/lib.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub mod serial;
3939

4040
const PAGE_SIZE: u64 = 4096;
4141

42-
/// Initialize a text-based logger using the given pixel-based framebuffer as output.
42+
/// Initialize a text-based logger using the given pixel-based framebuffer as output.
4343
pub fn init_logger(
4444
framebuffer: &'static mut [u8],
4545
info: FrameBufferInfo,
@@ -594,15 +594,21 @@ pub struct PageTables {
594594
///
595595
/// Must be the page table that the `kernel` field of this struct refers to.
596596
///
597-
/// This frame is loaded into the `CR3` register on the final context switch to the kernel.
597+
/// This frame is loaded into the `CR3` register on the final context switch to the kernel.
598598
pub kernel_level_4_frame: PhysFrame,
599599
}
600600

601601
/// Performs the actual context switch.
602602
unsafe fn context_switch(addresses: Addresses) -> ! {
603603
unsafe {
604604
asm!(
605-
"mov cr3, {}; mov rsp, {}; push 0; jmp {}",
605+
r#"
606+
xor rbp, rbp
607+
mov cr3, {}
608+
mov rsp, {}
609+
push 0
610+
jmp {}
611+
"#,
606612
in(reg) addresses.page_table.start_address().as_u64(),
607613
in(reg) addresses.stack_top.as_u64(),
608614
in(reg) addresses.entry_point.as_u64(),

0 commit comments

Comments
 (0)