File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Test LVI load hardening on SGX inline assembly code
2
+
3
+ // assembly-output: emit-asm
4
+ // compile-flags: --crate-type staticlib
5
+ // only-x86_64-fortanix-unknown-sgx
6
+
7
+ #![ feature( asm) ]
8
+
9
+ #[ no_mangle]
10
+ pub extern fn get ( ptr : * const u64 ) -> u64 {
11
+ let value : u64 ;
12
+ unsafe {
13
+ asm ! ( ".start_inline_asm:" ,
14
+ "mov {}, [{}]" ,
15
+ ".end_inline_asm:" ,
16
+ out( reg) value,
17
+ in( reg) ptr) ;
18
+ }
19
+ value
20
+ }
21
+
22
+ // CHECK: get
23
+ // CHECK: .start_inline_asm
24
+ // CHECK-NEXT: movq
25
+ // CHECK-NEXT: lfence
26
+ // CHECK-NEXT: .end_inline_asm
27
+
28
+ #[ no_mangle]
29
+ pub extern fn myret ( ) {
30
+ unsafe {
31
+ asm ! ( ".start_myret_inline_asm:
32
+ ret
33
+ .end_myret_inline_asm:" ) ;
34
+ }
35
+ }
36
+
37
+ // CHECK: myret
38
+ // CHECK: .start_myret_inline_asm
39
+ // CHECK-NEXT: shlq $0, (%rsp)
40
+ // CHECK-NEXT: lfence
41
+ // CHECK-NEXT: retq
You can’t perform that action at this time.
0 commit comments