public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 8/8] powerpc: Fix signal handling in backtrace
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
  2017-05-08 15:27 ` [PATCH 7/8] Consolidate Linux writev implementation Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-09 12:11   ` Tulio Magno Quites Machado Filho
  2017-05-08 15:27 ` [PATCH 4/8] Consolidate Linux read syscall Adhemerval Zanella
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

Now with read consolidation which uses SYSCALL_CANCEL macro, a frame
pointer is created in the syscall code and this makes the powerpc
backtrace obtain a bogus entry for the signal handling patch.

It is because it does not setup the correct frame pointer register
(r1) based on the saved value from the kernel sigreturn.  It was not
failing because the syscall frame pointer register was the same one
for the next frame (the function that actually called the syscall).

This patch fixes it by setup the next stack frame using the saved
one by the kernel sigreturn.  It fixes tst-backtrace{5,6} after
the read consolidation patch.

Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.

	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
	void* for argument type and use VDSO_SYMBOL macro.
	(is_sigtramp_address_rt): Likewise.
	(__backtrace): Setup expected frame pointer address for signal
	handling.
	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
	void* for argumetn type and use VSDO_SYMBOL macro.
	(__backtrace): Setup expected frame pointer address for signal
	handling.
---
 ChangeLog                             | 10 ++++++++++
 sysdeps/powerpc/powerpc32/backtrace.c | 17 ++++++++++-------
 sysdeps/powerpc/powerpc64/backtrace.c | 17 ++++++++++-------
 3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc97d16..dcda6c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2016-05-08  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
+	void* for argument type and use VDSO_SYMBOL macro.
+	(is_sigtramp_address_rt): Likewise.
+	(__backtrace): Setup expected frame pointer address for signal
+	handling.
+	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
+	void* for argumetn type and use VSDO_SYMBOL macro.
+	(__backtrace): Setup expected frame pointer address for signal
+	handling.
+
 	* sysdeps/unix/sysv/linux/writev.c: New file.
 
 	* sysdeps/unix/sysv/linux/readv.c: New file.
diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
index b60ac32..3940621 100644
--- a/sysdeps/powerpc/powerpc32/backtrace.c
+++ b/sysdeps/powerpc/powerpc32/backtrace.c
@@ -52,10 +52,10 @@ struct signal_frame_32 {
 };
 
 static inline int
-is_sigtramp_address (unsigned int nip)
+is_sigtramp_address (void *nip)
 {
 #ifdef SHARED
-  if (nip == (unsigned int)__vdso_sigtramp32)
+  if (nip == VDSO_SYMBOL (sigtramp32))
     return 1;
 #endif
   return 0;
@@ -69,10 +69,10 @@ struct rt_signal_frame_32 {
 };
 
 static inline int
-is_sigtramp_address_rt (unsigned int nip)
+is_sigtramp_address_rt (void * nip)
 {
 #ifdef SHARED
-  if (nip == (unsigned int)__vdso_sigtramp_rt32)
+  if (nip == VDSO_SYMBOL (sigtramp_rt32))
     return 1;
 #endif
   return 0;
@@ -100,20 +100,23 @@ __backtrace (void **array, int size)
 
       /* Check if the symbol is the signal trampoline and get the interrupted
        * symbol address from the trampoline saved area.  */
-      if (is_sigtramp_address ((unsigned int)current->return_address))
+      if (is_sigtramp_address (current->return_address))
 	{
 	  struct signal_frame_32 *sigframe =
 	    (struct signal_frame_32*) current;
           gregset = &sigframe->mctx.gregs;
         }
-      else if (is_sigtramp_address_rt ((unsigned int)current->return_address))
+      else if (is_sigtramp_address_rt (current->return_address))
 	{
 	  struct rt_signal_frame_32 *sigframe =
             (struct rt_signal_frame_32*) current;
           gregset = &sigframe->uc.uc_mcontext.uc_regs->gregs;
         }
       if (gregset)
-	array[++count] = (void*)((*gregset)[PT_NIP]);
+	{
+	  array[++count] = (void*)((*gregset)[PT_NIP]);
+	  current = (void*)((*gregset)[PT_R1]);
+	}
     }
 
   /* It's possible the second-last stack frame can't return
diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
index 83b963e..723948d 100644
--- a/sysdeps/powerpc/powerpc64/backtrace.c
+++ b/sysdeps/powerpc/powerpc64/backtrace.c
@@ -16,10 +16,12 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If
    not, see <http://www.gnu.org/licenses/>.  */
 
-#include <execinfo.h>
 #include <stddef.h>
 #include <string.h>
 #include <signal.h>
+#include <stdint.h>
+
+#include <execinfo.h>
 #include <libc-vdso.h>
 
 /* This is the stack layout we see with every stack frame.
@@ -37,7 +39,7 @@
 struct layout
 {
   struct layout *next;
-  long condition_register;
+  long int condition_register;
   void *return_address;
 };
 
@@ -47,16 +49,16 @@ struct layout
    dummy frame to make it look like it has a caller.  */
 struct signal_frame_64 {
 #define SIGNAL_FRAMESIZE 128
-  char            dummy[SIGNAL_FRAMESIZE];
+  char dummy[SIGNAL_FRAMESIZE];
   struct ucontext uc;
   /* We don't care about the rest, since the IP value is at 'uc' field.  */
 };
 
 static inline int
-is_sigtramp_address (unsigned long nip)
+is_sigtramp_address (void *nip)
 {
 #ifdef SHARED
-  if (nip == (unsigned long)__vdso_sigtramp_rt64)
+  if (nip == VDSO_SYMBOL (sigtramp_rt64))
     return 1;
 #endif
   return 0;
@@ -82,10 +84,11 @@ __backtrace (void **array, int size)
 
       /* Check if the symbol is the signal trampoline and get the interrupted
        * symbol address from the trampoline saved area.  */
-      if (is_sigtramp_address ((unsigned long)current->return_address))
+      if (is_sigtramp_address (current->return_address))
         {
 	  struct signal_frame_64 *sigframe = (struct signal_frame_64*) current;
-          array[++count] = (void*)sigframe->uc.uc_mcontext.gp_regs[PT_NIP];
+          array[++count] = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_NIP];
+	  current = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_R1];
 	}
     }
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 6/8] Consolidate Linux readv implementation
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2017-05-08 15:27 ` [PATCH 5/8] Consolidate Linux write syscall Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:33   ` Andreas Schwab
  2017-05-11 14:48 ` [PATCH 1/8] Consolidate Linux close syscall generation Andreas Schwab
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the readv Linux syscall implementation on
sysdeps/unix/sysv/linux/readv.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/readv.c: New file.
---
 ChangeLog                       |  2 ++
 sysdeps/unix/sysv/linux/readv.c | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/readv.c

