Skip to content

Commit 978182a

Browse files
committed
[main] Add Guarded Control Stack intrinsics
1 parent 04101a9 commit 978182a

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

main/acle.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4674,6 +4674,54 @@ two pointers, ignoring the tags.
46744674
The return value is the sign-extended result of the computation.
46754675
The tag bits in the input pointers are ignored for this operation.
46764676

4677+
# Guarded Control Stack intrinsics
4678+
4679+
## Introduction
4680+
4681+
This section describes the intrinsics for the instructions of the
4682+
Guarded Control Stack (GCS) extension. The GCS instructions are present
4683+
in the AArch64 execution state only.
4684+
4685+
When GCS protection is enabled then function calls save the return
4686+
address to a separate stack, the GCS, that is checked against the actual
4687+
return address when the function returns. At runtime GCS protection can
4688+
be disabled and then calls and returns do not access the GCS. The GCS
4689+
grows down and a GCS pointer points to the last entry of the GCS.
4690+
Each thread has a separate GCS and GCS pointer.
4691+
4692+
To use the intrinsics, `arm_acle.h` needs to be included.
4693+
4694+
These intrinsics are available when GCS instructions are supported.
4695+
The `__chkfeat` intrinsics with `_CHKFEAT_GCS` can be used to check
4696+
if GCS protection is enabled at runtime. GCS protection is only
4697+
enabled at runtime if the code is GCS compatible and the GCS
4698+
instructions are supported.
4699+
4700+
## Intrinsics
4701+
4702+
4703+
``` c
4704+
const void *__gcspr(void);
4705+
```
4706+
4707+
Returns the GCS pointer of the current thread.
4708+
4709+
``` c
4710+
uint64_t __gcspopm(void);
4711+
```
4712+
4713+
Reads and returns the last entry on the GCS of the current thread and
4714+
updates the GCS pointer to point to the previous entry. If GCS
4715+
protection is disabled then it has no side effect and returns `0`.
4716+
4717+
``` c
4718+
const void *__gcsss(const void *);
4719+
```
4720+
4721+
Switches the GCS of the current thread, where the argument is the new
4722+
GCS pointer, and returns the old GCS pointer. If GCS protection is
4723+
disabled then it has no side effect and returns `NULL`.
4724+
46774725
# State management
46784726

46794727
The specification for SME is in

0 commit comments

Comments
 (0)