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

Side by Side Diff: src/trusted/validator_ragel/dfa_validate_common.c

Issue 1234393005: A mechanism to identify/forbid/"rewrite" non-temporal instructions (and other) (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Renaming Created 5 years, 5 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
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 /* 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
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 NaClDfaForbidOrRewriteInstruction(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 ForbidRewriteCallbackData *data = callback_data;
Petr Hosek 2015/07/20 23:58:57 Shouldn't you doing a cast here? Is this actually
ruiq 2015/07/21 00:39:44 This is valid in C, while not in C++. In C++, an e
Petr Hosek 2015/07/21 00:46:58 I'd still include an explicit cast, even if this p
ruiq 2015/07/21 02:52:24 I left this as it is: 1) It is not ambiguous; 2) i
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) == FORBID_OR_REWRITE_INSTRUCTION) {
47 if (data->pnacl_mode)
48 return FALSE;
49 else {
50 /* TODO: rewrite instruction. For now, we keep the original instruction
Petr Hosek 2015/07/20 23:58:57 Nit: Please include your LDAP in the TODO, i.e. "T
ruiq 2015/07/21 02:52:24 Done.
51 * and indicate validation success, which is consistent with current
52 * validation results. */
53 data->did_rewrite = 1;
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698