diff --git a/sysdeps/unix/sysv/linux/readv.c b/sysdeps/unix/sysv/linux/readv.c
new file mode 100644
index 0000000..142a0a9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/readv.c
@@ -0,0 +1,27 @@
+/* Linux implementation for readv syscall.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+
+ssize_t
+__readv (int fd, const struct iovec *iov, int iovcnt)
+{
+  return SYSCALL_CANCEL (readv, fd, iov, iovcnt);
+}
+weak_alias (__readv, readv)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 7/8] Consolidate Linux writev implementation
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:33   ` Andreas Schwab
  2017-05-08 15:27 ` [PATCH 8/8] powerpc: Fix signal handling in backtrace Adhemerval Zanella
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the writev Linux syscall implementation on
sysdeps/unix/sysv/linux/writev.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/writev.c: New file.
---
 ChangeLog                        |  2 ++
 sysdeps/unix/sysv/linux/writev.c | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/writev.c

diff --git a/sysdeps/unix/sysv/linux/writev.c b/sysdeps/unix/sysv/linux/writev.c
new file mode 100644
index 0000000..1b56cbb
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/writev.c
@@ -0,0 +1,27 @@
+/* Linux writev syscall implementation.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+
+ssize_t
+__writev (int fd, const struct iovec *iov, int iovcnt)
+{
+  return SYSCALL_CANCEL (writev, fd, iov, iovcnt);
+}
+weak_alias (__writev, writev)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 4/8] Consolidate Linux read syscall
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
  2017-05-08 15:27 ` [PATCH 7/8] Consolidate Linux writev implementation Adhemerval Zanella
  2017-05-08 15:27 ` [PATCH 8/8] powerpc: Fix signal handling in backtrace Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:17   ` Andreas Schwab
  2017-05-08 15:27 ` [PATCH 3/8] Consolidate Linux creat implementation Adhemerval Zanella
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the read Linux syscall implementation on
sysdeps/unix/sysv/linux/read.c.  This leads to a different frame
pointer creation on some architectures:

	* It fixes BZ#21428 on aarch64, since now the returned
	address for the read syscall can be correctly found out
	by backtrace_symbols.

	* It makes tst-backtrace{5,6} fails on powerpc due an
	issue on its custom backtrace implementation.  It is
	fixed on last patch from this set.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	[BZ #21428]
	* include/unistd.h (read): Add hidden proto.
	* io/Makefile (CFLAGS-read.c): New rule.
	* nptl/Makefile (CFLAGS-read.c): New rule.
	* sysdeps/unix/sysv/linux/read.c: New file.
---
 ChangeLog                      |  4 ++++
 include/unistd.h               |  1 +
 io/Makefile                    |  1 +
 nptl/Makefile                  |  1 +
 sysdeps/unix/sysv/linux/read.c | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/read.c

diff --git a/include/unistd.h b/include/unistd.h
index f36759b..01556d3 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -53,6 +53,7 @@ extern ssize_t __libc_pwrite64 (int __fd, const void *__buf, size_t __n,
 				__off64_t __offset) attribute_hidden;
 extern ssize_t __libc_read (int __fd, void *__buf, size_t __n);
 libc_hidden_proto (__libc_read)
+libc_hidden_proto (read)
 extern ssize_t __libc_write (int __fd, const void *__buf, size_t __n);
 libc_hidden_proto (__libc_write)
 extern int __pipe (int __pipedes[2]);
diff --git a/io/Makefile b/io/Makefile
index 8b1c250..db14c0d 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -100,6 +100,7 @@ CFLAGS-posix_fallocate64.c = -fexceptions
 CFLAGS-fallocate.c = -fexceptions
 CFLAGS-fallocate64.c = -fexceptions
 CFLAGS-sync_file_range.c = -fexceptions
+CFLAGS-read.c = -fexceptions
 
 CFLAGS-test-stat.c = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
 CFLAGS-test-lfs.c = -D_LARGEFILE64_SOURCE
diff --git a/nptl/Makefile b/nptl/Makefile
index 8251ac4..faabd45 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -214,6 +214,7 @@ CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables
 
 CFLAGS-pt-system.c = -fexceptions
 
diff --git a/sysdeps/unix/sysv/linux/read.c b/sysdeps/unix/sysv/linux/read.c
new file mode 100644
index 0000000..2a02c1b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/read.c
@@ -0,0 +1,33 @@
+/* Linux read syscall implementation.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+
+/* Read NBYTES into BUF from FD.  Return the number read or -1.  */
+ssize_t
+__libc_read (int fd, void *buf, size_t nbytes)
+{
+  return SYSCALL_CANCEL (read, fd, buf, nbytes);
+}
+libc_hidden_def (__libc_read)
+
+libc_hidden_def (__read)
+weak_alias (__libc_read, __read)
+libc_hidden_def (read)
+weak_alias (__libc_read, read)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2/8] Consolidate Linux open implementation
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2017-05-08 15:27 ` [PATCH 3/8] Consolidate Linux creat implementation Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:06   ` Andreas Schwab
  2017-05-15 12:47   ` Tulio Magno Quites Machado Filho
  2017-05-08 15:27 ` [PATCH 5/8] Consolidate Linux write syscall Adhemerval Zanella
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the open Linux syscall implementation on
sysdeps/unix/sysv/linux/open{64}.c.  The changes are:

  1. Remove open{64} from auto-generation syscalls.list.
  2. Add a new open{64}.c implementation.  For architectures that
     define __OFF_T_MATCHES_OFF64_T the default open64 will create
     alias to required open symbols.
  3. Use __NR_open where possible, otherwise use __NR_openat.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/generic/open.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/open64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/open64.c: Likewise.
	* sysdeps/unix/sysv/linux/open.c: New file.
	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Use O_LARGEFILE
	only for __OFF_T_MATCHES_OFF64_T and add alias to open if the case.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove open
	from auto-generated list.
