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 /* Implement the functions common for ia32 and x86-64 architectures. */ | 7 /* Implement the functions common for ia32 and x86-64 architectures. */ |
8 #include "native_client/src/trusted/validator_ragel/dfa_validate_common.h" | 8 #include "native_client/src/trusted/validator_ragel/dfa_validate_common.h" |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 Bool NaClDfaProcessValidationError(const uint8_t *begin, const uint8_t *end, | 26 Bool NaClDfaProcessValidationError(const uint8_t *begin, const uint8_t *end, |
27 uint32_t info, void *callback_data) { | 27 uint32_t info, void *callback_data) { |
28 UNREFERENCED_PARAMETER(begin); | 28 UNREFERENCED_PARAMETER(begin); |
29 UNREFERENCED_PARAMETER(end); | 29 UNREFERENCED_PARAMETER(end); |
30 UNREFERENCED_PARAMETER(info); | 30 UNREFERENCED_PARAMETER(info); |
31 UNREFERENCED_PARAMETER(callback_data); | 31 UNREFERENCED_PARAMETER(callback_data); |
32 | 32 |
33 return FALSE; | 33 return FALSE; |
34 } | 34 } |
35 | 35 |
36 Bool NaClDfaStubOutCPUUnsupportedInstruction(const uint8_t *begin, | 36 Bool NaClDfaStubOutUnsupportedInstruction(const uint8_t *begin, |
37 const uint8_t *end, | 37 const uint8_t *end, |
38 uint32_t info, | 38 uint32_t info, |
39 void *callback_data) { | 39 void *callback_data) { |
40 struct StubOutCallbackData *data = callback_data; | |
40 /* Stub-out instructions unsupported on this CPU, but valid on other CPUs. */ | 41 /* Stub-out instructions unsupported on this CPU, but valid on other CPUs. */ |
41 if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) { | 42 if ((info & VALIDATION_ERRORS_MASK) == CPUID_UNSUPPORTED_INSTRUCTION) { |
42 int *did_stubout = callback_data; | 43 data->did_rewrite = 1; |
43 *did_stubout = 1; | |
44 memset((uint8_t *)begin, NACL_HALT_OPCODE, end - begin); | 44 memset((uint8_t *)begin, NACL_HALT_OPCODE, end - begin); |
45 return TRUE; | 45 return TRUE; |
46 } else if ((info & VALIDATION_ERRORS_MASK) == UNSUPPORTED_INSTRUCTION) { | |
47 if (data->flags == DISABLE_NONTEMPORALS) { | |
Mark Seaborn
2015/07/29 16:09:23
Shouldn't this be "(data->flags & DISABLE_NONTEMPO
| |
48 return FALSE; | |
49 } else { | |
50 /* TODO(ruiq): rewrite instruction. For now, we keep the original | |
51 * instruction and indicate validation success, which is consistent | |
52 * with current validation results. */ | |
53 data->did_rewrite = 0; | |
54 return TRUE; | |
55 } | |
46 } else { | 56 } else { |
47 return FALSE; | 57 return FALSE; |
48 } | 58 } |
49 } | 59 } |
50 | 60 |
51 Bool NaClDfaProcessCodeCopyInstruction(const uint8_t *begin_new, | 61 Bool NaClDfaProcessCodeCopyInstruction(const uint8_t *begin_new, |
52 const uint8_t *end_new, | 62 const uint8_t *end_new, |
53 uint32_t info_new, | 63 uint32_t info_new, |
54 void *callback_data) { | 64 void *callback_data) { |
55 struct CodeCopyCallbackData *data = callback_data; | 65 struct CodeCopyCallbackData *data = callback_data; |
(...skipping 12 matching lines...) Expand all Loading... | |
68 | 78 |
69 Bool NaClDfaCodeReplacementIsStubouted(const uint8_t *begin_existing, | 79 Bool NaClDfaCodeReplacementIsStubouted(const uint8_t *begin_existing, |
70 size_t instruction_length) { | 80 size_t instruction_length) { |
71 | 81 |
72 /* Unsupported instruction must have been replaced with HLTs. */ | 82 /* Unsupported instruction must have been replaced with HLTs. */ |
73 if (memcmp(kStubOutMem, begin_existing, instruction_length) == 0) | 83 if (memcmp(kStubOutMem, begin_existing, instruction_length) == 0) |
74 return TRUE; | 84 return TRUE; |
75 else | 85 else |
76 return FALSE; | 86 return FALSE; |
77 } | 87 } |
OLD | NEW |