2004-07-07 David S. Miller <davem@nuts.davemloft.net>
* linux/sparc/syscallent.h: Sync with reality.
* linux/sparc/syscall.h (sys_sendfile64, sys_futex, sys_gettid,
sys_sched_setaffinity, sys_sched_getaffinity, sys_setxattr,
sys_lsetxattr, sys_fsetxattr, sys_getxattr, sys_lgetxattr,
sys_fgetxattr, sys_listxattr, sys_llistxattr, sys_flistxattr,
sys_removexattr, sys_lremovexattr, sys_fremovexattr,
sys_remap_file_pages, sys_readahead, sys_tgkill, sys_statfs64,
sys_fstatfs64, sys_clock_settime, sys_clock_gettime,
sys_clock_getres, sys_clock_nanosleep, sys_timer_create,
sys_timer_settime, sys_timer_gettime): New declarations.
* linux/sparc64/dummy2.h, linux/sparc64/syscallent2.h,
linux/sparc64/syscall.h, linux/sparc64/errnoent.h,
linux/sparc64/errnoent1.h, linux/sparc64/errnoent2.h,
linux/sparc64/ioctlent.h, linux/sparc64/ioctlent1.h,
linux/sparc64/ioctlent2.h, linux/sparc64/signalent.h,
linux/sparc64/signalent.h, linux/sparc64/signalent.h,
linux/sparc64/signalent1.h, linux/sparc64/signalent2.h,
linux/sparc64/syscall1.h, linux/sparc64/syscallent.h,
linux/sparc64/syscallent1.h: New files.
* defs.h (LINUXSPARC): Define also when SPARC64.
(LINUX && SPARC64): Set SUPPORTED_PERSONALITIES to 3.
Ignore SIGTRAP after execve by defining TCB_WAITEXECVE.
Define possibly missing __NR_exit_group. Declare getrval2.
* configure.ac (sparc64): New architecture case.
* config.h.in (SPARC64): New define.
* file.c (stat_sparc64): New structure.
(printstat_sparc64): New output routine for that.
(printstat): Call it, if personality is 2.
(printstat64): Likewise.
* util.c: Conditionalize ptrace defines on LINUXSPARC
not LINUX && SPARC.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(_hack_syscall5): Correct trap number when SPARC64.
(PTRACE_WRITE{TEXT,DATA}): Add SPARC64 to ifdef guard.
(getpc): Handle SPARC64 && LINUX.
(printcall): Likewise.
(arg fetching/setting): Use same code for SPARC64 LINUX
as for SPARC.
(setbpt): Handle SPARC64 && LINUX.
(clearbpt): Likewise.
* signal.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(m_siginfo): Use same definition on SPARC64 as SPARC.
(sys_sigreturn): Handle LINUX && SPARC64.
* syscall.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(getscno): Use same static state on SPARC64 as SPARC,
and add SPARC64 handling.
(get_error): Handle LINUX && SPARC64.
(force_result): Likewise.
(syscall_enter): Likewise.
(trace_syscall): Handle sys_socketcall and sys_ipc on SPARC64
just like SPARC.
(getrval2): Handle LINUX && SPARC64.
* process.c: Conditionalize ptrace defines on SPARC and
SPARC64.
(SPARC64 && LINUX): Define r_pc to r_tpc, and PTRACE_FOOREGS
to PTRACE_FOOREGS64 so that more sparc code can be shared
between 64-bit and 32-bit.
(change_syscall): Handle LINUX && SPARC64.
(struct_user_offsets): Ifdef out those which do not exist
on SPARC64.
* net.c (sys_pipe): Handle LINUX && SPARC64.
* ioctl.c: Fix initializer typo for nioctlents2, was
nioctlents1 by accident.
diff --git a/util.c b/util.c
index d4cc290..68b0f7d 100644
--- a/util.c
+++ b/util.c
@@ -78,7 +78,7 @@
#include <sys/utsname.h>
#endif /* SUNOS4_KERNEL_ARCH_KLUDGE */
-#if defined(LINUX) && defined(SPARC)
+#if defined(LINUXSPARC)
# define fpq kernel_fpq
# define fq kernel_fq
@@ -88,6 +88,14 @@
# undef fq
# undef fpu
+#if defined (SPARC64)
+# define r_pc r_tpc
+# undef PTRACE_GETREGS
+# define PTRACE_GETREGS PTRACE_GETREGS64
+# undef PTRACE_SETREGS
+# define PTRACE_SETREGS PTRACE_SETREGS64
+#endif /* SPARC64 */
+
#if !defined(__GLIBC__)
#include <linux/unistd.h>
@@ -104,7 +112,11 @@
"or %%g0, %4, %%o3\n\t" \
"or %%g0, %5, %%o4\n\t" \
"or %%g0, %6, %%g1\n\t" \
+#if defined (SPARC64)
+ "t 0x6d\n\t" \
+#else
"t 0x10\n\t" \
+#endif
"bcc 1f\n\t" \
"or %%g0, %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
@@ -800,10 +812,10 @@
}
#ifdef LINUX
-#ifndef SPARC
+#if !defined (SPARC) && !defined(SPARC64)
#define PTRACE_WRITETEXT 101
#define PTRACE_WRITEDATA 102
-#endif /* !SPARC */
+#endif /* !SPARC && !SPARC64 */
#endif /* LINUX */
#ifdef SUNOS4
@@ -977,7 +989,7 @@
#elif defined(MIPS)
if (upeek(tcp->pid, REG_EPC, &pc) < 0)
return -1;
-#elif defined(SPARC)
+#elif defined(SPARC) || defined(SPARC64)
struct regs regs;
if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)®s,0) < 0)
return -1;
@@ -1078,7 +1090,7 @@
return;
}
tprintf("[%08lx] ", pc);
-#elif defined(SPARC)
+#elif defined(SPARC) || defined(SPARC64)
struct regs regs;
if (ptrace(PTRACE_GETREGS,tcp->pid,(char *)®s,0) < 0) {
tprintf("[????????] ");
@@ -1254,7 +1266,7 @@
return errno ? -1 : 0;
}
-#elif defined (SPARC)
+#elif defined (SPARC) || defined (SPARC64)
typedef struct regs arg_setup_state;
@@ -1426,10 +1438,11 @@
{
#ifdef LINUX
-#ifdef SPARC
+#if defined (SPARC) || defined (SPARC64)
/* We simply use the SunOS breakpoint code. */
struct regs regs;
+ unsigned long inst;
#define LOOPA 0x30800000 /* ba,a 0 */
if (tcp->flags & TCB_BPTSET) {
@@ -1459,14 +1472,19 @@
* Of cause, if we evaporate ourselves in the middle of all this...
*/
errno = 0;
- ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, LOOPA);
+ inst = LOOPA;
+#if defined (SPARC64)
+ inst <<= 32;
+ inst |= (tcp->inst[0] & 0xffffffffUL);
+#endif
+ ptrace(PTRACE_POKETEXT, tcp->pid, (char *) tcp->baddr, inst);
if(errno) {
perror("setbpt: ptrace(PTRACE_POKETEXT, ...)");
return -1;
}
tcp->flags |= TCB_BPTSET;
-#else /* !SPARC */
+#else /* !SPARC && !SPARC64 */
#ifdef IA64
if (ia32) {
# define LOOP 0x0000feeb
@@ -1615,7 +1633,7 @@
tcp->flags |= TCB_BPTSET;
#endif /* !IA64 */
-#endif /* SPARC */
+#endif /* SPARC || SPARC64 */
#endif /* LINUX */
#ifdef SUNOS4
@@ -1690,7 +1708,7 @@
long pc;
#endif /* architecture */
-#ifdef SPARC
+#if defined (SPARC) || defined (SPARC64)
/* Again, we borrow the SunOS breakpoint code. */
if (!(tcp->flags & TCB_BPTSET)) {
fprintf(stderr, "PANIC: TCB not set in pid %u\n", tcp->pid);
@@ -1770,7 +1788,7 @@
return 0;
}
}
-#else /* !IA64 && ! SPARC */
+#else /* !IA64 && !SPARC && !SPARC64 */
if (debug)
fprintf(stderr, "[%d] clearing bpt\n", tcp->pid);
@@ -1868,7 +1886,7 @@
}
#endif /* arch */
-#endif /* !SPARC && !IA64 */
+#endif /* !SPARC && !SPARC64 && !IA64 */
#endif /* LINUX */
#ifdef SUNOS4