---
 ChangeLog                                         |  9 +++++
 sysdeps/unix/sysv/linux/generic/open64.c          | 44 -----------------------
 sysdeps/unix/sysv/linux/{generic => }/open.c      | 29 ++++++---------
 sysdeps/unix/sysv/linux/open64.c                  | 28 ++++++++++++---
 sysdeps/unix/sysv/linux/wordsize-64/open64.c      |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list |  1 -
 6 files changed, 44 insertions(+), 68 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/generic/open64.c
 rename sysdeps/unix/sysv/linux/{generic => }/open.c (78%)
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/open64.c

diff --git a/sysdeps/unix/sysv/linux/generic/open64.c b/sysdeps/unix/sysv/linux/generic/open64.c
deleted file mode 100644
index 88312a1..0000000
--- a/sysdeps/unix/sysv/linux/generic/open64.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <sysdep-cancel.h>
-
-/* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
-   a third argument is the file protection.  */
-int
-__libc_open64 (const char *file, int oflag, ...)
-{
-  int mode = 0;
-
-  if (__OPEN_NEEDS_MODE (oflag))
-    {
-      va_list arg;
-      va_start (arg, oflag);
-      mode = va_arg (arg, int);
-      va_end (arg);
-    }
-
-  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, mode);
-}
-weak_alias (__libc_open64, __open64)
-libc_hidden_weak (__open64)
-weak_alias (__libc_open64, open64)
diff --git a/sysdeps/unix/sysv/linux/generic/open.c b/sysdeps/unix/sysv/linux/open.c
similarity index 78%
rename from sysdeps/unix/sysv/linux/generic/open.c
rename to sysdeps/unix/sysv/linux/open.c
index 10cdbe0..9321bd4 100644
--- a/sysdeps/unix/sysv/linux/generic/open.c
+++ b/sysdeps/unix/sysv/linux/open.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
@@ -16,12 +16,15 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <stdarg.h>
-#include <stdio.h>
+
 #include <sysdep-cancel.h>
 
+#ifndef __OFF_T_MATCHES_OFF64_T
+
 /* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
    a third argument is the file protection.  */
 int
@@ -37,7 +40,11 @@ __libc_open (const char *file, int oflag, ...)
       va_end (arg);
     }
 
+# ifdef __NR_open
+  return SYSCALL_CANCEL (open, file, oflag, mode);
+# else
   return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag, mode);
+# endif
 }
 libc_hidden_def (__libc_open)
 
@@ -45,18 +52,4 @@ weak_alias (__libc_open, __open)
 libc_hidden_weak (__open)
 weak_alias (__libc_open, open)
 
