Chromium Code Reviews| Index: tests/syscall_return_sandboxing/sandboxed_mips.S |
| diff --git a/tests/syscall_return_sandboxing/sandboxed_mips.S b/tests/syscall_return_sandboxing/sandboxed_mips.S |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff2882115fffb8112ff23290b0df44a0a1fd8c4c |
| --- /dev/null |
| +++ b/tests/syscall_return_sandboxing/sandboxed_mips.S |
| @@ -0,0 +1,68 @@ |
| +/* |
| + * Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +/* |
| + * Assume 32-byte trampoline slots, 16-byte bundles. |
| + */ |
| +#define GETTIMEOFDAY_ADDR 0x10500 |
| +#define STORE_MASK $t7 |
| +#define JUMP_MASK $t6 |
| +#define BREAK_INST .word 0xd |
| + |
| + .data |
| +timebuf: |
| + .space 0x200 /* enough for a timeval */ |
| + .text |
| + .globl SyscallReturnIsSandboxed |
| +SyscallReturnIsSandboxed: |
| + .set noreorder |
| + |
| + addiu $sp, $sp, -24 |
| + and $sp, $sp, STORE_MASK |
| + sw $ra, 20($sp) |
| + lui $a0, %hi(timebuf) |
| + |
| + addiu $a0, $a0, %lo(timebuf) |
| + addu $a1, $zero, $zero |
| + lui $ra, %hi(bad) |
| + addiu $ra, $ra, %lo(bad) |
| + |
| + lui $a2, %hi(GETTIMEOFDAY_ADDR) |
| + addiu $a2, $a2, %lo(GETTIMEOFDAY_ADDR) |
| + and $a2, $a2, JUMP_MASK |
| + jr $a2 |
| + |
| + nop |
|
Mark Seaborn
2013/03/12 21:55:24
FWIW, adding in ".p2align 4" as well makes this mo
|
| + nop |
| + nop |
| + nop |
| + |
| + /* Expected return address */ |
| + b done |
| + nop |
| + /* |
| + * We don't expect the syscall to return to the following unaligned |
| + * address or to align up to the bundle boundary after it. |
| + */ |
| +bad: |
| + BREAK_INST /* Abort */ |
| + BREAK_INST |
| + |
| + BREAK_INST |
| + BREAK_INST |
| + BREAK_INST |
| + BREAK_INST |
| + |
| +done: |
| + ori $v0, $zero, 1 /* Indicate success */ |
| + lw $ra, 20($sp) |
| + addiu $sp, $sp, 24 |
| + and $sp, $sp, STORE_MASK |
| + |
| + and $ra, $ra, JUMP_MASK |
| + jr $ra |
| + nop |
| + |