]> sourceware.org Git - glibc.git/commit
aarch64: Define jmp_buf offset for GCS
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 25 Nov 2022 18:16:07 +0000 (18:16 +0000)
committerYury Khrustalev <yury.khrustalev@arm.com>
Mon, 20 Jan 2025 09:22:41 +0000 (09:22 +0000)
commit13cbbb0cb29153bab099e040002e7cc78a0ceaaa
treed7d20b306766268cea6dbc655baf404a3f5b485d
parent640c209a72b3a3d3712dffb8c728f6ce3c504715
aarch64: Define jmp_buf offset for GCS

The target specific internal __longjmp is called with a __jmp_buf
argument which has its size exposed in the ABI. On aarch64 this has
no space left, so GCSPR cannot be restored in longjmp in the usual
way, which is needed for the Guarded Control Stack (GCS) extension.

setjmp is implemented via __sigsetjmp which has a jmp_buf argument
however it is also called with __pthread_unwind_buf_t argument cast
to jmp_buf (in cancellation cleanup code built with -fno-exception).
The two types, jmp_buf and __pthread_unwind_buf_t, have common bits
beyond the __jmp_buf field and there is unused space there which we
can use for saving GCSPR.

For this to work some bits of those two generic types have to be
reserved for target specific use and the generic code in glibc has
to ensure that __longjmp is always called with a __jmp_buf that is
embedded into one of those two types. Morally __longjmp should be
changed to take jmp_buf as argument, but that is an intrusive change
across targets.

Note: longjmp is never called with __pthread_unwind_buf_t from user
code, only the internal __libc_longjmp is called with that type and
thus the two types could have separate longjmp implementations on a
target. We don't rely on this now (but might in the future given that
cancellation unwind does not need to restore GCSPR).

Given the above this patch finds an unused slot for GCSPR. This
placement is not exposed in the ABI so it may change in the future.
This is also very target ABI specific so the generic types cannot
be easily changed to clearly mark the reserved fields.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
sysdeps/aarch64/jmpbuf-offsets.h
This page took 0.033574 seconds and 5 git commands to generate.