OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Native Client Authors. All rights reserved. | 2 * Copyright 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 * Copyright 2012, Google Inc. | 5 * Copyright 2012, Google Inc. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H | 8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H |
9 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H | 9 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 * This is an abstract base class intended to be overridden with the details of | 52 * This is an abstract base class intended to be overridden with the details of |
53 * particular instruction-classes. | 53 * particular instruction-classes. |
54 * | 54 * |
55 * ClassDecoders should be stateless, and should provide a no-arg constructor | 55 * ClassDecoders should be stateless, and should provide a no-arg constructor |
56 * for use by the generated decoder. | 56 * for use by the generated decoder. |
57 */ | 57 */ |
58 class ClassDecoder { | 58 class ClassDecoder { |
59 public: | 59 public: |
60 /* | 60 /* |
61 * Checks how safe this instruction is, in isolation. | 61 * Checks how safe this instruction is, in isolation. |
62 * This will detect any violation in the Mips spec -- undefined encodings, | 62 * This will detect any violation in the MIPS spec -- undefined encodings, |
63 * use of registers that are unpredictable -- and the most basic constraints | 63 * use of registers that are unpredictable -- and the most basic constraints |
64 * in our SFI model. Because ClassDecoders are referentially-transparent and | 64 * in our SFI model. Because ClassDecoders are referentially-transparent and |
65 * cannot touch global state, this will not check things that may vary with | 65 * cannot touch global state, this will not check things that may vary with |
66 * ABI version. | 66 * ABI version. |
67 * | 67 * |
68 * The most positive result this can return is called MAY_BE_SAFE because it | 68 * The most positive result this can return is called MAY_BE_SAFE because it |
69 * is necessary, but not sufficient: the validator has the final say. | 69 * is necessary, but not sufficient: the validator has the final say. |
70 */ | 70 */ |
71 virtual SafetyLevel safety(const Instruction instr) const = 0; | 71 virtual SafetyLevel safety(const Instruction instr) const = 0; |
72 | 72 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return kRegisterNone; | 162 return kRegisterNone; |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 protected: | 166 protected: |
167 ClassDecoder() {} | 167 ClassDecoder() {} |
168 virtual ~ClassDecoder() {} | 168 virtual ~ClassDecoder() {} |
169 }; | 169 }; |
170 | 170 |
171 /* | 171 /* |
172 * Current Mips NaCl halt (jr $zero). | 172 * Current MIPS NaCl halt (break). |
173 */ | 173 */ |
174 class NaClHalt : public ClassDecoder { | 174 class NaClHalt : public ClassDecoder { |
175 public: | 175 public: |
176 virtual ~NaClHalt() {} | 176 virtual ~NaClHalt() {} |
177 virtual SafetyLevel safety(const Instruction instr) const { | 177 virtual SafetyLevel safety(const Instruction instr) const { |
178 UNREFERENCED_PARAMETER(instr); | 178 UNREFERENCED_PARAMETER(instr); |
179 return MAY_BE_SAFE; | 179 return MAY_BE_SAFE; |
180 } | 180 } |
181 }; | 181 }; |
182 | 182 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 public: | 429 public: |
430 virtual ~Unrecognized() {} | 430 virtual ~Unrecognized() {} |
431 virtual SafetyLevel safety(const Instruction instr) const { | 431 virtual SafetyLevel safety(const Instruction instr) const { |
432 UNREFERENCED_PARAMETER(instr); | 432 UNREFERENCED_PARAMETER(instr); |
433 return FORBIDDEN; | 433 return FORBIDDEN; |
434 } | 434 } |
435 }; | 435 }; |
436 } // namespace | 436 } // namespace |
437 | 437 |
438 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H | 438 #endif // NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_MIPS_INST_CLASSES_H |
OLD | NEW |