about summary refs log tree commit diff
path: root/tests/assembly-llvm/x86_64-fortanix-unknown-sgx-lvi-inline-assembly.rs
blob: 215fb4b804ac2516d84f30d8fd50520954b547a3 (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
35
36
37
38
// Test LVI load hardening on SGX inline assembly code

//@ add-core-stubs
//@ assembly-output: emit-asm
//@ compile-flags: --target x86_64-fortanix-unknown-sgx
//@ needs-llvm-components: x86

#![feature(no_core, lang_items, f16)]
#![crate_type = "lib"]
#![no_core]

extern crate minicore;
use minicore::*;

#[no_mangle]
pub extern "C" fn get(ptr: *const u64) -> u64 {
    // CHECK-LABEL: get
    // CHECK: movq
    // CHECK-NEXT: lfence
    let value: u64;
    unsafe {
        asm!("mov {}, [{}]",
            out(reg) value,
            in(reg) ptr);
    }
    value
}

#[no_mangle]
pub extern "C" fn myret() {
    // CHECK-LABEL: myret
    // CHECK: shlq $0, (%rsp)
    // CHECK-NEXT: lfence
    // CHECK-NEXT: retq
    unsafe {
        asm!("ret");
    }
}