Skip to content

Commit 915c25b

Browse files
phil-oppFreax13
andcommitted
Apply more code review suggestions
Co-authored-by: Tom Dohrmann <[email protected]>
1 parent b0e805e commit 915c25b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

bios/stage-2/src/protected_mode.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ pub unsafe fn copy_to_protected_mode(target: *mut u8, bytes: &[u8]) {
9292
let dst = target.wrapping_add(offset);
9393
// we need to do the write in inline assembly because the compiler
9494
// seems to truncate the address
95-
unsafe { asm!("mov [{}], {}", in(reg) dst, in(reg_byte) *byte) };
95+
unsafe {
96+
asm!("mov [{}], {}", in(reg) dst, in(reg_byte) *byte, options(nostack, preserves_flags))
97+
};
9698
assert_eq!(read_from_protected_mode(dst), *byte);
9799
}
98100
}
@@ -102,7 +104,9 @@ pub unsafe fn read_from_protected_mode(ptr: *mut u8) -> u8 {
102104
let res;
103105
// we need to do the read in inline assembly because the compiler
104106
// seems to truncate the address
105-
unsafe { asm!("mov {}, [{}]", out(reg_byte) res, in(reg) ptr) };
107+
unsafe {
108+
asm!("mov {}, [{}]", out(reg_byte) res, in(reg) ptr, options(pure, readonly, nostack, preserves_flags))
109+
};
106110
res
107111
}
108112

bios/stage-3/src/paging.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fn create_mappings() {
2121
l3.entries[i] = (l2 as *mut PageTable as u64) | common_flags;
2222
let offset = u64::try_from(i).unwrap() * 1024 * 1024 * 1024;
2323
for (j, entry) in l2.entries.iter_mut().enumerate() {
24+
// map huge pages
2425
*entry =
2526
(offset + u64::try_from(j).unwrap() * (2 * 1024 * 1024)) | common_flags | (1 << 7);
2627
}

0 commit comments

Comments
 (0)