2002-10-07 Michal Ludvig <mludvig@suse.cz>

Merged s390x port by Heiko Carstens <Heiko.Carstens@de.ibm.com>
        and bugfixes to s390 by D.J. Barrow.
This commit is contained in:
Michal Ludvig 2002-10-07 14:31:00 +00:00
parent c57fb8e410
commit 10a88d09eb
12 changed files with 98 additions and 39 deletions

View File

@ -1,3 +1,8 @@
2002-10-07 Michal Ludvig <mludvig@suse.cz>
Merged s390x port by Heiko Carstens <Heiko.Carstens@de.ibm.com>
and bugfixes to s390 by D.J. Barrow.
2002-09-23 Michal Ludvig <mludvig@suse.cz>
Merged x86-64 port by Andi Kleen <ak@suse.de>

View File

@ -50,7 +50,8 @@ INCLUDES = -I. -I$(OS)/$(ARCH) -I$(srcdir)/$(OS)/$(ARCH) -I$(OS) \
-I$(srcdir)/$(OS)
SUBDIRS = $(OSARCH)
ALL_SUBDIRS = test linux linux/alpha linux/powerpc sunos4 svr4 freebsd/i386
ALL_SUBDIRS = test linux linux/alpha linux/powerpc sunos4 svr4 \
linux/s390 linux/s390x freebsd/i386
OBJ = strace.o version.o syscall.o util.o desc.o file.o ipc.o \
io.o ioctl.o mem.o net.o process.o bjm.o \
resource.o signal.o sock.o system.o term.o time.o \

View File

@ -51,6 +51,9 @@
/* Define if this is a x86-64 architecture. */
#undef X86_64
/* Define if this is a S390X architecture. */
#undef S390X
/* Define if you have a SVR4 MP type procfs. I.E. /dev/xxx/ctl,
/dev/xxx/status. Also implies that you have the pr_lwp
member in prstatus. */

6
config.sub vendored
View File

@ -756,6 +756,12 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
s390)
basic_machine=s390-ibm
;;
s390x)
basic_machine=s390x-ibm
;;
sequent)
basic_machine=i386-sequent
;;

View File

@ -64,6 +64,9 @@ arm)
s390)
arch=s390
;;
s390x)
arch=s390x
;;
hppa*|parisc*)
arch=hppa
;;
@ -81,7 +84,7 @@ AC_MSG_RESULT($arch)
# Autoheader trick. Heh, heh.
arch_list='
@@@syms="$syms I386 IA64 M68K SPARC MIPS ALPHA ARM POWERPC S390 HPPA SH X86_64"@@@
@@@syms="$syms I386 IA64 M68K SPARC MIPS ALPHA ARM POWERPC S390 S390X HPPA SH X86_64"@@@
'
osarch="$opsys"

19
file.c
View File

@ -40,6 +40,7 @@
#include <linux/types.h>
#include <linux/dirent.h>
#undef dirent
#undef dirent64
#else
#define kernel_dirent dirent
#endif
@ -889,7 +890,8 @@ long addr;
}
#endif /* HAVE_STAT64 */
#if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64)
#if defined(LINUX) && !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
&& !defined(S390) && !defined(S390X)
static void
convertoldstat(oldbuf, newbuf)
const struct __old_kernel_stat *oldbuf;
@ -942,7 +944,7 @@ long addr;
convertoldstat(&statbuf, &newstatbuf);
realprintstat(tcp, &newstatbuf);
}
#endif /* LINUX && !IA64 */
#endif /* LINUX && !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
#ifndef HAVE_LONG_LONG_OFF_T
int
@ -977,7 +979,8 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
&& !defined(S390) && !defined(S390X)
int
sys_oldstat(tcp)
struct tcb *tcp;
@ -1024,7 +1027,8 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
&& !defined(S390) && !defined(S390X)
int
sys_oldfstat(tcp)
struct tcb *tcp;
@ -1036,7 +1040,7 @@ struct tcb *tcp;
}
return 0;
}
# endif /* !IA64 && !HPPA*/
# endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
#endif
#ifndef HAVE_LONG_LONG_OFF_T
@ -1072,7 +1076,8 @@ struct tcb *tcp;
}
#ifdef LINUX
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64)
# if !defined(IA64) && !defined(HPPA) && !defined(X86_64) \
&& !defined(S390) && !defined(S390X)
int
sys_oldlstat(tcp)
struct tcb *tcp;
@ -1085,7 +1090,7 @@ struct tcb *tcp;
}
return 0;
}
# endif /* !IA64 && !HPPA */
# endif /* !IA64 && !HPPA && !X86_64 && !S390 && !S390X */
#endif

