| OLD | NEW |
| (Empty) | |
| 1 @ Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 2 @ Use of this source code is governed by a BSD-style license that can be |
| 3 @ found in the LICENSE file. |
| 4 |
| 5 @ |
| 6 @ Tests both legal and illegal variations on loads -- both loads that |
| 7 @ require masking, and loads that are guaranteed sandboxed (i.e. through SP) |
| 8 @ |
| 9 |
| 10 @ we restrict loads to the lower 1GB of the address space |
| 11 #define MASK 0xc0000000 |
| 12 |
| 13 .globl _start |
| 14 _start: |
| 15 .align 4 |
| 16 |
| 17 bundle0: |
| 18 bic r1, r3, #MASK @ Generating a confined address |
| 19 ldr r0, [r1] @ and storing to it is fine. |
| 20 |
| 21 bic r1, r1, #MASK @ Confining an address in place |
| 22 ldr r0, [r1] @ and storing to it is fine. |
| 23 |
| 24 bundle1: |
| 25 mov r1, r3 @ Just poking at the address |
| 26 ldr r0, [r1] @ and storing to it is an ERROR. |
| 27 |
| 28 bic r1, r3, #0 @ Even if we use BIC, if the mask is wrong, |
| 29 ldr r0, [r1] @ still an ERROR. |
| 30 |
| 31 bundle2: |
| 32 nop |
| 33 nop |
| 34 nop |
| 35 bic r1, r3, #MASK @ If the BIC is in a different bundle... |
| 36 |
| 37 bundle3: |
| 38 ldr r0, [r1] @ ...then the loads is an ERROR. |
| 39 nop |
| 40 |
| 41 biceq r2, r2, #0xC0000000 @ Mask a register and |
| 42 ldrexeq r0, [r2] @ use it in a load-exclusive. Should pass. |
| 43 |
| 44 bundle4: |
| 45 bic r2, r2, #0 @ Mask incorrectly and |
| 46 ldrex r0, [r2] @ use it in a load-exclusive, for an ERROR. |
| 47 |
| 48 nop |
| 49 nop |
| 50 |
| 51 bundle5: |
| 52 bic r0, r0, #0xC0000000 @ Mask a register, and |
| 53 ldr r1, [r0], r2 @ use it in register post-index load: should pass. |
| 54 nop @ Don't mask, and |
| 55 ldr r1, [r0], r2 @ use it in register post-index load: ERROR. |
| 56 |
| 57 bundle6: |
| 58 bic r1, r1, #MASK @ Confining an address in place |
| 59 ldr pc, [r1] @ loading into pc is an ERROR |
| 60 |
| 61 bic r1, r1, #MASK @ Confining an address in place |
| 62 ldr sp, [r1] @ loading into sp is an ERROR without a mask |
| 63 |
| 64 bundle7: |
| 65 bic r1, r1, #MASK @ Confining an address in place |
| 66 ldr sp, [r1] @ loading into sp is OK with a mask afterwards |
| 67 bic sp, sp, #MASK @ Confining an address in place |
| 68 nop |
| 69 |
| 70 bundle8: |
| 71 bic r1, r1, #MASK @ Confining an address in place |
| 72 ldr r1, [r1, r2] @ loading with an index is an ERROR |
| 73 |
| 74 nop |
| 75 nop |
| 76 |
| 77 bundle9: |
| 78 ldr r1, [sp], #1024 @ post-indexing sp by a constant is fine. |
| 79 ldr r1, [sp], r2 @ post-indexing sp by a register is an ERROR |
| 80 nop |
| 81 nop |
| 82 |
| 83 |
| 84 conditional_sandbox: |
| 85 tst r0, #0xC0000000 @ Set Z if the top two bits are clear, and |
| 86 ldreq r1, [r0] @ load: should work. |
| 87 |
| 88 tst r0, #0xC0000000 @ Set Z if the top two bits are clear, and |
| 89 ldr r1, [r0] @ load unconditionally: ERROR. |
| 90 |
| 91 tst r0, #0xC0000000 @ Set Z if the top two bits are clear, and |
| 92 ldrgt r1, [r0] @ load using wrong predicate: ERROR. |
| 93 |
| 94 tsteq r0, #0xC0000000 @ Conditionally set Z if the top two bits are clear, |
| 95 ldrgt r1, [r0] @ and load using wrong predicate: ERROR. |
| OLD | NEW |