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

Side by Side Diff: src/trusted/validator/x86/64/ncvalidate.c

Issue 10134056: Refactor the process of choosing validators. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: draft that does not fully build Created 8 years, 8 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 ApplyValidator API for the x86-64 architecture. */ 7 /* Implement the ApplyValidator 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"
(...skipping 15 matching lines...) Expand all
26 int readonly_text, 26 int readonly_text,
27 const NaClCPUFeaturesX86 *cpu_features, 27 const NaClCPUFeaturesX86 *cpu_features,
28 struct NaClValidatorState** vstate_ptr) { 28 struct NaClValidatorState** vstate_ptr) {
29 *vstate_ptr = NaClValidatorStateCreate(guest_addr, size, RegR15, 29 *vstate_ptr = NaClValidatorStateCreate(guest_addr, size, RegR15,
30 readonly_text, cpu_features); 30 readonly_text, cpu_features);
31 return (*vstate_ptr == NULL) 31 return (*vstate_ptr == NULL)
32 ? NaClValidationFailedOutOfMemory 32 ? NaClValidationFailedOutOfMemory
33 : NaClValidationSucceeded; /* or at least to this point! */ 33 : NaClValidationSucceeded; /* or at least to this point! */
34 } 34 }
35 35
36 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, x86, 64) ( 36 static NaClValidationStatus ApplyValidator_x86_64(
37 uintptr_t guest_addr, 37 uintptr_t guest_addr,
38 uint8_t *data, 38 uint8_t *data,
39 size_t size, 39 size_t size,
40 int stubout_mode, 40 int stubout_mode,
41 int readonly_text, 41 int readonly_text,
42 const NaClCPUFeaturesX86 *cpu_features, 42 const NaClCPUFeaturesX86 *cpu_features,
43 struct NaClValidationCache *cache) { 43 struct NaClValidationCache *cache) {
44 struct NaClValidatorState *vstate; 44 struct NaClValidatorState *vstate;
45 NaClValidationStatus status; 45 NaClValidationStatus status;
46 void *query = NULL; 46 void *query = NULL;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 /* Don't cache the result if the code is modified. */ 91 /* Don't cache the result if the code is modified. */
92 if (status == NaClValidationSucceeded && !NaClValidatorDidStubOut(vstate)) 92 if (status == NaClValidationSucceeded && !NaClValidatorDidStubOut(vstate))
93 cache->SetKnownToValidate(query); 93 cache->SetKnownToValidate(query);
94 cache->DestroyQuery(query); 94 cache->DestroyQuery(query);
95 } 95 }
96 96
97 NaClValidatorStateDestroy(vstate); 97 NaClValidatorStateDestroy(vstate);
98 return status; 98 return status;
99 } 99 }
100 100
101 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, x86, 64) 101 static NaClValidationStatus ApplyValidatorCodeReplacement_x86_64(
102 (uintptr_t guest_addr, 102 uintptr_t guest_addr,
103 uint8_t *data_old, 103 uint8_t *data_old,
104 uint8_t *data_new, 104 uint8_t *data_new,
105 size_t size, 105 size_t size,
106 const NaClCPUFeaturesX86 *cpu_features) { 106 const NaClCPUFeaturesX86 *cpu_features) {
107 NaClValidationStatus status; 107 NaClValidationStatus status;
108 struct NaClValidatorState *vstate; 108 struct NaClValidatorState *vstate;
109 109
110 /* Check that the given parameter values are supported. */ 110 /* Check that the given parameter values are supported. */
111 if (!NaClArchSupported(cpu_features)) 111 if (!NaClArchSupported(cpu_features))
112 return NaClValidationFailedCpuNotSupported; 112 return NaClValidationFailedCpuNotSupported;
113 113
114 /* Init then validator state. */ 114 /* Init then validator state. */
115 status = NaClValidatorSetup_x86_64(guest_addr, size, FALSE, 115 status = NaClValidatorSetup_x86_64(guest_addr, size, FALSE,
116 cpu_features, &vstate); 116 cpu_features, &vstate);
117 if (status != NaClValidationSucceeded) 117 if (status != NaClValidationSucceeded)
118 return status; 118 return status;
119 NaClValidatorStateSetLogVerbosity(vstate, LOG_ERROR); 119 NaClValidatorStateSetLogVerbosity(vstate, LOG_ERROR);
120 120
121 /* Validate. */ 121 /* Validate. */
122 NaClValidateSegmentPair(data_old, data_new, guest_addr, size, vstate); 122 NaClValidateSegmentPair(data_old, data_new, guest_addr, size, vstate);
123 status = NaClValidatesOk(vstate) ? 123 status = NaClValidatesOk(vstate) ?
124 NaClValidationSucceeded : NaClValidationFailed; 124 NaClValidationSucceeded : NaClValidationFailed;
125 125
126 NaClValidatorStateDestroy(vstate); 126 NaClValidatorStateDestroy(vstate);
127 return status; 127 return status;
128 } 128 }
129
130 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, x86, 64)
131 (uintptr_t guest_addr,
Nick Bray 2012/04/27 22:21:36 '(' on previous line; indent.
pasko-google - do not use 2012/05/12 12:18:40 Done.
132 uint8_t *data_old,
133 uint8_t *data_new,
134 size_t size,
135 const NaClCPUFeaturesX86 *cpu_features);
136
137 static struct NaClValidatorInterface validator = {
Nick Bray 2012/04/27 22:21:36 const?
pasko-google - do not use 2012/05/12 12:18:40 Done.
138 ApplyValidator_x86_64,
139 NACL_SUBARCH_NAME(ApplyValidatorCopy, x86, 64),
140 ApplyValidatorCodeReplacement_x86_64,
141 };
142
143 void NaClValidatorInit_x86_64(struct NaClValidatorInterface **val) {
Nick Bray 2012/04/27 22:21:36 Maybe this should be a getter (returns the pointer
pasko-google - do not use 2012/05/12 12:18:40 yep, cleaner also has a viral effect on NaClSelect
144 *val = &validator;
145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698