@@ -4595,6 +4595,56 @@ two pointers, ignoring the tags.
45954595The return value is the sign-extended result of the computation.
45964596The tag bits in the input pointers are ignored for this operation.
45974597
4598+ # Guarded Control Stack intrinsics
4599+
4600+ ## Introduction
4601+
4602+ This section describes the intrinsics for the instructions of the
4603+ Guarded Control Stack (GCS) extension. The GCS instructions are present
4604+ in the AArch64 execution state only.
4605+
4606+ When GCS protection is enabled then function calls save the return
4607+ address to a separate stack, the GCS, that is checked against the actual
4608+ return address when the function returns. At runtime GCS protection can
4609+ be disabled and then calls and returns do not access the GCS. The GCS
4610+ grows down and a GCS pointer points to the last entry of the GCS.
4611+ Each thread has a separate GCS and GCS pointer.
4612+
4613+ To use the intrinsics, `arm_acle.h` needs to be included.
4614+
4615+ The intrinsics are only valid to call when GCS instructions are
4616+ supported. The `__chkfeat` intrinsics with `_CHKFEAT_GCS` can be used
4617+ to check if GCS protection is enabled at runtime. If GCS protection is
4618+ enabled then GCS instructions are supported and the code was compiled
4619+ in a GCS protection compatible way (`__ARM_FEATURE_GCS_DEFAULT` was
4620+ defined).
4621+
4622+
4623+ ## Intrinsics
4624+
4625+
4626+ ``` c
4627+ const void *__gcspr(void);
4628+ ```
4629+
4630+ Returns the GCS pointer of the current thread.
4631+
4632+ ``` c
4633+ uint64_t __gcspopm(void);
4634+ ```
4635+
4636+ Reads and returns the last entry on the GCS of the current thread and
4637+ updates the GCS pointer to point to the previous entry. If GCS
4638+ protection is disabled then it has no side effect and returns `0`.
4639+
4640+ ``` c
4641+ const void *__gcsss(const void *);
4642+ ```
4643+
4644+ Switches the GCS of the current thread, where the argument is the new
4645+ GCS pointer, and returns the old GCS pointer. If GCS protection is
4646+ disabled then it has no side effect and returns `NULL`.
4647+
45984648# System register access
45994649
46004650## Special register intrinsics
0 commit comments