diff --git a/aarch64-sys-ptrace-update.patch b/aarch64-sys-ptrace-update.patch new file mode 100644 index 0000000..bea5aa1 --- /dev/null +++ b/aarch64-sys-ptrace-update.patch @@ -0,0 +1,30 @@ +2018-02-10 Dmitry V. Levin + + [BZ #22433] + * sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request): + Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS, + and PTRACE_SETHBPREGS. + +Index: glibc-2.27/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h ++++ glibc-2.27/sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h +@@ -78,18 +78,10 @@ enum __ptrace_request + PTRACE_DETACH = 17, + #define PT_DETACH PTRACE_DETACH + +- PTRACE_GET_THREAD_AREA = 22, +- + /* Continue and stop at the next entry to or return from syscall. */ + PTRACE_SYSCALL = 24, + #define PT_SYSCALL PTRACE_SYSCALL + +- /* Get all hardware breakpoint registers. */ +- PTRACE_GETHBPREGS = 29, +- +- /* Set all hardware breakpoint registers. */ +- PTRACE_SETHBPREGS = 30, +- + /* Set ptrace filter options. */ + PTRACE_SETOPTIONS = 0x4200, + #define PT_SETOPTIONS PTRACE_SETOPTIONS diff --git a/glibc.changes b/glibc.changes index 5498a8a..e069074 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Thu Mar 22 09:48:53 UTC 2018 - schwab@suse.de + +- pkey-get-reserved-name.patch: Linux: use reserved name __key in pkey_get + (BZ #22797) +- aarch64-sys-ptrace-update.patch: linux/aarch64: sync sys/ptrace.h with + Linux 4.15 (BZ #22433) +- powerpc-sys-ptrace-undefine-macros.patch: powerpc: Undefine Linux ptrace + macros that conflict with __ptrace_request +- powerpc-sys-ptrace-update.patch: linux/powerpc: sync sys/ptrace.h with + Linux 4.15 (BZ #22433, BZ #22807) +- netgroup-cache-keys.patch: Fix netgroup cache keys (BZ #22342) +- i386-sigaction-sa-restorer.patch: i386: Fix i386 sigaction sa_restorer + initialization (BZ #21269) +- riscv-tls-init.patch: RISC-V: Do not initialize $gp in TLS macros +- riscv-fmax-fmin-nan.patch: RISC-V: fmax/fmin: Handle signalling NaNs + correctly (BZ #22884) + ------------------------------------------------------------------- Wed Mar 7 09:14:55 UTC 2018 - schwab@suse.de diff --git a/glibc.spec b/glibc.spec index 61467eb..57133d3 100644 --- a/glibc.spec +++ b/glibc.spec @@ -284,6 +284,22 @@ Patch306: glibc-fix-double-loopback.diff Patch1000: riscv-readelflib.patch # PATCH-FIX-UPSTREAM Fix multiple definitions of __nss_*_database (BZ #22918) Patch1001: nss-database-multiple-dfn.patch +# PATCH-FIX-UPSTREAM Linux: use reserved name __key in pkey_get (BZ #22797) +Patch1002: pkey-get-reserved-name.patch +# PATCH-FIX-UPSTREAM linux/aarch64: sync sys/ptrace.h with Linux 4.15 (BZ #22433) +Patch1003: aarch64-sys-ptrace-update.patch +# PATCH-FIX-UPSTREAM powerpc: Undefine Linux ptrace macros that conflict with __ptrace_request +Patch1004: powerpc-sys-ptrace-undefine-macros.patch +# PATCH-FIX-UPSTREAM linux/powerpc: sync sys/ptrace.h with Linux 4.15 (BZ #22433, BZ #22807) +Patch1005: powerpc-sys-ptrace-update.patch +# PATCH-FIX-UPSTREAM Fix netgroup cache keys (BZ #22342) +Patch1006: netgroup-cache-keys.patch +# PATCH-FIX-UPSTREAM i386: Fix i386 sigaction sa_restorer initialization (BZ #21269) +Patch1007: i386-sigaction-sa-restorer.patch +# PATCH-FIX-UPSTREAM RISC-V: Do not initialize $gp in TLS macros +Patch1008: riscv-tls-init.patch +# PATCH-FIX-UPSTREAM RISC-V: fmax/fmin: Handle signalling NaNs correctly (BZ #22884) +Patch1009: riscv-fmax-fmin-nan.patch ### # Patches awaiting upstream approval @@ -495,6 +511,14 @@ mv crypt_blowfish-%crypt_bf_version/*.[chS] crypt/ %patch1000 -p1 %patch1001 -p1 +%patch1002 -p1 +%patch1003 -p1 +%patch1004 -p1 +%patch1005 -p1 +%patch1006 -p1 +%patch1007 -p1 +%patch1008 -p1 +%patch1009 -p1 %patch2000 -p1 %patch2004 -p1 diff --git a/i386-sigaction-sa-restorer.patch b/i386-sigaction-sa-restorer.patch new file mode 100644 index 0000000..0e735ec --- /dev/null +++ b/i386-sigaction-sa-restorer.patch @@ -0,0 +1,281 @@ +2018-03-03 Adhemerval Zanella + + [BZ #21269] + * sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269. + * sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear + sa_restorer for vDSO case. + * sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file. + +Index: glibc-2.27/sysdeps/unix/sysv/linux/i386/Makefile +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/i386/Makefile ++++ glibc-2.27/sysdeps/unix/sysv/linux/i386/Makefile +@@ -3,6 +3,9 @@ default-abi := 32 + + ifeq ($(subdir),misc) + sysdep_routines += ioperm iopl vm86 ++ ++tests += tst-bz21269 ++$(objpfx)tst-bz21269: $(shared-thread-library) + endif + + ifeq ($(subdir),elf) +Index: glibc-2.27/sysdeps/unix/sysv/linux/i386/sigaction.c +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/i386/sigaction.c ++++ glibc-2.27/sysdeps/unix/sysv/linux/i386/sigaction.c +@@ -42,7 +42,6 @@ extern void restore_rt (void) asm ("__re + #endif + extern void restore (void) asm ("__restore") attribute_hidden; + +- + /* If ACT is not NULL, change the action for SIG to *ACT. + If OACT is not NULL, put the old action for SIG in *OACT. */ + int +@@ -65,6 +64,8 @@ __libc_sigaction (int sig, const struct + kact.sa_restorer = ((act->sa_flags & SA_SIGINFO) + ? &restore_rt : &restore); + } ++ else ++ kact.sa_restorer = NULL; + } + + /* XXX The size argument hopefully will have to be changed to the +Index: glibc-2.27/sysdeps/unix/sysv/linux/i386/tst-bz21269.c +=================================================================== +--- /dev/null ++++ glibc-2.27/sysdeps/unix/sysv/linux/i386/tst-bz21269.c +@@ -0,0 +1,233 @@ ++/* Test for i386 sigaction sa_restorer handling (BZ#21269) ++ Copyright (C) 2017 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 ++ . */ ++ ++/* This is based on Linux test tools/testing/selftests/x86/ldt_gdt.c, ++ more specifically in do_multicpu_tests function. The main changes ++ are: ++ ++ - C11 atomics instead of plain access. ++ - Remove x86_64 support which simplifies the syscall handling ++ and fallbacks. ++ - Replicate only the test required to trigger the issue for the ++ BZ#21269. */ ++ ++#include ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++static int ++xset_thread_area (struct user_desc *u_info) ++{ ++ long ret = syscall (SYS_set_thread_area, u_info); ++ TEST_VERIFY_EXIT (ret == 0); ++ return ret; ++} ++ ++static void ++xmodify_ldt (int func, const void *ptr, unsigned long bytecount) ++{ ++ TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, 1, ptr, bytecount) == 0); ++} ++ ++static int ++futex (int *uaddr, int futex_op, int val, void *timeout, int *uaddr2, ++ int val3) ++{ ++ return syscall (SYS_futex, uaddr, futex_op, val, timeout, uaddr2, val3); ++} ++ ++static void ++xsethandler (int sig, void (*handler)(int, siginfo_t *, void *), int flags) ++{ ++ struct sigaction sa = { 0 }; ++ sa.sa_sigaction = handler; ++ sa.sa_flags = SA_SIGINFO | flags; ++ TEST_VERIFY_EXIT (sigemptyset (&sa.sa_mask) == 0); ++ TEST_VERIFY_EXIT (sigaction (sig, &sa, 0) == 0); ++} ++ ++static jmp_buf jmpbuf; ++ ++static void ++sigsegv_handler (int sig, siginfo_t *info, void *ctx_void) ++{ ++ siglongjmp (jmpbuf, 1); ++} ++ ++/* Points to an array of 1024 ints, each holding its own index. */ ++static const unsigned int *counter_page; ++static struct user_desc *low_user_desc; ++static struct user_desc *low_user_desc_clear; /* Used to delete GDT entry. */ ++static int gdt_entry_num; ++ ++static void ++setup_counter_page (void) ++{ ++ long page_size = sysconf (_SC_PAGE_SIZE); ++ TEST_VERIFY_EXIT (page_size > 0); ++ unsigned int *page = xmmap (NULL, page_size, PROT_READ | PROT_WRITE, ++ MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, -1); ++ for (int i = 0; i < (page_size / sizeof (unsigned int)); i++) ++ page[i] = i; ++ counter_page = page; ++} ++ ++static void ++setup_low_user_desc (void) ++{ ++ low_user_desc = xmmap (NULL, 2 * sizeof (struct user_desc), ++ PROT_READ | PROT_WRITE, ++ MAP_ANONYMOUS | MAP_PRIVATE | MAP_32BIT, -1); ++ ++ low_user_desc->entry_number = -1; ++ low_user_desc->base_addr = (unsigned long) &counter_page[1]; ++ low_user_desc->limit = 0xffff; ++ low_user_desc->seg_32bit = 1; ++ low_user_desc->contents = 0; ++ low_user_desc->read_exec_only = 0; ++ low_user_desc->limit_in_pages = 1; ++ low_user_desc->seg_not_present = 0; ++ low_user_desc->useable = 0; ++ ++ xset_thread_area (low_user_desc); ++ ++ low_user_desc_clear = low_user_desc + 1; ++ low_user_desc_clear->entry_number = gdt_entry_num; ++ low_user_desc_clear->read_exec_only = 1; ++ low_user_desc_clear->seg_not_present = 1; ++} ++ ++/* Possible values of futex: ++ 0: thread is idle. ++ 1: thread armed. ++ 2: thread should clear LDT entry 0. ++ 3: thread should exit. */ ++static atomic_uint ftx; ++ ++static void * ++threadproc (void *ctx) ++{ ++ while (1) ++ { ++ futex ((int *) &ftx, FUTEX_WAIT, 1, NULL, NULL, 0); ++ while (atomic_load (&ftx) != 2) ++ { ++ if (atomic_load (&ftx) >= 3) ++ return NULL; ++ } ++ ++ /* clear LDT entry 0. */ ++ const struct user_desc desc = { 0 }; ++ xmodify_ldt (1, &desc, sizeof (desc)); ++ ++ /* If ftx == 2, set it to zero, If ftx == 100, quit. */ ++ if (atomic_fetch_add (&ftx, -2) != 2) ++ return NULL; ++ } ++} ++ ++ ++/* As described in testcase, for historical reasons x86_32 Linux (and compat ++ on x86_64) interprets SA_RESTORER clear with nonzero sa_restorer as a ++ request for stack switching if the SS segment is 'funny' (this is default ++ scenario for vDSO system). This means that anything that tries to mix ++ signal handling with segmentation should explicit clear the sa_restorer. ++ ++ This testcase check if sigaction in fact does it by changing the local ++ descriptor table (LDT) through the modify_ldt syscall and triggering ++ a synchronous segfault on iret fault by trying to install an invalid ++ segment. With a correct zeroed sa_restorer it should not trigger an ++ 'real' SEGSEGV and allows the siglongjmp in signal handler. */ ++ ++static int ++do_test (void) ++{ ++ setup_counter_page (); ++ setup_low_user_desc (); ++ ++ pthread_t thread; ++ unsigned short orig_ss; ++ ++ xsethandler (SIGSEGV, sigsegv_handler, 0); ++ /* 32-bit kernels send SIGILL instead of SIGSEGV on IRET faults. */ ++ xsethandler (SIGILL, sigsegv_handler, 0); ++ ++ thread = xpthread_create (0, threadproc, 0); ++ ++ asm volatile ("mov %%ss, %0" : "=rm" (orig_ss)); ++ ++ for (int i = 0; i < 5; i++) ++ { ++ if (sigsetjmp (jmpbuf, 1) != 0) ++ continue; ++ ++ /* Make sure the thread is ready after the last test. */ ++ while (atomic_load (&ftx) != 0) ++ ; ++ ++ struct user_desc desc = { ++ .entry_number = 0, ++ .base_addr = 0, ++ .limit = 0xffff, ++ .seg_32bit = 1, ++ .contents = 0, ++ .read_exec_only = 0, ++ .limit_in_pages = 1, ++ .seg_not_present = 0, ++ .useable = 0 ++ }; ++ ++ xmodify_ldt (0x11, &desc, sizeof (desc)); ++ ++ /* Arm the thread. */ ++ ftx = 1; ++ futex ((int*) &ftx, FUTEX_WAKE, 0, NULL, NULL, 0); ++ ++ asm volatile ("mov %0, %%ss" : : "r" (0x7)); ++ ++ /* Fire up thread modify_ldt call. */ ++ atomic_store (&ftx, 2); ++ ++ while (atomic_load (&ftx) != 0) ++ ; ++ ++ /* On success, modify_ldt will segfault us synchronously and we will ++ escape via siglongjmp. */ ++ support_record_failure (); ++ } ++ ++ atomic_store (&ftx, 100); ++ futex ((int*) &ftx, FUTEX_WAKE, 0, NULL, NULL, 0); ++ ++ xpthread_join (thread); ++ ++ return 0; ++} ++ ++#include diff --git a/netgroup-cache-keys.patch b/netgroup-cache-keys.patch new file mode 100644 index 0000000..1702d71 --- /dev/null +++ b/netgroup-cache-keys.patch @@ -0,0 +1,19 @@ +2018-03-01 DJ Delorie + + [BZ #22342] + * nscd/netgroupcache.c (addinnetgrX): Include trailing NUL in + key value. + +Index: glibc-2.27/nscd/netgroupcache.c +=================================================================== +--- glibc-2.27.orig/nscd/netgroupcache.c ++++ glibc-2.27/nscd/netgroupcache.c +@@ -480,7 +480,7 @@ addinnetgrX (struct database_dyn *db, in + { + const char *group = key; + key = (char *) rawmemchr (key, '\0') + 1; +- size_t group_len = key - group - 1; ++ size_t group_len = key - group; + const char *host = *key++ ? key : NULL; + if (host != NULL) + key = (char *) rawmemchr (key, '\0') + 1; diff --git a/pkey-get-reserved-name.patch b/pkey-get-reserved-name.patch new file mode 100644 index 0000000..3708292 --- /dev/null +++ b/pkey-get-reserved-name.patch @@ -0,0 +1,19 @@ +2018-02-07 Igor Gnatenko + + [BZ #22797] + * sysdeps/unix/sysv/linux/bits/mman-shared.h (pkey_get): Add + missing second underscore to parameter name. + +Index: glibc-2.27/sysdeps/unix/sysv/linux/bits/mman-shared.h +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/bits/mman-shared.h ++++ glibc-2.27/sysdeps/unix/sysv/linux/bits/mman-shared.h +@@ -61,7 +61,7 @@ int pkey_set (int __key, unsigned int __ + + /* Return the access rights for the current thread for KEY, which must + have been allocated using pkey_alloc. */ +-int pkey_get (int _key) __THROW; ++int pkey_get (int __key) __THROW; + + /* Free an allocated protection key, which must have been allocated + using pkey_alloc. */ diff --git a/powerpc-sys-ptrace-undefine-macros.patch b/powerpc-sys-ptrace-undefine-macros.patch new file mode 100644 index 0000000..371d21a --- /dev/null +++ b/powerpc-sys-ptrace-undefine-macros.patch @@ -0,0 +1,59 @@ +2018-02-26 Tulio Magno Quites Machado Filho + + * sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux + macros used in __ptrace_request. + +Index: glibc-2.27/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h ++++ glibc-2.27/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h +@@ -24,6 +24,49 @@ + + __BEGIN_DECLS + ++#if defined _LINUX_PTRACE_H || defined _ASM_POWERPC_PTRACE_H ++/* Do not let Linux headers macros interfere with enum __ptrace_request. */ ++# undef PTRACE_ATTACH ++# undef PTRACE_CONT ++# undef PTRACE_DETACH ++# undef PTRACE_GET_DEBUGREG ++# undef PTRACE_GETEVENTMSG ++# undef PTRACE_GETEVRREGS ++# undef PTRACE_GETFPREGS ++# undef PTRACE_GETREGS ++# undef PTRACE_GETREGS64 ++# undef PTRACE_GETREGSET ++# undef PTRACE_GETSIGINFO ++# undef PTRACE_GETSIGMASK ++# undef PTRACE_GETVRREGS ++# undef PTRACE_GETVSRREGS ++# undef PTRACE_INTERRUPT ++# undef PTRACE_KILL ++# undef PTRACE_LISTEN ++# undef PTRACE_PEEKDATA ++# undef PTRACE_PEEKSIGINFO ++# undef PTRACE_PEEKTEXT ++# undef PTRACE_POKEDATA ++# undef PTRACE_POKETEXT ++# undef PTRACE_SECCOMP_GET_FILTER ++# undef PTRACE_SEIZE ++# undef PTRACE_SET_DEBUGREG ++# undef PTRACE_SETEVRREGS ++# undef PTRACE_SETFPREGS ++# undef PTRACE_SETOPTIONS ++# undef PTRACE_SETREGS ++# undef PTRACE_SETREGS64 ++# undef PTRACE_SETREGSET ++# undef PTRACE_SETSIGINFO ++# undef PTRACE_SETSIGMASK ++# undef PTRACE_SETVRREGS ++# undef PTRACE_SETVSRREGS ++# undef PTRACE_SINGLEBLOCK ++# undef PTRACE_SINGLESTEP ++# undef PTRACE_SYSCALL ++# undef PTRACE_TRACEME ++#endif ++ + /* Type of the REQUEST argument to `ptrace.' */ + enum __ptrace_request + { diff --git a/powerpc-sys-ptrace-update.patch b/powerpc-sys-ptrace-update.patch new file mode 100644 index 0000000..a75c667 --- /dev/null +++ b/powerpc-sys-ptrace-update.patch @@ -0,0 +1,95 @@ +2018-02-26 Dmitry V. Levin + + [BZ #22433] + [BZ #22807] + * sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h (__ptrace_request): Add + PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS, PTRACE_SETFPREGS, + PTRACE_GETVRREGS, PTRACE_SETVRREGS, PTRACE_GETEVRREGS, + PTRACE_SETEVRREGS, PTRACE_GETREGS64, PTRACE_SETREGS64, + PTRACE_GET_DEBUGREG, PTRACE_SET_DEBUGREG, PTRACE_GETVSRREGS, + PTRACE_SETVSRREGS, and PTRACE_SINGLEBLOCK. + +Index: glibc-2.27/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h +=================================================================== +--- glibc-2.27.orig/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h ++++ glibc-2.27/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h +@@ -112,6 +112,22 @@ enum __ptrace_request + PTRACE_SINGLESTEP = 9, + #define PT_STEP PTRACE_SINGLESTEP + ++ /* Get all general purpose registers used by a process. */ ++ PTRACE_GETREGS = 12, ++#define PT_GETREGS PTRACE_GETREGS ++ ++ /* Set all general purpose registers used by a process. */ ++ PTRACE_SETREGS = 13, ++#define PT_SETREGS PTRACE_SETREGS ++ ++ /* Get all floating point registers used by a process. */ ++ PTRACE_GETFPREGS = 14, ++#define PT_GETFPREGS PTRACE_GETFPREGS ++ ++ /* Set all floating point registers used by a process. */ ++ PTRACE_SETFPREGS = 15, ++#define PT_SETFPREGS PTRACE_SETFPREGS ++ + /* Attach to a process that is already running. */ + PTRACE_ATTACH = 16, + #define PT_ATTACH PTRACE_ATTACH +@@ -120,10 +136,56 @@ enum __ptrace_request + PTRACE_DETACH = 17, + #define PT_DETACH PTRACE_DETACH + ++ /* Get all altivec registers used by a process. */ ++ PTRACE_GETVRREGS = 18, ++#define PT_GETVRREGS PTRACE_GETVRREGS ++ ++ /* Set all altivec registers used by a process. */ ++ PTRACE_SETVRREGS = 19, ++#define PT_SETVRREGS PTRACE_SETVRREGS ++ ++ /* Get all SPE registers used by a process. */ ++ PTRACE_GETEVRREGS = 20, ++#define PT_GETEVRREGS PTRACE_GETEVRREGS ++ ++ /* Set all SPE registers used by a process. */ ++ PTRACE_SETEVRREGS = 21, ++#define PT_SETEVRREGS PTRACE_SETEVRREGS ++ ++ /* Same as PTRACE_GETREGS except a 32-bit process will obtain ++ the full 64-bit registers. Implemented by 64-bit kernels only. */ ++ PTRACE_GETREGS64 = 22, ++#define PT_GETREGS64 PTRACE_GETREGS64 ++ ++ /* Same as PTRACE_SETREGS except a 32-bit process will set ++ the full 64-bit registers. Implemented by 64-bit kernels only. */ ++ PTRACE_SETREGS64 = 23, ++#define PT_SETREGS64 PTRACE_SETREGS64 ++ + /* Continue and stop at the next entry to or return from syscall. */ + PTRACE_SYSCALL = 24, + #define PT_SYSCALL PTRACE_SYSCALL + ++ /* Get a debug register of a process. */ ++ PTRACE_GET_DEBUGREG = 25, ++#define PT_GET_DEBUGREG PTRACE_GET_DEBUGREG ++ ++ /* Set a debug register of a process. */ ++ PTRACE_SET_DEBUGREG = 26, ++#define PT_SET_DEBUGREG PTRACE_SET_DEBUGREG ++ ++ /* Get the first 32 VSX registers of a process. */ ++ PTRACE_GETVSRREGS = 27, ++#define PT_GETVSRREGS PTRACE_GETVSRREGS ++ ++ /* Set the first 32 VSX registers of a process. */ ++ PTRACE_SETVSRREGS = 28, ++#define PT_SETVSRREGS PTRACE_SETVSRREGS ++ ++ /* Execute process until next taken branch. */ ++ PTRACE_SINGLEBLOCK = 256, ++#define PT_STEPBLOCK PTRACE_SINGLEBLOCK ++ + /* Set ptrace filter options. */ + PTRACE_SETOPTIONS = 0x4200, + #define PT_SETOPTIONS PTRACE_SETOPTIONS diff --git a/riscv-fmax-fmin-nan.patch b/riscv-fmax-fmin-nan.patch new file mode 100644 index 0000000..95dbfcd --- /dev/null +++ b/riscv-fmax-fmin-nan.patch @@ -0,0 +1,112 @@ +2018-02-22 Andrew Waterman + + [BZ # 22884] + * sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly. + * sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise. + * sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise. + * sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise. + +Index: glibc-2.27/sysdeps/riscv/rvd/s_fmax.c +=================================================================== +--- glibc-2.27.orig/sysdeps/riscv/rvd/s_fmax.c ++++ glibc-2.27/sysdeps/riscv/rvd/s_fmax.c +@@ -17,12 +17,19 @@ + . */ + + #include ++#include + #include + + double + __fmax (double x, double y) + { +- asm ("fmax.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); +- return x; ++ double res; ++ ++ if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) ++ return x + y; ++ else ++ asm ("fmax.d %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); ++ ++ return res; + } + libm_alias_double (__fmax, fmax) +Index: glibc-2.27/sysdeps/riscv/rvd/s_fmin.c +=================================================================== +--- glibc-2.27.orig/sysdeps/riscv/rvd/s_fmin.c ++++ glibc-2.27/sysdeps/riscv/rvd/s_fmin.c +@@ -17,12 +17,19 @@ + . */ + + #include ++#include + #include + + double + __fmin (double x, double y) + { +- asm ("fmin.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); +- return x; ++ double res; ++ ++ if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) ++ return x + y; ++ else ++ asm ("fmin.d %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); ++ ++ return res; + } + libm_alias_double (__fmin, fmin) +Index: glibc-2.27/sysdeps/riscv/rvf/s_fmaxf.c +=================================================================== +--- glibc-2.27.orig/sysdeps/riscv/rvf/s_fmaxf.c ++++ glibc-2.27/sysdeps/riscv/rvf/s_fmaxf.c +@@ -17,12 +17,19 @@ + . */ + + #include ++#include + #include + + float + __fmaxf (float x, float y) + { +- asm ("fmax.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); +- return x; ++ float res; ++ ++ if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) ++ return x + y; ++ else ++ asm ("fmax.s %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); ++ ++ return res; + } + libm_alias_float (__fmax, fmax) +Index: glibc-2.27/sysdeps/riscv/rvf/s_fminf.c +=================================================================== +--- glibc-2.27.orig/sysdeps/riscv/rvf/s_fminf.c ++++ glibc-2.27/sysdeps/riscv/rvf/s_fminf.c +@@ -17,12 +17,19 @@ + . */ + + #include ++#include + #include + + float + __fminf (float x, float y) + { +- asm ("fmin.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); +- return x; ++ float res; ++ ++ if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) ++ return x + y; ++ else ++ asm ("fmin.s %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); ++ ++ return res; + } + libm_alias_float (__fmin, fmin) diff --git a/riscv-tls-init.patch b/riscv-tls-init.patch new file mode 100644 index 0000000..83e8649 --- /dev/null +++ b/riscv-tls-init.patch @@ -0,0 +1,51 @@ +2018-02-22 DJ Delorie + + * sysdeps/riscv/tls-macros.h: Do not initialize $gp. + +Index: glibc-2.27/sysdeps/riscv/tls-macros.h +=================================================================== +--- glibc-2.27.orig/sysdeps/riscv/tls-macros.h ++++ glibc-2.27/sysdeps/riscv/tls-macros.h +@@ -23,19 +23,9 @@ + #include + #include "dl-tls.h" + +-#define LOAD_GP \ +- ".option push\n\t" \ +- ".option norelax\n\t" \ +- "la gp, __global_pointer$\n\t" \ +- ".option pop\n\t" +- +-#define UNLOAD_GP +- + #define TLS_GD(x) \ + ({ void *__result; \ +- asm (LOAD_GP \ +- "la.tls.gd %0, " #x "\n\t" \ +- UNLOAD_GP \ ++ asm ("la.tls.gd %0, " #x "\n\t" \ + : "=r" (__result)); \ + __tls_get_addr (__result); }) + +@@ -43,19 +33,15 @@ + + #define TLS_IE(x) \ + ({ void *__result; \ +- asm (LOAD_GP \ +- "la.tls.ie %0, " #x "\n\t" \ ++ asm ("la.tls.ie %0, " #x "\n\t" \ + "add %0, %0, tp\n\t" \ +- UNLOAD_GP \ + : "=r" (__result)); \ + __result; }) + + #define TLS_LE(x) \ + ({ void *__result; \ +- asm (LOAD_GP \ +- "lui %0, %%tprel_hi(" #x ")\n\t" \ ++ asm ("lui %0, %%tprel_hi(" #x ")\n\t" \ + "add %0, %0, tp, %%tprel_add(" #x ")\n\t" \ + "addi %0, %0, %%tprel_lo(" #x ")\n\t" \ +- UNLOAD_GP \ + : "=r" (__result)); \ + __result; })