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

Side by Side Diff: src/trusted/validator_ragel/unreviewed/dfa_validate_64.c

Issue 10134056: Refactor the process of choosing validators. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: more aesthetics Created 8 years, 6 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 | Annotate | Revision Log
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 ApplyDfaValidator API for the x86-64 architecture. */ 7 /* Implement the Validator API for the x86-64 architecture. */
8 #include <assert.h> 8 #include <assert.h>
9 #include "native_client/src/shared/platform/nacl_log.h" 9 #include "native_client/src/shared/platform/nacl_log.h"
10 #include "native_client/src/trusted/validator/ncvalidate.h" 10 #include "native_client/src/trusted/validator/ncvalidate.h"
11 #include "native_client/src/trusted/validator/validation_cache.h" 11 #include "native_client/src/trusted/validator/validation_cache.h"
12 #include "native_client/src/trusted/validator_ragel/unreviewed/validator.h" 12 #include "native_client/src/trusted/validator_ragel/unreviewed/validator.h"
13 13
14 /* Be sure the correct compile flags are defined for this. */ 14 /* Be sure the correct compile flags are defined for this. */
15 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 15 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86
16 # error("Can't compile, target is for x86-64") 16 # error("Can't compile, target is for x86-64")
17 #else 17 #else
18 # if NACL_TARGET_SUBARCH != 64 18 # if NACL_TARGET_SUBARCH != 64
19 # error("Can't compile, target is for x86-64") 19 # error("Can't compile, target is for x86-64")
20 # endif 20 # endif
21 #endif 21 #endif
22 22
23 static void ProcessError(const uint8_t *ptr, void *userdata) { 23 static void ProcessError(const uint8_t *ptr, void *userdata) {
24 UNREFERENCED_PARAMETER(ptr); 24 UNREFERENCED_PARAMETER(ptr);
25 UNREFERENCED_PARAMETER(userdata); 25 UNREFERENCED_PARAMETER(userdata);
26 } 26 }
27 27
28 NaClValidationStatus NACL_SUBARCH_NAME(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 int readonly_text, 33 int readonly_text,
34 const NaClCPUFeaturesX86 *cpu_features, 34 const NaClCPUFeaturesX86 *cpu_features,
35 struct NaClValidationCache *cache) { 35 struct NaClValidationCache *cache) {
36 UNREFERENCED_PARAMETER(guest_addr); 36 UNREFERENCED_PARAMETER(guest_addr);
37 UNREFERENCED_PARAMETER(cache); 37 UNREFERENCED_PARAMETER(cache);
38 38
39 if (stubout_mode || readonly_text) { 39 if (stubout_mode || readonly_text) {
40 return NaClValidationFailedNotImplemented; 40 return NaClValidationFailedNotImplemented;
41 } 41 }
42 if (!NaClArchSupported(cpu_features)) { 42 if (!NaClArchSupported(cpu_features)) {
43 return NaClValidationFailedCpuNotSupported; 43 return NaClValidationFailedCpuNotSupported;
44 } 44 }
45 if (ValidateChunkAMD64(data, size, cpu_features, ProcessError, 0) == 0) { 45 if (ValidateChunkAMD64(data, size, cpu_features, ProcessError, 0) == 0) {
46 return NaClValidationSucceeded; 46 return NaClValidationSucceeded;
47 } 47 }
48 return NaClValidationFailed; 48 return NaClValidationFailed;
49 } 49 }
50
51 static NaClValidationStatus ValidatorCopyNotImplemented(
52 uintptr_t guest_addr,
53 uint8_t *data_old,
54 uint8_t *data_new,
55 size_t size,
56 const NaClCPUFeatures *cpu_features,
57 NaClCopyInstructionFunc copy_func) {
58 UNREFERENCED_PARAMETER(guest_addr);
59 UNREFERENCED_PARAMETER(data_old);
60 UNREFERENCED_PARAMETER(data_new);
61 UNREFERENCED_PARAMETER(size);
62 UNREFERENCED_PARAMETER(cpu_features);
63 UNREFERENCED_PARAMETER(copy_func);
64 return NaClValidationFailedNotImplemented;
65 }
66
67 static NaClValidationStatus ValidatorCodeReplacementNotImplemented(
68 uintptr_t guest_addr,
69 uint8_t *data_old,
70 uint8_t *data_new,
71 size_t size,
72 const NaClCPUFeatures *cpu_features) {
73 UNREFERENCED_PARAMETER(guest_addr);
74 UNREFERENCED_PARAMETER(data_old);
75 UNREFERENCED_PARAMETER(data_new);
76 UNREFERENCED_PARAMETER(size);
77 UNREFERENCED_PARAMETER(cpu_features);
78 return NaClValidationFailedNotImplemented;
79 }
80
81 static const struct NaClValidatorInterface validator = {
82 ApplyDfaValidator_x86_64,
83 ValidatorCopyNotImplemented,
84 ValidatorCodeReplacementNotImplemented,
85 };
86
87 const struct NaClValidatorInterface *NaClDfaValidatorCreate_x86_64() {
88 return &validator;
89 }
OLDNEW
« no previous file with comments | « src/trusted/validator_ragel/unreviewed/dfa_validate_32.c ('k') | src/trusted/validator_x86/nccopycode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698