Skip to content

Commit ed4c654

Browse files
paulcacheuxmaelgui
authored andcommitted
Fix asm! macro options
1 parent 5502384 commit ed4c654

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

mythril/src/error.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ pub fn check_vm_insruction(rflags: u64, error: String) -> Result<()> {
5252
} else if rflags.contains(RFlags::FLAGS_ZF) {
5353
let errno = unsafe {
5454
let value: u64;
55-
asm!("vmread rdx, rax",
56-
in("rax") vmcs::VmcsField::VmInstructionError as u64,
57-
out("rdx") value);
55+
asm!(
56+
"vmread rdx, rax",
57+
in("rax") vmcs::VmcsField::VmInstructionError as u64,
58+
out("rdx") value,
59+
options(nostack)
60+
);
5861
value
5962
};
6063
let vm_error = VmInstructionError::try_from(errno)
@@ -135,7 +138,7 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
135138
loop {
136139
unsafe {
137140
// Try to at least keep CPU from running at 100%
138-
asm!("hlt");
141+
asm!("hlt", options(nostack, nomem));
139142
}
140143
}
141144
}

mythril/src/interrupt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ pub const TIMER_VECTOR: u8 = 48;
55
pub const IPC_VECTOR: u8 = 49;
66

77
pub unsafe fn enable_interrupts() {
8-
asm!("sti");
8+
asm!("sti", options(nomem, nostack));
99
}
1010

1111
pub unsafe fn disable_interrupts() {
12-
asm!("cli");
12+
asm!("cli", options(nomem, nostack));
1313
}

mythril/src/logger.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub unsafe fn raw_write_console(s: impl AsRef<str>) {
8989
in("rdx") 0x3f8,
9090
in("rcx") len as u64,
9191
inout("rsi") ptr as u64 => _,
92+
options(nostack)
9293
);
9394
}
9495

mythril/src/percore.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ impl fmt::Display for CoreId {
8181
pub fn read_core_id() -> CoreId {
8282
unsafe {
8383
let value: u64;
84-
asm!("mov rax, fs",
85-
out("rax") value);
84+
asm!(
85+
"mov rax, fs",
86+
lateout("rax") value,
87+
options(nomem, nostack)
88+
);
8689
((value >> 3) as u32).into() // Shift away the RPL and TI bits (they will always be 0)
8790
}
8891
}

mythril/src/registers.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ impl IdtrBase {
1515
};
1616
asm!(
1717
"sidt fword ptr [{0}]",
18-
in(reg) &mut info
18+
in(reg) &mut info,
19+
options(nostack)
1920
);
2021
info.base_addr
2122
}
@@ -36,7 +37,8 @@ impl GdtrBase {
3637
let mut info = GdtInfo { size: 0, offset: 0 };
3738
asm!(
3839
"sgdt fword ptr [{0}]",
39-
in(reg) &mut info
40+
in(reg) &mut info,
41+
options(nostack)
4042
);
4143
info.offset
4244
}

mythril/src/vmx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Vmx {
2626
"mov cr0, rax",
2727
in("rdx") 0x20,
2828
lateout("rax") _,
29-
options(nomem)
29+
options(nomem, nostack)
3030
);
3131

3232
// Enable vmx in CR4
@@ -36,7 +36,7 @@ impl Vmx {
3636
"mov cr4, rax",
3737
in("rdx") VMX_ENABLE_FLAG,
3838
lateout("rax") _,
39-
options(nomem)
39+
options(nomem, nostack)
4040
);
4141
}
4242

0 commit comments

Comments
 (0)