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

Side by Side Diff: src/trusted/validator_arm/actual_classes.cc

Issue 10879090: ARM validator: continue with extra_load_store_instructions. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Update with more tables. Created 8 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/actual_classes.h" 7 #include "native_client/src/trusted/validator_arm/actual_classes.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 if (t2.reg(i).Equals(kRegisterPc)) { 336 if (t2.reg(i).Equals(kRegisterPc)) {
337 return UNPREDICTABLE; 337 return UNPREDICTABLE;
338 } 338 }
339 339
340 if (HasWriteBack(i) && n.reg(i).Equals(t2.reg(i))) { 340 if (HasWriteBack(i) && n.reg(i).Equals(t2.reg(i))) {
341 return UNPREDICTABLE; 341 return UNPREDICTABLE;
342 } 342 }
343 343
344 if (m.reg(i).Equals(t.reg(i)) || m.reg(i).Equals(t2.reg(i))) {
345 return UNPREDICTABLE;
346 }
347
344 // Now apply non-double width restrictions for this instruction. 348 // Now apply non-double width restrictions for this instruction.
345 return LoadBasedOffsetMemory::safety(i); 349 return LoadBasedOffsetMemory::safety(i);
346 } 350 }
347 351
348 RegisterList LoadBasedOffsetMemoryDouble::defs(Instruction i) const { 352 RegisterList LoadBasedOffsetMemoryDouble::defs(Instruction i) const {
349 return LoadBasedOffsetMemory::defs(i).Add(t2.reg(i)); 353 return LoadBasedOffsetMemory::defs(i).Add(t2.reg(i));
350 } 354 }
351 355
352 RegisterList LoadBasedImmedMemory:: 356 RegisterList LoadBasedImmedMemory::
353 immediate_addressing_defs(const Instruction i) const { 357 immediate_addressing_defs(const Instruction i) const {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return UNPREDICTABLE; 391 return UNPREDICTABLE;
388 } 392 }
389 393
390 if (HasWriteBack(i) && 394 if (HasWriteBack(i) &&
391 (n.reg(i).Equals(kRegisterPc))) { 395 (n.reg(i).Equals(kRegisterPc))) {
392 // NOTE: The manual states that that it is also unpredictable 396 // NOTE: The manual states that that it is also unpredictable
393 // when HasWriteBack(i) and Rn=Rt. However, the compilers 397 // when HasWriteBack(i) and Rn=Rt. However, the compilers
394 // may not check for this. For the moment, we are changing 398 // may not check for this. For the moment, we are changing
395 // the code to ignore this case for stores. 399 // the code to ignore this case for stores.
396 // TODO(karl): Should we not allow this? 400 // TODO(karl): Should we not allow this?
401 // TODO(jfb) Fix this.
397 return UNPREDICTABLE; 402 return UNPREDICTABLE;
398 } 403 }
399 404
400 // Don't let addressing writeback alter PC (NaCl constraint). 405 // Don't let addressing writeback alter PC (NaCl constraint).
401 if (defs(i).Contains(kRegisterPc)) return FORBIDDEN_OPERANDS; 406 if (defs(i).Contains(kRegisterPc)) return FORBIDDEN_OPERANDS;
402 407
403 return MAY_BE_SAFE; 408 return MAY_BE_SAFE;
404 } 409 }
405 410
406 RegisterList StoreBasedMemoryWithWriteBack::defs(const Instruction i) const { 411 RegisterList StoreBasedMemoryWithWriteBack::defs(const Instruction i) const {
(...skipping 14 matching lines...) Expand all
421 return UNPREDICTABLE; 426 return UNPREDICTABLE;
422 } 427 }
423 428
424 if (HasWriteBack(i) && 429 if (HasWriteBack(i) &&
425 (n.reg(i).Equals(kRegisterPc))) { 430 (n.reg(i).Equals(kRegisterPc))) {
426 // NOTE: The manual states that that it is also unpredictable 431 // NOTE: The manual states that that it is also unpredictable
427 // when HasWriteBack(i) and Rn=Rt. However, the compilers 432 // when HasWriteBack(i) and Rn=Rt. However, the compilers
428 // may not check for this. For the moment, we are changing 433 // may not check for this. For the moment, we are changing
429 // the code to ignore this case for stores. 434 // the code to ignore this case for stores.
430 // TODO(karl): Should we not allow this? 435 // TODO(karl): Should we not allow this?
436 // TODO(jfb) FIx this.
431 return UNPREDICTABLE; 437 return UNPREDICTABLE;
432 } 438 }
433 439
434 return StoreBasedMemoryWithWriteBack::safety(i); 440 return StoreBasedMemoryWithWriteBack::safety(i);
435 } 441 }
436 442
437 SafetyLevel StoreBasedOffsetMemoryDouble::safety(const Instruction i) const { 443 SafetyLevel StoreBasedOffsetMemoryDouble::safety(const Instruction i) const {
438 // Arm double width restrictions for this instruction. 444 // Arm double width restrictions for this instruction.
439 if (!t.IsEven(i)) { 445 if (!t.IsEven(i)) {
440 return UNDEFINED; 446 return UNDEFINED;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 UNREFERENCED_PARAMETER(i); 512 UNREFERENCED_PARAMETER(i);
507 return MAY_BE_SAFE; 513 return MAY_BE_SAFE;
508 } 514 }
509 515
510 RegisterList Roadblock::defs(Instruction i) const { 516 RegisterList Roadblock::defs(Instruction i) const {
511 UNREFERENCED_PARAMETER(i); 517 UNREFERENCED_PARAMETER(i);
512 return RegisterList(); 518 return RegisterList();
513 } 519 }
514 520
515 // Breakpoint 521 // Breakpoint
522 SafetyLevel Breakpoint::safety(Instruction i) const {
523 return i.GetCondition() == Instruction::AL
524 ? MAY_BE_SAFE
525 : UNPREDICTABLE;
526 }
527
516 bool Breakpoint::is_literal_pool_head(const Instruction i) const { 528 bool Breakpoint::is_literal_pool_head(const Instruction i) const {
517 return i.GetCondition() == Instruction::AL 529 return i.GetCondition() == Instruction::AL
518 && i.Bits(19, 8) == 0x777 530 && i.Bits(19, 8) == 0x777
519 && i.Bits(3, 0) == 0x7; 531 && i.Bits(3, 0) == 0x7;
520 } 532 }
521 533
522 SafetyLevel PackSatRev::safety(const Instruction i) const { 534 SafetyLevel PackSatRev::safety(const Instruction i) const {
523 if (defs(i).Contains(kRegisterPc)) { 535 if (defs(i).Contains(kRegisterPc)) {
524 return FORBIDDEN_OPERANDS; 536 return FORBIDDEN_OPERANDS;
525 } 537 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 712 }
701 713
702 714
703 RegisterList MoveDoubleFromCoprocessor::defs(Instruction i) const { 715 RegisterList MoveDoubleFromCoprocessor::defs(Instruction i) const {
704 return RegisterList(Rt(i)).Add(Rt2(i)); 716 return RegisterList(Rt(i)).Add(Rt2(i));
705 } 717 }
706 718
707 // Control flow 719 // Control flow
708 720
709 SafetyLevel BxBlx::safety(Instruction i) const { 721 SafetyLevel BxBlx::safety(Instruction i) const {
722 // Extra NaCl constraint: can't branch to PC. This would branch to 8 bytes
723 // after the current instruction. This instruction should be in an instruction
724 // pair, the mask should therefore be to PC and fail checking, but there's
725 // little harm in checking.
726 if (m.reg(i).Equals(kRegisterPc)) return FORBIDDEN_OPERANDS;
727
728 // Redundant with the above, but this is actually UNPREDICTABLE. Expect DCE.
710 if (link_register.IsUpdated(i) && m.reg(i).Equals(kRegisterPc)) { 729 if (link_register.IsUpdated(i) && m.reg(i).Equals(kRegisterPc)) {
711 return UNPREDICTABLE; 730 return UNPREDICTABLE;
712 } 731 }
713 732
714 return MAY_BE_SAFE; 733 return MAY_BE_SAFE;
715 } 734 }
716 735
717 RegisterList BxBlx::defs(const Instruction i) const { 736 RegisterList BxBlx::defs(const Instruction i) const {
718 return RegisterList(kRegisterPc). 737 return RegisterList(kRegisterPc).
719 Add(link_register.IsUpdated(i) ? kRegisterLink : kRegisterNone); 738 Add(link_register.IsUpdated(i) ? kRegisterLink : kRegisterNone);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 int width = msbit + 1 - lsbit; 818 int width = msbit + 1 - lsbit;
800 if (width == 32) { 819 if (width == 32) {
801 return mask == 0; 820 return mask == 0;
802 } else { 821 } else {
803 uint32_t bit_mask = (((1 << width) - 1) << lsbit); 822 uint32_t bit_mask = (((1 << width) - 1) << lsbit);
804 return (bit_mask & mask) == mask; 823 return (bit_mask & mask) == mask;
805 } 824 }
806 } 825 }
807 826
808 } // namespace nacl_arm_dec 827 } // namespace nacl_arm_dec
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698