about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2023-07-17 08:31:05 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2024-02-02 15:58:11 +0000
commit200010339f4fa0449a7bd76555931881eaea916c (patch)
tree838c67f8ca1093e3b26c6a1c392ac5b6a83d28ad /sysdeps/unix/sysv/linux/aarch64/cpu-features.c
parent56253d5f47330f502dd6bc8f3e12eeabf6c20a8b (diff)
downloadglibc-200010339f4fa0449a7bd76555931881eaea916c.tar.gz
glibc-200010339f4fa0449a7bd76555931881eaea916c.tar.xz
glibc-200010339f4fa0449a7bd76555931881eaea916c.zip
aarch64: Add glibc.cpu.aarch64_gcs tunable
This tunable is for controlling the GCS status. It is the argument to
the PR_SET_SHADOW_STACK_STATUS prctl, by default 0, so GCS is disabled.

The status is stored into GL(dl_aarch64_gcs) early and only applied
later, since enabling GCS is tricky: it must happen on a top level
stack frame. (Using GL instead of GLRO because it may need updates
depending on loaded libraries that happen after readonly protection
is applied, however library marking based GCS setting is not yet
implemented.)
Diffstat (limited to 'sysdeps/unix/sysv/linux/aarch64/cpu-features.c')
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/cpu-features.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
index b1a3f673f0..a8b6a4654a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
+++ b/sysdeps/unix/sysv/linux/aarch64/cpu-features.c
@@ -128,4 +128,8 @@ init_cpu_features (struct cpu_features *cpu_features)
 
   /* Check if MOPS is supported.  */
   cpu_features->mops = GLRO (dl_hwcap2) & HWCAP2_MOPS;
+
+  if (GLRO (dl_hwcap2) & HWCAP2_GCS)
+    /* GCS status may be updated later by binary compatibility checks.  */
+    GL (dl_aarch64_gcs) = TUNABLE_GET (glibc, cpu, aarch64_gcs, uint64_t, 0);
 }