-int
-__open_nocancel (const char *file, int oflag, ...)
-{
-  int mode = 0;
-
-  if (__OPEN_NEEDS_MODE (oflag))
-    {
-      va_list arg;
-      va_start (arg, oflag);
-      mode = va_arg (arg, int);
-      va_end (arg);
-    }
-
-  return INLINE_SYSCALL (openat, 4, AT_FDCWD, file, oflag, mode);
-}
+#endif
diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c
index 5e209ee..6ad8f77 100644
--- a/sysdeps/unix/sysv/linux/open64.c
+++ b/sysdeps/unix/sysv/linux/open64.c
@@ -15,10 +15,11 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <stdarg.h>
-#include <stdio.h>
+
 #include <sysdep-cancel.h>
 
 /* Open FILE with access OFLAG.  If O_CREAT or O_TMPFILE is in OFLAG,
@@ -36,8 +37,27 @@ __libc_open64 (const char *file, int oflag, ...)
       va_end (arg);
     }
 
-  return SYSCALL_CANCEL (open, file, oflag | O_LARGEFILE, mode);
+#ifdef __OFF_T_MATCHES_OFF64_T
+# define EXTRA_OPEN_FLAGS 0
+#else
+# define EXTRA_OPEN_FLAGS O_LARGEFILE
+#endif
+
+#ifdef __NR_open
+  return SYSCALL_CANCEL (open, file, oflag | EXTRA_OPEN_FLAGS, mode);
+#else
+  return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
+			 mode);
+#endif
 }
-weak_alias (__libc_open64, __open64)
+
+strong_alias (__libc_open64, __open64)
 libc_hidden_weak (__open64)
 weak_alias (__libc_open64, open64)
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (__libc_open64, __libc_open)
+strong_alias (__libc_open64, __open)
+libc_hidden_weak (__open)
+weak_alias (__libc_open64, open)
+#endif
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/open64.c b/sysdeps/unix/sysv/linux/wordsize-64/open64.c
deleted file mode 100644
index 0abe30e..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/open64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined in open syscall.  */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 0c60647..6549ed8 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -6,7 +6,6 @@ readahead	-	readahead	i:iii	__readahead	readahead
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
 sync_file_range	-	sync_file_range	Ci:iiii	sync_file_range
 creat		-	creat		Ci:si	creat		creat64
-open		-	open		Ci:siv	__libc_open	__open open __open64 open64
 prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
 
 fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/8] Consolidate Linux close syscall generation
