summaryrefslogtreecommitdiffstats
path: root/tests/assembly/x86_64-fortanix-unknown-sgx-lvi-inline-assembly.rs
blob: 4745ebc4fcd44a9aa6f77513e0b85e3279d0bb86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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 {
        asm!("mov {}, [{}]",
            out(reg) value,
            in(reg) ptr);
    }
    value
}

// CHECK: get
// CHECK: movq
// CHECK-NEXT: lfence

#[no_mangle]
pub extern "C" fn myret() {
    unsafe {
        asm!("ret");
    }
}

// CHECK: myret
// CHECK: shlq $0, (%rsp)
// CHECK-NEXT: lfence
// CHECK-NEXT: retq