Skip to content

Commit

Permalink
remove #[cmse_nonsecure_entry]
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Jul 15, 2024
1 parent b1dd190 commit 8da0efe
Show file tree
Hide file tree
Showing 30 changed files with 46 additions and 267 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));
}
if let Some(align) = codegen_fn_attrs.alignment {
llvm::set_alignment(llfn, align);
}
Expand Down
18 changes: 0 additions & 18 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}
}
}
sym::cmse_nonsecure_entry => {
if let Some(fn_sig) = fn_sig()
&& !matches!(fn_sig.skip_binder().abi(), abi::Abi::C { .. })
{
struct_span_code_err!(
tcx.dcx(),
attr.span,
E0776,
"`#[cmse_nonsecure_entry]` requires C ABI"
)
.emit();
}
if !tcx.sess.target.llvm_target.contains("thumbv8m") {
struct_span_code_err!(tcx.dcx(), attr.span, E0775, "`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension")
.emit();
}
codegen_fn_attrs.flags |= CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY
}
sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL,
sym::track_caller => {
let is_closure = tcx.is_closure_like(did.to_def_id());
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0776.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#### Note: this error code is no longer emitted by the compiler.

`#[cmse_nonsecure_entry]` functions require a C ABI

Erroneous code example:
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,4 @@ E0797: 0797,
// E0723, // unstable feature in `const` context
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
// E0744, // merged into E0728
// E0776, // Removed; cmse_nonsecure_entry is now `C-cmse-nonsecure-entry`
4 changes: 0 additions & 4 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
EncodeCrossCrate::No, experimental!(register_tool),
),