@ 2017-05-08 15:27 Adhemerval Zanella
  2017-05-08 15:27 ` [PATCH 7/8] Consolidate Linux writev implementation Adhemerval Zanella
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the close Linux syscall generation on
sysdeps/unix/sysv/linux/close.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* nptl/Makefile (CFLAGS-close.c): New flag.
	* sysdeps/unix/sysv/linux/close.c: New file.
---
 ChangeLog                       |  5 +++++
 nptl/Makefile                   |  1 +
 sysdeps/unix/sysv/linux/close.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/close.c

diff --git a/nptl/Makefile b/nptl/Makefile
index 6d48c0c..8251ac4 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -213,6 +213,7 @@ CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
 
 CFLAGS-pt-system.c = -fexceptions
 
diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c
new file mode 100644
index 0000000..1ac71ce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/close.c
@@ -0,0 +1,30 @@
+/* Linux close syscall implementation.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+
+/* Close the file descriptor FD.  */
+int
+__close (int fd)
+{
+  return SYSCALL_CANCEL (close, fd);
+}
+libc_hidden_def (__close)
+strong_alias (__close, __libc_close)
+weak_alias (__close, close)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 5/8] Consolidate Linux write syscall
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2017-05-08 15:27 ` [PATCH 2/8] Consolidate Linux open implementation Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:21   ` Andreas Schwab
  2017-05-08 15:27 ` [PATCH 6/8] Consolidate Linux readv implementation Adhemerval Zanella
  2017-05-11 14:48 ` [PATCH 1/8] Consolidate Linux close syscall generation Andreas Schwab
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the write Linux syscall implementation on
sysdeps/unix/sysv/linux/write.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* io/Makefile (CFLAGS-write.c): New rule.
	* nptl/Makefile (CFLAGS-write.c): Likewise.
	* sysdeps/unix/sysv/linux/write.c: New file.
---
 ChangeLog                       |  4 ++++
 include/unistd.h                |  1 +
 io/Makefile                     |  1 +
 nptl/Makefile                   |  1 +
 sysdeps/unix/sysv/linux/write.c | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/write.c

diff --git a/include/unistd.h b/include/unistd.h
index 01556d3..0cdf06e 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -56,6 +56,7 @@ libc_hidden_proto (__libc_read)
 libc_hidden_proto (read)
 extern ssize_t __libc_write (int __fd, const void *__buf, size_t __n);
 libc_hidden_proto (__libc_write)
+libc_hidden_proto (write)
 extern int __pipe (int __pipedes[2]);
 libc_hidden_proto (__pipe)
 extern int __pipe2 (int __pipedes[2], int __flags);
diff --git a/io/Makefile b/io/Makefile
index db14c0d..16365e5 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -101,6 +101,7 @@ CFLAGS-fallocate.c = -fexceptions
 CFLAGS-fallocate64.c = -fexceptions
 CFLAGS-sync_file_range.c = -fexceptions
 CFLAGS-read.c = -fexceptions
+CFLAGS-write.c = -fexceptions
 
 CFLAGS-test-stat.c = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
 CFLAGS-test-lfs.c = -D_LARGEFILE64_SOURCE
diff --git a/nptl/Makefile b/nptl/Makefile
index faabd45..5b34b5c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -215,6 +215,7 @@ CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-write.c = -fexceptions -fasynchronous-unwind-tables
 
 CFLAGS-pt-system.c = -fexceptions
 
diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c
new file mode 100644
index 0000000..d495145
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/write.c
@@ -0,0 +1,33 @@
+/* Linux write syscall implementation.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+
+/* Write NBYTES of BUF to FD.  Return the number written, or -1.  */
+ssize_t
+__libc_write (int fd, const void *buf, size_t nbytes)
+{
+  return SYSCALL_CANCEL (write, fd, buf, nbytes);
+}
+libc_hidden_def (__libc_write)
+
+weak_alias (__libc_write, __write)
+libc_hidden_weak (__write)
+weak_alias (__libc_write, write)
+libc_hidden_weak (write)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 3/8] Consolidate Linux creat implementation
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2017-05-08 15:27 ` [PATCH 4/8] Consolidate Linux read syscall Adhemerval Zanella
@ 2017-05-08 15:27 ` Adhemerval Zanella
  2017-05-11 15:16   ` Andreas Schwab
  2017-05-08 15:27 ` [PATCH 2/8] Consolidate Linux open implementation Adhemerval Zanella
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-08 15:27 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the creat Linux syscall implementation on
sysdeps/unix/sysv/linux/creat{64}.c.  The changes are:

  1. Remove creat{64} from auto-generation syscalls.list.
  2. Add a new creat{64}.c implementation.  For architectures that
     define __OFF_T_MATCHES_OFF64_T the default creat64 will create
     alias to required creat symbols.
  3. Use __NR_creat where possible, otherwise use internal open{64}
     call with expected flags.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* io/Makefile (CFLAGS-creat.c): New rule.
	(CFLAGS-creat64.c): Likewise.
	* sysdeps/unix/sysv/linux/alpha/creat.c: Remove file.
	* sysdeps/unix/sysv/linux/generic/creat.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/creat64.c: Likewise.
	* sysdeps/unix/sysv/linux/creat.c: New file.
	* sysdeps/unix/sysv/linux/creat64.c: Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list: Remove create from
	auto-generated list.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
---
 ChangeLog                                         | 11 +++++++
 io/Makefile                                       |  2 ++
 sysdeps/unix/sysv/linux/alpha/creat.c             |  8 -----
 sysdeps/unix/sysv/linux/{generic => }/creat.c     | 17 ++++++-----
 sysdeps/unix/sysv/linux/creat64.c                 | 37 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/syscalls.list             |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/creat64.c     |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list |  1 -
 8 files changed, 60 insertions(+), 18 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/creat.c
 rename sysdeps/unix/sysv/linux/{generic => }/creat.c (77%)
 create mode 100644 sysdeps/unix/sysv/linux/creat64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/creat64.c

diff --git a/io/Makefile b/io/Makefile
index 95e04b2..8b1c250 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -80,6 +80,8 @@ include ../Rules
 
 CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-creat64.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/alpha/creat.c b/sysdeps/unix/sysv/linux/alpha/creat.c
deleted file mode 100644
index 7a5afed..0000000
--- a/sysdeps/unix/sysv/linux/alpha/creat.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list defines creat and
-   creat64 for most linux targets, but on alpha creat is not a syscall.
-   If we do nothing, we'll wind up with creat64 being undefined, because
-   the syscalls.list assumes the creat->creat64 alias was created.  We
-   could have overridden that with a create64.c, but we might as well do
-   the right thing and set up creat64 as an alias.  */
-#include <io/creat.c>
-weak_alias(creat, creat64)
diff --git a/sysdeps/unix/sysv/linux/generic/creat.c b/sysdeps/unix/sysv/linux/creat.c
similarity index 77%
rename from sysdeps/unix/sysv/linux/generic/creat.c
rename to sysdeps/unix/sysv/linux/creat.c
index 34cb210..31e0248 100644
--- a/sysdeps/unix/sysv/linux/generic/creat.c
+++ b/sysdeps/unix/sysv/linux/creat.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+/* Linux default implementation for creat.
+   Copyright (C) 2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -18,20 +18,23 @@
 
 #include <fcntl.h>
 #include <sys/types.h>
+
 #include <sysdep-cancel.h>
 
-#undef	creat
+#ifndef __OFF_T_MATCHES_OFF64_T
 
 /* Create FILE with protections MODE.  */
 int
-creat (const char *file, mode_t mode)
+__creat (const char *file, mode_t mode)
 {
+# ifdef __NR_creat
+  return SYSCALL_CANCEL (creat, file, mode);
+# else
   return __open (file, O_WRONLY | O_CREAT | O_TRUNC, mode);
+# endif
 }
+weak_alias (__creat, creat)
 
-/* __open handles cancellation.  */
 LIBC_CANCEL_HANDLED ();
 
-#if __WORDSIZE == 64
-weak_alias (creat, creat64)
 #endif
diff --git a/sysdeps/unix/sysv/linux/creat64.c b/sysdeps/unix/sysv/linux/creat64.c
new file mode 100644
index 0000000..5241085
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/creat64.c
@@ -0,0 +1,37 @@
+/* Linux default implementation for LFS creat.
+   Copyright (C) 2016 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sysdep-cancel.h>
+
+/* Create FILE with protections MODE.  */
+int
+__creat64 (const char *file, mode_t mode)
+{
+  /* We need to pass O_LARGEFILE.  */
+  return __open64 (file, O_WRONLY | O_CREAT | O_TRUNC, mode);
+}
+weak_alias (__creat64, creat64)
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (__creat64, __creat)
+weak_alias (__creat64, creat)
+#endif
+
+LIBC_CANCEL_HANDLED ();
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 1a10903..f4abf3e 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -6,7 +6,6 @@ bdflush		EXTRA	bdflush		i:ii	__compat_bdflush	bdflush@GLIBC_2.0:GLIBC_2.23
 capget		EXTRA	capget		i:pp	capget
 capset		EXTRA	capset		i:pp	capset
 clock_adjtime	EXTRA	clock_adjtime	i:ip	clock_adjtime
-creat		-	creat		Ci:si	creat
 create_module	EXTRA	create_module	3	__compat_create_module	create_module@GLIBC_2.0:GLIBC_2.23
 delete_module	EXTRA	delete_module	3	delete_module
 epoll_create	EXTRA	epoll_create	i:i	epoll_create
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/creat64.c b/sysdeps/unix/sysv/linux/wordsize-64/creat64.c
deleted file mode 100644
index c106e2b..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/creat64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Defined as alias for the syscall.  */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 6549ed8..5c78677 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -5,7 +5,6 @@ statfs		-	statfs		i:sp	__statfs	statfs statfs64
 readahead	-	readahead	i:iii	__readahead	readahead
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
 sync_file_range	-	sync_file_range	Ci:iiii	sync_file_range
-creat		-	creat		Ci:si	creat		creat64
 prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
 
 fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
-- 
2.7.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 8/8] powerpc: Fix signal handling in backtrace
  2017-05-08 15:27 ` [PATCH 8/8] powerpc: Fix signal handling in backtrace Adhemerval Zanella
