Skip to content

Commit 7681011

Browse files
committed
[main] Add Guarded Control Stack intrinsics
1 parent 565aeaf commit 7681011

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

main/acle.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4506,6 +4506,56 @@ two pointers, ignoring the tags.
45064506
The return value is the sign-extended result of the computation.
45074507
The tag bits in the input pointers are ignored for this operation.
45084508

4509+
# Guarded Control Stack intrinsics
4510+
4511+
## Introduction
4512+
4513+
This section describes the intrinsics for the instructions of the
4514+
Guarded Control Stack (GCS) extension. The GCS instructions are present
4515+
in the AArch64 execution state only.
4516+
4517+
When GCS protection is enabled then function calls save the return
4518+
address to a separate stack, the GCS, that is checked against the actual
4519+
return address when the function returns. At runtime GCS protection can
4520+
be disabled and then calls and returns do not access the GCS. The GCS
4521+
grows down and a GCS pointer points to the last entry of the GCS.
4522+
Each thread has a separate GCS and GCS pointer.
4523+
4524+
To use the intrinsics, `arm_acle.h` needs to be included.
4525+
4526+
The intrinsics are only valid to call when GCS instructions are
4527+
supported. The `__chkfeat` intrinsics with `_CHKFEAT_GCS` can be used
4528+
to check if GCS protection is enabled at runtime. If GCS protection is
4529+
enabled then GCS instructions are supported and the code was compiled
4530+
in a GCS protection compatible way (`__ARM_FEATURE_GCS_DEFAULT` was
4531+
defined).
4532+
4533+
4534+
## Intrinsics
4535+
4536+
4537+
``` c
4538+
const void *__gcspr(void);
4539+
```
4540+
4541+
Returns the GCS pointer of the current thread.
4542+
4543+
``` c
4544+
uint64_t __gcspopm(void);
4545+
```
4546+
4547+
Reads and returns the last entry on the GCS of the current thread and
4548+
updates the GCS pointer to point to the previous entry. If GCS
4549+
protection is disabled then it has no side effect and returns `0`.
4550+
4551+
``` c
4552+
const void *__gcsss(const void *);
4553+
```
4554+
4555+
Switches the GCS of the current thread, where the argument is the new
4556+
GCS pointer, and returns the old GCS pointer. If GCS protection is
4557+
disabled then it has no side effect and returns `NULL`.
4558+
45094559
# System register access
45104560

45114561
## Special register intrinsics

0 commit comments

Comments
 (0)