rust/tests/assembly/x86_64-fortanix-unknown-sgx-lvi-inline-assembly.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
603 B
Rust
Raw Permalink Normal View History

// Test LVI load hardening on SGX inline assembly code
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type staticlib
//@ only-x86_64-fortanix-unknown-sgx
use std::arch::asm;
#[no_mangle]
pub extern "C" fn get(ptr: *const u64) -> u64 {
let value: u64;
unsafe {
2023-02-22 03:45:37 -06:00
asm!("mov {}, [{}]",
out(reg) value,
in(reg) ptr);
}
value
}
// CHECK: get
2023-02-22 03:45:37 -06:00
// CHECK: movq
// CHECK-NEXT: lfence
#[no_mangle]
pub extern "C" fn myret() {
unsafe {
2023-02-22 03:45:37 -06:00
asm!("ret");
}
}
// CHECK: myret
2023-02-22 03:45:37 -06:00
// CHECK: shlq $0, (%rsp)
// CHECK-NEXT: lfence
// CHECK-NEXT: retq