Chromium Code Reviews| Index: sandbox/linux/seccomp-bpf/linux_seccomp.h |
| diff --git a/sandbox/linux/seccomp-bpf/linux_seccomp.h b/sandbox/linux/seccomp-bpf/linux_seccomp.h |
| index 0de0259da39ecdb745e5923b9a6ff3961c13be00..7a17ebf71a0c5551fbb60957bc2a30ee03669f60 100644 |
| --- a/sandbox/linux/seccomp-bpf/linux_seccomp.h |
| +++ b/sandbox/linux/seccomp-bpf/linux_seccomp.h |
| @@ -26,6 +26,9 @@ |
| #ifndef EM_X86_64 |
| #define EM_X86_64 62 |
| #endif |
| +#ifndef EM_MIPS |
| +#define EM_MIPS 8 |
| +#endif |
| #ifndef __AUDIT_ARCH_64BIT |
| #define __AUDIT_ARCH_64BIT 0x80000000 |
| @@ -42,6 +45,9 @@ |
| #ifndef AUDIT_ARCH_X86_64 |
| #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
| #endif |
| +#ifndef AUDIT_ARCH_MIPSEL |
| +#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE) |
| +#endif |
| // For prctl.h |
| #ifndef PR_SET_SECCOMP |
| @@ -189,6 +195,40 @@ |
| #define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
| 8*(nr) + 0) |
| +#elif defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32) |
| +#define MIN_SYSCALL __NR_O32_Linux |
| +#define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_Linux_syscalls) |
| +#define MAX_SYSCALL MAX_PUBLIC_SYSCALL |
| +#define SECCOMP_ARCH AUDIT_ARCH_MIPSEL |
| + |
| +// MIPS sigcontext_t is different from i386/x86_64 and ARM. |
| +// See </arch/mips/include/uapi/asm/sigcontext.h> in the Linux kernel. |
| +#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.gregs[_reg]) |
| +// Based on MIPS o32 ABI syscall convention. |
| +// On MIPS, when indirect syscall is being made (syscall(__NR_foo)), |
| +// real identificator (__NR_foo) is not in v0, but in a0 |
| +#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 2) |
| +#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 2) |
| +#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.pc |
| +#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 4) |
| +#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 5) |
| +#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 6) |
| +#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 7) |
| +// Only the first 4 arguments of syscall are in registers. |
| +// The rest are on the stack. |
| +#define SECCOMP_PARM5(_ctx) (long int)(*((intptr_t*)SECCOMP_REG(_ctx, 29)+4)) |
|
jln (very slow on Chromium)
2014/05/02 20:42:04
Nit: wrap
nedeljko
2014/05/07 15:40:05
Done.
|
| +#define SECCOMP_PARM6(_ctx) (long int)(*((intptr_t*)SECCOMP_REG(_ctx, 29)+5)) |
|
jln (very slow on Chromium)
2014/05/02 20:42:04
Nit: wrap
nedeljko
2014/05/07 15:40:05
Done.
|
| +#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) |
| +#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) |
| +#define SECCOMP_IP_MSB_IDX (offsetof(struct arch_seccomp_data, \ |
| + instruction_pointer) + 4) |
| +#define SECCOMP_IP_LSB_IDX (offsetof(struct arch_seccomp_data, \ |
| + instruction_pointer) + 0) |
| +#define SECCOMP_ARG_MSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
| + 8*(nr) + 4) |
| +#define SECCOMP_ARG_LSB_IDX(nr) (offsetof(struct arch_seccomp_data, args) + \ |
| + 8*(nr) + 0) |
| + |
| #else |
| #error Unsupported target platform |