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

Side by Side Diff: src/trusted/validator_ragel/dfa_validate_64.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: Fixing nits Created 5 years, 4 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 Validator API for the x86-64 architecture. */ 7 /* Implement the Validator API for the x86-64 architecture. */
8 #include <errno.h> 8 #include <errno.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 12 matching lines...) Expand all
23 #if NACL_ARCH(NACL_BUILD_ARCH) != NACL_x86 || NACL_BUILD_SUBARCH != 64 23 #if NACL_ARCH(NACL_BUILD_ARCH) != NACL_x86 || NACL_BUILD_SUBARCH != 64
24 # error "Can't compile, target is for x86-64" 24 # error "Can't compile, target is for x86-64"
25 #endif 25 #endif
26 26
27 27
28 static NaClValidationStatus ApplyDfaValidator_x86_64( 28 static NaClValidationStatus ApplyDfaValidator_x86_64(
29 uintptr_t guest_addr, 29 uintptr_t guest_addr,
30 uint8_t *data, 30 uint8_t *data,
31 size_t size, 31 size_t size,
32 int stubout_mode, 32 int stubout_mode,
33 uint32_t flags,
33 int readonly_text, 34 int readonly_text,
34 const NaClCPUFeatures *f, 35 const NaClCPUFeatures *f,
35 const struct NaClValidationMetadata *metadata, 36 const struct NaClValidationMetadata *metadata,
36 struct NaClValidationCache *cache) { 37 struct NaClValidationCache *cache) {
37 /* TODO(jfb) Use a safe cast here. */ 38 /* TODO(jfb) Use a safe cast here. */
38 NaClCPUFeaturesX86 *cpu_features = (NaClCPUFeaturesX86 *) f; 39 NaClCPUFeaturesX86 *cpu_features = (NaClCPUFeaturesX86 *) f;
39 enum NaClValidationStatus status = NaClValidationFailed; 40 enum NaClValidationStatus status = NaClValidationFailed;
40 int did_stubout = 0;
41 void *query = NULL; 41 void *query = NULL;
42 struct StubOutCallbackData callback_data;
43 callback_data.flags = flags;
44 callback_data.did_rewrite = 0;
42 UNREFERENCED_PARAMETER(guest_addr); 45 UNREFERENCED_PARAMETER(guest_addr);
43 46
44 if (stubout_mode) 47 if (stubout_mode)
45 return NaClValidationFailedNotImplemented; 48 return NaClValidationFailedNotImplemented;
46 if (!NaClArchSupportedX86(cpu_features)) 49 if (!NaClArchSupportedX86(cpu_features))
47 return NaClValidationFailedCpuNotSupported; 50 return NaClValidationFailedCpuNotSupported;
48 if (size & kBundleMask) 51 if (size & kBundleMask)
49 return NaClValidationFailed; 52 return NaClValidationFailed;
50 53
51 /* 54 /*
(...skipping 13 matching lines...) Expand all
65 } 68 }
66 } 69 }
67 70
68 if (readonly_text) { 71 if (readonly_text) {
69 if (ValidateChunkAMD64(data, size, 0 /*options*/, cpu_features, 72 if (ValidateChunkAMD64(data, size, 0 /*options*/, cpu_features,
70 NaClDfaProcessValidationError, 73 NaClDfaProcessValidationError,
71 NULL)) 74 NULL))
72 status = NaClValidationSucceeded; 75 status = NaClValidationSucceeded;
73 } else { 76 } else {
74 if (ValidateChunkAMD64(data, size, 0 /*options*/, cpu_features, 77 if (ValidateChunkAMD64(data, size, 0 /*options*/, cpu_features,
75 NaClDfaStubOutCPUUnsupportedInstruction, 78 NaClDfaStubOutUnsupportedInstruction,
76 &did_stubout)) 79 &callback_data))
77 status = NaClValidationSucceeded; 80 status = NaClValidationSucceeded;
78 } 81 }
79 82
80 if (status != NaClValidationSucceeded && errno == ENOMEM) 83 if (status != NaClValidationSucceeded && errno == ENOMEM)
81 status = NaClValidationFailedOutOfMemory; 84 status = NaClValidationFailedOutOfMemory;
82 85
83 /* Cache the result if validation succeeded and the code was not modified. */ 86 /* Cache the result if validation succeeded and the code was not modified. */
84 if (query != NULL) { 87 if (query != NULL) {
85 if (status == NaClValidationSucceeded && did_stubout == 0) 88 if (status == NaClValidationSucceeded && callback_data.did_rewrite == 0)
86 cache->SetKnownToValidate(query); 89 cache->SetKnownToValidate(query);
87 cache->DestroyQuery(query); 90 cache->DestroyQuery(query);
88 } 91 }
89 92
90 return status; 93 return status;
91 } 94 }
92 95
93 96
94 static NaClValidationStatus ValidatorCodeCopy_x86_64( 97 static NaClValidationStatus ValidatorCodeCopy_x86_64(
95 uintptr_t guest_addr, 98 uintptr_t guest_addr,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 sizeof(NaClCPUFeaturesX86), 304 sizeof(NaClCPUFeaturesX86),
302 NaClSetAllCPUFeaturesX86, 305 NaClSetAllCPUFeaturesX86,
303 NaClGetCurrentCPUFeaturesX86, 306 NaClGetCurrentCPUFeaturesX86,
304 NaClFixCPUFeaturesX86, 307 NaClFixCPUFeaturesX86,
305 IsOnInstBoundary_x86_64, 308 IsOnInstBoundary_x86_64,
306 }; 309 };
307 310
308 const struct NaClValidatorInterface *NaClDfaValidatorCreate_x86_64(void) { 311 const struct NaClValidatorInterface *NaClDfaValidatorCreate_x86_64(void) {
309 return &validator; 312 return &validator;
310 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698