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

Side by Side Diff: src/trusted/validator_ragel/unreviewed/validator.h

Issue 11000033: Move validator_x86_XX.rl out of unreviewed. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 2 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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_ 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_ 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_
9 9
10 #include "native_client/src/trusted/validator_ragel/unreviewed/decoder.h" 10 #include "native_client/src/trusted/validator_ragel/decoder.h"
11 11
12 EXTERN_C_BEGIN 12 EXTERN_C_BEGIN
13 13
14 enum validation_callback_info { 14 /*
15 * Bits and masks used to transfer information from validator to user_callback.
16 * See validator_internals.html for details.
17 */
18 enum ValidationCallbackInfo {
15 /* Anyfield info mask: you can use to parse information about anyfields. */ 19 /* Anyfield info mask: you can use to parse information about anyfields. */
16 ANYFIELD_INFO_MASK = 0x000000ff, 20 ANYFIELD_INFO_MASK = 0x000000ff,
17 /* Immediate sizes (immediates always come at the end of instruction). */ 21 /* Immediate sizes (immediates always come at the end of instruction). */
18 IMMEDIATES_SIZE_MASK = 0x0000000f, 22 IMMEDIATES_SIZE_MASK = 0x0000000f,
19 IMMEDIATE_8BIT = 0x00000001, 23 IMMEDIATE_8BIT = 0x00000001,
20 IMMEDIATE_16BIT = 0x00000002, 24 IMMEDIATE_16BIT = 0x00000002,
21 IMMEDIATE_32BIT = 0x00000004, 25 IMMEDIATE_32BIT = 0x00000004,
22 IMMEDIATE_64BIT = 0x00000008, 26 IMMEDIATE_64BIT = 0x00000008,
23 /* Second 8bit immediate is only used in "extrq/insertq" instructions. */ 27 /* Second 8bit immediate is only used in "extrq/insertq" instructions. */
24 SECOND_IMMEDIATE_8BIT = 0x00000011, 28 SECOND_IMMEDIATE_8BIT = 0x00000011,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 /* 96 /*
93 * Callback is invoked by ValidateChunk* for all erroneous instructions 97 * Callback is invoked by ValidateChunk* for all erroneous instructions
94 * (or for all instructions if CALL_USER_CALLBACK_ON_EACH_INSTRUCTION is set). 98 * (or for all instructions if CALL_USER_CALLBACK_ON_EACH_INSTRUCTION is set).
95 * It's up to the callback to decide whether this particual place is indeed 99 * It's up to the callback to decide whether this particual place is indeed
96 * a violation. If callback returns FALSE at least once, validation result 100 * a violation. If callback returns FALSE at least once, validation result
97 * becomes FALSE. 101 * becomes FALSE.
98 * 102 *
99 * When callback is called for invalid jump tagret, 103 * When callback is called for invalid jump tagret,
100 * instruction_start = instruction_end = jump target 104 * instruction_start = instruction_end = jump target
101 * 105 *
102 * Minimal user_callback looks like this: 106 * Minimal user_callback for CALL_USER_CALLBACK_ON_EACH_INSTRUCTION case looks
107 * like this:
103 * ... 108 * ...
104 * if (validation_info & (VALIDATION_ERRORS_MASK | BAD_JUMP_TARGET)) 109 * if (validation_info & (VALIDATION_ERRORS_MASK | BAD_JUMP_TARGET))
105 * return FALSE; 110 * return FALSE;
106 * else 111 * else
107 * return TRUE; 112 * return TRUE;
108 * ... 113 * ...
109 */ 114 */
110 typedef Bool (*ValidationCallbackFunc) (const uint8_t *instruction_start, 115 typedef Bool (*ValidationCallbackFunc) (const uint8_t *instruction_start,
111 const uint8_t *instruction_end, 116 const uint8_t *instruction_end,
112 uint32_t validation_info, 117 uint32_t validation_info,
(...skipping 23 matching lines...) Expand all
136 */ 141 */
137 Bool ValidateChunkIA32(const uint8_t *data, size_t size, 142 Bool ValidateChunkIA32(const uint8_t *data, size_t size,
138 enum ValidationOptions options, 143 enum ValidationOptions options,
139 const NaClCPUFeaturesX86 *cpu_features, 144 const NaClCPUFeaturesX86 *cpu_features,
140 ValidationCallbackFunc user_callback, 145 ValidationCallbackFunc user_callback,
141 void *callback_data); 146 void *callback_data);
142 147
143 EXTERN_C_END 148 EXTERN_C_END
144 149
145 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_ */ 150 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698