Skip to content

Commit 09cfb24

Browse files
committed
Avoid using rbx in SGX inline assembly since it is reserved
1 parent e6a731e commit 09cfb24

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

library/std/src/sys/sgx/ext/arch.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
3232
let error;
3333

3434
asm!(
35+
// rbx is reserved by LLVM
36+
"xchg {}, rbx",
3537
"enclu",
38+
"mov rbx, {}",
39+
inout(reg) request => _,
3640
inlateout("eax") ENCLU_EGETKEY => error,
37-
in("rbx") request,
3841
in("rcx") out.as_mut_ptr(),
3942
options(nostack),
4043
);
@@ -60,9 +63,12 @@ pub fn ereport(
6063
let mut report = MaybeUninit::uninit();
6164

6265
asm!(
66+
// rbx is reserved by LLVM
67+
"xchg {}, rbx",
6368
"enclu",
69+
"mov rbx, {}",
70+
inout(reg) targetinfo => _,
6471
in("eax") ENCLU_EREPORT,
65-
in("rbx") targetinfo,
6672
in("rcx") reportdata,
6773
in("rdx") report.as_mut_ptr(),
6874
options(preserves_flags, nostack),

0 commit comments

Comments
 (0)