@ 2017-05-09 12:11   ` Tulio Magno Quites Machado Filho
  2017-05-09 13:13     ` Adhemerval Zanella
  0 siblings, 1 reply; 21+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2017-05-09 12:11 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> Now with read consolidation which uses SYSCALL_CANCEL macro, a frame
> pointer is created in the syscall code and this makes the powerpc
> backtrace obtain a bogus entry for the signal handling patch.
>
> It is because it does not setup the correct frame pointer register
> (r1) based on the saved value from the kernel sigreturn.  It was not
> failing because the syscall frame pointer register was the same one
> for the next frame (the function that actually called the syscall).
>
> This patch fixes it by setup the next stack frame using the saved
> one by the kernel sigreturn.  It fixes tst-backtrace{5,6} after
> the read consolidation patch.
>
> Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.
>
> 	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
> 	void* for argument type and use VDSO_SYMBOL macro.
> 	(is_sigtramp_address_rt): Likewise.
> 	(__backtrace): Setup expected frame pointer address for signal
> 	handling.
> 	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use

The files are duplicated in the ChangeLog.

Looks good to me with that fix as soon as patch #4 is integrated.

Thanks!

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 8/8] powerpc: Fix signal handling in backtrace
  2017-05-09 12:11   ` Tulio Magno Quites Machado Filho
@ 2017-05-09 13:13     ` Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-09 13:13 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho, libc-alpha



On 09/05/2017 09:11, Tulio Magno Quites Machado Filho wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> 
>> Now with read consolidation which uses SYSCALL_CANCEL macro, a frame
>> pointer is created in the syscall code and this makes the powerpc
>> backtrace obtain a bogus entry for the signal handling patch.
>>
>> It is because it does not setup the correct frame pointer register
>> (r1) based on the saved value from the kernel sigreturn.  It was not
>> failing because the syscall frame pointer register was the same one
>> for the next frame (the function that actually called the syscall).
>>
>> This patch fixes it by setup the next stack frame using the saved
>> one by the kernel sigreturn.  It fixes tst-backtrace{5,6} after
>> the read consolidation patch.
>>
>> Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.
>>
>> 	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
>> 	void* for argument type and use VDSO_SYMBOL macro.
>> 	(is_sigtramp_address_rt): Likewise.
>> 	(__backtrace): Setup expected frame pointer address for signal
>> 	handling.
>> 	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address): Use
> 
> The files are duplicated in the ChangeLog.
> 
> Looks good to me with that fix as soon as patch #4 is integrated.
> 
> Thanks!
> 

Second item should be sysdeps/powerpc/powerpc64/backtrace.c, I will fix.
Thanks.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/8] Consolidate Linux close syscall generation
  2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2017-05-08 15:27 ` [PATCH 6/8] Consolidate Linux readv implementation Adhemerval Zanella
@ 2017-05-11 14:48 ` Andreas Schwab
  7 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 14:48 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* nptl/Makefile (CFLAGS-close.c): New flag.