View File

@ -96,6 +96,7 @@ int sys_shutdown(), sys_setsockopt(), sys_getsockopt();
/* new ones */
int sys_query_module();
int sys_poll();
int sys_mincore();
/* architecture-specific calls */
#ifdef ALPHA
@ -137,11 +138,11 @@ int sys_osf_utimes();
# undef SYS_sendmsg
# undef SYS_recvmsg
#endif /* IA64 */
#ifdef POWERPC
#if defined(POWERPC) || defined(S390) || defined(S390X)
# define SYS_socket_subcall 256
#else
# define SYS_socket_subcall 230
#endif
#endif /* (POWERPC || S390 || S390X) */
#define SYS_socket (SYS_socket_subcall + 1)
#define SYS_bind (SYS_socket_subcall + 2)
#define SYS_connect (SYS_socket_subcall + 3)
@ -192,11 +193,11 @@ int sys_shmat(), sys_shmdt(), sys_shmget(), sys_shmctl();
# undef SYS_shmget
# undef SYS_shmctl
# endif /* IA64 */
#ifdef POWERPC
#if defined(POWERPC) || defined(S390) || defined(S390X)
# define SYS_ipc_subcall ((SYS_socket_subcall)+(SYS_socket_nsubcalls))
#else
# define SYS_ipc_subcall 250
#endif
#endif /* (POWERPC || S390 || S390X) */
#define SYS_semop (SYS_ipc_subcall + 1)
#define SYS_semget (SYS_ipc_subcall + 2)
#define SYS_semctl (SYS_ipc_subcall + 3)

View File

