[PATCH] get[gpu]id.2, pipe.2, syscall.2: describe 2nd return value peculiarity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some architectures (ab)use second return value register for additional
return value in some system calls. Let's describe this.

Signed-off-by: Eugene Syromiatnikov <esyr@xxxxxxxxxx>
---
 man2/getgid.2  | 19 +++++++++++++++++
 man2/getpid.2  | 19 +++++++++++++++++
 man2/getuid.2  | 19 +++++++++++++++++
 man2/pipe.2    | 26 +++++++++++++++++++++++
 man2/syscall.2 | 65 ++++++++++++++++++++++++++++++++++------------------------
 5 files changed, 121 insertions(+), 27 deletions(-)

diff --git a/man2/getgid.2 b/man2/getgid.2
index ba8f376..c3fe4aa 100644
--- a/man2/getgid.2
+++ b/man2/getgid.2
@@ -59,6 +59,25 @@ The glibc
 and
 .BR getegid ()
 wrapper functions transparently deal with the variations across kernel versions.
+.PP
+On Alpha, instead of pair of
+.BR getgid "() and " getegid ()
+system calls, single
+.BR getxgid ()
+system call is provided, which returns a pair of real and effective GIDs.
+The glibc
+.BR getgid ()
+and
+.BR getegid ()
+wrapper functions transparently deal with this.
+See
+.BR syscall (2)
+for details regarding register mapping.
+Other examples of such peculiarity are Alpha-specific
+.BR getxpid "(2) and " getxuid (2),
+along with
+.BR pipe (2)
+on several architectures.
 .SH SEE ALSO
 .BR getresgid (2),
 .BR setgid (2),
diff --git a/man2/getpid.2 b/man2/getpid.2
index cddde07..b317ece 100644
--- a/man2/getpid.2
+++ b/man2/getpid.2
@@ -136,6 +136,25 @@ calls to
 always invoke the actual system call, rather than returning a cached value.
 .\" FIXME .
 .\" Review progress of https://bugzilla.redhat.com/show_bug.cgi?id=1469757
+.PP
+On Alpha, instead of pair of
+.BR getpid "() and " getppid ()
+system calls, single
+.BR getxpid ()
+system call is provided, which returns a pair of PID and parent PID.
+The glibc
+.BR getpid ()
+and
+.BR getppid ()
+wrapper functions transparently deal with this.
+See
+.BR syscall (2)
+for details regarding register mapping.
+Other examples of such peculiarity are Alpha-specific
+.BR getxuid "(2) and " getxgid (2),
+along with
+.BR pipe (2)
+on several architectures.
 .SH SEE ALSO
 .BR clone (2),
 .BR fork (2),
diff --git a/man2/getuid.2 b/man2/getuid.2
index 61f5fa1..0ebab76 100644
--- a/man2/getuid.2
+++ b/man2/getuid.2
@@ -70,6 +70,25 @@ The glibc
 and
 .BR geteuid ()
 wrapper functions transparently deal with the variations across kernel versions.
+.PP
+On Alpha, instead of pair of
+.BR getuid "() and " geteuid ()
+system calls, single
+.BR getxuid ()
+system call is provided, which returns a pair of real and effective UIDs.
+The glibc
+.BR getuid ()
+and
+.BR geteuid ()
+wrapper functions transparently deal with this.
+See
+.BR syscall (2)
+for details regarding register mapping.
+Other examples of such peculiarity are Alpha-specific
+.BR getxpid "(2) and " getxgid (2),
+along with
+.BR pipe (2)
+on several architectures.
 .SH SEE ALSO
 .BR getresuid (2),
 .BR setreuid (2),
diff --git a/man2/pipe.2 b/man2/pipe.2
index fcae8c0..5a282d4 100644
--- a/man2/pipe.2
+++ b/man2/pipe.2
@@ -40,6 +40,13 @@ pipe, pipe2 \- create pipe
 .nf
 .B #include <unistd.h>
 .PP