> 	* sysdeps/unix/sysv/linux/close.c: New file.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/8] Consolidate Linux open implementation
  2017-05-08 15:27 ` [PATCH 2/8] Consolidate Linux open implementation Adhemerval Zanella
@ 2017-05-11 15:06   ` Andreas Schwab
  2017-05-11 15:20     ` Adhemerval Zanella
  2017-05-15 12:47   ` Tulio Magno Quites Machado Filho
  1 sibling, 1 reply; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:06 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> This patch consolidates the open Linux syscall implementation on
> sysdeps/unix/sysv/linux/open{64}.c.  The changes are:
>
>   1. Remove open{64} from auto-generation syscalls.list.
>   2. Add a new open{64}.c implementation.  For architectures that
>      define __OFF_T_MATCHES_OFF64_T the default open64 will create
>      alias to required open symbols.
>   3. Use __NR_open where possible, otherwise use __NR_openat.

Perhaps we should use __NR_openat unconditionally?  (Even 2.6.32 already
had it.)

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/8] Consolidate Linux creat implementation
  2017-05-08 15:27 ` [PATCH 3/8] Consolidate Linux creat implementation Adhemerval Zanella
@ 2017-05-11 15:16   ` Andreas Schwab
  2017-05-11 15:21     ` Adhemerval Zanella
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:16 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

>   1. Remove creat{64} from auto-generation syscalls.list.
>   2. Add a new creat{64}.c implementation.  For architectures that
>      define __OFF_T_MATCHES_OFF64_T the default creat64 will create
>      alias to required creat symbols.

Previously, 64-bit archs that have __NR_creat used it for creat64, now
it is routed through open64.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/8] Consolidate Linux read syscall
  2017-05-08 15:27 ` [PATCH 4/8] Consolidate Linux read syscall Adhemerval Zanella
@ 2017-05-11 15:17   ` Andreas Schwab
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:17 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	[BZ #21428]
> 	* include/unistd.h (read): Add hidden proto.
> 	* io/Makefile (CFLAGS-read.c): New rule.
> 	* nptl/Makefile (CFLAGS-read.c): New rule.

s/New rule/Define/

> 	* sysdeps/unix/sysv/linux/read.c: New file.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/8] Consolidate Linux open implementation
  2017-05-11 15:06   ` Andreas Schwab
@ 2017-05-11 15:20     ` Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-11 15:20 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha



On 11/05/2017 12:06, Andreas Schwab wrote:
> On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>> This patch consolidates the open Linux syscall implementation on
>> sysdeps/unix/sysv/linux/open{64}.c.  The changes are:
>>
>>   1. Remove open{64} from auto-generation syscalls.list.
>>   2. Add a new open{64}.c implementation.  For architectures that
>>      define __OFF_T_MATCHES_OFF64_T the default open64 will create
>>      alias to required open symbols.
>>   3. Use __NR_open where possible, otherwise use __NR_openat.
> 
> Perhaps we should use __NR_openat unconditionally?  (Even 2.6.32 already
> had it.)
> 
> Andreas.
> 

I would prefer also, although using __NR_open is a marginal optimization 
(which I do not think it would mater).  I will change it.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] Consolidate Linux write syscall
  2017-05-08 15:27 ` [PATCH 5/8] Consolidate Linux write syscall Adhemerval Zanella
@ 2017-05-11 15:21   ` Andreas Schwab
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:21 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* io/Makefile (CFLAGS-write.c): New rule.

s/New rule/Define/

> 	* nptl/Makefile (CFLAGS-write.c): Likewise.
> 	* sysdeps/unix/sysv/linux/write.c: New file.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/8] Consolidate Linux creat implementation
  2017-05-11 15:16   ` Andreas Schwab
@ 2017-05-11 15:21     ` Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-11 15:21 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha



On 11/05/2017 12:16, Andreas Schwab wrote:
> On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>>   1. Remove creat{64} from auto-generation syscalls.list.
>>   2. Add a new creat{64}.c implementation.  For architectures that
>>      define __OFF_T_MATCHES_OFF64_T the default creat64 will create
>>      alias to required creat symbols.
> 
> Previously, 64-bit archs that have __NR_creat used it for creat64, now
> it is routed through open64.
> 
> Andreas.
> 

I do not have strong opinion here, I can use the same login on creat.c
as well.  I will change it.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/8] Consolidate Linux readv implementation
  2017-05-08 15:27 ` [PATCH 6/8] Consolidate Linux readv implementation Adhemerval Zanella
@ 2017-05-11 15:33   ` Andreas Schwab
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:33 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* sysdeps/unix/sysv/linux/readv.c: New file.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 7/8] Consolidate Linux writev implementation
  2017-05-08 15:27 ` [PATCH 7/8] Consolidate Linux writev implementation Adhemerval Zanella
