2020-03-19 15:40:33 +00:00
|
|
|
// Test LVI load hardening on SGX inline assembly code
|
|
|
|
|
|
|
|
// assembly-output: emit-asm
|
|
|
|
// compile-flags: --crate-type staticlib
|
|
|
|
// only-x86_64-fortanix-unknown-sgx
|
|
|
|
|
2021-12-10 00:15:33 +00:00
|
|
|
use std::arch::asm;
|
2020-03-19 15:40:33 +00:00
|
|
|
|
|
|
|
#[no_mangle]
|
2021-12-10 00:15:33 +00:00
|
|
|
pub extern "C" fn get(ptr: *const u64) -> u64 {
|
|
|
|
let value: u64;
|
2020-03-19 15:40:33 +00:00
|
|
|
unsafe {
|
|
|
|
asm!(".start_inline_asm:",
|
|
|
|
"mov {}, [{}]",
|
|
|
|
".end_inline_asm:",
|
|
|
|
out(reg) value,
|
|
|
|
in(reg) ptr);
|
|
|
|
}
|
|
|
|
value
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: get
|
|
|
|
// CHECK: .start_inline_asm
|
|
|
|
// CHECK-NEXT: movq
|
|
|
|
// CHECK-NEXT: lfence
|
|
|
|
// CHECK-NEXT: .end_inline_asm
|
|
|
|
|
|
|
|
#[no_mangle]
|
2021-12-10 00:15:33 +00:00
|
|
|
pub extern "C" fn myret() {
|
2020-03-19 15:40:33 +00:00
|
|
|
unsafe {
|
2021-12-10 00:15:33 +00:00
|
|
|
asm!(
|
2021-12-11 00:11:26 +00:00
|
|
|
".start_myret_inline_asm:",
|
|
|
|
"ret",
|
|
|
|
".end_myret_inline_asm:",
|
2021-12-10 00:15:33 +00:00
|
|
|
);
|
2020-03-19 15:40:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: myret
|
|
|
|
// CHECK: .start_myret_inline_asm
|
|
|
|
// CHECK-NEXT: shlq $0, (%rsp)
|
|
|
|
// CHECK-NEXT: lfence
|
|
|
|
// CHECK-NEXT: retq
|