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 Validator API for the x86-32 architecture. */ | 7 /* Implement the Validator API for the x86-32 architecture. */ |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 uint32_t flags, | 33 uint32_t flags, |
34 int readonly_text, | 34 int readonly_text, |
35 const NaClCPUFeatures *f, | 35 const NaClCPUFeatures *f, |
36 const struct NaClValidationMetadata *metadata, | 36 const struct NaClValidationMetadata *metadata, |
37 struct NaClValidationCache *cache) { | 37 struct NaClValidationCache *cache) { |
38 /* TODO(jfb) Use a safe cast here. */ | 38 /* TODO(jfb) Use a safe cast here. */ |
39 NaClCPUFeaturesX86 *cpu_features = (NaClCPUFeaturesX86 *) f; | 39 NaClCPUFeaturesX86 *cpu_features = (NaClCPUFeaturesX86 *) f; |
40 enum NaClValidationStatus status = NaClValidationFailed; | 40 enum NaClValidationStatus status = NaClValidationFailed; |
41 void *query = NULL; | 41 void *query = NULL; |
42 struct StubOutCallbackData callback_data; | 42 struct StubOutCallbackData callback_data; |
| 43 |
43 callback_data.flags = flags; | 44 callback_data.flags = flags; |
44 callback_data.did_rewrite = 0; | 45 callback_data.did_rewrite = 0; |
| 46 callback_data.chunk_processed_as_a_contiguous_stream = 0; |
| 47 callback_data.bundle_begin_offset = (intptr_t) data & kBundleMask; |
| 48 callback_data.cpu_features = cpu_features; |
45 UNREFERENCED_PARAMETER(guest_addr); | 49 UNREFERENCED_PARAMETER(guest_addr); |
46 | 50 |
47 if (stubout_mode) | 51 if (stubout_mode) |
48 return NaClValidationFailedNotImplemented; | 52 return NaClValidationFailedNotImplemented; |
49 if (!NaClArchSupportedX86(cpu_features)) | 53 if (!NaClArchSupportedX86(cpu_features)) |
50 return NaClValidationFailedCpuNotSupported; | 54 return NaClValidationFailedCpuNotSupported; |
51 if (size & kBundleMask) | 55 if (size & kBundleMask) |
52 return NaClValidationFailed; | 56 return NaClValidationFailed; |
53 | 57 |
54 /* | 58 /* |
(...skipping 17 matching lines...) Expand all Loading... |
72 if (ValidateChunkIA32(data, size, 0 /*options*/, cpu_features, | 76 if (ValidateChunkIA32(data, size, 0 /*options*/, cpu_features, |
73 NaClDfaProcessValidationError, | 77 NaClDfaProcessValidationError, |
74 NULL)) | 78 NULL)) |
75 status = NaClValidationSucceeded; | 79 status = NaClValidationSucceeded; |
76 } else { | 80 } else { |
77 if (ValidateChunkIA32(data, size, 0 /*options*/, cpu_features, | 81 if (ValidateChunkIA32(data, size, 0 /*options*/, cpu_features, |
78 NaClDfaStubOutUnsupportedInstruction, | 82 NaClDfaStubOutUnsupportedInstruction, |
79 &callback_data)) | 83 &callback_data)) |
80 status = NaClValidationSucceeded; | 84 status = NaClValidationSucceeded; |
81 } | 85 } |
| 86 |
82 if (status != NaClValidationSucceeded && errno == ENOMEM) | 87 if (status != NaClValidationSucceeded && errno == ENOMEM) |
83 status = NaClValidationFailedOutOfMemory; | 88 status = NaClValidationFailedOutOfMemory; |
84 | 89 |
85 /* Cache the result if validation succeeded and the code was not modified. */ | 90 /* Cache the result if validation succeeded and the code was not modified. */ |
86 if (query != NULL) { | 91 if (query != NULL) { |
87 if (status == NaClValidationSucceeded && callback_data.did_rewrite == 0) | 92 if (status == NaClValidationSucceeded && callback_data.did_rewrite == 0) |
88 cache->SetKnownToValidate(query); | 93 cache->SetKnownToValidate(query); |
89 cache->DestroyQuery(query); | 94 cache->DestroyQuery(query); |
90 } | 95 } |
91 | 96 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 sizeof(NaClCPUFeaturesX86), | 369 sizeof(NaClCPUFeaturesX86), |
365 NaClSetAllCPUFeaturesX86, | 370 NaClSetAllCPUFeaturesX86, |
366 NaClGetCurrentCPUFeaturesX86, | 371 NaClGetCurrentCPUFeaturesX86, |
367 NaClFixCPUFeaturesX86, | 372 NaClFixCPUFeaturesX86, |
368 IsOnInstBoundary_x86_32, | 373 IsOnInstBoundary_x86_32, |
369 }; | 374 }; |
370 | 375 |
371 const struct NaClValidatorInterface *NaClDfaValidatorCreate_x86_32(void) { | 376 const struct NaClValidatorInterface *NaClDfaValidatorCreate_x86_32(void) { |
372 return &validator; | 377 return &validator; |
373 } | 378 } |
OLD | NEW |