@ 2017-05-11 15:33   ` Andreas Schwab
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2017-05-11 15:33 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mai 08 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* sysdeps/unix/sysv/linux/writev.c: New file.

Ok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/8] Consolidate Linux open implementation
  2017-05-08 15:27 ` [PATCH 2/8] Consolidate Linux open implementation Adhemerval Zanella
  2017-05-11 15:06   ` Andreas Schwab
@ 2017-05-15 12:47   ` Tulio Magno Quites Machado Filho
  2017-05-15 13:01     ` Adhemerval Zanella
  1 sibling, 1 reply; 21+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2017-05-15 12:47 UTC (permalink / raw)
  To: libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> This patch consolidates the open Linux syscall implementation on
> sysdeps/unix/sysv/linux/open{64}.c.  The changes are:
>
>   1. Remove open{64} from auto-generation syscalls.list.
>   2. Add a new open{64}.c implementation.  For architectures that
>      define __OFF_T_MATCHES_OFF64_T the default open64 will create
>      alias to required open symbols.
>   3. Use __NR_open where possible, otherwise use __NR_openat.
>
> Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
> arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
>
> 	* sysdeps/unix/sysv/linux/generic/open.c: Remove file.
> 	* sysdeps/unix/sysv/linux/generic/open64.c: Likewise.
> 	* sysdeps/unix/sysv/linux/wordsize-64/open64.c: Likewise.
> 	* sysdeps/unix/sysv/linux/open.c: New file.
> 	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Use O_LARGEFILE
> 	only for __OFF_T_MATCHES_OFF64_T and add alias to open if the case.
> 	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove open
> 	from auto-generated list.

For the record: there was a build error in our POWER8 BuildSlave right after
this patch was merged [1].

I was not able to reproduce this error on my servers and I suspect it might
be related to issues in our BuildBot setup which may still be leaving
old files before starting a new build.

This patch is not related to the failures on build 464 on the same builder.

[1] http://144.217.14.79/builders/glibc-power8-linux/builds/463

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/8] Consolidate Linux open implementation
  2017-05-15 12:47   ` Tulio Magno Quites Machado Filho
@ 2017-05-15 13:01     ` Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-05-15 13:01 UTC (permalink / raw)
  To: libc-alpha



On 15/05/2017 09:47, Tulio Magno Quites Machado Filho wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> 
>> This patch consolidates the open Linux syscall implementation on
>> sysdeps/unix/sysv/linux/open{64}.c.  The changes are:
>>
>>   1. Remove open{64} from auto-generation syscalls.list.
>>   2. Add a new open{64}.c implementation.  For architectures that
>>      define __OFF_T_MATCHES_OFF64_T the default open64 will create
>>      alias to required open symbols.
>>   3. Use __NR_open where possible, otherwise use __NR_openat.
>>
>> Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
>> arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
>>
>> 	* sysdeps/unix/sysv/linux/generic/open.c: Remove file.
>> 	* sysdeps/unix/sysv/linux/generic/open64.c: Likewise.
>> 	* sysdeps/unix/sysv/linux/wordsize-64/open64.c: Likewise.
>> 	* sysdeps/unix/sysv/linux/open.c: New file.
>> 	* sysdeps/unix/sysv/linux/open64.c (__libc_open64): Use O_LARGEFILE
>> 	only for __OFF_T_MATCHES_OFF64_T and add alias to open if the case.
>> 	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove open
>> 	from auto-generated list.
> 
> For the record: there was a build error in our POWER8 BuildSlave right after
> this patch was merged [1].
> 
> I was not able to reproduce this error on my servers and I suspect it might
> be related to issues in our BuildBot setup which may still be leaving
> old files before starting a new build.
> 
> This patch is not related to the failures on build 464 on the same builder.
> 
> [1] http://144.217.14.79/builders/glibc-power8-linux/builds/463
> 

It is unexpected because I did checked natively on powerpc64le-linux-gnu
(power8) and also on cross-compiling using build-many-glibc.py.

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-05-15 13:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 15:27 [PATCH 1/8] Consolidate Linux close syscall generation Adhemerval Zanella
2017-05-08 15:27 ` [PATCH 7/8] Consolidate Linux writev implementation Adhemerval Zanella
2017-05-11 15:33   ` Andreas Schwab
2017-05-08 15:27 ` [PATCH 8/8] powerpc: Fix signal handling in backtrace Adhemerval Zanella
2017-05-09 12:11   ` Tulio Magno Quites Machado Filho
2017-05-09 13:13     ` Adhemerval Zanella
2017-05-08 15:27 ` [PATCH 4/8] Consolidate Linux read syscall Adhemerval Zanella
2017-05-11 15:17   ` Andreas Schwab
2017-05-08 15:27 ` [PATCH 3/8] Consolidate Linux creat implementation Adhemerval Zanella
2017-05-11 15:16   ` Andreas Schwab
2017-05-11 15:21     ` Adhemerval Zanella
2017-05-08 15:27 ` [PATCH 2/8] Consolidate Linux open implementation Adhemerval Zanella
2017-05-11 15:06   ` Andreas Schwab
2017-05-11 15:20     ` Adhemerval Zanella
2017-05-15 12:47   ` Tulio Magno Quites Machado Filho
2017-05-15 13:01     ` Adhemerval Zanella
2017-05-08 15:27 ` [PATCH 5/8] Consolidate Linux write syscall Adhemerval Zanella
2017-05-11 15:21   ` Andreas Schwab
2017-05-08 15:27 ` [PATCH 6/8] Consolidate Linux readv implementation Adhemerval Zanella
2017-05-11 15:33   ` Andreas Schwab
2017-05-11 14:48 ` [PATCH 1/8] Consolidate Linux close syscall generation Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).