| 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 <assert.h> | 7 #include <assert.h> |
| 8 #include "native_client/src/trusted/service_runtime/nacl_config.h" | 8 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
| 9 #include "native_client/src/trusted/validator_mips/validator.h" | 9 #include "native_client/src/trusted/validator_mips/validator.h" |
| 10 #include "native_client/src/include/nacl_macros.h" | 10 #include "native_client/src/include/nacl_macros.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 208 } |
| 209 out->ReportProblem(second.addr(), second.safety(), | 209 out->ReportProblem(second.addr(), second.safety(), |
| 210 kProblemUnsafeLoadStore); | 210 kProblemUnsafeLoadStore); |
| 211 return PATTERN_UNSAFE; | 211 return PATTERN_UNSAFE; |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 return NO_MATCH; | 214 return NO_MATCH; |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 /* |
| 219 * Checks if there is jump/branch in the delay slot. |
| 220 */ |
| 221 static PatternMatch CheckBranchInDelaySlot(const SfiValidator &sfi, |
| 222 const DecodedInstruction &first, |
| 223 const DecodedInstruction &second, |
| 224 ProblemSink *out) { |
| 225 UNREFERENCED_PARAMETER(sfi); |
| 226 if (first.HasDelaySlot() && second.HasDelaySlot()) { |
| 227 out->ReportProblem(second.addr(), second.safety(), |
| 228 kProblemBranchInDelaySlot); |
| 229 return PATTERN_UNSAFE; |
| 230 } |
| 231 return NO_MATCH; |
| 232 } |
| 233 |
| 234 |
| 218 /********************************************************* | 235 /********************************************************* |
| 219 * Pseudo-instruction patterns. | 236 * Pseudo-instruction patterns. |
| 220 *********************************************************/ | 237 *********************************************************/ |
| 221 | 238 |
| 222 /* | 239 /* |
| 223 * Checks if a pseudo-instruction that starts with instr will cross bundle | 240 * Checks if a pseudo-instruction that starts with instr will cross bundle |
| 224 * border (i.e. if it starts in one and ends in second). | 241 * border (i.e. if it starts in one and ends in second). |
| 225 * The exception to this rule are pseudo-instructions altering the data register | 242 * The exception to this rule are pseudo-instructions altering the data register |
| 226 * value (because mask is the second instruction). | 243 * value (because mask is the second instruction). |
| 227 */ | 244 */ |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // Type for two-instruction pattern functions. | 428 // Type for two-instruction pattern functions. |
| 412 typedef PatternMatch (*TwoInstPattern)(const SfiValidator &, | 429 typedef PatternMatch (*TwoInstPattern)(const SfiValidator &, |
| 413 const DecodedInstruction &first, | 430 const DecodedInstruction &first, |
| 414 const DecodedInstruction &second, | 431 const DecodedInstruction &second, |
| 415 ProblemSink *out); | 432 ProblemSink *out); |
| 416 // The list of patterns -- defined in static functions up top. | 433 // The list of patterns -- defined in static functions up top. |
| 417 static const TwoInstPattern two_inst_patterns[] = { | 434 static const TwoInstPattern two_inst_patterns[] = { |
| 418 &CheckJmpReg, | 435 &CheckJmpReg, |
| 419 &CheckDataRegisterUpdate, | 436 &CheckDataRegisterUpdate, |
| 420 &CheckDataRegisterDslot, | 437 &CheckDataRegisterDslot, |
| 421 &CheckLoadStore | 438 &CheckLoadStore, |
| 439 &CheckBranchInDelaySlot |
| 422 }; | 440 }; |
| 423 | 441 |
| 424 bool complete_success = true; | 442 bool complete_success = true; |
| 425 | 443 |
| 426 for (uint32_t i = 0; i < NACL_ARRAY_SIZE(two_inst_patterns); i++) { | 444 for (uint32_t i = 0; i < NACL_ARRAY_SIZE(two_inst_patterns); i++) { |
| 427 PatternMatch r = two_inst_patterns[i](*this, first, second, out); | 445 PatternMatch r = two_inst_patterns[i](*this, first, second, out); |
| 428 switch (r) { | 446 switch (r) { |
| 429 case NO_MATCH: | 447 case NO_MATCH: |
| 430 break; | 448 break; |
| 431 case PATTERN_UNSAFE: | 449 case PATTERN_UNSAFE: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 DecodedInstruction::DecodedInstruction(uint32_t vaddr, | 501 DecodedInstruction::DecodedInstruction(uint32_t vaddr, |
| 484 Instruction inst, | 502 Instruction inst, |
| 485 const ClassDecoder &decoder) | 503 const ClassDecoder &decoder) |
| 486 : vaddr_(vaddr), | 504 : vaddr_(vaddr), |
| 487 inst_(inst), | 505 inst_(inst), |
| 488 decoder_(&decoder), | 506 decoder_(&decoder), |
| 489 safety_(decoder.safety(inst_)) | 507 safety_(decoder.safety(inst_)) |
| 490 {} | 508 {} |
| 491 | 509 |
| 492 } // namespace | 510 } // namespace |
| OLD | NEW |