Skip to content

Commit 31bbc3b

Browse files
committed
Auto merge of rust-lang#84658 - Amanieu:reserved_regs, r=petrochenkov
Be stricter about rejecting LLVM reserved registers in asm! LLVM will silently produce incorrect code if these registers are used as operands. cc `@rust-lang/wg-inline-asm`
2 parents 0838ae6 + fce0c49 commit 31bbc3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
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 {0}, rbx",
3537
"enclu",
38+
"mov rbx, {0}",
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 {0}, rbx",
6368
"enclu",
69+
"mov rbx, {0}",
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)