gated!(
cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
EncodeCrossCrate::No, experimental!(cmse_nonsecure_entry)
),
// RFC 2632
gated!(
const_trait, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, const_trait_impl,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ declare_features! (
(unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
/// Allows `#[track_caller]` on closures and coroutines.
(unstable, closure_track_caller, "1.57.0", Some(87417)),
/// Allows to use the `#[cmse_nonsecure_entry]` attribute.
/// Allows `extern "C-cmse-nonsecure-entry" fn()`.
(unstable, cmse_nonsecure_entry, "1.48.0", Some(75835)),
/// Allows `async {}` expressions in const contexts.
(unstable, const_async_blocks, "1.53.0", Some(85368)),
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ bitflags::bitflags! {
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
/// declaration.
const FFI_CONST = 1 << 12;
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
/// function as an entry function from Non-Secure code.
const CMSE_NONSECURE_ENTRY = 1 << 13;
// (Bit 13 was used for `#[cmse_nonsecure_entry]`, but is now unused.)
// (Bit 14 was used for `#[coverage(off)]`, but is now unused.)
/// `#[used(linker)]`:
/// indicates that neither LLVM nor the linker will eliminate this function.
Expand Down
25 changes: 0 additions & 25 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| [sym::rustc_must_implement_one_of]
| [sym::rustc_deny_explicit_impl]
| [sym::const_trait] => self.check_must_be_applied_to_trait(attr, span, target),
[sym::cmse_nonsecure_entry] => {
self.check_cmse_nonsecure_entry(hir_id, attr, span, target)
}
[sym::collapse_debuginfo] => self.check_collapse_debuginfo(attr, span, target),
[sym::must_not_suspend] => self.check_must_not_suspend(attr, span, target),
[sym::must_use] => self.check_must_use(hir_id, attr, target),
Expand Down Expand Up @@ -433,28 +430,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
}

/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
fn check_cmse_nonsecure_entry(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
target: Target,
) -> bool {
match target {
Target::Fn
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
_ => {
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
attr_span: attr.span,
defn_span: span,
on_crate: hir_id == CRATE_HIR_ID,
});
false
}
}
}

/// Debugging aid for `object_lifetime_default` query.
fn check_object_lifetime_default(&self, hir_id: HirId) {
let tcx = self.tcx;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,9 +1251,9 @@ impl StackProbeType {
.and_then(|o| o.as_array())
.ok_or_else(|| "expected `min-llvm-version-for-inline` to be an array")?;
let mut iter = min_version.into_iter().map(|v| {
let int = v.as_u64().ok_or_else(|| {
"expected `min-llvm-version-for-inline` values to be integers"
})?;
let int = v.as_u64().ok_or_else(
|| "expected `min-llvm-version-for-inline` values to be integers",
)?;
u32::try_from(int)
.map_err(|_| "`min-llvm-version-for-inline` values don't convert to u32")
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ LLVM, the Rust compiler and the linker are providing
TrustZone-M feature.

One of the things provided, with this unstable feature, is the
`cmse_nonsecure_entry` attribute. This attribute marks a Secure function as an
`C-cmse-nonsecure-entry` ABI. This ABI marks a Secure function as an
entry function (see [section
5.4](https://developer.arm.com/documentation/ecm0359818/latest/) for details).
With this attribute, the compiler will do the following:
With this ABI, the compiler will do the following:
* add a special symbol on the function which is the `__acle_se_` prefix and the
standard function name
* constrain the number of parameters to avoid using the Non-Secure stack
Expand All @@ -38,11 +38,11 @@ gateway veneer.
<!-- NOTE(ignore) this example is specific to thumbv8m targets -->

``` rust,ignore
#![no_std]
#![feature(cmse_nonsecure_entry)]
#[no_mangle]
#[cmse_nonsecure_entry]
pub extern "C" fn entry_function(input: u32) -> u32 {
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
input + 6
}
```
Expand Down
2 changes: 0 additions & 2 deletions src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ ui/async-await/return-type-notation/issue-110963-early.rs
ui/async-await/return-type-notation/issue-110963-late.rs
ui/async-await/track-caller/issue-105134.rs
ui/attributes/issue-100631.rs
ui/attributes/issue-105594-invalid-attr-validation.rs
ui/attributes/issue-115264-expr-field.rs
ui/attributes/issue-115264-pat-field.rs
ui/attributes/issue-40962.rs
Expand Down Expand Up @@ -467,7 +466,6 @@ ui/closures/issue-87814-2.rs
ui/closures/issue-90871.rs
ui/closures/issue-97607.rs
ui/closures/issue-99565.rs
ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs
ui/codegen/auxiliary/issue-97708-aux.rs
ui/codegen/issue-101585-128bit-repeat.rs
ui/codegen/issue-16602-1.rs
Expand Down
13 changes: 0 additions & 13 deletions tests/ui/attributes/issue-105594-invalid-attr-validation.rs

This file was deleted.

26 changes: 0 additions & 26 deletions tests/ui/attributes/issue-105594-invalid-attr-validation.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/gate_test.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/gate_test.stderr

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry-abi/trustzone-only.rs

This file was deleted.

This file was deleted.

7 changes: 3 additions & 4 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// gate-test-cmse_nonsecure_entry

#[no_mangle]
#[cmse_nonsecure_entry]
//~^ ERROR [E0775]
//~| ERROR [E0658]
pub extern "C" fn entry_function(input: u32) -> u32 {
pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
//~^ ERROR [E0570]
//~| ERROR [E0658]
input + 6
}

Expand Down
18 changes: 9 additions & 9 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error[E0658]: the `#[cmse_nonsecure_entry]` attribute is an experimental feature
--> $DIR/gate_test.rs:4:1
error[E0658]: C-cmse-nonsecure-entry ABI is experimental and subject to change
--> $DIR/gate_test.rs:4:12
|
LL | #[cmse_nonsecure_entry]
| ^^^^^^^^^^^^^^^^^^^^^^^
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #75835 <https://github.com/rust-lang/rust/issues/75835> for more information
= help: add `#![feature(cmse_nonsecure_entry)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0775]: `#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M extension
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
--> $DIR/gate_test.rs:4:1
|
LL | #[cmse_nonsecure_entry]
| ^^^^^^^^^^^^^^^^^^^^^^^
LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0658, E0775.
For more information about an error, try `rustc --explain E0658`.
Some errors have detailed explanations: E0570, E0658.
For more information about an error, try `rustc --explain E0570`.
9 changes: 0 additions & 9 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/cmse-nonsecure/cmse-nonsecure-entry/issue-83475.stderr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
//@ needs-llvm-components: arm
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[lang="copy"]
trait Copy { }
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
impl Copy for u32 {}

#[no_mangle]
#[cmse_nonsecure_entry]
pub extern "C" fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
pub extern "C-cmse-nonsecure-entry" fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
d
}
Loading

0 comments on commit 8da0efe

Please sign in to comment.