alpha: take a bunch of syscalls into osf_sys.c
authorAl Viro <viro@ZenIV.linux.org.uk>
Sun, 19 Aug 2012 02:40:59 +0000 (14:40 +1200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 19 Aug 2012 15:41:19 +0000 (08:41 -0700)
New helper: current_thread_info().  Allows to do a bunch of odd syscalls
in C. While we are at it, there had never been a reason to do
osf_getpriority() in assembler.  We also get "namespace"-aware (read:
consistent with getuid(2), etc.) behaviour from getx?id() syscalls now.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Michael Cree <mcree@orcon.net.nz>
Acked-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/alpha/include/asm/ptrace.h
arch/alpha/kernel/entry.S
arch/alpha/kernel/osf_sys.c
arch/alpha/kernel/systbls.S
kernel/timer.c

index fd698a174f26a9358a2c8e63b663c68bc47a56c1..b87755a1955482f9a46282749ed68755afca4973 100644 (file)
@@ -76,7 +76,10 @@ struct switch_stack {
 #define task_pt_regs(task) \
   ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1)
 
-#define force_successful_syscall_return() (task_pt_regs(current)->r0 = 0)
+#define current_pt_regs() \
+  ((struct pt_regs *) ((char *)current_thread_info() + 2*PAGE_SIZE) - 1)
+
+#define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
 
 #endif
 
index 6d159cee5f2f43a48bc9aac8355069a3e588ef7f..22b0c4d414a7cec4413d78be35482e91f6c4a2f2 100644 (file)
@@ -796,115 +796,6 @@ sys_rt_sigreturn:
        br      ret_from_sys_call
 .end sys_rt_sigreturn
 
-       .align  4
-       .globl  sys_sethae
-       .ent    sys_sethae
-sys_sethae:
-       .prologue 0
-       stq     $16, 152($sp)
-       ret
-.end sys_sethae
-
-       .align  4
-       .globl  osf_getpriority
-       .ent    osf_getpriority
-osf_getpriority:
-       lda     $sp, -16($sp)
-       stq     $26, 0($sp)
-       .prologue 0
-
-       jsr     $26, sys_getpriority
-
-       ldq     $26, 0($sp)
-       blt     $0, 1f
-
-       /* Return value is the unbiased priority, i.e. 20 - prio.
-          This does result in negative return values, so signal
-          no error by writing into the R0 slot.  */
-       lda     $1, 20
-       stq     $31, 16($sp)
-       subl    $1, $0, $0
-       unop
-
-1:     lda     $sp, 16($sp)
-       ret
-.end osf_getpriority
-
-       .align  4
-       .globl  sys_getxuid
-       .ent    sys_getxuid
-sys_getxuid:
-       .prologue 0
-       ldq     $2, TI_TASK($8)
-       ldq     $3, TASK_CRED($2)
-       ldl     $0, CRED_UID($3)
-       ldl     $1, CRED_EUID($3)
-       stq     $1, 80($sp)
-       ret
-.end sys_getxuid
-
-       .align  4
-       .globl  sys_getxgid
-       .ent    sys_getxgid
-sys_getxgid:
-       .prologue 0
-       ldq     $2, TI_TASK($8)
-       ldq     $3, TASK_CRED($2)
-       ldl     $0, CRED_GID($3)
-       ldl     $1, CRED_EGID($3)
-       stq     $1, 80($sp)
-       ret
-.end sys_getxgid
-
-       .align  4
-       .globl  sys_getxpid
-       .ent    sys_getxpid
-sys_getxpid:
-       .prologue 0
-       ldq     $2, TI_TASK($8)
-
-       /* See linux/kernel/timer.c sys_getppid for discussion
-          about this loop.  */
-       ldq     $3, TASK_GROUP_LEADER($2)
-       ldq     $4, TASK_REAL_PARENT($3)
-       ldl     $0, TASK_TGID($2)
-1:     ldl     $1, TASK_TGID($4)
-#ifdef CONFIG_SMP
-       mov     $4, $5
-       mb
-       ldq     $3, TASK_GROUP_LEADER($2)
-       ldq     $4, TASK_REAL_PARENT($3)
-       cmpeq   $4, $5, $5
-       beq     $5, 1b
-#endif
-       stq     $1, 80($sp)
-       ret
-.end sys_getxpid
-
-       .align  4
-       .globl  sys_alpha_pipe
-       .ent    sys_alpha_pipe
-sys_alpha_pipe:
-       lda     $sp, -16($sp)
-       stq     $26, 0($sp)
-       .prologue 0
-
-       mov     $31, $17
-       lda     $16, 8($sp)
-       jsr     $26, do_pipe_flags
-
-       ldq     $26, 0($sp)
-       bne     $0, 1f
-
-       /* The return values are in $0 and $20.  */
-       ldl     $1, 12($sp)
-       ldl     $0, 8($sp)
-
-       stq     $1, 80+16($sp)
-1:     lda     $sp, 16($sp)
-       ret
-.end sys_alpha_pipe
-
        .align  4
        .globl  sys_execve
        .ent    sys_execve
index 98a103621af6c24e04c219b318281d412ce5018d..bc1acdda7a5ed8ab3945b72559c09a9e763ec030 100644 (file)
@@ -1404,3 +1404,52 @@ SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
 }
 
 #endif
