-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be stricter about rejecting LLVM reserved registers in asm! #84658
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit e6a731e has been approved by |
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`
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``
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```
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````
Possibly failed in #84739 (comment) @bors rollup=iffy |
@bors r=petrochenkov |
📌 Commit 2fb751c1edd59b7199fe33207767c01f1cd98487 has been approved by |
The asm!(
"enclu",
in("rax") EREPORT,
in("rbx") ti.as_ptr(),
in("rcx") data.0.as_ptr(),
in("rdx") report.as_mut_ptr(),
); to asm!(
"xchg rsi, rbx",
"enclu",
"xchg rsi, rbx",
in("rax") EREPORT,
in("rsi") ti.as_ptr(),
in("rcx") data.0.as_ptr(),
in("rdx") report.as_mut_ptr(),
); |
Yes. See the changes here. |
@Amanieu thanks! |
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
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
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>
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
match arch { | ||
InlineAsmArch::X86 => Ok(()), | ||
InlineAsmArch::X86_64 => { | ||
Err("rbx is used internally by LLVM and cannot be used as an operand for inline asm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a problematic restriction. Many x86 instructions that you might want to run with asm!
take rbx
as an operand. Same applies to esi
below, really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the RFC:
The intent is that support for asm! should be independent of the rustc back-end used
Given that, I think backend limitations such as these should be handled by rustc prior to passing the assembly to the backend. It shouldn't be visible to the user. Otherwise, asm!
would only be able to support the intersection of all inline assembly implementations across all codegen backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling this in rustc is actually non-trivial (see this long Zulip discussion), which is also why LLVM doesn't just do it for us.
error: invalid register rbx: rbx is used internally by LLVM and cannot be used as an operand for inline asm So, we pull in a newer `sgx` crate version, which has this fixed. 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>
error: invalid register rbx: rbx is used internally by LLVM and cannot be used as an operand for inline asm So, we pull in a newer `sgx` crate version, which has this fixed. 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>
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>
error: invalid register rbx: rbx is used internally by LLVM and cannot be used as an operand for inline asm So, we pull in a newer `sgx` crate version, which has this fixed. 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>
Fix: - clippy::needless_borrow Silence: - clippy::manual_flatten Not addressed: - deprecated `llvm_asm!()` is deprecated, but must be used. The new `asm!()` does not allow using `ebx` [1], which holds the argument for the SMMSTORE command. [1]: rust-lang/rust#84658 Signed-off-by: Tim Crawford <tcrawford@system76.com>
Fix: - clippy::needless_borrow Silence: - clippy::manual_flatten Not addressed: - deprecated `llvm_asm!()` is deprecated, but must be used. The new `asm!()` does not allow using `ebx` [1], which holds the argument for the SMMSTORE command. [1]: rust-lang/rust#84658 Signed-off-by: Tim Crawford <tcrawford@system76.com>
Fix: - clippy::needless_borrow Silence: - clippy::manual_flatten Not addressed: - deprecated `llvm_asm!()` is deprecated, but must be used. The new `asm!()` does not allow using `ebx` [1], which holds the argument for the SMMSTORE command. [1]: rust-lang/rust#84658 Signed-off-by: Tim Crawford <tcrawford@system76.com>
Fix: - clippy::needless_borrow - clippy::bool_assert_comparison Silence: - clippy::manual_flatten Not addressed: - deprecated `llvm_asm!()` is deprecated, but must be used. The new `asm!()` does not allow using `ebx` [1], which holds the argument for the SMMSTORE command. [1]: rust-lang/rust#84658 Signed-off-by: Tim Crawford <tcrawford@system76.com>
Fix: - clippy::needless_borrow - clippy::bool_assert_comparison Silence: - clippy::manual_flatten Not addressed: - deprecated `llvm_asm!()` is deprecated, but must be used. The new `asm!()` does not allow using `ebx` [1], which holds the argument for the SMMSTORE command. [1]: rust-lang/rust#84658 Signed-off-by: Tim Crawford <tcrawford@system76.com>
LLVM will silently produce incorrect code if these registers are used as operands.
cc @rust-lang/wg-inline-asm