about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* aarch64: Add aarch64-specific files for memory tagging support rearnsha/mte-v3.0Richard Earnshaw2020-11-206-0/+221
| | | | | This final patch provides the architecture-specific implementation of the memory-tagging support hooks for aarch64.
* aarch64: Add sysv specific enabling code for memory taggingRichard Earnshaw2020-11-204-0/+37
| | | | | | | | | | | | | | | Add various defines and stubs for enabling MTE on AArch64 sysv-like systems such as Linux. The HWCAP feature bit is copied over in the same way as other feature bits. Similarly we add a new wrapper header for mman.h to define the PROT_MTE flag that can be used with mmap and related functions. We add a new field to struct cpu_features that can be used, for example, to check whether or not certain ifunc'd routines should be bound to MTE-safe versions. Finally, if we detect that MTE should be enabled (ie via the glibc tunable); we enable MTE during startup as required.
* linux: Add compatibility definitions to sys/prctl.h for MTERichard Earnshaw2020-11-201-0/+18
| | | | | | | | | Older versions of the Linux kernel headers obviously lack support for memory tagging, but we still want to be able to build in support when using those (obviously it can't be enabled on such systems). The linux kernel extensions are made to the platform-independent header (linux/prctl.h), so this patch takes a similar approach.
* malloc: support MALLOC_CHECK_ in conjunction with _MTAG_ENABLE.Richard Earnshaw2020-11-203-78/+127
| | | | | | Note, I propose that this patch will be merged into the main malloc changes before committing, it is kept separate here to simplify reviewing.
* malloc: Clean up commentaryRichard Earnshaw2020-11-203-21/+101
| | | | | This patch will be merged with its predecessor before being committed, it is kept separate for now to ease reviewing.
* malloc: Basic support for memory tagging in the malloc() familyRichard Earnshaw2020-11-205-42/+252
| | | | | | | | | | | | | | | | | This patch adds the basic support for memory tagging. Various flavours are supported, particularly being able to turn on tagged memory at run-time: this allows the same code to be used on systems where memory tagging support is not present without neededing a separate build of glibc. Also, depending on whether the kernel supports it, the code will use mmap for the default arena if morecore does not, or cannot support tagged memory (on AArch64 it is not available). All the hooks use function pointers to allow this to work without needing ifuncs. malloc: allow memory tagging to be controlled from a tunable
* elf: Add a tunable to control use of tagged memoryRichard Earnshaw2020-11-202-0/+40
| | | | | | | | | | | | Add a new glibc tunable: mtag.enable, bound to the environment variable _MTAG_ENABLE. This is a decimal constant in the range 0-255 but used as a bit-field. Bit 0 enables use of tagged memory in the malloc family of functions. Bit 1 enables precise faulting of tag failure on platforms where this can be controlled. Other bits are currently unused, but if set will cause memory tag checking for the current process to be enabled in the kernel.
* config: Allow memory tagging to be enabled when configuring glibcRichard Earnshaw2020-11-206-0/+59
| | | | | | | | This patch adds the configuration machinery to allow memory tagging to be enabled from the command line via the configure option --enable-memory-tagging. The current default is off, though in time we may change that once the API is more stable.
* hurd: Enable using ifuncSamuel Thibault2020-11-162-6/+0
| | | | Bugs have been fixed in binutils/gcc/glibc.
* Add {,sysdep-}ld-library-path make variableSamuel Thibault2020-11-166-5/+10
| | | | | | | | On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some more paths, here mach/ and hurd/.
* nptl: Move stack list variables into _rtld_globalFlorian Weimer2020-11-1637-184/+243
| | | | | | | | | Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT, formerly __wait_lookup_done) can be implemented directly in ld.so, eliminating the unprotected GL (dl_wait_lookup_done) function pointer. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: let _dl_argv and __libc_stack_end be relroSamuel Thibault2020-11-151-7/+0
| | | | libpthread does not switch stacks.
* hurd: Remove some remnants of cthreadsSamuel Thibault2020-11-1527-80/+77
| | | | | Libc has actually been using mach's lock-internal.h mutex for a long time already.
* nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64Lukasz Majewski2020-11-142-2/+3
| | | | | | | | | | | | | On ports with __TIMESIZE != 64 the remaining time argument always receives pointer to struct __timespec64 instance. This is the different behavior when compared to 64 bit versions of clock_nanosleep and nanosleep functions, which receive NULL. To avoid any potential issues, we also pass NULL when *rem pointer is NULL. Reported-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* y2038: Convert thrd_sleep to support 64 bit timeLukasz Majewski2020-11-142-0/+60
| | | | | | | | | | | | | | | The thrd_sleep function has been converted to support 64 bit time. It was also necessary to provide Linux specific copy of it to avoid problems on i686-gnu (i.e. HURD) port, which is not providing clock_nanosleep() supporting 64 bit time. The thrd_sleep is a wrapper on POSIX threads to provide C11 standard threads interface. It directly calls __clock_nanosleep64(). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* y2038: Convert mtx_timedlock to support 64 bit timeLukasz Majewski2020-11-142-0/+47
| | | | | | | | | | | | | | | The mtx_timedlock function has been converted to support 64 bit time. It was also necessary to provide Linux specific copy of it to avoid problems on i686-gnu (i.e. HURD) port, which is not providing pthread_mutex_timedlock() supporting 64 bit time. The mtx_timedlock is a wrapper on POSIX threads to provide C11 standard threads interface. It directly calls __pthread_mutex_timedlock64(). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* y2038: Convert cnd_timedwait to support 64 bit timeLukasz Majewski2020-11-142-0/+71
| | | | | | | | | | | | | | | | | | The cnd_timedwait function has been converted to support 64 bit time. It was also necessary to provide Linux specific copy of it to avoid problems on i686-gnu (i.e. HURD) port, which is not providing pthread_cond_timedwait() supporting 64 bit time. Moreover, a linux specific copy of thrd_priv.h header file has been added as well. The cnd_timedwait is a wrapper on POSIX threads to provide C11 standard threads interface. It directly calls __pthread_cond_timedwait64(). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* hurd: Drop CLOCK_MONOTONIC change which slipped inSamuel Thibault2020-11-141-1/+0
|
* hurd: make ptsname fail with ENOTTY on non-master-ptySamuel Thibault2020-11-141-0/+8
|
* mach: Add missing assert.h includeSamuel Thibault2020-11-141-0/+2
|
* hurd: break relocation loop between libc.so and lib{mach,hurd}user.soSamuel Thibault2020-11-145-15/+44
| | | | | | | | | | | | | See https://sourceware.org/pipermail/libc-alpha/2020-November/119575.html lib{mach,hurd}user.so gets relocated before libc.so, but its references to strpcpy and memcpy would need an ifunc decision, which e.g. on x86 relies on cpu_features, but libc.so's _rtld_global_ro is not relocated yet. We can however just make lib{mach,hurd}user.so only call non-ifunc functions, which can be relocated before libc.so is relocated.
* Remove obsolete defines for HPUX support from fcntl.h and update O_NONBLOCK.John David Anglin2020-11-131-4/+1
|
* Remove tls.h inclusion from internal errno.hAdhemerval Zanella2020-11-1371-70/+83
| | | | | | | | | | | | The tls.h inclusion is not really required and limits possible definition on more arch specific headers. This is a cleanup to allow inline functions on sysdep.h, more specifically on i386 and ia64 which requires to access some tls definitions its own. No semantic changes expected, checked with a build against all affected ABIs.
* nptl: Eliminate <smp.h> and __is_smpFlorian Weimer2020-11-139-121/+20
| | | | | | | | | | | Most systems are SMP, so optimizing for the UP case is no longer approriate. A dynamic check based on the kernel identification has been only implemented for i386 anyway. To disable adaptive mutexes on sh, define DEFAULT_ADAPTIVE_COUNT as zero for this architecture. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* powerpc: Eliminate UP macro conditionalsFlorian Weimer2020-11-133-14/+5
| | | | | | The macro is never defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Remove UP macro. Define LOCK_PREFIX unconditionally.Florian Weimer2020-11-135-35/+5
| | | | | | | The UP macro is never defined. Also define LOCK_PREFIX unconditionally, to the same string. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* alpha: Remove UP preprocessor conditionalsFlorian Weimer2020-11-131-10/+4
| | | | | | The macro is never defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Make sure signals get startedSamuel Thibault2020-11-131-3/+3
| | | | | | Now that _hurd_libc_proc_init is idempotent, we can always call it, independently of the __libc_multiple_libcs test which may not match whether signals should be started or not.
* hurd: initialize libpthread before starting the signal threadSamuel Thibault2020-11-131-0/+6
| | | | | We cannot rely on csu calling __pthread_initialize_minimal before posixland_init, in some cases _init gets called before that.
* hurd: Make _hurd_libc_proc_init idempotentSamuel Thibault2020-11-131-11/+19
| | | | | For the cases where _init is getting called several times during startup. Better clean pointers anyway.
* powerpc: Add optimized stpncpy for POWER9Raphael M Zinsly2020-11-126-2/+135
| | | | | | | Add stpncpy support into the POWER9 strncpy. Reviewed-by: Matheus Castanho <msc@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* powerpc: Add optimized strncpy for POWER9Raphael M Zinsly2020-11-125-1/+391
| | | | | | | | Similar to the strcpy P9 optimization, this version uses VSX to improve performance. Reviewed-by: Matheus Castanho <msc@linux.ibm.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* Don't use nested function in test-ffsSiddhesh Poyarekar2020-11-121-22/+14
| | | | | There is no real need to use a nested function in that test, so break it out so that it can build with clang too.
* Use __builtin___stpncpy_chk when availableSiddhesh Poyarekar2020-11-121-1/+8
| | | | | | | | | | | | The builtin has been available in gcc since 4.7.0 and in clang since 2.6. This fixes stpncpy fortification with clang since it does a better job of plugging in __stpncpy_chk in the right place than the header hackery. This has been tested by building and running all tests with gcc 10.2.1 and also with clang tip as of a few days ago (just the tests in debug/ since running all tests don't work with clang at the moment) to make sure that both compilers pass the stpncpy tests.
* tests: Remove NULL check for an arraySiddhesh Poyarekar2020-11-124-8/+0
| | | | | The NULL check for an array on stack is pointless since it will always be false, so drop it.
* hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbolsSamuel Thibault2020-11-1126-219/+510
| | | | | | We do not actually need them, so we can move their implementations into the standard {,f,l}stat{,at} variants and only keep compatibility wrappers.
* hurd: Notify the proc server later during initializationSamuel Thibault2020-11-113-11/+31
| | | | | | Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed.
* htl: Initialize laterSamuel Thibault2020-11-119-122/+32
| | | | | | | | Since htl does not actually need a stack switch, we can initialize it like nptl is, avoiding all sorts of startup issues with ifunc. More precisely, htl defines __pthread_initialize_minimal instead of the elder _cthread_init_routine. We can then drop the stack switching dances.
* htl: Keep thread signals blocked during its initializationSamuel Thibault2020-11-112-2/+13
| | | | | One may send signals immediately after creating a thread. We need to block them until the thread is ready to run signal handlers.
* htl: Fix spurious symbols in namespacesSamuel Thibault2020-11-115-5/+5
| | | | | pthread_attr_{{get,set}stack{addr,size},setstack} were defining a strong alias for no reason, turning them to weak.
* Use O_CLOEXEC in sysconf [BZ #26791]Maximilian Krüger2020-11-111-1/+1
| | | | | If sysconf is used in multithreaded processes, various filedescriptors may leak due to missing O_CLOEXEC. This commit adds the flag.
* struct _Unwind_Exception alignment should not depend on compiler flagsFlorian Weimer2020-11-111-9/+15
| | | | | | | | | | | | __attribute__((__aligned__)) selects an alignment that depends on the micro-architecture selected by GCC flags. Enabling vector extensions may increase the allignment. This is a problem when building glibc as a collection of ELF multilibs with different GCC flags because ld.so and libc.so/libpthread.so/&c may end up with a different layout of struct pthread because of the changing offset of its struct _Unwind_Exception field. Tested-By: Matheus Castanho <msc@linux.ibm.com>
* hurd: keep only required PLTs in ld.soSamuel Thibault2020-11-1117-34/+20
| | | | | | | | | | | | | | | | | | | | | We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so. See Roland's comment in https://sourceware.org/bugzilla/show_bug.cgi?id=15605 "in the Hurd it's crucial that calls like __mmap be the libc ones instead of the rtld-local ones after the bootstrap phase, when the dynamic linker is being used for dlopen and the like." We used to just avoid all hidden use in the rtld ; this commit switches to keeping only those that should use PLT calls, i.e. essentially those defined in sysdeps/mach/hurd/dl-sysdep.c: __assert_fail __assert_perror_fail __*stat64 _exit This fixes a few startup issues, notably the call to __tunable_get_val that is made before PLTs are set up.
* hurd: Add missing startup callsSamuel Thibault2020-11-111-0/+16
| | | | | | DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to missing x86 platform tuning, now mandatory with 0f09154c6400 ("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")
* riscv: Get cache information through sysconfZong Li2020-11-101-0/+100
| | | | | | | | Add support to query cache information on RISC-V through sysconf() function. The cache information had been added in AUX vector of RISC-V architecture in Linux kernel v.5.10-rc1. Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com> Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
* RISC-V: Add _dl_start_user.Jim Wilson2020-11-101-1/+3
| | | | | | | | | | | | | This is required for the debugglibc.sh script to work. Tested by successfully using this patched script, and a riscv64-linux testsuite run. We could perhaps call RTLD_EPILOGUE for ENTRY_POINT before calling RTLD_PROLOGUE for _dl_start_user, but I don't think it matters. OK? Jim
* linux: Allow adjtime with NULL argument [BZ #26833]Adhemerval Zanella2020-11-093-4/+54
| | | | | | | | | | | The adjtime interface allows return the amount of time remaining from any previous adjustment that has not yet been completed by passing a NULL as first argument. This was introduced with y2038 support 0308077e3a. Checked on i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* aarch64: Add unwind information to _start (bug 26853)Florian Weimer2020-11-091-4/+3
| | | | | | | This adds CFI directives which communicate that the stack ends with this function. Fixes bug 26853.
* bsd unlockpt: unlockpt needs to fail with EINVAL, not ENOTTYSamuel Thibault2020-11-081-1/+6
| | | | | The EINVAL error code is mandated by POSIX, while ptsname_r returns ENOTTY, so we need to translate.
* Rearrange bsd_getpt vs bsd_openpt and implement posix_openpt on BSDSamuel Thibault2020-11-071-10/+8
| | | | | | | | | * sysdeps/unix/bsd/getpt.c (__getpt): Add oflag parameter, pass it to the _open call and rename to... (__bsd_openpt): ... new function. (__getpt): Reimplement on top of __bsd_openpt. (__posix_openpt): Replace stub with implementation on top of __bsd_openpt. (posix_openpt): Remove stub warning.