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

Side by Side Diff: src/trusted/validator_ragel/unreviewed/validator_x86_64.rl

Issue 10883051: Add documentation for the dynamic code modifications. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « src/trusted/validator_ragel/unreviewed/validator_x86_32.rl ('k') | no next file » | 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 <errno.h> 8 #include <errno.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 11 matching lines...) Expand all
22 variable pe end_of_bundle; 22 variable pe end_of_bundle;
23 variable eof end_of_bundle; 23 variable eof end_of_bundle;
24 variable cs current_state; 24 variable cs current_state;
25 25
26 action check_access { 26 action check_access {
27 check_access(instruction_start - data, base, index, restricted_register, val id_targets, 27 check_access(instruction_start - data, base, index, restricted_register, val id_targets,
28 &instruction_info_collected); 28 &instruction_info_collected);
29 } 29 }
30 30
31 action rel8_operand { 31 action rel8_operand {
32 instruction_info_collected |= RELATIVE_8BIT;
33 rel8_operand(current_position + 1, data, jump_dests, size, 32 rel8_operand(current_position + 1, data, jump_dests, size,
34 &instruction_info_collected); 33 &instruction_info_collected);
35 } 34 }
36 action rel16_operand { 35 action rel16_operand {
37 #error rel16_operand should never be used in nacl 36 #error rel16_operand should never be used in nacl
38 } 37 }
39 action rel32_operand { 38 action rel32_operand {
40 instruction_info_collected |= RELATIVE_32BIT;
41 rel32_operand(current_position + 1, data, jump_dests, size, 39 rel32_operand(current_position + 1, data, jump_dests, size,
42 &instruction_info_collected); 40 &instruction_info_collected);
43 } 41 }
44 42
45 action opcode_in_imm { 43 action last_byte_is_not_immediate {
46 instruction_info_collected |= LAST_BYTE_IS_NOT_IMMEDIATE; 44 instruction_info_collected |= LAST_BYTE_IS_NOT_IMMEDIATE;
47 } 45 }
46
48 action modifiable_instruction { 47 action modifiable_instruction {
49 instruction_info_collected |= MODIFIABLE_INSTRUCTION; 48 instruction_info_collected |= MODIFIABLE_INSTRUCTION;
50 } 49 }
51 50
52 action process_0_operands { 51 action process_0_operands {
53 process_0_operands(&restricted_register, &instruction_info_collected); 52 process_0_operands(&restricted_register, &instruction_info_collected);
54 } 53 }
55 action process_1_operand { 54 action process_1_operand {
56 process_1_operand(&restricted_register, &instruction_info_collected, 55 process_1_operand(&restricted_register, &instruction_info_collected,
57 rex_prefix, operand_states); 56 rex_prefix, operand_states);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (((current_position - data) & kBundleMask) != kBundleMask) 364 if (((current_position - data) & kBundleMask) != kBundleMask)
366 instruction_info_collected |= BAD_CALL_ALIGNMENT; 365 instruction_info_collected |= BAD_CALL_ALIGNMENT;
367 }; 366 };
368 367
369 368
370 main := ((call_alignment | normal_instruction | special_instruction) 369 main := ((call_alignment | normal_instruction | special_instruction)
371 >{ 370 >{
372 BitmapSetBit(valid_targets, current_position - data); 371 BitmapSetBit(valid_targets, current_position - data);
373 } 372 }
374 @{ 373 @{
375 if (instruction_info_collected & VALIDATION_ERRORS || 374 if ((instruction_info_collected & VALIDATION_ERRORS_MASK) ||
376 options & CALL_USER_CALLBACK_ON_EACH_INSTRUCTION) { 375 (options & CALL_USER_CALLBACK_ON_EACH_INSTRUCTION)) {
377 result &= user_callback( 376 result &= user_callback(
378 instruction_start, current_position, 377 instruction_start, current_position,
379 instruction_info_collected | 378 instruction_info_collected |
380 ((restricted_register << RESTRICTED_REGISTER_SHIFT) & 379 ((restricted_register << RESTRICTED_REGISTER_SHIFT) &
381 RESTRICTED_REGISTER_MASK), callback_data); 380 RESTRICTED_REGISTER_MASK), callback_data);
382 } 381 }
383 /* On successful match the instruction start must point to the next byte 382 /* On successful match the instruction start must point to the next byte
384 * to be able to report the new offset as the start of instruction 383 * to be able to report the new offset as the start of instruction
385 * causing error. */ 384 * causing error. */
386 instruction_start = current_position + 1; 385 instruction_start = current_position + 1;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 user_callback, callback_data); 474 user_callback, callback_data);
476 475
477 /* We only use malloc for a large code sequences */ 476 /* We only use malloc for a large code sequences */
478 if (size > sizeof(bitmap_word)) { 477 if (size > sizeof(bitmap_word)) {
479 free(jump_dests); 478 free(jump_dests);
480 free(valid_targets); 479 free(valid_targets);
481 } 480 }
482 if (!result) errno = EINVAL; 481 if (!result) errno = EINVAL;
483 return result; 482 return result;
484 } 483 }
OLDNEW
« no previous file with comments | « src/trusted/validator_ragel/unreviewed/validator_x86_32.rl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698