From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id A0D99385E44B; Wed, 14 Feb 2024 15:07:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0D99385E44B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707923228; bh=D9nl8ICAxRIA+HoBRDMyudnfAz/NsXBi3VGn/CAkOfU=; h=From:To:Subject:Date:From; b=N6Vu1Lqj07VnRTzHd9AxHb95HKYjpcQP207/ZDHWJMgaYl3g28Kz1u2XDAttoRYIn +7h0Yc0E7RHAyVYaFWbDL8m3YgcLcMC7JZ8aRXAyDEsFR6J42np8wTmTSFPjVvo8tV cB6DoRu3mxpSCM4wEQXBs2sE9nyIBo+ABDKdxDF0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/gcs] aarch64: Add glibc.cpu.aarch64_gcs tunable X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/gcs X-Git-Oldrev: 56253d5f47330f502dd6bc8f3e12eeabf6c20a8b X-Git-Newrev: 200010339f4fa0449a7bd76555931881eaea916c Message-Id: <20240214150708.A0D99385E44B@sourceware.org> Date: Wed, 14 Feb 2024 15:07:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=200010339f4fa0449a7bd76555931881eaea916c commit 200010339f4fa0449a7bd76555931881eaea916c Author: Szabolcs Nagy Date: Mon Jul 17 08:31:05 2023 +0100 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.) Diff: --- sysdeps/aarch64/dl-tunables.list | 5 ++++ sysdeps/unix/sysv/linux/aarch64/cpu-features.c | 4 +++ sysdeps/unix/sysv/linux/aarch64/dl-procruntime.c | 37 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/sysdeps/aarch64/dl-tunables.list b/sysdeps/aarch64/dl-tunables.list index 92c6cbfa92..c08be86932 100644 --- a/sysdeps/aarch64/dl-tunables.list +++ b/sysdeps/aarch64/dl-tunables.list @@ -21,5 +21,10 @@ glibc { name { type: STRING } + aarch64_gcs { + type: UINT_64 + minval: 0 + default: 0 + } } } 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); } diff --git a/sysdeps/unix/sysv/linux/aarch64/dl-procruntime.c b/sysdeps/unix/sysv/linux/aarch64/dl-procruntime.c new file mode 100644 index 0000000000..23c61da6c4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/dl-procruntime.c @@ -0,0 +1,37 @@ +/* Data for processor runtime information. AArch64 version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef PROCINFO_CLASS +# define PROCINFO_CLASS +#endif + +#if !IS_IN (ldconfig) +# if !defined PROCINFO_DECL && defined SHARED + ._dl_aarch64_gcs +# else +PROCINFO_CLASS unsigned long _dl_aarch64_gcs +# endif +# ifndef PROCINFO_DECL += 0 +# endif +# if !defined SHARED || defined PROCINFO_DECL +; +# else +, +# endif +#endif