Skip to content

Commit 4bb50e5

Browse files
haraldhenarxbot
authored andcommitted
fix: do not use rbx register in asm!()
error: invalid register `rbx`: rbx is used internally by LLVM and cannot be used as an operand for inline asm See: rust-lang/rust#84658 (comment) and: https://github.com/rust-lang/rust/pull/84658/files#diff-d7283132d97a993fad4e2d491ac883dbce4e17fe248cdf37fa3f9334e2a5a115
1 parent 9e3617b commit 4bb50e5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/attestation_types/ti.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ impl TargetInfo {
5050
let mut report = core::mem::MaybeUninit::<report::Report>::uninit();
5151

5252
asm!(
53+
"xchg {RBX}, rbx",
5354
"enclu",
55+
"mov rbx, {RBX}",
5456

57+
RBX = inout(reg) self => _,
5558
in("rax") EREPORT,
56-
in("rbx") self,
5759
in("rcx") data.0.as_ptr(),
5860
in("rdx") report.as_mut_ptr(),
5961
);

src/enclave/enclave.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ impl Thread {
193193
let rax: i32;
194194
unsafe {
195195
asm!(
196+
"push rbx", // save rbx
196197
"push rbp", // save rbp
197198
"mov rbp, rsp", // save rsp
198199
"and rsp, ~0xf", // align to 16+0
@@ -203,6 +204,7 @@ impl Thread {
203204

204205
"mov rsp, rbp", // restore rsp
205206
"pop rbp", // restore rbp
207+
"pop rbx", // restore rbx
206208

207209
inout("rdi") usize::from(registers.rdi) => _,
208210
inout("rsi") usize::from(registers.rsi) => _,
@@ -212,7 +214,6 @@ impl Thread {
212214
inout("r9") usize::from(registers.r9) => _,
213215
inout("r10") &mut run => _,
214216
inout("r11") self.fnc => _,
215-
lateout("rbx") _,
216217
lateout("r12") _,
217218
lateout("r13") _,
218219
lateout("r14") _,

0 commit comments

Comments
 (0)