mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
S390: Always use svc 0
On s390x syscalls are triggered by svc instruction. One can pass the syscall number encoded in the instruction "svc 123" or by storing it in r1: lghi r1,123 svc 0 If the syscall number is encoded in the instruction, this can cause broken syscall restarts. Therefore this patch is now just passing the syscall number in r1. See also kernel-commit: "s390/signal: switch to using vdso for sigreturn and syscall restart" https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/s390/[%e2%80%a6]call.c?h=v6.0-rc1&id=df29a7440c4b5c65765c8f60396b3b13063e24e9 As information, the "svc 0" feature was introduced in kernel 2.5.62: commit b5aad611393ef2e132e3648fa4c6e56a9cfa8708
This commit is contained in:
parent
1d495912a7
commit
e57d8fc97b
13 changed files with 46 additions and 66 deletions
|
@ -30,9 +30,10 @@
|
||||||
|
|
||||||
.text
|
.text
|
||||||
ENTRY(__clone)
|
ENTRY(__clone)
|
||||||
st %r6,24(%r15) /* store %r6 to save area */
|
stm %r6,%r7,24(%r15) /* Save registers. */
|
||||||
|
cfi_offset (%r7, -68)
|
||||||
cfi_offset (%r6, -72)
|
cfi_offset (%r6, -72)
|
||||||
ltr %r1,%r2 /* check fn and move to %r1 */
|
ltr %r7,%r2 /* check fn and move to %r7 */
|
||||||
jz error /* no NULL function pointers */
|
jz error /* no NULL function pointers */
|
||||||
lhi %r0,-8 /* Align the child_stack to a ... */
|
lhi %r0,-8 /* Align the child_stack to a ... */
|
||||||
nr %r3,%r0 /* double word boundary and ... */
|
nr %r3,%r0 /* double word boundary and ... */
|
||||||
|
@ -43,10 +44,11 @@ ENTRY(__clone)
|
||||||
lr %r4,%r6 /* move parent_tid to %r4 */
|
lr %r4,%r6 /* move parent_tid to %r4 */
|
||||||
l %r5,100(%r15) /* load child_tid from stack */
|
l %r5,100(%r15) /* load child_tid from stack */
|
||||||
l %r6,96(%r15) /* load tls from stack */
|
l %r6,96(%r15) /* load tls from stack */
|
||||||
svc SYS_ify(clone)
|
lhi %r1,SYS_ify(clone)
|
||||||
|
svc 0
|
||||||
ltr %r2,%r2 /* check return code */
|
ltr %r2,%r2 /* check return code */
|
||||||
jz thread_start
|
jz thread_start
|
||||||
l %r6,24(%r15) /* restore %r6 */
|
lm %r6,%r7,24(%r15) /* Load registers. */
|
||||||
jm SYSCALL_ERROR_LABEL
|
jm SYSCALL_ERROR_LABEL
|
||||||
br %r14
|
br %r14
|
||||||
error:
|
error:
|
||||||
|
@ -58,11 +60,11 @@ thread_start:
|
||||||
cfi_startproc
|
cfi_startproc
|
||||||
/* Mark r14 as undefined in order to stop unwinding here! */
|
/* Mark r14 as undefined in order to stop unwinding here! */
|
||||||
cfi_undefined (r14)
|
cfi_undefined (r14)
|
||||||
/* fn is in gpr 1, arg in gpr 0 */
|
/* fn is in gpr 7, arg in gpr 0 */
|
||||||
lr %r2,%r0 /* set first parameter to void *arg */
|
lr %r2,%r0 /* set first parameter to void *arg */
|
||||||
ahi %r15,-96 /* make room on the stack for the save area */
|
ahi %r15,-96 /* make room on the stack for the save area */
|
||||||
xc 0(4,%r15),0(%r15)
|
xc 0(4,%r15),0(%r15)
|
||||||
basr %r14,%r1 /* jump to fn */
|
basr %r14,%r7 /* jump to fn */
|
||||||
DO_CALL (exit, 1)
|
DO_CALL (exit, 1)
|
||||||
cfi_endproc
|
cfi_endproc
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,18 @@
|
||||||
other than the PRESERVED state. */
|
other than the PRESERVED state. */
|
||||||
|
|
||||||
ENTRY(__getcontext)
|
ENTRY(__getcontext)
|
||||||
lr %r1,%r2
|
lr %r0,%r2
|
||||||
|
|
||||||
/* rt_sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask, sigsetsize). */
|
/* rt_sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask, sigsetsize). */
|
||||||
|
la %r4,SC_MASK(%r2)
|
||||||
la %r2,SIG_BLOCK
|
la %r2,SIG_BLOCK
|
||||||
slr %r3,%r3
|
slr %r3,%r3
|
||||||
la %r4,SC_MASK(%r1)
|
|
||||||
lhi %r5,_NSIG8
|
lhi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lhi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Store fpu context. */
|
/* Store fpu context. */
|
||||||
|
lr %r1,%r0
|
||||||
stfpc SC_FPC(%r1)
|
stfpc SC_FPC(%r1)
|
||||||
std %f0,SC_FPRS(%r1)
|
std %f0,SC_FPRS(%r1)
|
||||||
std %f1,SC_FPRS+8(%r1)
|
std %f1,SC_FPRS+8(%r1)
|
||||||
|
|
|
@ -30,16 +30,18 @@
|
||||||
other than the PRESERVED state. */
|
other than the PRESERVED state. */
|
||||||
|
|
||||||
ENTRY(__setcontext)
|
ENTRY(__setcontext)
|
||||||
lr %r1,%r2
|
lr %r0,%r2
|
||||||
|
|
||||||
/* rt_sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL, sigsetsize). */
|
/* rt_sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL, sigsetsize). */
|
||||||
|
la %r3,SC_MASK(%r2)
|
||||||
la %r2,SIG_SETMASK
|
la %r2,SIG_SETMASK
|
||||||
la %r3,SC_MASK(%r1)
|
|
||||||
slr %r4,%r4
|
slr %r4,%r4
|
||||||
lhi %r5,_NSIG8
|
lhi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lhi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Load fpu context. */
|
/* Load fpu context. */
|
||||||
|
lr %r1,%r0
|
||||||
lfpc SC_FPC(%r1)
|
lfpc SC_FPC(%r1)
|
||||||
ld %f0,SC_FPRS(%r1)
|
ld %f0,SC_FPRS(%r1)
|
||||||
ld %f1,SC_FPRS+8(%r1)
|
ld %f1,SC_FPRS+8(%r1)
|
||||||
|
|
|
@ -73,7 +73,8 @@ ENTRY(__swapcontext)
|
||||||
la %r3,SC_MASK(%r5)
|
la %r3,SC_MASK(%r5)
|
||||||
la %r4,SC_MASK(%r1)
|
la %r4,SC_MASK(%r1)
|
||||||
lhi %r5,_NSIG8
|
lhi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lhi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Load fpu context. */
|
/* Load fpu context. */
|
||||||
lr %r5,%r0
|
lr %r5,%r0
|
||||||
|
|
|
@ -155,12 +155,8 @@
|
||||||
lr %r0,%r7; \
|
lr %r0,%r7; \
|
||||||
l %r7,96(%r15); \
|
l %r7,96(%r15); \
|
||||||
.endif; \
|
.endif; \
|
||||||
.if SYS_ify (syscall) < 256; \
|
|
||||||
svc SYS_ify (syscall); \
|
|
||||||
.else; \
|
|
||||||
lhi %r1,SYS_ify (syscall); \
|
lhi %r1,SYS_ify (syscall); \
|
||||||
svc 0; \
|
svc 0; \
|
||||||
.endif; \
|
|
||||||
.if args > 5; \
|
.if args > 5; \
|
||||||
lr %r7,%r0; \
|
lr %r7,%r0; \
|
||||||
.endif
|
.endif
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
ENTRY (__libc_vfork)
|
ENTRY (__libc_vfork)
|
||||||
/* Do vfork system call. */
|
/* Do vfork system call. */
|
||||||
svc SYS_ify (vfork)
|
lhi %r1,SYS_ify (vfork)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Check for error. */
|
/* Check for error. */
|
||||||
lhi %r4,-4095
|
lhi %r4,-4095
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
|
|
||||||
.text
|
.text
|
||||||
ENTRY(__clone)
|
ENTRY(__clone)
|
||||||
stg %r6,48(%r15) /* store %r6 to save area */
|
stmg %r6,%r7,48(%r15) /* Save registers. */
|
||||||
|
cfi_offset (%r7,-104)
|
||||||
cfi_offset (%r6,-112)
|
cfi_offset (%r6,-112)
|
||||||
ltgr %r1,%r2 /* check fn and move to %r1 */
|
ltgr %r7,%r2 /* check fn and move to %r7 */
|
||||||
jz error /* no NULL function pointers */
|
jz error /* no NULL function pointers */
|
||||||
lghi %r0,-16 /* Align the child_stack to a ... */
|
lghi %r0,-16 /* Align the child_stack to a ... */
|
||||||
ngr %r3,%r0 /* double word boundary and ... */
|
ngr %r3,%r0 /* double word boundary and ... */
|
||||||
|
@ -44,10 +45,11 @@ ENTRY(__clone)
|
||||||
lgr %r4,%r6 /* move parent_tid to %r4 */
|
lgr %r4,%r6 /* move parent_tid to %r4 */
|
||||||
lg %r5,168(%r15) /* load child_tid from stack */
|
lg %r5,168(%r15) /* load child_tid from stack */
|
||||||
lg %r6,160(%r15) /* load tls from stack */
|
lg %r6,160(%r15) /* load tls from stack */
|
||||||
svc SYS_ify(clone)
|
lghi %r1,SYS_ify (clone)
|
||||||
|
svc 0
|
||||||
ltgr %r2,%r2 /* check return code */
|
ltgr %r2,%r2 /* check return code */
|
||||||
jz thread_start
|
jz thread_start
|
||||||
lg %r6,48(%r15) /* restore %r6 */
|
lmg %r6,%r7,48(%r15) /* Restore registers. */
|
||||||
jgm SYSCALL_ERROR_LABEL
|
jgm SYSCALL_ERROR_LABEL
|
||||||
br %r14
|
br %r14
|
||||||
error:
|
error:
|
||||||
|
@ -59,11 +61,11 @@ thread_start:
|
||||||
cfi_startproc
|
cfi_startproc
|
||||||
/* Mark r14 as undefined in order to stop unwinding here! */
|
/* Mark r14 as undefined in order to stop unwinding here! */
|
||||||
cfi_undefined (r14)
|
cfi_undefined (r14)
|
||||||
/* fn is in gpr 1, arg in gpr 0 */
|
/* fn is in gpr 7, arg in gpr 0 */
|
||||||
lgr %r2,%r0 /* set first parameter to void *arg */
|
lgr %r2,%r0 /* set first parameter to void *arg */
|
||||||
aghi %r15,-160 /* make room on the stack for the save area */
|
aghi %r15,-160 /* make room on the stack for the save area */
|
||||||
xc 0(8,%r15),0(%r15)
|
xc 0(8,%r15),0(%r15)
|
||||||
basr %r14,%r1 /* jump to fn */
|
basr %r14,%r7 /* jump to fn */
|
||||||
DO_CALL (exit, 1)
|
DO_CALL (exit, 1)
|
||||||
cfi_endproc
|
cfi_endproc
|
||||||
|
|
||||||
|
|
|
@ -32,16 +32,18 @@
|
||||||
other than the PRESERVED state. */
|
other than the PRESERVED state. */
|
||||||
|
|
||||||
ENTRY(__getcontext)
|
ENTRY(__getcontext)
|
||||||
lgr %r1,%r2
|
lgr %r0,%r2
|
||||||
|
|
||||||
/* rt_sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask, sigsetsize). */
|
/* rt_sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask, sigsetsize). */
|
||||||
|
la %r4,SC_MASK(%r2)
|
||||||
la %r2,SIG_BLOCK
|
la %r2,SIG_BLOCK
|
||||||
slgr %r3,%r3
|
slgr %r3,%r3
|
||||||
la %r4,SC_MASK(%r1)
|
|
||||||
lghi %r5,_NSIG8
|
lghi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lghi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Store fpu context. */
|
/* Store fpu context. */
|
||||||
|
lgr %r1,%r0
|
||||||
stfpc SC_FPC(%r1)
|
stfpc SC_FPC(%r1)
|
||||||
std %f0,SC_FPRS(%r1)
|
std %f0,SC_FPRS(%r1)
|
||||||
std %f1,SC_FPRS+8(%r1)
|
std %f1,SC_FPRS+8(%r1)
|
||||||
|
|
|
@ -30,16 +30,18 @@
|
||||||
other than the PRESERVED state. */
|
other than the PRESERVED state. */
|
||||||
|
|
||||||
ENTRY(__setcontext)
|
ENTRY(__setcontext)
|
||||||
lgr %r1,%r2
|
lgr %r0,%r2
|
||||||
|
|
||||||
/* sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL). */
|
/* sigprocmask (SIG_SETMASK, &sc->sc_mask, NULL). */
|
||||||
|
la %r3,SC_MASK(%r2)
|
||||||
la %r2,SIG_SETMASK
|
la %r2,SIG_SETMASK
|
||||||
la %r3,SC_MASK(%r1)
|
|
||||||
slgr %r4,%r4
|
slgr %r4,%r4
|
||||||
lghi %r5,_NSIG8
|
lghi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lghi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Load fpu context. */
|
/* Load fpu context. */
|
||||||
|
lgr %r1,%r0
|
||||||
lfpc SC_FPC(%r1)
|
lfpc SC_FPC(%r1)
|
||||||
ld %f0,SC_FPRS(%r1)
|
ld %f0,SC_FPRS(%r1)
|
||||||
ld %f1,SC_FPRS+8(%r1)
|
ld %f1,SC_FPRS+8(%r1)
|
||||||
|
|
|
@ -73,7 +73,8 @@ ENTRY(__swapcontext)
|
||||||
la %r3,SC_MASK(%r5)
|
la %r3,SC_MASK(%r5)
|
||||||
la %r4,SC_MASK(%r1)
|
la %r4,SC_MASK(%r1)
|
||||||
lghi %r5,_NSIG8
|
lghi %r5,_NSIG8
|
||||||
svc SYS_ify(rt_sigprocmask)
|
lghi %r1,SYS_ify(rt_sigprocmask)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Load fpu context. */
|
/* Load fpu context. */
|
||||||
lgr %r5,%r0
|
lgr %r5,%r0
|
||||||
|
|
|
@ -153,12 +153,8 @@
|
||||||
lgr %r0,%r7; \
|
lgr %r0,%r7; \
|
||||||
lg %r7,160(%r15); \
|
lg %r7,160(%r15); \
|
||||||
.endif; \
|
.endif; \
|
||||||
.if SYS_ify (syscall) < 256; \
|
|
||||||
svc SYS_ify (syscall); \
|
|
||||||
.else; \
|
|
||||||
lghi %r1,SYS_ify (syscall); \
|
lghi %r1,SYS_ify (syscall); \
|
||||||
svc 0; \
|
svc 0; \
|
||||||
.endif; \
|
|
||||||
.if args > 5; \
|
.if args > 5; \
|
||||||
lgr %r7,%r0; \
|
lgr %r7,%r0; \
|
||||||
.endif
|
.endif
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
|
|
||||||
ENTRY (__libc_vfork)
|
ENTRY (__libc_vfork)
|
||||||
/* Do vfork system call. */
|
/* Do vfork system call. */
|
||||||
svc SYS_ify (vfork)
|
lghi %r1,SYS_ify (vfork)
|
||||||
|
svc 0
|
||||||
|
|
||||||
/* Check for error. */
|
/* Check for error. */
|
||||||
lghi %r4,-4095
|
lghi %r4,-4095
|
||||||
|
|
|
@ -21,32 +21,6 @@
|
||||||
#undef SYS_ify
|
#undef SYS_ify
|
||||||
#define SYS_ify(syscall_name) __NR_##syscall_name
|
#define SYS_ify(syscall_name) __NR_##syscall_name
|
||||||
|
|
||||||
#undef INTERNAL_SYSCALL_DIRECT
|
|
||||||
#define INTERNAL_SYSCALL_DIRECT(name, nr, args...) \
|
|
||||||
({ \
|
|
||||||
DECLARGS_##nr(args) \
|
|
||||||
register long int _ret __asm__("2"); \
|
|
||||||
__asm__ __volatile__ ( \
|
|
||||||
"svc %b1\n\t" \
|
|
||||||
: "=d" (_ret) \
|
|
||||||
: "i" (__NR_##name) ASMFMT_##nr \
|
|
||||||
: "memory" ); \
|
|
||||||
_ret; })
|
|
||||||
|
|
||||||
#undef INTERNAL_SYSCALL_SVC0
|
|
||||||
#define INTERNAL_SYSCALL_SVC0(name, nr, args...) \
|
|
||||||
({ \
|
|
||||||
DECLARGS_##nr(args) \
|
|
||||||
register unsigned long int _nr __asm__("1") = \
|
|
||||||
(unsigned long int)(__NR_##name); \
|
|
||||||
register long int _ret __asm__("2"); \
|
|
||||||
__asm__ __volatile__ ( \
|
|
||||||
"svc 0\n\t" \
|
|
||||||
: "=d" (_ret) \
|
|
||||||
: "d" (_nr) ASMFMT_##nr \
|
|
||||||
: "memory" ); \
|
|
||||||
_ret; })
|
|
||||||
|
|
||||||
#undef INTERNAL_SYSCALL_NCS
|
#undef INTERNAL_SYSCALL_NCS
|
||||||
#define INTERNAL_SYSCALL_NCS(no, nr, args...) \
|
#define INTERNAL_SYSCALL_NCS(no, nr, args...) \
|
||||||
({ \
|
({ \
|
||||||
|
@ -61,10 +35,8 @@
|
||||||
_ret; })
|
_ret; })
|
||||||
|
|
||||||
#undef INTERNAL_SYSCALL
|
#undef INTERNAL_SYSCALL
|
||||||
#define INTERNAL_SYSCALL(name, nr, args...) \
|
#define INTERNAL_SYSCALL(name, nr, args...) \
|
||||||
(((__NR_##name) < 256) \
|
INTERNAL_SYSCALL_NCS(__NR_##name, nr, args)
|
||||||
? INTERNAL_SYSCALL_DIRECT(name, nr, args) \
|
|
||||||
: INTERNAL_SYSCALL_SVC0(name, nr, args))
|
|
||||||
|
|
||||||
#define DECLARGS_0()
|
#define DECLARGS_0()
|
||||||
#define DECLARGS_1(arg1) \
|
#define DECLARGS_1(arg1) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue