| Index: src/trusted/validator_mips/testdata/test_sp_updates.S
|
| diff --git a/src/trusted/validator_mips/testdata/test_sp_updates.S b/src/trusted/validator_mips/testdata/test_sp_updates.S
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8151ef3b1c829e349a70223564d6e7ddfa0e7298
|
| --- /dev/null
|
| +++ b/src/trusted/validator_mips/testdata/test_sp_updates.S
|
| @@ -0,0 +1,86 @@
|
| +# Copyright 2012 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.
|
| +# Copyright 2012 MIPS Technologies / RT-RK.
|
| +
|
| +#
|
| +# Tests both legal and illegal variations on SP updates.
|
| +#
|
| +
|
| +
|
| +
|
| +.globl _start
|
| +_start:
|
| +.align 4
|
| +.set noreorder
|
| +.set STORE_MASK,$t7
|
| +
|
| +bundle_sp_dest_reg:
|
| + addiu $sp, $sp, 64 #error, b/c no mask after
|
| + and $sp, $a0, $a1 #error, b/c no mask after
|
| + mfhi $sp #error, b/c no mask after
|
| + clo $sp, $a2 #error, b/c no mask after
|
| + ins $sp, $s3, 2, 10 #error, b/c no mask after
|
| + lui $sp, 0x1f #error, b/c no mask after
|
| + mfc1 $sp, $f12 #error, b/c no mask after
|
| + mfhc1 $sp, $f10 #error, b/c no mask after
|
| + mflo $sp #error, b/c no mask after
|
| + movn $sp, $v0, $v1 #error, b/c no mask after
|
| + movt $sp, $s4, $fcc4 #error, b/c no mask after
|
| + mul $sp, $s0, $s1 #error, b/c no mask after
|
| +
|
| +#modify sp w/ lw;
|
| +bundle_load_into_sp:
|
| + lw $sp, 16($a0) #error, b/c no mask after
|
| + nop
|
| + lw $sp, 16($a0)
|
| + and $sp, $sp, STORE_MASK #error
|
| +
|
| +bundle_mask_doesnt_need_mask:
|
| +#ok
|
| + nop
|
| + and $sp, $sp, STORE_MASK
|
| + nop
|
| + nop
|
| +
|
| +# a few instructions where sp is
|
| +# 1st operand, but don't alter it
|
| +
|
| +bundle_sp_not_altered:
|
| + mthi $sp #ok
|
| + mult $sp, $t9 #ok
|
| + nop
|
| + nop
|
| +
|
| +bundle_jalr_sp_t9:
|
| +#this should be allowed, b/c $sp will still be in the untrusted area
|
| + nop
|
| + and $t9, $t9, $t6
|
| + jalr $sp, $t9 #error
|
| + nop
|
| +
|
| +bundle_chk_delay_slot:
|
| + b bundle_chk_cross_1
|
| + addiu $sp, $sp, -32 #error
|
| + and $sp, $sp, STORE_MASK
|
| + nop
|
| +
|
| +bundle_chk_cross_1:
|
| + nop
|
| + nop
|
| + nop
|
| + addiu $sp, $sp, -32 #ok
|
| +
|
| +bundle_chk_cross_2:
|
| + and $sp, $sp, STORE_MASK
|
| + nop
|
| + nop
|
| + nop
|
| +
|
| +bundle_ok:
|
| + add $sp, $sp, 64 #ok
|
| + and $sp, $sp, STORE_MASK
|
| + sub $sp, $sp, 56 #ok
|
| + and $sp, $sp, STORE_MASK
|
| +
|
| +end_of_code:
|
|
|