Support for the OpenRISC 1000 platform.

Christian Svensson blue at cmd.nu
Tue Feb 12 11:32:21 UTC 2013


>> @@ -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?

I had some vague reason for this since it was used in util.c in
change_syscall, but since that is deprecated code it's no longer
necessary.

>
>
>> +     {  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.

Will do, see comments at end of email as well.
>
>
>> -#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.

Ok.

>
>> +#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.

Ok.

>
>
>> @@ -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. */

Ok.

Thanks a lot for the feedback! I will submit a new patch with these
things fixed.

I talked with Jonas Bronn about this the syscall system a bit.
The arches tile, aarch64 and or1k uses the newer kernel interface
where the numbers are the same.
The number of arches which uses this scheme will probably not go down :-).

So, what about introducing a linux/syscallent.h that holds all
syscalls that are shared?

I did a mock-up:

/* Generic syscall for newer architectures */

#if !defined(__GENERIC_SYSCALL_1)
#define __GENERIC_SYSCALL_1
        { 2,    0,      sys_io_setup,                   "io_setup"
                 }, /*    0 */
        { 1,    0,      sys_io_destroy,                 "io_destroy"
                 }, /*    1 */
..
        { 4,    TN,     sys_accept4,                    "accept4"
                 }, /*  242 */
        { 5,    TN,     sys_recvmmsg,                   "recvmmsg"
                 }, /*  243 */
#elif !defined(__GENERIC_SYSCALL_2)
#define __GENERIC_SYSCALL_2
        { 4,    TP,     sys_wait4,                      "wait4"
                 }, /*  260 */
        { 4,    0,      sys_prlimit64,                  "prlimit64"
                 }, /*  261 */
..
        { 4,    TN,     sys_sendmmsg,                   "sendmmsg"
                 }, /*  269 */
#ifdef USE_PROCESS_VM
        { 6,    0,      sys_process_vm_readv,
"process_vm_readv"              }, /*  270 */
        { 6,    0,      sys_process_vm_writev,
"process_vm_writev"             }, /*  271 */
#else
        { },
        { },
#endif
#elif !defined(__GENERIC_SYSCALL_DEPRECATED)
#define __GENERIC_SYSCALL_DEPRECATED
        /* Quote from asm-generic/unistd.h:
         *
         * All syscalls below here should go away really,
         * these are provided for both review and as a porting
         * help for the C library version.
         *
         */
        { 3,    TD|TF,  sys_open,                       "open"
                 }, /* 1024 */
        { 2,    TF,     sys_link,                       "link"
                 }, /* 1025 */
...
        { 1,    0,      sys_sysctl,                     "sysctl"
                 }, /* 1078 */
        { 0,    TP,     sys_fork,                       "fork"
                 }, /* 1079 */
#endif

which will then reduce syscallent.h for openrisc to:

#include "../syscallent.h"

	/* Arch-specific block */
	{ 4,	0,	sys_or1k_atomic,		"or1k_atomic"		}, /* 244 */
	[245 ... 259] = { },

#include "../syscallent.h"

(Maybe it's too magical to include the same file twice?)

What do you think?

Regards,
Christian




More information about the Strace-devel mailing list