diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2020-03-29 22:50:54 +0000 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2020-03-30 23:14:24 +0200 |
commit | e948229914d830f51175e39520f84468577c925f (patch) | |
tree | ec656e8d7b0d5037a7353dc1e019088d1f71ae91 | |
parent | 68aef4378160b6bda355803a7df9bd60972e65d3 (diff) | |
download | strace-e948229914d830f51175e39520f84468577c925f.tar.gz |
sh64: switch to PTRACE_GETREGS API
Implement PTRACE_GETREGS API introduced on sh64 by Linux kernel commit
v2.6.28-rc1~99^2~56.
* configure.ac [sh64]: Remove arch_enable_Werror=no.
* linux/sh64/arch_regs.h: Remove.
* linux/sh64/get_syscall_result.c: Likewise.
* Makefile.am (EXTRA_DIST): Remove them.
* linux/sh64/arch_regs.c (sh64_regs): New variable.
(ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros.
(sh64_r9, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove.
* linux/sh64/get_error.c (arch_get_error): Use sh64_regs.regs[9].
* linux/sh64/get_scno.c (arch_get_scno): Use sh64_regs.regs[9].
* linux/sh64/get_syscall_args.c (arch_get_syscall_args): Use sh64_regs.regs.
* linux/sh64/set_error.c (arch_set_error, arch_set_success): Use
sh64_regs.gr[9].
* linux/sh64/set_scno.c (arch_set_scno): Use sh64_regs.regs[9].
* NEWS: Mention this change.
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | linux/sh64/arch_regs.c | 7 | ||||
-rw-r--r-- | linux/sh64/arch_regs.h | 22 | ||||
-rw-r--r-- | linux/sh64/get_error.c | 6 | ||||
-rw-r--r-- | linux/sh64/get_scno.c | 4 | ||||
-rw-r--r-- | linux/sh64/get_syscall_args.c | 10 | ||||
-rw-r--r-- | linux/sh64/get_syscall_result.c | 13 | ||||
-rw-r--r-- | linux/sh64/set_error.c | 8 | ||||
-rw-r--r-- | linux/sh64/set_scno.c | 5 |
11 files changed, 20 insertions, 62 deletions
diff --git a/Makefile.am b/Makefile.am index 4fd612465..54d7ff679 100644 --- a/Makefile.am +++ b/Makefile.am @@ -809,11 +809,9 @@ EXTRA_DIST = \ linux/sh/userent0.h \ linux/sh64/arch_defs_.h \ linux/sh64/arch_regs.c \ - linux/sh64/arch_regs.h \ linux/sh64/get_error.c \ linux/sh64/get_scno.c \ linux/sh64/get_syscall_args.c \ - linux/sh64/get_syscall_result.c \ linux/sh64/ioctls_arch0.h \ linux/sh64/ioctls_inc0.h \ linux/sh64/raw_syscall.h \ @@ -13,7 +13,7 @@ Noteworthy changes in release ?.? (????-??-??) * Ability to set precision for the absolute timestamp, relative timestamp, and syscall time output (using --absolute-timestamps, --relative-timestamps, and --syscall-times options, respectively). - * Implemented PTRACE_GETREGS API support on hppa and sh. + * Implemented PTRACE_GETREGS API support on hppa, sh, and sh64. * Enhanced decoding of BPF_MAP_CREATE and BPF_PROG_ATTACH bpf syscall commands. * Updated lists of BPF_* constants. @@ -23,7 +23,7 @@ Noteworthy changes in release ?.? (????-??-??) * Portability * On hppa, linux kernel >= 4.7 is required. - On sh, linux kernel >= 2.6.28 is required. + On sh and sh64, linux kernel >= 2.6.28 is required. Older versions without a decent PTRACE_GETREGS support will not work. Noteworthy changes in release 5.5 (2020-02-06) diff --git a/configure.ac b/configure.ac index 846529790..4ca867c40 100644 --- a/configure.ac +++ b/configure.ac @@ -164,7 +164,6 @@ s390x) ;; sh64*) arch=sh64 - arch_enable_Werror=no AC_DEFINE([SH64], 1, [Define for the SH64 architecture.]) ;; sh*) diff --git a/linux/sh64/arch_regs.c b/linux/sh64/arch_regs.c index 9b3d4eb3b..06f8a2ea5 100644 --- a/linux/sh64/arch_regs.c +++ b/linux/sh64/arch_regs.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later */ -static unsigned long sh64_r9; -#define ARCH_PC_PEEK_ADDR REG_PC -#define ARCH_SP_PEEK_ADDR REG_GENERAL(15) +static struct pt_regs sh64_regs; +#define ARCH_REGS_FOR_GETREGS sh64_regs +#define ARCH_PC_REG sh64_regs.pc +#define ARCH_SP_REG sh64_regs.regs[15] diff --git a/linux/sh64/arch_regs.h b/linux/sh64/arch_regs.h deleted file mode 100644 index 5bf759d64..000000000 --- a/linux/sh64/arch_regs.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2015-2018 The strace developers. - * All rights reserved. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -/* SH64 Linux - this code assumes the following kernel API for system calls: - PC Offset 0 - System Call Offset 16 (actually, (syscall no.) | (0x1n << 16), - where n = no. of parameters. - Other regs Offset 24+ - - On entry: R2-7 = parameters 1-6 (as many as necessary) - On return: R9 = result. -*/ - -/* Offset for peeks of registers */ -#define REG_OFFSET (24) -#define REG_GENERAL(x) (8*(x)+REG_OFFSET) -#define REG_PC (0*8) -#define REG_SYSCALL (2*8) diff --git a/linux/sh64/get_error.c b/linux/sh64/get_error.c index 795031c95..ac1ae3fab 100644 --- a/linux/sh64/get_error.c +++ b/linux/sh64/get_error.c @@ -10,10 +10,10 @@ static void arch_get_error(struct tcb *tcp, const bool check_errno) { - if (check_errno && is_negated_errno(sh64_r9)) { + if (check_errno && is_negated_errno(sh64_regs.regs[9])) { tcp->u_rval = -1; - tcp->u_error = -sh64_r9; + tcp->u_error = -sh64_regs.regs[9]; } else { - tcp->u_rval = sh64_r9; + tcp->u_rval = sh64_regs.regs[9]; } } diff --git a/linux/sh64/get_scno.c b/linux/sh64/get_scno.c index c85786bd7..cff360d6e 100644 --- a/linux/sh64/get_scno.c +++ b/linux/sh64/get_scno.c @@ -9,8 +9,6 @@ static int arch_get_scno(struct tcb *tcp) { - if (upeek(tcp, REG_SYSCALL, &tcp->scno) < 0) - return -1; - tcp->scno &= 0xffff; + tcp->scno = sh64_regs.regs[9]; return 1; } diff --git a/linux/sh64/get_syscall_args.c b/linux/sh64/get_syscall_args.c index 4b53e20ea..d5fc9f6e6 100644 --- a/linux/sh64/get_syscall_args.c +++ b/linux/sh64/get_syscall_args.c @@ -9,13 +9,7 @@ static int arch_get_syscall_args(struct tcb *tcp) { - /* Registers used by SH5 Linux system calls for parameters */ - static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 }; - unsigned int i; - - for (i = 0; i < n_args(tcp); ++i) - if (upeek(tcp, REG_GENERAL(syscall_regs[i]), - &tcp->u_arg[i]) < 0) - return -1; + for (unsigned int i = 0; i < n_args(tcp); ++i) + tcp->u_arg[i] = sh64_regs.regs[i + 2]; return 1; } diff --git a/linux/sh64/get_syscall_result.c b/linux/sh64/get_syscall_result.c deleted file mode 100644 index 1183f6873..000000000 --- a/linux/sh64/get_syscall_result.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2015-2018 The strace developers. - * All rights reserved. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -static int -get_syscall_result_regs(struct tcb *tcp) -{ - /* ABI defines result returned in r9 */ - return upeek(tcp, REG_GENERAL(9), &sh64_r9) < 0 ? -1 : 0; -} diff --git a/linux/sh64/set_error.c b/linux/sh64/set_error.c index 4a9835718..eee443bdd 100644 --- a/linux/sh64/set_error.c +++ b/linux/sh64/set_error.c @@ -8,13 +8,13 @@ static int arch_set_error(struct tcb *tcp) { - sh64_r9 = -tcp->u_error; - return upoke(tcp, REG_GENERAL(9), sh64_r9); + sh64_regs.regs[9] = -tcp->u_error; + return set_regs(tcp->pid); } static int arch_set_success(struct tcb *tcp) { - sh64_r9 = tcp->u_rval; - return upoke(tcp, REG_GENERAL(9), sh64_r9); + sh64_regs.regs[9] = tcp->u_rval; + return set_regs(tcp->pid); } diff --git a/linux/sh64/set_scno.c b/linux/sh64/set_scno.c index f7e0fdfa5..101e03f8e 100644 --- a/linux/sh64/set_scno.c +++ b/linux/sh64/set_scno.c @@ -8,5 +8,8 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp, REG_SYSCALL, scno); + if (ptrace_syscall_info_is_valid() && get_regs(tcp) < 0) + return -1; + sh64_regs.regs[9] = scno; + return set_regs(tcp->pid); } |