@ -503,12 +503,10 @@ int new;
#elif defined(POWERPC)
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_R0), new) < 0)
return -1;
#elif defined(S390)
long pc;
if (upeek(tcp->pid, PT_PSWADDR,&pc)<0)
return -1;
if (ptrace(PTRACE_POKETEXT, tcp->pid, (char*)(pc-4), new)<0)
return -1;
#elif defined(S390) || defined(S390X)
/* s390 linux after 2.4.7 has a hook in entry.S to allow this */
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR2), new)<0)
return -1;
return 0;
#elif defined(M68K)
if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(4*PT_ORIG_D0), new)<0)
@ -598,6 +596,18 @@ setarg(tcp, argnum)
if (errno)
return -1;
}
#elif defined(S390) || defined(S390X)
{
if(argnum <= 5)
ptrace(PTRACE_POKEUSER, tcp->pid,
(char *) (argnum==0 ? PT_ORIGGPR2 :
PT_GPR2 + argnum*sizeof(long)),
tcp->u_arg[argnum]);
else
return -E2BIG;
if (errno)
return -1;
}
#else
# warning Sorry, setargs not implemented for this architecture.
#endif
@ -1769,7 +1779,7 @@ static
#endif /* !SUNOS4_KERNEL_ARCH_KLUDGE */
struct xlat struct_user_offsets[] = {
#ifdef LINUX
#ifdef S390
#if defined(S390) || defined(S390X)
{ PT_PSWMASK, "psw_mask" },
{ PT_PSWADDR, "psw_addr" },
{ PT_GPR0, "gpr0" },
@ -1806,6 +1816,7 @@ struct xlat struct_user_offsets[] = {
{ PT_ACR15, "acr15" },
{ PT_ORIGGPR2, "orig_gpr2" },
{ PT_FPC, "fpc" },
#if defined(S390)
{ PT_FPR0_HI, "fpr0.hi" },
{ PT_FPR0_LO, "fpr0.lo" },
{ PT_FPR1_HI, "fpr1.hi" },
@ -1838,9 +1849,29 @@ struct xlat struct_user_offsets[] = {
{ PT_FPR14_LO, "fpr14.lo" },
{ PT_FPR15_HI, "fpr15.hi" },
{ PT_FPR15_LO, "fpr15.lo" },
#endif
#if defined(S390X)
{ PT_FPR0, "fpr0" },
{ PT_FPR1, "fpr1" },
{ PT_FPR2, "fpr2" },
{ PT_FPR3, "fpr3" },
{ PT_FPR4, "fpr4" },
{ PT_FPR5, "fpr5" },
{ PT_FPR6, "fpr6" },
{ PT_FPR7, "fpr7" },
{ PT_FPR8, "fpr8" },
{ PT_FPR9, "fpr9" },
{ PT_FPR10, "fpr10" },
{ PT_FPR11, "fpr11" },
{ PT_FPR12, "fpr12" },
{ PT_FPR13, "fpr13" },
{ PT_FPR14, "fpr14" },
{ PT_FPR15, "fpr15" },
#endif
{ PT_CR_9, "cr9" },
{ PT_CR_10, "cr10" },
{ PT_CR_11, "cr11" },
{ PT_IEEE_IP, "ieee_exception_ip" },
#endif
#if defined(SPARC)
/* XXX No support for these offsets yet. */
@ -2147,7 +2178,7 @@ struct xlat struct_user_offsets[] = {
{ 4*REG_FPSCR, "4*REG_FPSCR" },
#endif /* SH */
#if !defined(S390) && !defined(MIPS)
#if !defined(S390) && !defined(S390X) && !defined(MIPS)
{ uoff(u_fpvalid), "offsetof(struct user, u_fpvalid)" },
#endif
#if defined(I386) || defined(X86_64)
@ -2163,11 +2194,11 @@ struct xlat struct_user_offsets[] = {
{ uoff(start_code), "offsetof(struct user, start_code)" },
{ uoff(start_stack), "offsetof(struct user, start_stack)" },
{ uoff(signal), "offsetof(struct user, signal)" },
#if !defined(S390) && !defined(MIPS) && !defined(SH)
#if !defined(S390) && !defined(S390X) && !defined(MIPS) && !defined(SH)
{ uoff(reserved), "offsetof(struct user, reserved)" },
#endif
{ uoff(u_ar0), "offsetof(struct user, u_ar0)" },
#if !defined(ARM) && !defined(MIPS) && !defined(S390)
#if !defined(ARM) && !defined(MIPS) && !defined(S390) && !defined(S390X)
{ uoff(u_fpstate), "offsetof(struct user, u_fpstate)" },
#endif
{ uoff(magic), "offsetof(struct user, magic)" },

View File

@ -1163,7 +1163,7 @@ int
sys_sigreturn(tcp)
struct tcb *tcp;
{
#ifdef S390
#if defined(S390) || defined(S390X)
long usp;
struct sigcontext_struct sc;
@ -1179,7 +1179,7 @@ struct tcb *tcp;
tcp->u_rval = tcp->u_error = 0;
if (tcp->u_arg[0] == 0)
return 0;
tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1]);
tcp->auxstr = sprintsigmask("mask now ",(sigset_t *)&tcp->u_arg[1],0);
return RVAL_NONE | RVAL_STR;
}
return 0;

View File

@ -1054,7 +1054,7 @@ int arg;
break;
#endif /* SI_GETUDATA */
default:
printstr(tcp, (int) si.ic_dp, si.ic_len);
printstr(tcp, (long) si.ic_dp, si.ic_len);
break;
}
if (exiting(tcp)) {

View File

@ -506,7 +506,8 @@ int subcall;
int nsubcalls;
enum subcall_style style;
{
int i, addr, mask, arg;
long addr, mask, arg;
int i;
switch (style) {
case shift_style:
@ -679,7 +680,7 @@ struct tcb *tcp;
#elif defined(MIPS)
static long a3;
static long r2;
#elif defined(S390)
#elif defined(S390) || defined(S390X)
static long gpr2;
static long pc;
#elif defined(HPPA)
@ -705,10 +706,10 @@ struct tcb *tcp;
#endif /* !PROCFS */
#ifdef LINUX
#if defined(S390)
if (upeek(tcp->pid,PT_PSWADDR,&pc) < 0)
#if defined(S390) || defined(S390X)
if (upeek(pid,PT_PSWADDR,&pc) < 0)
return -1;
scno = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)(pc-4),0);
scno = ptrace(PTRACE_PEEKTEXT, pid, (char *)(pc-sizeof(long)),0);
if (errno)
return -1;
scno&=0xFF;
@ -1098,7 +1099,7 @@ struct tcb *tcp;
fprintf(stderr, "stray syscall exit: rax = %ld\n", rax);
return 0;
}
#elif defined (S390)
#elif defined (S390) || defined (S390X)
if (upeek(pid, PT_GPR2, &gpr2) < 0)
return -1;
if (gpr2 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
@ -1154,7 +1155,7 @@ struct tcb *tcp;
{
int u_error = 0;
#ifdef LINUX
#ifdef S390
#if defined(S390) || defined(S390X)
if (gpr2 && (unsigned) -gpr2 < nerrnos) {
tcp->u_rval = -1;
u_error = -gpr2;
@ -1163,7 +1164,7 @@ struct tcb *tcp;
tcp->u_rval = gpr2;
u_error = 0;
}
#else /* !S390 */
#else /* !S390 && !S390X */
#ifdef I386
if (eax < 0 && -eax < nerrnos) {
tcp->u_rval = -1;
@ -1297,7 +1298,7 @@ struct tcb *tcp;
#endif /* IA64 */
#endif /* X86_64 */
#endif /* I386 */
#endif /* S390 */
#endif /* S390 || S390X */
#endif /* LINUX */
#ifdef SUNOS4
/* get error code from user struct */
@ -1381,7 +1382,7 @@ struct tcb *tcp;
int pid = tcp->pid;
#endif /* !USE_PROCFS */
#ifdef LINUX
#if defined(S390)
#if defined(S390) || defined(S390X)
{
int i;
if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
@ -1389,7 +1390,7 @@ struct tcb *tcp;
else
tcp->u_nargs = MAX_ARGS;
for (i = 0; i < tcp->u_nargs; i++) {
if (upeek(pid,i==0 ? PT_ORIGGPR2:PT_GPR2+(i<<2), &tcp->u_arg[i]) < 0)
if (upeek(pid,i==0 ? PT_ORIGGPR2:PT_GPR2+i*sizeof(long), &tcp->u_arg[i]) < 0)
return -1;
}
}

7
util.c
View File

@ -955,8 +955,9 @@ struct tcb *tcp;
if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)&regs,0) < 0)
return -1;
pc = regs.r_pc;
#elif defined(S390)
#elif defined(S390) || defined(S390X)
if(upeek(tcp->pid,PT_PSWADDR,&pc) < 0)
return -1;
#elif defined(HPPA)
if(upeek(tcp->pid,PT_IAOQ0,&pc) < 0)
return -1;
@ -1239,6 +1240,8 @@ struct tcb *tcp;
#define LOOP 0x1000ffff
#elif defined(S390)
#define LOOP 0xa7f40000 /* BRC 15,0 */
#elif defined(S390X)
#define LOOP 0xa7f4000000000000UL /* BRC 15,0 */
#elif defined(HPPA)
#define LOOP 0xe81f1ff7 /* b,l,n <loc>,r0 */
#elif defined(SH)
@ -1273,7 +1276,7 @@ struct tcb *tcp;
#elif defined (POWERPC)
if (upeek(tcp->pid, 4*PT_NIP, &tcp->baddr) < 0)
return -1;
#elif defined(S390)
#elif defined(S390) || defined(S390X)
if (upeek(tcp->pid,PT_PSWADDR, &tcp->baddr) < 0)
return -1;
#elif defined(HPPA)