Skip to content

Commit

Permalink
Avoid using rbx in SGX inline assembly since it is reserved
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Apr 30, 2021
1 parent e6a731e commit 09cfb24
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/std/src/sys/sgx/ext/arch.rs
Expand Up @@ -32,9 +32,12 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
let error;

asm!(
// rbx is reserved by LLVM
"xchg {}, rbx",
"enclu",
"mov rbx, {}",
inout(reg) request => _,
inlateout("eax") ENCLU_EGETKEY => error,
in("rbx") request,
in("rcx") out.as_mut_ptr(),
options(nostack),
);
Expand All @@ -60,9 +63,12 @@ pub fn ereport(
let mut report = MaybeUninit::uninit();

asm!(
// rbx is reserved by LLVM
"xchg {}, rbx",
"enclu",
"mov rbx, {}",
inout(reg) targetinfo => _,
in("eax") ENCLU_EREPORT,
in("rbx") targetinfo,
in("rcx") reportdata,
in("rdx") report.as_mut_ptr(),
options(preserves_flags, nostack),
Expand Down

0 comments on commit 09cfb24

Please sign in to comment.