Skip to content

Commit 674910e

Browse files
authored
1 parent 267ae1f commit 674910e

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

compiler-builtins/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(compiler_builtins)]
88
#![feature(core_intrinsics)]
99
#![feature(linkage)]
10+
#![feature(asm_cfg)]
1011
#![feature(naked_functions)]
1112
#![feature(repr_simd)]
1213
#![feature(macro_metavar_expr_concat)]

compiler-builtins/src/probestack.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,6 @@
5858
#[unsafe(naked)]
5959
#[rustc_std_internal_symbol]
6060
pub unsafe extern "custom" fn __rust_probestack() {
61-
#[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))]
62-
macro_rules! ret {
63-
() => {
64-
"ret"
65-
};
66-
}
67-
68-
#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
69-
macro_rules! ret {
70-
// for this target, [manually patch for LVI].
71-
//
72-
// [manually patch for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
73-
() => {
74-
"
75-
pop %r11
76-
lfence
77-
jmp *%r11
78-
"
79-
};
80-
}
81-
8261
core::arch::naked_asm!(
8362
"
8463
.cfi_startproc
@@ -128,8 +107,18 @@ pub unsafe extern "custom" fn __rust_probestack() {
128107
.cfi_def_cfa_register %rsp
129108
.cfi_adjust_cfa_offset -8
130109
",
131-
ret!(),
132-
"
110+
#[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))]
111+
" ret",
112+
#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
113+
"
114+
// for this target, [manually patch for LVI].
115+
//
116+
// [manually patch for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
117+
pop %r11
118+
lfence
119+
jmp *%r11
120+
",
121+
"
133122
.cfi_endproc
134123
",
135124
options(att_syntax)

0 commit comments

Comments
 (0)