public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* Broken cancelable syscalls in librt w/ linuxthreads
@ 2004-08-20 21:45 Andreas Schwab
  2004-08-20 22:25 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-08-20 21:45 UTC (permalink / raw)
  To: libc-hacker

When building with linuxthreads the functions __librt_enable_asynccancel
and __librt_disable_asynccancel are just aliases to the libc variants,
thus part of libc instead of librt.  The ia64 syscall stubs don't expect
that and don't save gp around these calls.  That hasn't been a problem
before, because librt didn't include any cancelable functions that were
implemented as direct syscalls.

Andreas.

2004-08-20  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Save gp
	around CENABLE/CDISABLE calls.

--- linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h.~1.9.~	2003-07-08 12:00:51.000000000 +0200
+++ linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h	2004-08-20 15:03:54.831834009 +0200
@@ -45,13 +45,15 @@ ENTRY (name)								      \
 __GC_##name:								      \
 .Lpseudo_cancel:							      \
      .prologue;								      \
-     .regstk args, 5, args, 0;						      \
+     .regstk args, 6, args, 0;						      \
      .save ar.pfs, loc0;						      \
-     alloc loc0 = ar.pfs, args, 5, args, 0;				      \
+     alloc loc0 = ar.pfs, args, 6, args, 0;				      \
      .save rp, loc1;							      \
-     mov loc1 = rp;;							      \
+     mov loc1 = rp;							      \
+     mov loc5 = gp;;							      \
      .body;								      \
      CENABLE;;								      \
+     mov gp = loc5;							      \
      mov loc2 = r8;							      \
      COPY_ARGS_##args							      \
      mov r15 = SYS_ify(syscall_name);					      \
@@ -60,6 +62,7 @@ __GC_##name:								      \
      mov loc4 = r10;							      \
      mov out0 = loc2;							      \
      CDISABLE;;								      \
+     mov gp = loc5;							      \
      cmp.eq p6,p0=-1,loc4;						      \
 (p6) br.cond.spnt.few __syscall_error_##args;				      \
      mov r8 = loc3;							      \
@@ -76,14 +79,13 @@ __GC_##name:								      \
      .size __syscall_error_##args, 64;					      \
 __syscall_error_##args:							      \
      .prologue;								      \
-     .regstk args, 5, args, 0;						      \
+     .regstk args, 6, args, 0;						      \
      .save ar.pfs, loc0;						      \
      .save rp, loc1;							      \
      .body;								      \
-     mov loc4 = r1;;							      \
      br.call.sptk.many b0 = __errno_location;;				      \
      st4 [r8] = loc3;							      \
-     mov r1 = loc4;							      \
+     mov gp = loc5;							      \
      mov rp = loc1;							      \
      mov r8 = -1;							      \
      mov ar.pfs = loc0

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Broken cancelable syscalls in librt w/ linuxthreads
  2004-08-20 21:45 Broken cancelable syscalls in librt w/ linuxthreads Andreas Schwab
@ 2004-08-20 22:25 ` Jakub Jelinek
  2004-08-22 18:03   ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2004-08-20 22:25 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

On Fri, Aug 20, 2004 at 11:45:35PM +0200, Andreas Schwab wrote:
> When building with linuxthreads the functions __librt_enable_asynccancel
> and __librt_disable_asynccancel are just aliases to the libc variants,
> thus part of libc instead of librt.  The ia64 syscall stubs don't expect
> that and don't save gp around these calls.  That hasn't been a problem
> before, because librt didn't include any cancelable functions that were
> implemented as direct syscalls.

Then it should be done only #ifdef IS_IN_librt and not for libpthread
or libc.

	Jakub

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

* Re: Broken cancelable syscalls in librt w/ linuxthreads
  2004-08-20 22:25 ` Jakub Jelinek
