2020-03-19 10:40:33 -05: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-09 18:15:33 -06:00
|
|
|
use std::arch::asm;
|
2020-03-19 10:40:33 -05:00
|
|
|
|
|
|
|
#[no_mangle]
|
2021-12-09 18:15:33 -06:00
|
|
|
pub extern "C" fn get(ptr: *const u64) -> u64 {
|
|
|
|
let value: u64;
|
2020-03-19 10:40:33 -05:00
|
|
|
unsafe {
|
2023-02-22 03:45:37 -06:00
|
|
|
asm!("mov {}, [{}]",
|
2020-03-19 10:40:33 -05:00
|
|
|
out(reg) value,
|
|
|
|
in(reg) ptr);
|
|
|
|
}
|
|
|
|
value
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: get
|
2023-02-22 03:45:37 -06:00
|
|
|
// CHECK: movq
|
2020-03-19 10:40:33 -05:00
|
|
|
// CHECK-NEXT: lfence
|
|
|
|
|
|
|
|
#[no_mangle]
|
2021-12-09 18:15:33 -06:00
|
|
|
pub extern "C" fn myret() {
|
2020-03-19 10:40:33 -05:00
|
|
|
unsafe {
|
2023-02-22 03:45:37 -06:00
|
|
|
asm!("ret");
|
2020-03-19 10:40:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: myret
|
2023-02-22 03:45:37 -06:00
|
|
|
// CHECK: shlq $0, (%rsp)
|
2020-03-19 10:40:33 -05:00
|
|
|
// CHECK-NEXT: lfence
|
|
|
|
// CHECK-NEXT: retq
|