Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: src/trusted/validator_mips/testdata/test_tp_access.S

Issue 1535443005: [MIPS] Make validator allow only two load patterns via $t8 (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/validator_mips/testdata/test_tp_access.S
diff --git a/src/trusted/validator_mips/testdata/test_tp_access.S b/src/trusted/validator_mips/testdata/test_tp_access.S
new file mode 100644
index 0000000000000000000000000000000000000000..60b418a7f90ca8b0f2a33c10df231188fd5aa6ab
--- /dev/null
+++ b/src/trusted/validator_mips/testdata/test_tp_access.S
@@ -0,0 +1,72 @@
+# Copyright 2015 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.
+
+# Several test cases are implemented in this file:
+# 1. Test if regular way to access thread pointers is allowed.
+# 2. Test different random examples of forbidden stores through $t8.
+# 3. Test different random examples of forbidden loads through $t8.
+
+
+ .align 4
Mark Seaborn 2015/12/27 03:46:35 Nit: can you use a consistent indentation? There'
petarj 2015/12/28 14:07:00 Done. More files in this directory could be modifi
+ .globl __start
+__start:
+ .set noreorder
+ .set mips32r2
+
+ # Test valid tp access
+valid_load_access:
+ lw $a0, 0($t8) # OK
+ lw $a0, 4($t8) # OK
+ nop
+ nop
+
+ # Test invalid tp access
+invalid_store_access:
+ sb $a0, 4($t8) # Error, forbidden thread pointer access.
+ sc $a0, 4($t8) # Error, forbidden thread pointer access.
+ sdc1 $0, 4($t8) # Error, forbidden thread pointer access.
+ sdc2 $8, 4($t8) # Error, forbidden thread pointer access.
+
+ sh $a0, 4($t8) # Error, forbidden thread pointer access.
+ sw $a0, 4($t8) # Error, forbidden thread pointer access.
+ swc1 $f2, 4($t8) # Error, forbidden thread pointer access.
+ swc2 $22, 4($t8) # Error, forbidden thread pointer access.
+
+ swl $a0, 4($t8) # Error, forbidden thread pointer access.
+ swr $a0, 4($t8) # Error, forbidden thread pointer access.
+ sdxc1 $f6, $a2($t8) # Error, forbidden instruction.
+ suxc1 $f4, $t8($t8) # Error, forbidden instruction.
+
+ swxc1 $f4, $t8($t8) # Error, forbidden instruction.
+ nop
+ nop
+ nop
+
+invalid_load_access:
+ lb $a0, 4($t8) # Error, forbidden thread pointer access.
+ lw $a0, 8($t8) # Error, forbidden thread pointer access.
+ lbu $a0, 4($t8) # Error, forbidden thread pointer access.
+ ldc1 $f0, 4($t8) # Error, forbidden thread pointer access.
+
+ ldc2 $10, -24($t8) # Error, forbidden thread pointer access.
+ lh $a0, 4($t8) # Error, forbidden thread pointer access.
+ lhu $a0, 4($t8) # Error, forbidden thread pointer access.
+ ll $a0, 4($t8) # Error, forbidden thread pointer access.
+
+ lwc1 $f0, 4($t8) # Error, forbidden thread pointer access.
+ lwc2 $10, 4($t8) # Error, forbidden thread pointer access.
+ lwl $a0, 4($t8) # Error, forbidden thread pointer access.
+ lwr $a0, 4($t8) # Error, forbidden thread pointer access.
+
+ ldxc1 $f0, $0($t8) # Error, forbidden instruction.
+ luxc1 $f0, $a2($t8) # Error, forbidden instruction.
+ lwxc1 $f6, $v0($t8) # Error, forbidden instruction.
+ nop
+
+ .set dsp
+ lbux $a3, $t2($t8) # Error, forbidden instruction.
+ lhx $a1, $a2($t8) # Error, forbidden instruction.
+ lwx $t1, $t2($t8) # Error, forbidden instruction.
+ nop
+end_of_code:

Powered by Google App Engine
This is Rietveld 408576698