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

Side by Side Diff: src/trusted/validator_mips/validator.cc

Issue 11415031: [MIPS] Forbid $sp update at the end of the last bundle. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Presubmit errors have been fixed. Created 8 years, 1 month 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
« no previous file with comments | « src/trusted/validator_mips/validator.h ('k') | src/trusted/validator_mips/validator_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 /* 196 /*
197 * Checks if load and store instructions are preceded by load/store mask. 197 * Checks if load and store instructions are preceded by load/store mask.
198 */ 198 */
199 static PatternMatch CheckLoadStore(const SfiValidator &sfi, 199 static PatternMatch CheckLoadStore(const SfiValidator &sfi,
200 const DecodedInstruction &first, 200 const DecodedInstruction &first,
201 const DecodedInstruction &second, 201 const DecodedInstruction &second,
202 ProblemSink *out) { 202 ProblemSink *out) {
203 if (second.IsLoadStore()) { 203 if (second.IsLoadStore()) {
204 Register base_addr_reg = second.BaseAddressRegister(); 204 Register base_addr_reg = second.BaseAddressRegister();
205 if (!sfi.data_address_registers().ContainsAll(base_addr_reg)) { 205 if (!sfi.data_address_registers().
206 ContainsAll(RegisterList(base_addr_reg))) {
206 if (first.IsMask(base_addr_reg, kRegisterLoadStoreMask)) { 207 if (first.IsMask(base_addr_reg, kRegisterLoadStoreMask)) {
207 return PATTERN_SAFE; 208 return PATTERN_SAFE;
208 } 209 }
209 out->ReportProblem(second.addr(), second.safety(), 210 out->ReportProblem(second.addr(), second.safety(),
210 kProblemUnsafeLoadStore); 211 kProblemUnsafeLoadStore);
211 return PATTERN_UNSAFE; 212 return PATTERN_UNSAFE;
212 } 213 }
213 } 214 }
214 return NO_MATCH; 215 return NO_MATCH;
215 } 216 }
216 217
217 218
218 /* 219 /*
219 * Checks if there is jump/branch in the delay slot. 220 * Checks if there is jump/branch in the delay slot.
220 */ 221 */
221 static PatternMatch CheckBranchInDelaySlot(const SfiValidator &sfi, 222 static PatternMatch CheckBranchInDelaySlot(const SfiValidator &sfi,
222 const DecodedInstruction &first, 223 const DecodedInstruction &first,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 complete_success &= ApplyPatterns(prev, inst, critical, out); 349 complete_success &= ApplyPatterns(prev, inst, critical, out);
349 if (!out->ShouldContinue()) return false; 350 if (!out->ShouldContinue()) return false;
350 351
351 if (inst.IsDirectJump()) { 352 if (inst.IsDirectJump()) {
352 branches->Add(inst.addr()); 353 branches->Add(inst.addr());
353 branch_targets->Add(inst.DestAddr()); 354 branch_targets->Add(inst.DestAddr());
354 } 355 }
355 356
356 prev = inst; 357 prev = inst;
357 } 358 }
359
360 // Validate the last instruction, paired with a nop.
361 const Instruction nop(nacl_mips_dec::kNop);
362 DecodedInstruction one_past_end(segment.EndAddr(), nop,
363 nacl_mips_dec::decode(nop, decode_state_));
364 complete_success &= ApplyPatterns(prev, one_past_end, critical, out);
365
358 return complete_success; 366 return complete_success;
359 } 367 }
360 368
361 bool SfiValidator::ValidatePseudos(const SfiValidator &sfi, 369 bool SfiValidator::ValidatePseudos(const SfiValidator &sfi,
362 const std::vector<CodeSegment> &segments, 370 const std::vector<CodeSegment> &segments,
363 const AddressSet &branches, 371 const AddressSet &branches,
364 const AddressSet &branch_targets, 372 const AddressSet &branch_targets,
365 const AddressSet &critical, 373 const AddressSet &critical,
366 ProblemSink* out) { 374 ProblemSink* out) {
367 bool complete_success = true; 375 bool complete_success = true;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 DecodedInstruction::DecodedInstruction(uint32_t vaddr, 509 DecodedInstruction::DecodedInstruction(uint32_t vaddr,
502 Instruction inst, 510 Instruction inst,
503 const ClassDecoder &decoder) 511 const ClassDecoder &decoder)
504 : vaddr_(vaddr), 512 : vaddr_(vaddr),
505 inst_(inst), 513 inst_(inst),
506 decoder_(&decoder), 514 decoder_(&decoder),
507 safety_(decoder.safety(inst_)) 515 safety_(decoder.safety(inst_))
508 {} 516 {}
509 517
510 } // namespace 518 } // namespace
OLDNEW
« no previous file with comments | « src/trusted/validator_mips/validator.h ('k') | src/trusted/validator_mips/validator_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698