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

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: draft that does not fully build Created 8 years, 7 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::kRegisterStack; 22 using nacl_arm_dec::kRegisterStack;
23 using std::vector; 23 using std::vector;
24 24
25 class EarlyExitProblemSink : public nacl_arm_val::ProblemSink { 25 class EarlyExitProblemSink : public nacl_arm_val::ProblemSink {
26 private: 26 private:
(...skipping 11 matching lines...) Expand all
38 UNREFERENCED_PARAMETER(problem_code); 38 UNREFERENCED_PARAMETER(problem_code);
39 UNREFERENCED_PARAMETER(ref_vaddr); 39 UNREFERENCED_PARAMETER(ref_vaddr);
40 40
41 problems_ = true; 41 problems_ = true;
42 } 42 }
43 virtual bool should_continue() { 43 virtual bool should_continue() {
44 return !problems_; 44 return !problems_;
45 } 45 }
46 }; 46 };
47 47
48 static NaClValidationStatus ValidatorCopyNotImplemented(
Nick Bray 2012/04/27 22:21:36 For consistency with ragel, place these functions
pasko-google - do not use 2012/05/12 12:18:40 I do not see an interface declaration here, which
49 uintptr_t guest_addr,
50 uint8_t *data_old,
51 uint8_t *data_new,
52 size_t size,
53 const NaClCPUFeatures *cpu_features) {
54 UNREFERENCED_PARAMETER(guest_addr);
55 UNREFERENCED_PARAMETER(data_old);
56 UNREFERENCED_PARAMETER(data_new);
57 UNREFERENCED_PARAMETER(size);
58 UNREFERENCED_PARAMETER(cpu_features);
59 return NaClValidationFailedNotImplemented;
60 }
61
62 static NaClValidationStatus ValidatorCodeReplacementNotImplemented(
63 uintptr_t guest_addr,
64 uint8_t *data_old,
65 uint8_t *data_new,
66 size_t size,
67 const NaClCPUFeatures *cpu_features) {
68 UNREFERENCED_PARAMETER(guest_addr);
69 UNREFERENCED_PARAMETER(data_old);
70 UNREFERENCED_PARAMETER(data_new);
71 UNREFERENCED_PARAMETER(size);
72 UNREFERENCED_PARAMETER(cpu_features);
73 return NaClValidationFailedNotImplemented;
74 }
75
48 EXTERN_C_BEGIN 76 EXTERN_C_BEGIN
49 77
50 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size) { 78 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size) {
51 SfiValidator validator( 79 SfiValidator validator(
52 16, // bytes per bundle 80 16, // bytes per bundle
53 1U * 1024 * 1024 * 1024, // bytes of code space 81 1U * 1024 * 1024 * 1024, // bytes of code space
54 1U * 1024 * 1024 * 1024, // bytes of data space 82 1U * 1024 * 1024 * 1024, // bytes of data space
55 Register(9), // read only register(s) 83 Register(9), // read only register(s)
56 kRegisterStack); // data addressing register(s) 84 kRegisterStack); // data addressing register(s)
57 85
58 EarlyExitProblemSink sink; 86 EarlyExitProblemSink sink;
59 87
60 vector<CodeSegment> segments; 88 vector<CodeSegment> segments;
61 segments.push_back(CodeSegment(mbase, vbase, size)); 89 segments.push_back(CodeSegment(mbase, vbase, size));
62 90
63 bool success = validator.validate(segments, &sink); 91 bool success = validator.validate(segments, &sink);
64 if (!success) return 2; // for compatibility with old validator 92 if (!success) return 2; // for compatibility with old validator
65 return 0; 93 return 0;
66 } 94 }
67 95
68 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, arm, 32) ( 96 static NaClValidationStatus ApplyValidatorArm(
69 uintptr_t guest_addr, 97 uintptr_t guest_addr,
70 uint8_t *data, 98 uint8_t *data,
71 size_t size, 99 size_t size,
72 int stubout_mode, 100 int stubout_mode,
73 int readonly_text, 101 int readonly_text,
74 const NaClCPUFeaturesArm *cpu_features, 102 const NaClCPUFeatures *cpu_features,
75 struct NaClValidationCache *cache) { 103 struct NaClValidationCache *cache) {
76 UNREFERENCED_PARAMETER(cpu_features); 104 UNREFERENCED_PARAMETER(cpu_features);
77 /* The ARM validator is currently unsafe w.r.t. caching. */ 105 /* The ARM validator is currently unsafe w.r.t. caching. */
78 UNREFERENCED_PARAMETER(cache); 106 UNREFERENCED_PARAMETER(cache);
79 107
80 if (stubout_mode) 108 if (stubout_mode)
81 return NaClValidationFailedNotImplemented; 109 return NaClValidationFailedNotImplemented;
82 if (readonly_text) 110 if (readonly_text)
83 return NaClValidationFailedNotImplemented; 111 return NaClValidationFailedNotImplemented;
84 112
85 return ((0 == NCValidateSegment(data, guest_addr, size)) 113 return ((0 == NCValidateSegment(data, guest_addr, size))
86 ? NaClValidationSucceeded : NaClValidationFailed); 114 ? NaClValidationSucceeded : NaClValidationFailed);
87 } 115 }
88 116
89 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) 117 static struct NaClValidatorInterface validator = {
90 (uintptr_t guest_addr, 118 ApplyValidatorArm,
91 uint8_t *data_old, 119 ValidatorCopyNotImplemented,
92 uint8_t *data_new, 120 ValidatorCodeReplacementNotImplemented,
93 size_t size, 121 };
94 const NaClCPUFeaturesArm *cpu_features) {
95 UNREFERENCED_PARAMETER(guest_addr);
96 UNREFERENCED_PARAMETER(data_old);
97 UNREFERENCED_PARAMETER(data_new);
98 UNREFERENCED_PARAMETER(size);
99 UNREFERENCED_PARAMETER(cpu_features);
100 return NaClValidationFailedNotImplemented;
101 }
102 122
103 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, arm, 32) 123 void NaClValidatorInitArm(struct NaClValidatorInterface **val) {
104 (uintptr_t guest_addr, 124 *val = &validator;
105 uint8_t *data_old,
106 uint8_t *data_new,
107 size_t size,
108 const NaClCPUFeaturesArm *cpu_features) {
109 UNREFERENCED_PARAMETER(guest_addr);
110 UNREFERENCED_PARAMETER(data_old);
111 UNREFERENCED_PARAMETER(data_new);
112 UNREFERENCED_PARAMETER(size);
113 UNREFERENCED_PARAMETER(cpu_features);
114 return NaClValidationFailedNotImplemented;
115 } 125 }
116 126
117 EXTERN_C_END 127 EXTERN_C_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698