From 24090a219d8bf902db530bfd9bd73e837f13c435 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 3 Apr 2023 11:54:30 -0700 Subject: [PATCH] x86-64: Make glibc.cpu.prefer_map_32bit_exec Linux specific Add to make glibc.cpu.prefer_map_32bit_exec Linux specific. --- .../sysv/linux/x86_64/64/map-32bit-exec.h | 29 +++++++++++++++++++ sysdeps/x86/cpu-features.c | 16 ++-------- sysdeps/x86/map-32bit-exec.h | 19 ++++++++++++ 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/x86_64/64/map-32bit-exec.h create mode 100644 sysdeps/x86/map-32bit-exec.h diff --git a/sysdeps/unix/sysv/linux/x86_64/64/map-32bit-exec.h b/sysdeps/unix/sysv/linux/x86_64/64/map-32bit-exec.h new file mode 100644 index 0000000000..74763853e1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/64/map-32bit-exec.h @@ -0,0 +1,29 @@ +/* Handle glibc.cpu.prefer_map_32bit_exec. Linux/x86-64 version. + This file is part of the GNU C Library. + Copyright (C) 2023 Free Software Foundation, Inc. + + 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 + . */ + +static void +TUNABLE_CALLBACK (set_prefer_map_32bit_exec) (tunable_val_t *valp) +{ + if (valp->numval) + GLRO(dl_x86_cpu_features).preferred[index_arch_Prefer_MAP_32BIT_EXEC] + |= bit_arch_Prefer_MAP_32BIT_EXEC; +} + +#define TUNABLE_GET_prefer_map_32bit_exec() \ + TUNABLE_GET (prefer_map_32bit_exec, tunable_val_t *, \ + TUNABLE_CALLBACK (set_prefer_map_32bit_exec)); diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 978eb29f72..75a011dab7 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -22,20 +22,11 @@ #include #include #include +#include extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *) attribute_hidden; -#ifdef __LP64__ -static void -TUNABLE_CALLBACK (set_prefer_map_32bit_exec) (tunable_val_t *valp) -{ - if (valp->numval) - GLRO(dl_x86_cpu_features).preferred[index_arch_Prefer_MAP_32BIT_EXEC] - |= bit_arch_Prefer_MAP_32BIT_EXEC; -} -#endif - #if CET_ENABLED extern void TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *) attribute_hidden; @@ -710,10 +701,7 @@ no_cpuid: TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); -#ifdef __LP64__ - TUNABLE_GET (prefer_map_32bit_exec, tunable_val_t *, - TUNABLE_CALLBACK (set_prefer_map_32bit_exec)); -#endif + TUNABLE_GET_prefer_map_32bit_exec (); bool disable_xsave_features = false; diff --git a/sysdeps/x86/map-32bit-exec.h b/sysdeps/x86/map-32bit-exec.h new file mode 100644 index 0000000000..9771338df3 --- /dev/null +++ b/sysdeps/x86/map-32bit-exec.h @@ -0,0 +1,19 @@ +/* Handle glibc.cpu.prefer_map_32bit_exec. Generic x86 version. + This file is part of the GNU C Library. + Copyright (C) 2023 Free Software Foundation, Inc. + + 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 + . */ + +#define TUNABLE_GET_prefer_map_32bit_exec() -- 2.39.2