| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/validator_arm/baseline_classes.h" | 7 #include "native_client/src/trusted/validator_arm/baseline_classes.h" |
| 8 | 8 |
| 9 #include <assert.h> | 9 #include <assert.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 UNREFERENCED_PARAMETER(i); | 83 UNREFERENCED_PARAMETER(i); |
| 84 return true; | 84 return true; |
| 85 } | 85 } |
| 86 | 86 |
| 87 int32_t BranchImmediate24::branch_target_offset(Instruction i) const { | 87 int32_t BranchImmediate24::branch_target_offset(Instruction i) const { |
| 88 return imm24.relative_address(i); | 88 return imm24.relative_address(i); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // BreakPointAndConstantPoolHead | 91 // BreakPointAndConstantPoolHead |
| 92 SafetyLevel BreakPointAndConstantPoolHead::safety(const Instruction i) const { | 92 SafetyLevel BreakPointAndConstantPoolHead::safety(const Instruction i) const { |
| 93 return i.GetCondition() == Instruction::AL | 93 if (i.GetCondition() != Instruction::AL) |
| 94 ? MAY_BE_SAFE | 94 return UNPREDICTABLE; |
| 95 : UNPREDICTABLE; | 95 // Restrict BKPT's encoding to values we've chosen as safe. |
| 96 if ((i.Bits(31, 0) == kLiteralPoolHead) || |
| 97 (i.Bits(31, 0) == kBreakpoint)) |
| 98 return MAY_BE_SAFE; |
| 99 return FORBIDDEN_OPERANDS; |
| 96 } | 100 } |
| 101 |
| 97 bool BreakPointAndConstantPoolHead:: | 102 bool BreakPointAndConstantPoolHead:: |
| 98 is_literal_pool_head(const Instruction i) const { | 103 is_literal_pool_head(const Instruction i) const { |
| 99 return i.Bits(31, 0) == kLiteralPoolHeadInstruction; | 104 return i.Bits(31, 0) == kLiteralPoolHead; |
| 100 } | 105 } |
| 101 | 106 |
| 102 // BranchToRegister | 107 // BranchToRegister |
| 103 SafetyLevel BranchToRegister::safety(const Instruction i) const { | 108 SafetyLevel BranchToRegister::safety(const Instruction i) const { |
| 104 // Extra NaCl constraint: can't branch to PC. This would branch to 8 bytes | 109 // Extra NaCl constraint: can't branch to PC. This would branch to 8 bytes |
| 105 // after the current instruction. This instruction should be in an instruction | 110 // after the current instruction. This instruction should be in an instruction |
| 106 // pair, the mask should therefore be to PC and fail checking, but there's | 111 // pair, the mask should therefore be to PC and fail checking, but there's |
| 107 // little harm in checking. | 112 // little harm in checking. |
| 108 if (m.reg(i).Equals(Register::Pc())) return FORBIDDEN_OPERANDS; | 113 if (m.reg(i).Equals(Register::Pc())) return FORBIDDEN_OPERANDS; |
| 109 | 114 |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 // InstructionBarrier | 1344 // InstructionBarrier |
| 1340 SafetyLevel InstructionBarrier::safety(Instruction i) const { | 1345 SafetyLevel InstructionBarrier::safety(Instruction i) const { |
| 1341 if (option.value(i) != 0xF) | 1346 if (option.value(i) != 0xF) |
| 1342 return FORBIDDEN_OPERANDS; | 1347 return FORBIDDEN_OPERANDS; |
| 1343 return UncondDecoder::safety(i); | 1348 return UncondDecoder::safety(i); |
| 1344 } | 1349 } |
| 1345 | 1350 |
| 1346 } // namespace nacl_arm_dec | 1351 } // namespace nacl_arm_dec |
| OLD | NEW |