Skip to content

Commit e54777b

Browse files
committed
fix wrong return type being used
1 parent b68256d commit e54777b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

text/0000-cmse-calling-conventions.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ type T0 = extern "cmse-nonsecure-call" fn(_: i32, _: i32, _: i32, _: i32) -> i32
5858
type T1 = extern "cmse-nonsecure-call" fn(_: i64, _: i64) -> i64;
5959

6060
#[repr(transparent)] struct U64(u64);
61-
type T3 = extern "cmse-nonsecure-call" fn() -> U64;
61+
type T2 = extern "cmse-nonsecure-call" fn() -> U64;
6262

6363
// Invalid: too many argument registers used
64-
type T1 = extern "cmse-nonsecure-call" fn(_: i64, _: u8, _: u8, _: u8) -> i64;
64+
type T3 = extern "cmse-nonsecure-call" fn(_: i64, _: u8, _: u8, _: u8) -> i64;
6565

6666
// Invalid: return type too large
67-
type T1 = extern "cmse-nonsecure-call" fn() -> i128;
67+
type T4 = extern "cmse-nonsecure-call" fn() -> i128;
6868

6969
// Invalid: return type does not fit in one register, and is not abi-compatible with a 64-bit scalar
70-
#[repr(C)] struct I64(i64);
71-
type T2 = extern "cmse-nonsecure-call" fn(_: i64, _: i64) -> i64;
70+
#[repr(C)] struct WrappedI64(i64);
71+
type T5 = extern "cmse-nonsecure-call" fn(_: i64, _: i64) -> WrappedI64;
7272
```
7373

7474
An error is emitted when the program contains a signature that violates the calling convention's constraints:
@@ -124,7 +124,7 @@ Evaluating entry functions during constant evaluation is valid. The context swit
124124

125125
The `cmse-nonsecure-call` calling convention can only be used on function pointers, which cannot be evaluated during constant evaluation.
126126

127-
Miri is not a register machine, so the clearing of registers is not relevant. The context switching also does not need to be considered, because a Miri input program cannot use FFI and therefore cannot cross the secure boundary. Any attempt to do so would rely on a transmute or similar and would for that reason be unsound.
127+
Miri is not a register machine, so the clearing of registers is not relevant. The context switching also does not need to be considered, because a Miri input program cannot use FFI and therefore cannot cross the secure boundary. Any attempt to do so would rely on a transmute or similar and would for that reason be unsound.
128128
### Warn on partially uninitialized values crossing the secure boundary
129129

130130
Unions and types with padding or niches can contain uninitialized memory, and this uninitialized memory can contain stale secure information. Clang warns when union values cross the security boundary (see https://godbolt.org/z/vq9xnrnEs), and rust does the same.
@@ -163,7 +163,7 @@ extern "cmse-nonsecure-entry" fn padded_struct() -> PaddedStruct {
163163
A `cmse-nonsecure-call` function call will emit a warning when any of its arguments has a partially uninitialized type, and a `cmse-nonsecure-entry` function warns at any (implicit) return when the return type may be partially uninitialized.
164164

165165
Ultimately guaranteeing the security properties of the system is up to the programmer, but warning on types with potentially uninitialized memory is a helpful signal that the compiler can provide.
166-
## Background
166+
## Background
167167

168168
Additional background on what these calling conventions do, and how they are meant to be used. This information is not strictly required to understand the RFC, but has informed the design and may explain certain design choices.
169169

@@ -284,7 +284,7 @@ The [`cortex_m`](https://docs.rs/cortex-m/latest/cortex_m/cmse/index.html) crate
284284
# Future possibilities
285285
[future-possibilities]: #future-possibilities
286286

287-
## Lint on references crossing the secure boundary
287+
## Lint on references crossing the secure boundary
288288

289289
The secure application should never accept a reference because there is no guarantee that a hostile non-secure application does not provide an invalid value (`NULL`, not properly aligned, etc.). There are other types with layout assumptions (e.g. `NonZeroU64` and friends) that are almost certainly invalid for a secure application to accept.
290290

@@ -298,7 +298,7 @@ A suggestion that was floated is to provide some mechanism to ensure that a valu
298298
One potential method is to extend the`repr` attribute with an option that adds fields where padding is needed internally. These user-hidden padding fields would be zeroed upon creation.
299299
```rust
300300
#[repr(C, align(8), initialized)]
301-
struct Foo {
301+
struct Foo {
302302
a: u8,
303303
// implicit _padding0: [u8; 1],
304304
b: u16,

0 commit comments

Comments
 (0)