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

Side by Side Diff: src/trusted/validator_arm/ncvalidate.cc

Issue 10134056: Refactor the process of choosing validators. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: tweaks for win64 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 #include "native_client/src/trusted/validator_arm/ncvalidate.h" 7 #include "native_client/src/trusted/validator_arm/ncvalidate.h"
8 8
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "native_client/src/include/nacl_string.h" 12 #include "native_client/src/include/nacl_string.h"
13 #include "native_client/src/include/portability.h" 13 #include "native_client/src/include/portability.h"
14 #include "native_client/src/trusted/validator_arm/cpuid_arm.h" 14 #include "native_client/src/trusted/validator_arm/cpuid_arm.h"
15 #include "native_client/src/trusted/validator_arm/model.h"
15 #include "native_client/src/trusted/validator_arm/validator.h" 16 #include "native_client/src/trusted/validator_arm/validator.h"
16 #include "native_client/src/trusted/validator_arm/model.h"
17 #include "native_client/src/trusted/validator/ncvalidate.h" 17 #include "native_client/src/trusted/validator/ncvalidate.h"
18 18
19 using nacl_arm_val::SfiValidator; 19 using nacl_arm_val::SfiValidator;
20 using nacl_arm_val::CodeSegment; 20 using nacl_arm_val::CodeSegment;
21 using nacl_arm_dec::Register; 21 using nacl_arm_dec::Register;
22 using nacl_arm_dec::RegisterList; 22 using nacl_arm_dec::RegisterList;
23 using nacl_arm_dec::kRegisterStack; 23 using nacl_arm_dec::kRegisterStack;
24 using std::vector; 24 using std::vector;
25 25
26 class EarlyExitProblemSink : public nacl_arm_val::ProblemSink { 26 class EarlyExitProblemSink : public nacl_arm_val::ProblemSink {
(...skipping 14 matching lines...) Expand all
41 nacl_arm_val::ValidatorProblemUserData user_data) { 41 nacl_arm_val::ValidatorProblemUserData user_data) {
42 UNREFERENCED_PARAMETER(vaddr); 42 UNREFERENCED_PARAMETER(vaddr);
43 UNREFERENCED_PARAMETER(problem); 43 UNREFERENCED_PARAMETER(problem);
44 UNREFERENCED_PARAMETER(method); 44 UNREFERENCED_PARAMETER(method);
45 UNREFERENCED_PARAMETER(user_data); 45 UNREFERENCED_PARAMETER(user_data);
46 46
47 problems_ = true; 47 problems_ = true;
48 } 48 }
49 }; 49 };
50 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
51 EXTERN_C_BEGIN 81 EXTERN_C_BEGIN
52 82
53 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size) { 83 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size) {
54 SfiValidator validator( 84 SfiValidator validator(
55 16, // bytes per bundle 85 16, // bytes per bundle
56 1U * 1024 * 1024 * 1024, // bytes of code space 86 1U * 1024 * 1024 * 1024, // bytes of code space
57 1U * 1024 * 1024 * 1024, // bytes of data space 87 1U * 1024 * 1024 * 1024, // bytes of data space
58 RegisterList(Register(9)), 88 RegisterList(Register(9)),
59 RegisterList(kRegisterStack)); 89 RegisterList(kRegisterStack));
60 90
61 EarlyExitProblemSink sink; 91 EarlyExitProblemSink sink;
62 92
63 vector<CodeSegment> segments; 93 vector<CodeSegment> segments;
64 segments.push_back(CodeSegment(mbase, vbase, size)); 94 segments.push_back(CodeSegment(mbase, vbase, size));
65 95
66 bool success = validator.validate(segments, &sink); 96 bool success = validator.validate(segments, &sink);
67 if (!success) return 2; // for compatibility with old validator 97 if (!success) return 2; // for compatibility with old validator
68 return 0; 98 return 0;
69 } 99 }
70 100
71 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, arm, 32) ( 101 static NaClValidationStatus ApplyValidatorArm(
72 uintptr_t guest_addr, 102 uintptr_t guest_addr,
73 uint8_t *data, 103 uint8_t *data,
74 size_t size, 104 size_t size,
75 int stubout_mode, 105 int stubout_mode,
76 int readonly_text, 106 int readonly_text,
77 const NaClCPUFeaturesArm *cpu_features, 107 const NaClCPUFeatures *cpu_features,
78 struct NaClValidationCache *cache) { 108 struct NaClValidationCache *cache) {
79 UNREFERENCED_PARAMETER(cpu_features); 109 UNREFERENCED_PARAMETER(cpu_features);
80 /* The ARM validator is currently unsafe w.r.t. caching. */ 110 /* The ARM validator is currently unsafe w.r.t. caching. */
81 UNREFERENCED_PARAMETER(cache); 111 UNREFERENCED_PARAMETER(cache);
82 112
83 if (stubout_mode) 113 if (stubout_mode)
84 return NaClValidationFailedNotImplemented; 114 return NaClValidationFailedNotImplemented;
85 if (readonly_text) 115 if (readonly_text)
86 return NaClValidationFailedNotImplemented; 116 return NaClValidationFailedNotImplemented;
87 117
88 return ((0 == NCValidateSegment(data, guest_addr, size)) 118 return ((0 == NCValidateSegment(data, guest_addr, size))
89 ? NaClValidationSucceeded : NaClValidationFailed); 119 ? NaClValidationSucceeded : NaClValidationFailed);
90 } 120 }
91 121
92 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) 122 static struct NaClValidatorInterface validator = {
93 (uintptr_t guest_addr, 123 ApplyValidatorArm,
94 uint8_t *data_old, 124 ValidatorCopyNotImplemented,
95 uint8_t *data_new, 125 ValidatorCodeReplacementNotImplemented,
96 size_t size, 126 };
97 const NaClCPUFeaturesArm *cpu_features) {
98 UNREFERENCED_PARAMETER(guest_addr);
99 UNREFERENCED_PARAMETER(data_old);
100 UNREFERENCED_PARAMETER(data_new);
101 UNREFERENCED_PARAMETER(size);
102 UNREFERENCED_PARAMETER(cpu_features);
103 return NaClValidationFailedNotImplemented;
104 }
105 127
106 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, arm, 32) 128 const struct NaClValidatorInterface* NaClValidatorCreateArm() {
Mark Seaborn 2012/06/21 18:42:01 Use " *" spacing style
pasko-google - do not use 2012/06/22 10:11:27 Done.
107 (uintptr_t guest_addr, 129 return &validator;
108 uint8_t *data_old,
109 uint8_t *data_new,
110 size_t size,
111 const NaClCPUFeaturesArm *cpu_features) {
112 UNREFERENCED_PARAMETER(guest_addr);
113 UNREFERENCED_PARAMETER(data_old);
114 UNREFERENCED_PARAMETER(data_new);
115 UNREFERENCED_PARAMETER(size);
116 UNREFERENCED_PARAMETER(cpu_features);
117 return NaClValidationFailedNotImplemented;
118 } 130 }
119 131
120 EXTERN_C_END 132 EXTERN_C_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698