OLD | NEW |
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 insternals (inline | 8 * This file contains common parts of x86-32 and x86-64 insternals (inline |
9 * functions and defines). | 9 * functions and defines). |
10 */ | 10 */ |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 * in a current instruction. | 363 * in a current instruction. |
364 */ | 364 */ |
365 static FORCEINLINE void rel8_operand(const uint8_t *rip, | 365 static FORCEINLINE void rel8_operand(const uint8_t *rip, |
366 const uint8_t* codeblock_start, | 366 const uint8_t* codeblock_start, |
367 bitmap_word *jump_dests, | 367 bitmap_word *jump_dests, |
368 size_t jumpdests_size, | 368 size_t jumpdests_size, |
369 uint32_t *instruction_info_collected) { | 369 uint32_t *instruction_info_collected) { |
370 int8_t offset = (uint8_t) (rip[-1]); | 370 int8_t offset = (uint8_t) (rip[-1]); |
371 size_t jump_dest = offset + (rip - codeblock_start); | 371 size_t jump_dest = offset + (rip - codeblock_start); |
372 | 372 |
373 if (!MarkJumpTarget(jump_dest, jump_dests, jumpdests_size)) { | 373 if (!MarkJumpTarget(jump_dest, jump_dests, jumpdests_size)) |
374 *instruction_info_collected |= DIRECT_JUMP_OUT_OF_RANGE; | 374 *instruction_info_collected |= RELATIVE_8BIT | DIRECT_JUMP_OUT_OF_RANGE; |
375 } | 375 else |
| 376 *instruction_info_collected |= RELATIVE_8BIT; |
376 } | 377 } |
377 | 378 |
378 /* | 379 /* |
379 * Process rel32_operand. Note: rip points to the beginning of the next | 380 * Process rel32_operand. Note: rip points to the beginning of the next |
380 * instruction here and x86 encoding guarantees rel32 field is the last one | 381 * instruction here and x86 encoding guarantees rel32 field is the last one |
381 * in a current instruction. | 382 * in a current instruction. |
382 */ | 383 */ |
383 static FORCEINLINE void rel32_operand(const uint8_t *rip, | 384 static FORCEINLINE void rel32_operand(const uint8_t *rip, |
384 const uint8_t* codeblock_start, | 385 const uint8_t* codeblock_start, |
385 bitmap_word *jump_dests, | 386 bitmap_word *jump_dests, |
386 size_t jumpdests_size, | 387 size_t jumpdests_size, |
387 uint32_t *instruction_info_collected) { | 388 uint32_t *instruction_info_collected) { |
388 int32_t offset = (rip[-4] + 256U * (rip[-3] + 256U * ( | 389 int32_t offset = (rip[-4] + 256U * (rip[-3] + 256U * ( |
389 rip[-2] + 256U * ((uint32_t) rip[-1])))); | 390 rip[-2] + 256U * ((uint32_t) rip[-1])))); |
390 size_t jump_dest = offset + (rip - codeblock_start); | 391 size_t jump_dest = offset + (rip - codeblock_start); |
391 | 392 |
392 if (!MarkJumpTarget(jump_dest, jump_dests, jumpdests_size)) { | 393 if (!MarkJumpTarget(jump_dest, jump_dests, jumpdests_size)) |
393 *instruction_info_collected |= DIRECT_JUMP_OUT_OF_RANGE; | 394 *instruction_info_collected |= RELATIVE_32BIT | DIRECT_JUMP_OUT_OF_RANGE; |
394 } | 395 else |
| 396 *instruction_info_collected |= RELATIVE_32BIT; |
395 } | 397 } |
396 | 398 |
397 static INLINE void check_access(ptrdiff_t instruction_start, | 399 static INLINE void check_access(ptrdiff_t instruction_start, |
398 enum register_name base, | 400 enum register_name base, |
399 enum register_name index, | 401 enum register_name index, |
400 uint8_t restricted_register, | 402 uint8_t restricted_register, |
401 bitmap_word *valid_targets, | 403 bitmap_word *valid_targets, |
402 uint32_t *instruction_info_collected) { | 404 uint32_t *instruction_info_collected) { |
403 if ((base == REG_RIP) || (base == REG_R15) || | 405 if ((base == REG_RIP) || (base == REG_R15) || |
404 (base == REG_RSP) || (base == REG_RBP)) { | 406 (base == REG_RSP) || (base == REG_RBP)) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 *instruction_info_collected |= RESTRICTED_RBP_UNPROCESSED; | 560 *instruction_info_collected |= RESTRICTED_RBP_UNPROCESSED; |
559 } | 561 } |
560 /* Take 2 bits of operand type from operand_states as *restricted_register, | 562 /* Take 2 bits of operand type from operand_states as *restricted_register, |
561 * make sure operand_states denotes a register (12th bit == 0). */ | 563 * make sure operand_states denotes a register (12th bit == 0). */ |
562 } else if ((operand_states & 0x7000) == (OperandSandboxRestricted << 13)) { | 564 } else if ((operand_states & 0x7000) == (OperandSandboxRestricted << 13)) { |
563 *restricted_register = (operand_states & 0x0f00) >> 8; | 565 *restricted_register = (operand_states & 0x0f00) >> 8; |
564 } | 566 } |
565 } | 567 } |
566 | 568 |
567 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ */ | 569 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_VALIDATOR_INTERNAL_H_ */ |
OLD | NEW |