summaryrefslogtreecommitdiffstats
path: root/src/test/assembly/x86_64-fortanix-unknown-sgx-lvi-inline-assembly.rs
blob: c316379d5b12e4be84bc532854616db68ffd23a2 (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
39
40
41
42
43
// 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!(".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]
pub extern "C" fn myret() {
    unsafe {
        asm!(
            ".start_myret_inline_asm:",
            "ret",
            ".end_myret_inline_asm:",
        );
    }
}

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