OLD | NEW |
| (Empty) |
1 /* | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NCVALIDATE_ITER_IN
TERNAL_H__ | |
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NCVALIDATE_ITER_IN
TERNAL_H__ | |
9 | |
10 /* Defines the internal data structure for the validator state. */ | |
11 | |
12 #include "native_client/src/shared/utils/types.h" | |
13 #include "native_client/src/trusted/cpu_features/arch/x86/cpu_x86.h" | |
14 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_cpu_checks.h" | |
15 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_jumps.h" | |
16 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_opcode_histog
ram.h" | |
17 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_protect_base.
h" | |
18 | |
19 struct NaClDecodeTables; | |
20 struct NaClExpVector; | |
21 struct NaClInst; | |
22 struct NaClInstIter; | |
23 struct NaClInstState; | |
24 struct NaClValidatorState; | |
25 | |
26 #ifdef NCVAL_TESTING | |
27 /* Maximum size for pre/post conditions (as strings). */ | |
28 #define NCVAL_CONDITION_SIZE 1024 | |
29 #endif | |
30 | |
31 struct NaClValidatorState { | |
32 /* Holds the decoder tables to use. */ | |
33 const struct NaClDecodeTables* decoder_tables; | |
34 /* Holds the vbase value passed to NaClValidatorStateCreate. */ | |
35 NaClPcAddress vbase; | |
36 /* Holds the size value passed to NaClValidatorStateCreate. */ | |
37 NaClMemorySize codesize; | |
38 /* Holds the bundle size value passed to NaClValidatorStateCreate. */ | |
39 uint8_t bundle_size; | |
40 /* Holds the bundle mask, which when applied to an address catches any lower | |
41 * bits that violate alignment. | |
42 */ | |
43 NaClPcAddress bundle_mask; | |
44 /* Holds the value for the base register, or RegUnknown if undefined. */ | |
45 NaClOpKind base_register; | |
46 /* Holds if the validation is still valid. */ | |
47 Bool validates_ok; | |
48 #ifdef NCVAL_TESTING | |
49 /* Hold if any problems occured during validation of any instruction. | |
50 * This is needed when generating pre/post conditions because we | |
51 * need to override validates_ok on each instruction so that we | |
52 * will generate pre/post conditions for all instructions. | |
53 */ | |
54 Bool validates_ok_with_conditions; | |
55 #endif | |
56 /* Holds if any stubouts have been performed. */ | |
57 Bool did_stub_out; | |
58 /* If >= 0, holds how many errors can be reported. If negative, | |
59 * reports all errors. | |
60 */ | |
61 int quit_after_error_count; | |
62 #ifdef NCVAL_TESTING | |
63 /* Define whether we should report pre/post conditions, even | |
64 * if the instruction does not validate. | |
65 */ | |
66 Bool report_conditions_on_all; | |
67 #endif | |
68 /* Holds the error reporting object to use. */ | |
69 NaClErrorReporter* error_reporter; | |
70 /* Holds the cpu features of the machine it is running on. */ | |
71 NaClCPUFeaturesX86 cpu_features; | |
72 /* Flag controlling whether an opcode histogram is collected while | |
73 * validating. | |
74 */ | |
75 Bool print_opcode_histogram; | |
76 /* Flag controling whether each in struciton is traced while validating | |
77 * instructions. | |
78 */ | |
79 Bool trace_instructions; | |
80 /* Flag controlling whether the internals of each instruction is traced | |
81 * as they are visited by the validator. | |
82 */ | |
83 Bool trace_inst_internals; | |
84 /* Defines the verbosity of messages to print. */ | |
85 int log_verbosity; | |
86 /* Cached instruction state. Only guaranteed to be defined when a | |
87 * NaClValidator is called. When not defined, is NULL. | |
88 */ | |
89 struct NaClInstState* cur_inst_state; | |
90 /* The iterator currently being used, or NULL if no such iterator. */ | |
91 struct NaClInstIter* cur_iter; | |
92 /* Cached instruction. Only guaranteed to be defined when a NaClValidator is | |
93 * called. When not defined, is NULL. | |
94 */ | |
95 const struct NaClInst* cur_inst; | |
96 /* Cached translation of instruction. Only guaranteed to be defined when a | |
97 * NaClValidator is called. When not defined, is NULL. | |
98 */ | |
99 struct NaClExpVector* cur_inst_vector; | |
100 /* Cached quit value. Kept up to date throughout the lifetime of the | |
101 * validator state. Safe to use within registered validator functions. | |
102 */ | |
103 Bool quit; | |
104 /* Define whether we should stub out instructions (i.e. replace with HALT), | |
105 * if they are found to be illegal. | |
106 */ | |
107 Bool do_stub_out; | |
108 /* Define whether the text segment should be handled as read-only. | |
109 */ | |
110 Bool readonly_text; | |
111 /* When true, generate detailed error messages instead of summary messages. */ | |
112 Bool do_detailed; | |
113 /* Defines the local data needed while analyzing jumps and instruction | |
114 * boundaries. | |
115 */ | |
116 NaClJumpSets jump_sets; | |
117 /* Defines the locals used to record registers set in the current instruction, | |
118 * that are a problem if not used correctly in the next instruction. | |
119 */ | |
120 NaClBaseRegisterLocals set_base_registers; | |
121 /* Defines the set of cpu features aplpied to the code. */ | |
122 NaClCpuCheckState cpu_checks; | |
123 /* Defines the collected opcode histogram data. */ | |
124 NaClOpcodeHistogram opcode_histogram; | |
125 #ifdef NCVAL_TESTING | |
126 /* The string containing validator preconditions. */ | |
127 char precond[NCVAL_CONDITION_SIZE]; | |
128 /* The string containing validator postconditions. */ | |
129 char postcond[NCVAL_CONDITION_SIZE]; | |
130 #endif | |
131 }; | |
132 | |
133 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVAL_REG_SFI_NCVALIDATE_ITER
_INTERNAL_H__ */ | |
OLD | NEW |