Skip to content

Commit be53db6

Browse files
Al Virotorvalds
authored andcommitted
alpha: take a bunch of syscalls into osf_sys.c
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 <[email protected]> Signed-off-by: Michael Cree <[email protected]> Acked-by: Matt Turner <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f2db633 commit be53db6

5 files changed

Lines changed: 54 additions & 120 deletions

File tree

arch/alpha/include/asm/ptrace.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ struct switch_stack {
7676
#define task_pt_regs(task) \
7777
((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1)
7878

79-
#define force_successful_syscall_return() (task_pt_regs(current)->r0 = 0)
79+
#define current_pt_regs() \
80+
((struct pt_regs *) ((char *)current_thread_info() + 2*PAGE_SIZE) - 1)
81+
82+
#define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
8083

8184
#endif
8285

arch/alpha/kernel/entry.S

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -796,115 +796,6 @@ sys_rt_sigreturn:
796796
br ret_from_sys_call
797797
.end sys_rt_sigreturn
798798

799-
.align 4
800-
.globl sys_sethae
801-
.ent sys_sethae
802-
sys_sethae:
803-
.prologue 0
804-
stq $16, 152($sp)
805-
ret
806-
.end sys_sethae
807-
808-
.align 4
809-
.globl osf_getpriority
810-
.ent osf_getpriority
811-
osf_getpriority:
812-
lda $sp, -16($sp)
813-
stq $26, 0($sp)
814-
.prologue 0
815-
816-
jsr $26, sys_getpriority
817-
818-
ldq $26, 0($sp)
819-
blt $0, 1f
820-
821-
/* Return value is the unbiased priority, i.e. 20 - prio.
822-
This does result in negative return values, so signal
823-
no error by writing into the R0 slot. */
824-
lda $1, 20
825-
stq $31, 16($sp)
826-
subl $1, $0, $0
827-
unop
828-
829-
1: lda $sp, 16($sp)
830-
ret
831-
.end osf_getpriority
832-
833-
.align 4
834-
.globl sys_getxuid
835-
.ent sys_getxuid
836-
sys_getxuid:
837-
.prologue 0
838-
ldq $2, TI_TASK($8)
839-
ldq $3, TASK_CRED($2)
840-
ldl $0, CRED_UID($3)
841-
ldl $1, CRED_EUID($3)
842-
stq $1, 80($sp)
843-
ret
844-
.end sys_getxuid
845-
846-
.align 4
847-
.globl sys_getxgid
848-
.ent sys_getxgid
849-
sys_getxgid:
850-
.prologue 0
851-
ldq $2, TI_TASK($8)
852-
ldq $3, TASK_CRED($2)
853-
ldl $0, CRED_GID($3)
854-
ldl $1, CRED_EGID($3)
855-
stq $1, 80($sp)
856-
ret
857-
.end sys_getxgid
858-
859-
.align 4
860-
.globl sys_getxpid
861-
.ent sys_getxpid
862-
sys_getxpid:
863-
.prologue 0
864-
ldq $2, TI_TASK($8)
865-
866-
/* See linux/kernel/timer.c sys_getppid for discussion
867-
about this loop. */
868-
ldq $3, TASK_GROUP_LEADER($2)
869-
ldq $4, TASK_REAL_PARENT($3)
870-
ldl $0, TASK_TGID($2)
871-
1: ldl $1, TASK_TGID($4)
872-
#ifdef CONFIG_SMP
873-
mov $4, $5
874-
mb
875-
ldq $3, TASK_GROUP_LEADER($2)
876-
ldq $4, TASK_REAL_PARENT($3)
877-
cmpeq $4, $5, $5
878-
beq $5, 1b
879-
#endif
880-
stq $1, 80($sp)
881-
ret
882-
.end sys_getxpid
883-
884-
.align 4
885-
.globl sys_alpha_pipe
886-
.ent sys_alpha_pipe
887-
sys_alpha_pipe:
888-
lda $sp, -16($sp)
889-
stq $26, 0($sp)
890-
.prologue 0
891-
892-
mov $31, $17
893-
lda $16, 8($sp)
894-
jsr $26, do_pipe_flags
895-
896-
ldq $26, 0($sp)
897-
bne $0, 1f
898-
899-
/* The return values are in $0 and $20. */
900-
ldl $1, 12($sp)
901-
ldl $0, 8($sp)
902-
903-
stq $1, 80+16($sp)
904-
1: lda $sp, 16($sp)
905-
ret
906-
.end sys_alpha_pipe
907-
908799
.align 4
909800
.globl sys_execve
910801
.ent sys_execve

arch/alpha/kernel/osf_sys.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,3 +1404,52 @@ SYSCALL_DEFINE3(osf_writev, unsigned long, fd,
14041404
}
14051405

14061406
#endif
1407+
1408+
SYSCALL_DEFINE2(osf_getpriority, int, which, int, who)
1409+
{
1410+
int prio = sys_getpriority(which, who);
1411+
if (prio >= 0) {
1412+
/* Return value is the unbiased priority, i.e. 20 - prio.
1413+
This does result in negative return values, so signal
1414+
no error */
1415+
force_successful_syscall_return();
1416+
prio = 20 - prio;
1417+
}
1418+
return prio;
1419+
}
1420+
1421+
SYSCALL_DEFINE0(getxuid)
1422+
{
1423+
current_pt_regs()->r20 = sys_geteuid();
1424+
return sys_getuid();
1425+
}
1426+
1427+
SYSCALL_DEFINE0(getxgid)
1428+
{
1429+
current_pt_regs()->r20 = sys_getegid();
1430+
return sys_getgid();
1431+
}
1432+
1433+
SYSCALL_DEFINE0(getxpid)
1434+
{
1435+
current_pt_regs()->r20 = sys_getppid();
1436+
return sys_getpid();
1437+
}
1438+
1439+
SYSCALL_DEFINE0(alpha_pipe)
1440+
{
1441+
int fd[2];
1442+
int res = do_pipe_flags(fd, 0);
1443+
if (!res) {
1444+
/* The return values are in $0 and $20. */
1445+
current_pt_regs()->r20 = fd[1];
1446+
res = fd[0];
1447+
}
1448+
return res;
1449+
}
1450+
1451+
SYSCALL_DEFINE1(sethae, unsigned long, val)
1452+
{
1453+
current_pt_regs()->hae = val;
1454+
return 0;
1455+
}

arch/alpha/kernel/systbls.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ sys_call_table:
111111
.quad sys_socket
112112
.quad sys_connect
113113
.quad sys_accept
114-
.quad osf_getpriority /* 100 */
114+
.quad sys_osf_getpriority /* 100 */
115115
.quad sys_send
116116
.quad sys_recv
117117
.quad sys_sigreturn

kernel/timer.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,13 +1407,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, seconds)
14071407

14081408
#endif
14091409

1410-
#ifndef __alpha__
1411-
1412-
/*
1413-
* The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
1414-
* should be moved into arch/i386 instead?
1415-
*/
1416-
14171410
/**
14181411
* sys_getpid - return the thread group id of the current process
14191412
*
@@ -1469,8 +1462,6 @@ SYSCALL_DEFINE0(getegid)
14691462
return from_kgid_munged(current_user_ns(), current_egid());
14701463
}
14711464

1472-
#endif
1473-
14741465
static void process_timeout(unsigned long __data)
14751466
{
14761467
wake_up_process((struct task_struct *)__data);

0 commit comments

Comments
 (0)