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

Side by Side Diff: src/trusted/validator_ragel/validator_internal.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 /* 7 /*
8 * This file contains common parts of x86-32 and x86-64 internals (inline 8 * This file contains common parts of x86-32 and x86-64 internals (inline
9 * functions and defines). 9 * functions and defines).
10 */ 10 */
11 11
12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_
13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ 13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_
14 14
15 #include "native_client/src/shared/platform/nacl_check.h" 15 #include "native_client/src/shared/platform/nacl_check.h"
16 #include "native_client/src/shared/utils/types.h" 16 #include "native_client/src/shared/utils/types.h"
17 #include "native_client/src/trusted/validator_ragel/unreviewed/decoder_internal. h" 17 #include "native_client/src/trusted/validator_ragel/unreviewed/decoding.h"
18 #include "native_client/src/trusted/validator_ragel/unreviewed/validator.h" 18 #include "native_client/src/trusted/validator_ragel/unreviewed/validator.h"
19 19
20 /* Maximum set of R-DFA allowable CPUID features. */ 20 /* Maximum set of R-DFA allowable CPUID features. */
21 extern const NaClCPUFeaturesX86 validator_cpuid_features; 21 extern const NaClCPUFeaturesX86 validator_cpuid_features;
22 22
23 /* Macroses to suppport CPUID handling. */ 23 /* Macroses to suppport CPUID handling. */
24 #define SET_CPU_FEATURE(F) \ 24 #define SET_CPU_FEATURE(F) \
25 if (!(F##_Allowed)) { \ 25 if (!(F##_Allowed)) { \
26 instruction_info_collected |= UNRECOGNIZED_INSTRUCTION; \ 26 instruction_info_collected |= UNRECOGNIZED_INSTRUCTION; \
27 } \ 27 } \
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 (((((bitmap_word)1) << bits) - 1) << (index % NACL_HOST_WORDSIZE))) != 0; 297 (((((bitmap_word)1) << bits) - 1) << (index % NACL_HOST_WORDSIZE))) != 0;
298 } 298 }
299 299
300 /* All the bits must be in a single 32-bit bundle. */ 300 /* All the bits must be in a single 32-bit bundle. */
301 static FORCEINLINE void BitmapSetBits(bitmap_word *bitmap, 301 static FORCEINLINE void BitmapSetBits(bitmap_word *bitmap,
302 size_t index, size_t bits) { 302 size_t index, size_t bits) {
303 bitmap[index / NACL_HOST_WORDSIZE] |= 303 bitmap[index / NACL_HOST_WORDSIZE] |=
304 ((((bitmap_word)1) << bits) - 1) << (index % NACL_HOST_WORDSIZE); 304 ((((bitmap_word)1) << bits) - 1) << (index % NACL_HOST_WORDSIZE);
305 } 305 }
306 306
307 /* Mark the destination of a jump instruction and make an early validity check: 307 /*
308 * Mark the destination of a jump instruction and make an early validity check:
308 * to jump outside given code region, the target address must be aligned. 309 * to jump outside given code region, the target address must be aligned.
309 * 310 *
310 * Returns TRUE iff the jump passes the early validity check. 311 * Returns TRUE iff the jump passes the early validity check.
311 */ 312 */
312 static FORCEINLINE int MarkJumpTarget(size_t jump_dest, 313 static FORCEINLINE int MarkJumpTarget(size_t jump_dest,
313 bitmap_word *jump_dests, 314 bitmap_word *jump_dests,
314 size_t size) { 315 size_t size) {
315 if ((jump_dest & kBundleMask) == 0) { 316 if ((jump_dest & kBundleMask) == 0) {
316 return TRUE; 317 return TRUE;
317 } 318 }
318 if (jump_dest >= size) { 319 if (jump_dest >= size) {
319 return FALSE; 320 return FALSE;
320 } 321 }
321 BitmapSetBit(jump_dests, jump_dest); 322 BitmapSetBit(jump_dests, jump_dest);
322 return TRUE; 323 return TRUE;
323 } 324 }
324 325
326 /*
327 * Mark the gived address as valid jump target address.
328 */
329 static FORCEINLINE void MakeJumpTargetValid(size_t address,
330 bitmap_word *valid_targets) {
331 BitmapSetBit(valid_targets, address);
332 }
333
334 /*
335 * Mark the gived address as invalid jump target address.
336 */
337 static FORCEINLINE void MakeJumpTargetInvalid(size_t address,
338 bitmap_word *valid_targets) {
339 BitmapClearBit(valid_targets, address);
340 }
325 341
326 static INLINE Bool ProcessInvalidJumpTargets( 342 static INLINE Bool ProcessInvalidJumpTargets(
327 const uint8_t *data, 343 const uint8_t *data,
328 size_t size, 344 size_t size,
329 bitmap_word *valid_targets, 345 bitmap_word *valid_targets,
330 bitmap_word *jump_dests, 346 bitmap_word *jump_dests,
331 validation_callback_func user_callback, 347 validation_callback_func user_callback,
332 void *callback_data) { 348 void *callback_data) {
333 size_t elements = (size + NACL_HOST_WORDSIZE - 1) / NACL_HOST_WORDSIZE; 349 size_t elements = (size + NACL_HOST_WORDSIZE - 1) / NACL_HOST_WORDSIZE;
334 size_t i, j; 350 size_t i, j;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 *instruction_info_collected |= RESTRICTED_RBP_UNPROCESSED; 572 *instruction_info_collected |= RESTRICTED_RBP_UNPROCESSED;
557 } 573 }
558 /* Take 2 bits of operand type from operand_states as *restricted_register, 574 /* Take 2 bits of operand type from operand_states as *restricted_register,
559 * make sure operand_states denotes a register (12th bit == 0). */ 575 * make sure operand_states denotes a register (12th bit == 0). */
560 } else if ((operand_states & 0x7000) == (OperandSandboxRestricted << 13)) { 576 } else if ((operand_states & 0x7000) == (OperandSandboxRestricted << 13)) {
561 *restricted_register = (operand_states & 0x0f00) >> 8; 577 *restricted_register = (operand_states & 0x0f00) >> 8;
562 } 578 }
563 } 579 }
564 580
565 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ */ 581 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698