+/* On Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64; see NOTES */
+.B struct fd_pair {
+.B "    long fd[2];"
+.B "};"
+.B struct fd_pair pipe();
+.PP
+/* On all other architectures */
 .BI "int pipe(int " pipefd "[2]);"
 
 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
@@ -184,6 +191,25 @@ has been reached and the caller is not privileged; see
 was added to Linux in version 2.6.27;
 glibc support is available starting with
 version 2.9.
+.SH NOTES
+.\" See http://math-atlas.sourceforge.net/devel/assembly/64.psabi.1.33.ps.Z
+.\" for example, section 3.2.1 "Registers and the Stack Frame".
+SystemV ABI on some architectures allows using more than one register
+for returning multiple values; several architectures
+(namely, Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64)
+(ab)use this feature in order to implement
+.BR pipe ()
+system call in a functional manner: it doesn't take any arguments and returns
+a pair of file descriptors as a return value on success.
+The glibc
+.BR pipe ()
+wrapper function transparently deal with this.
+See
+.BR syscall (2)
+for information regarding registers used for storing second file descriptor.
+Other examples of such peculiarity are
+.BR getxpid (2)/ getxuid (2)/ getxgid (2)
+on Alpha.
 .SH CONFORMING TO
 .BR pipe ():
 POSIX.1-2001, POSIX.1-2008.
diff --git a/man2/syscall.2 b/man2/syscall.2
index 8b168e0..c156a85 100644
--- a/man2/syscall.2
+++ b/man2/syscall.2
@@ -172,39 +172,39 @@ The first table lists the instruction used to transition to kernel mode
 so you might have to refer to
 .BR vdso (7)),
 the register used to indicate the system call number,
-the register used to return the system call result,
+the register(s) used to return the system call result,
 and the register used to signal an error.
 .if t \{\
 .ft CW
 \}
 .TS
-l2	l2	l2	l2	l2	l.
-arch/ABI	instruction	syscall #	retval	error	Notes
+l2	l2	l2	l2	l2	l2	l.
+arch/ABI	instruction	syscall #	retval	retval2	error	Notes
 _
-alpha	callsys	v0	v0	a3	[1]
-arc	trap0	r8	r0	-
-arm/OABI	swi NR	-	a1	-	[2]
-arm/EABI	swi 0x0	r7	r0	-
-arm64	svc #0	x8	x0	-
-blackfin	excpt 0x0	P0	R0	-
-i386	int $0x80	eax	eax	-
-ia64	break 0x100000	r15	r8	r10	[1]
-m68k	trap #0	d0	d0	-
-microblaze	brki r14,8	r12	r3	-
-mips	syscall	v0	v0	a3	[1]
-nios2	trap	r2	r2	r7
-parisc	ble 0x100(%sr2, %r0)	r20	r28	-
-powerpc	sc	r0	r3	r0	[1]
-riscv	scall	a7	a0	-
-s390	svc 0	r1	r2	-	[3]
-s390x	svc 0	r1	r2	-	[3]
-superh	trap #0x17	r3	r0	-	[4]
-sparc/32	t 0x10	g1	o0	psr/csr	[1]
-sparc/64	t 0x6d	g1	o0	psr/csr	[1]
-tile	swint1	R10	R00	R01	[1]
-x86-64	syscall	rax	rax	-	[5]
-x32	syscall	rax	rax	-	[5]
-xtensa	syscall	a2	a2	-
+alpha	callsys	v0	v0	a4	a3	[1], [6]
+arc	trap0	r8	r0	-	-
+arm/OABI	swi NR	-	a1	-	-	[2]
+arm/EABI	swi 0x0	r7	r0	r1	-
+arm64	svc #0	x8	x0	x1	-
+blackfin	excpt 0x0	P0	R0	-	-
+i386	int $0x80	eax	eax	edx	-
+ia64	break 0x100000	r15	r8	r9	r10	[1], [6]
+m68k	trap #0	d0	d0	-	-
+microblaze	brki r14,8	r12	r3	-	-
+mips	syscall	v0	v0	v1	a3	[1], [6]
+nios2	trap	r2	r2	-	r7
+parisc	ble 0x100(%sr2, %r0)	r20	r28	-	-
+powerpc	sc	r0	r3	-	r0	[1]
+riscv	scall	a7	a0	a1	-
+s390	svc 0	r1	r2	r3	-	[3]
+s390x	svc 0	r1	r2	r3	-	[3]
+superh	trap #0x17	r3	r0	r1	-	[4], [6]
+sparc/32	t 0x10	g1	o0	o1	psr/csr	[1], [6]
+sparc/64	t 0x6d	g1	o0	o1	psr/csr	[1], [6]
+tile	swint1	R10	R00	-	R01	[1]
+x86-64	syscall	rax	rax	rdx	-	[5]
+x32	syscall	rax	rax	rdx	-	[5]
+xtensa	syscall	a2	a2	-	-
 .TE
 .PP
 Notes:
@@ -279,6 +279,17 @@ but passes an 8-byte
 .I pos
 argument in a single register and not two, as is done in every other ABI.
 .RE
+.IP [6]
+Some architectures
+(namely, Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64)
+use second return value register in order to pass second return value in
+.BR pipe (2)
+system call;
+Alpha uses it in the architecture-specific
+.BR getxpid "(2), " getxuid "(2), and " getxgid (2)
+system calls as well.
+Other architectures do not use the second return value register
+in the system call interface, even if it is defined in the SystemV ABI.
 .RE
 .if t \{\
 .in
-- 
2.1.4




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux