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

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

Issue 10024039: Replace kind variable from validator API with Boolean stubout parameter. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: 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-32 architecture. */ 7 /* Implement the ApplyValidator API for the x86-32 architecture. */
8 8
9 #include "native_client/src/trusted/validator/ncvalidate.h" 9 #include "native_client/src/trusted/validator/ncvalidate.h"
10 #include "native_client/src/trusted/validator/validation_cache.h" 10 #include "native_client/src/trusted/validator/validation_cache.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (vstate == NULL) return NaClValidationFailedOutOfMemory; 83 if (vstate == NULL) return NaClValidationFailedOutOfMemory;
84 NCValidateSetStubOutMode(vstate, 1); 84 NCValidateSetStubOutMode(vstate, 1);
85 NCValidateSegment(data, guest_addr, size, vstate); 85 NCValidateSegment(data, guest_addr, size, vstate);
86 NCValidateFinish(vstate); 86 NCValidateFinish(vstate);
87 NCValidateFreeState(&vstate); 87 NCValidateFreeState(&vstate);
88 return NaClValidationSucceeded; 88 return NaClValidationSucceeded;
89 } 89 }
90 90
91 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, NACL_TARGET_ARCH, 32) ( 91 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, NACL_TARGET_ARCH, 32) (
92 enum NaClSBKind sb_kind, 92 enum NaClSBKind sb_kind,
93 NaClApplyValidationKind kind,
94 uintptr_t guest_addr, 93 uintptr_t guest_addr,
95 uint8_t *data, 94 uint8_t *data,
96 size_t size, 95 size_t size,
97 int bundle_size, 96 int bundle_size,
97 int stubout_mode,
98 int readonly_text, 98 int readonly_text,
99 const NaClCPUFeaturesX86 *cpu_features, 99 const NaClCPUFeaturesX86 *cpu_features,
100 struct NaClValidationCache *cache) { 100 struct NaClValidationCache *cache) {
101 NaClValidationStatus status = NaClValidationFailedNotImplemented; 101 NaClValidationStatus status = NaClValidationFailedNotImplemented;
102 assert(NACL_SB_DEFAULT == sb_kind); 102 assert(NACL_SB_DEFAULT == sb_kind);
103 if (bundle_size == 16 || bundle_size == 32) { 103 if (bundle_size == 16 || bundle_size == 32) {
104 if (!NaClArchSupported(cpu_features)) 104 if (!NaClArchSupported(cpu_features))
105 return NaClValidationFailedCpuNotSupported; 105 return NaClValidationFailedCpuNotSupported;
106 switch (kind) { 106 if (stubout_mode) {
107 case NaClApplyCodeValidation: 107 status = NCApplyValidatorStubout_x86_32(
108 status = NCApplyValidatorSilently_x86_32( 108 guest_addr, data, size, bundle_size, cpu_features);
109 } else {
110 status = NCApplyValidatorSilently_x86_32(
109 guest_addr, data, size, bundle_size, 111 guest_addr, data, size, bundle_size,
110 readonly_text, cpu_features, cache); 112 readonly_text, cpu_features, cache);
111 break;
112 case NaClApplyValidationDoStubout:
113 status = NCApplyValidatorStubout_x86_32(
114 guest_addr, data, size, bundle_size, cpu_features);
115 break;
116 default:
117 /* If reached, it isn't implemented (yet). */
118 break;
119 } 113 }
120 } 114 }
121 return status; 115 return status;
122 } 116 }
123 117
124 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, x86, 32) 118 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, x86, 32)
125 (enum NaClSBKind sb_kind, 119 (enum NaClSBKind sb_kind,
126 uintptr_t guest_addr, 120 uintptr_t guest_addr,
127 uint8_t *data_old, 121 uint8_t *data_old,
128 uint8_t *data_new, 122 uint8_t *data_new,
129 size_t size, 123 size_t size,
130 int bundle_size, 124 int bundle_size,
131 const NaClCPUFeaturesX86 *cpu_features) { 125 const NaClCPUFeaturesX86 *cpu_features) {
132 NaClValidationStatus status = NaClValidationFailedNotImplemented; 126 NaClValidationStatus status = NaClValidationFailedNotImplemented;
133 assert(NACL_SB_DEFAULT == sb_kind); 127 assert(NACL_SB_DEFAULT == sb_kind);
134 if (bundle_size == 16 || bundle_size == 32) { 128 if (bundle_size == 16 || bundle_size == 32) {
135 if (!NaClArchSupported(cpu_features)) { 129 if (!NaClArchSupported(cpu_features)) {
136 status = NaClValidationFailedCpuNotSupported; 130 status = NaClValidationFailedCpuNotSupported;
137 } else { 131 } else {
138 status = NCValidateSegmentPair(data_old, data_new, guest_addr, 132 status = NCValidateSegmentPair(data_old, data_new, guest_addr,
139 size, bundle_size, cpu_features) 133 size, bundle_size, cpu_features)
140 ? NaClValidationSucceeded : NaClValidationFailed; 134 ? NaClValidationSucceeded : NaClValidationFailed;
141 } 135 }
142 } 136 }
143 return status; 137 return status;
144 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698