Support for the OpenRISC 1000 platform.

Denys Vlasenko dvlasenk at redhat.com
Tue Feb 12 11:13:52 UTC 2013


On 02/11/2013 09:37 PM, Christian Svensson wrote:
> The following patch adds support for the or1k architecture.
> This architecture has been in mainline Linux since 3.1.
> 
> Feel free to give harsh feedback and other comments :-).
> 
> Support for the OpenRISC 1000 platform.
> 
>     * configure.ac: Added or1k.
>     * defs.h: Added or1k to use _regs system.
>     * linux/or1k/ioctlent.h.in: Use i386 ioctls.
>     * linux/or1k/syscallent.h: New.
>     * process.c: Added or1k.
>     * syscall.c: Added or1k handlers.
>       (or1k_io) iovec for or1k GETREGSET.
>       (or1k_regs) regset structure for or1k.
>     * util.c: Added or1k handler for change_syscall.
> ---
>  configure.ac             |    5 +
>  defs.h                   |    8 +-
>  linux/or1k/ioctlent.h.in |    1 +
>  linux/or1k/syscallent.h  | 1080 ++++++++++++++++++++++++++++++++++++++++++++++
>  process.c                |   41 +-
>  syscall.c                |   34 +-
>  util.c                   |    6 +
>  7 files changed, 1170 insertions(+), 5 deletions(-)
>  create mode 100644 linux/or1k/ioctlent.h.in
>  create mode 100644 linux/or1k/syscallent.h
> 
> diff --git a/configure.ac b/configure.ac
> index 80be383..8703f7c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -111,6 +111,11 @@ microblaze*)
>  	arch=microblaze
>  	AC_DEFINE([MICROBLAZE], 1, [Define for the MicroBlaze architecture.])
>  	;;
> +or1k*)
> +	arch=or1k
> +	AC_DEFINE([OR1K], 1, [Define for the OpenRISC 1000 architecture.])
> +	;;
> +
>  *)
>  	AC_MSG_RESULT([NO!])
>  	AC_MSG_ERROR([architecture $host_cpu is not supported by strace])
> diff --git a/defs.h b/defs.h
> index 9756179..bfa765e 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -375,6 +375,12 @@ extern struct pt_regs arm_regs;
>  #if defined(TILE)
>  extern struct pt_regs tile_regs;
>  #endif
> +#if defined(OR1K)
> +extern struct user_regs_struct or1k_regs;
> +extern struct iovec or1k_io;
> +#endif

Do you need to expose or1k_io as extern?


> +	{  1, 	TD, 	sys_syncfs, 			"syncfs"		}, /* 267 */
> +	{  2, 	TD, 	sys_setns, 			"setns"			}, /* 268 */
> +	{  4, 	TN, 	sys_sendmmsg, 			"sendmmsg"		}, /* 269 */
> +	{  6, 	0, 	sys_process_vm_readv, 		"process_vm_readv"	}, /* 270 */
> +	{  6, 	0, 	sys_process_vm_writev, 		"process_vm_writev"	}, /* 271 */
> +	{ MA, 	0, 	NULL, 				NULL 			}, /* 272 (unused) */
> +	{ MA, 	0, 	NULL, 				NULL 			}, /* 273 (unused) */
...
> +	{ MA, 	0, 	NULL, 				NULL 			}, /* 1023 (unused) */

Collapse this hige block with "[a ... b] = { foo }" notation.


> -#if defined(AARCH64)
> +#if defined(AARCH64) || defined(OR1K)
>  # include <asm/ptrace.h>
> -# include <sys/uio.h>
>  # include <elf.h>
>  #endif

Do not share #define blocks with other arch. Create your own.

> +#elif defined(OR1K)
> +struct user_regs_struct or1k_regs;
> +struct iovec or1k_io = {
> +	.iov_base = &or1k_regs,
> +	.iov_len = sizeof(or1k_regs)
> +};

iov_len is kernel-writable field for GETREGSET.
Please reinitialize it before every new call.


> @@ -1291,6 +1291,12 @@ change_syscall(struct tcb *tcp, arg_setup_state
> *state, int new)
>  	if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new) < 0)
>  		return -1;
>  	return 0;
> +#elif defined(OR1K)
> +	if (ptrace(PTRACE_GETREGSET, tcp->pid, (void*)1, (long)&or1k_regs) < 0)
> +		return -1;
> +	or1k_regs.gpr[11] = new;
> +	if (ptrace(PTRACE_SETREGSET, tcp->pid, (void*)1, (long)&or1k_regs) < 0)
> +		return -1;
>  #else
>  #warning Do not know how to handle change_syscall for this architecture
>  #endif /* architecture */

We will never reach this code: kernels new enough to support OR1K
won't require fork/clone hacks (change_syscall is part of those).
Replace this code by a comment

	/* never reached; OR1K is only supported by kernels since M.N.K. */

-- 
vda




More information about the Strace-devel mailing list