@ 2004-08-22 18:03   ` Andreas Schwab
  2004-08-23  3:32     ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-08-22 18:03 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: libc-hacker

Jakub Jelinek <jakub@redhat.com> writes:

> Then it should be done only #ifdef IS_IN_librt and not for libpthread
> or libc.

Well, for most syscalls the extra insns just replace the existing nops.
But anyway, since its easy to do here's an updated patch.

Andreas.

2004-08-22  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO) [IS_IN_librt]:
	Save gp around CENABLE/CDISABLE calls.

--- linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h	22 Aug 2004 18:57:17 +0200	1.9
+++ linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h	22 Aug 2004 19:27:32 +0200	
@@ -25,6 +25,20 @@
 
 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
 
+# ifdef IS_IN_librt
+#  define PSEUDO_NLOCAL		6
+#  define PSEUDO_SAVE_GP	mov loc5 = gp
+#  define PSEUDO_RESTORE_GP	mov gp = loc5
+#  define PSEUDO_SAVE_GP_1
+#  define PSEUDO_RESTORE_GP_1	mov gp = loc5
+# else
+#  define PSEUDO_NLOCAL		5
+#  define PSEUDO_SAVE_GP
+#  define PSEUDO_RESTORE_GP
+#  define PSEUDO_SAVE_GP_1	mov loc4 = gp;;
+#  define PSEUDO_RESTORE_GP_1	mov gp = loc4
+# endif
+
 # undef PSEUDO
 # define PSEUDO(name, syscall_name, args)				      \
 .text;									      \
@@ -45,13 +59,15 @@ ENTRY (name)								      \
 __GC_##name:								      \
 .Lpseudo_cancel:							      \
      .prologue;								      \
-     .regstk args, 5, args, 0;						      \
+     .regstk args, PSEUDO_NLOCAL, args, 0;				      \
      .save ar.pfs, loc0;						      \
-     alloc loc0 = ar.pfs, args, 5, args, 0;				      \
+     alloc loc0 = ar.pfs, args, PSEUDO_NLOCAL, args, 0;			      \
      .save rp, loc1;							      \
-     mov loc1 = rp;;							      \
+     mov loc1 = rp;							      \
+     PSEUDO_SAVE_GP;;							      \
      .body;								      \
      CENABLE;;								      \
+     PSEUDO_RESTORE_GP;							      \
      mov loc2 = r8;							      \
      COPY_ARGS_##args							      \
      mov r15 = SYS_ify(syscall_name);					      \
@@ -60,6 +76,7 @@ __GC_##name:								      \
      mov loc4 = r10;							      \
      mov out0 = loc2;							      \
      CDISABLE;;								      \
+     PSEUDO_RESTORE_GP;							      \
      cmp.eq p6,p0=-1,loc4;						      \
 (p6) br.cond.spnt.few __syscall_error_##args;				      \
      mov r8 = loc3;							      \
@@ -76,14 +93,14 @@ __GC_##name:								      \
      .size __syscall_error_##args, 64;					      \
 __syscall_error_##args:							      \
      .prologue;								      \
-     .regstk args, 5, args, 0;						      \
+     .regstk args, PSEUDO_NLOCAL, args, 0;				      \
      .save ar.pfs, loc0;						      \
      .save rp, loc1;							      \
      .body;								      \
-     mov loc4 = r1;;							      \
+     PSEUDO_SAVE_GP_1;							      \
      br.call.sptk.many b0 = __errno_location;;				      \
      st4 [r8] = loc3;							      \
-     mov r1 = loc4;							      \
+     PSEUDO_RESTORE_GP_1;						      \
      mov rp = loc1;							      \
      mov r8 = -1;							      \
      mov ar.pfs = loc0

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Broken cancelable syscalls in librt w/ linuxthreads
  2004-08-22 18:03   ` Andreas Schwab
@ 2004-08-23  3:32     ` Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2004-08-23  3:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Jakub Jelinek, libc-hacker

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

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

end of thread, other threads:[~2004-08-23  3:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-20 21:45 Broken cancelable syscalls in librt w/ linuxthreads Andreas Schwab
2004-08-20 22:25 ` Jakub Jelinek
2004-08-22 18:03   ` Andreas Schwab
2004-08-23  3:32     ` Ulrich Drepper

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).