Skip to content

use asm_cfg in probestack #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#![feature(compiler_builtins)]
#![feature(core_intrinsics)]
#![feature(linkage)]
#![feature(asm_cfg)]
#![feature(naked_functions)]
#![feature(repr_simd)]
#![feature(macro_metavar_expr_concat)]
Expand Down
35 changes: 12 additions & 23 deletions compiler-builtins/src/probestack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,6 @@
#[unsafe(naked)]
#[rustc_std_internal_symbol]
pub unsafe extern "custom" fn __rust_probestack() {
#[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))]
macro_rules! ret {
() => {
"ret"
};
}

#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
macro_rules! ret {
// for this target, [manually patch for LVI].
//
// [manually patch for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
() => {
"
pop %r11
lfence
jmp *%r11
"
};
}

core::arch::naked_asm!(
"
.cfi_startproc
Expand Down Expand Up @@ -128,8 +107,18 @@ pub unsafe extern "custom" fn __rust_probestack() {
.cfi_def_cfa_register %rsp
.cfi_adjust_cfa_offset -8
",
ret!(),
"
#[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))]
" ret",
#[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
"
// for this target, [manually patch for LVI].
//
// [manually patch for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
pop %r11
lfence
jmp *%r11
",
"
.cfi_endproc
",
options(att_syntax)
Expand Down
Loading