Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
fix(sev): do not use rbx register in asm!()
Browse files Browse the repository at this point in the history
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

Signed-off-by: Harald Hoyer <harald@redhat.com>
  • Loading branch information
haraldh authored and npmccallum committed Jul 1, 2021
1 parent 8e16492 commit ac8220d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion helper/parse-trace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ while read line; do
fi

if [[ $ADDR2LINE = "REGS" ]]; then
if [[ $line = *"rflags:"* ]] || [[ $line = *"rsp:"* ]] || [[ $line = *"rbp:"* ]]; then
if [[ $line = *"rflags:"* ]] || [[ $line = *"rsp:"* ]] || [[ $line = *"rbp:"* ]] || [[ $line = *"rbx:"* ]]; then
continue
fi
fi
Expand Down
25 changes: 12 additions & 13 deletions internal/shim-sev/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@ pub unsafe fn _enarx_asm_triple_fault() -> ! {
// Provoke an #UD, which will lead to a triple fault, because of the invalid IDT
asm!("ud2",
in("rax") frames[2], // the first two frames are from panic
in("rbx") frames[3],
in("rcx") frames[4],
in("rdx") frames[5],
in("rsi") frames[6],
in("rdi") frames[7],
in("r8") frames[8],
in("r9") frames[9],
in("r10") frames[10],
in("r11") frames[11],
in("r12") frames[12],
in("r13") frames[13],
in("r14") frames[14],
in("r15") frames[15],
in("rcx") frames[3],
in("rdx") frames[4],
in("rsi") frames[5],
in("rdi") frames[6],
in("r8") frames[7],
in("r9") frames[8],
in("r10") frames[9],
in("r11") frames[10],
in("r12") frames[11],
in("r13") frames[12],
in("r14") frames[13],
in("r15") frames[14],
options(nomem, nostack)
);

Expand Down

0 comments on commit ac8220d

Please sign in to comment.