+
+SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
+{
+       int prio = sys_getpriority(which, who);
+       if (prio >= 0) {
+               /* Return value is the unbiased priority, i.e. 20 - prio.
+                  This does result in negative return values, so signal
+                  no error */
+               force_successful_syscall_return();
+               prio = 20 - prio;
+       }
+       return prio;
+}
+
+SYSCALL_DEFINE0(getxuid)
+{
+       current_pt_regs()->r20 = sys_geteuid();
+       return sys_getuid();
+}
+
+SYSCALL_DEFINE0(getxgid)
+{
+       current_pt_regs()->r20 = sys_getegid();
+       return sys_getgid();
+}
+
+SYSCALL_DEFINE0(getxpid)
+{
+       current_pt_regs()->r20 = sys_getppid();
+       return sys_getpid();
+}
+
+SYSCALL_DEFINE0(alpha_pipe)
+{
+       int fd[2];
+       int res = do_pipe_flags(fd, 0);
+       if (!res) {
+               /* The return values are in $0 and $20.  */
+               current_pt_regs()->r20 = fd[1];
+               res = fd[0];
+       }
+       return res;
+}
+
+SYSCALL_DEFINE1(sethae, unsigned long, val)
+{
+       current_pt_regs()->hae = val;
+       return 0;
+}
index b64157c98e02bdd7938a60c4f4aa57d6825194db..2ac6b45c3e0005d542a084bfabcc652b4747f75e 100644 (file)
@@ -111,7 +111,7 @@ sys_call_table:
        .quad sys_socket
        .quad sys_connect
        .quad sys_accept
-       .quad osf_getpriority                   /* 100 */
+       .quad sys_osf_getpriority                       /* 100 */
        .quad sys_send
        .quad sys_recv
        .quad sys_sigreturn
index a61c09374ebab1fdba0bdd370b56cf70018de62d..8c5e7b908c6814ed5342e63c65b69d4acb9ea037 100644 (file)
@@ -1407,13 +1407,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, seconds)
 
 #endif
 
-#ifndef __alpha__
-
-/*
- * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
- * should be moved into arch/i386 instead?
- */
-
 /**
  * sys_getpid - return the thread group id of the current process
  *
@@ -1469,8 +1462,6 @@ SYSCALL_DEFINE0(getegid)
        return from_kgid_munged(current_user_ns(), current_egid());
 }
 
-#endif
-
 static void process_timeout(unsigned long __data)
 {
        wake_up_process((struct task_struct *)__data);