| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 cpu_features, &vstate); | 96 cpu_features, &vstate); |
| 97 if (status != NaClValidationSucceeded) return status; | 97 if (status != NaClValidationSucceeded) return status; |
| 98 NaClValidatorStateSetDoStubOut(vstate, TRUE); | 98 NaClValidatorStateSetDoStubOut(vstate, TRUE); |
| 99 NaClValidateSegment(data, guest_addr, size, vstate); | 99 NaClValidateSegment(data, guest_addr, size, vstate); |
| 100 NaClValidatorStateDestroy(vstate); | 100 NaClValidatorStateDestroy(vstate); |
| 101 return NaClValidationSucceeded; | 101 return NaClValidationSucceeded; |
| 102 } | 102 } |
| 103 | 103 |
| 104 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, x86, 64) ( | 104 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, x86, 64) ( |
| 105 enum NaClSBKind sb_kind, | 105 enum NaClSBKind sb_kind, |
| 106 NaClApplyValidationKind kind, | |
| 107 uintptr_t guest_addr, | 106 uintptr_t guest_addr, |
| 108 uint8_t *data, | 107 uint8_t *data, |
| 109 size_t size, | 108 size_t size, |
| 110 int bundle_size, | 109 int bundle_size, |
| 110 int stubout_mode, |
| 111 int readonly_text, | 111 int readonly_text, |
| 112 const NaClCPUFeaturesX86 *cpu_features, | 112 const NaClCPUFeaturesX86 *cpu_features, |
| 113 struct NaClValidationCache *cache) { | 113 struct NaClValidationCache *cache) { |
| 114 NaClValidationStatus status = NaClValidationFailedNotImplemented; | 114 NaClValidationStatus status = NaClValidationFailedNotImplemented; |
| 115 assert(NACL_SB_DEFAULT == sb_kind); | 115 assert(NACL_SB_DEFAULT == sb_kind); |
| 116 if (bundle_size == 16 || bundle_size == 32) { | 116 if (bundle_size == 16 || bundle_size == 32) { |
| 117 if (!NaClArchSupported(cpu_features)) | 117 if (!NaClArchSupported(cpu_features)) |
| 118 return NaClValidationFailedCpuNotSupported; | 118 return NaClValidationFailedCpuNotSupported; |
| 119 switch (kind) { | 119 if (stubout_mode) { |
| 120 case NaClApplyCodeValidation: | 120 status = NaClApplyValidatorStubout_x86_64( |
| 121 status = NaClApplyValidatorSilently_x86_64( | 121 guest_addr, data, size, bundle_size, cpu_features); |
| 122 guest_addr, data, size, bundle_size, | 122 } else { |
| 123 readonly_text, cpu_features, cache); | 123 status = NaClApplyValidatorSilently_x86_64( |
| 124 break; | 124 guest_addr, data, size, bundle_size, |
| 125 case NaClApplyValidationDoStubout: | 125 readonly_text, cpu_features, cache); |
| 126 status = NaClApplyValidatorStubout_x86_64( | |
| 127 guest_addr, data, size, bundle_size, cpu_features); | |
| 128 break; | |
| 129 default: | |
| 130 break; | |
| 131 } | 126 } |
| 132 } | 127 } |
| 133 return status; | 128 return status; |
| 134 } | 129 } |
| 135 | 130 |
| 136 static NaClValidationStatus NaClApplyValidatorPair( | 131 static NaClValidationStatus NaClApplyValidatorPair( |
| 137 uintptr_t guest_addr, | 132 uintptr_t guest_addr, |
| 138 uint8_t *data_old, | 133 uint8_t *data_old, |
| 139 uint8_t *data_new, | 134 uint8_t *data_new, |
| 140 size_t size, | 135 size_t size, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 166 if (bundle_size == 16 || bundle_size == 32) { | 161 if (bundle_size == 16 || bundle_size == 32) { |
| 167 if (!NaClArchSupported(cpu_features)) { | 162 if (!NaClArchSupported(cpu_features)) { |
| 168 status = NaClValidationFailedCpuNotSupported; | 163 status = NaClValidationFailedCpuNotSupported; |
| 169 } else { | 164 } else { |
| 170 status = NaClApplyValidatorPair(guest_addr, data_old, data_new, | 165 status = NaClApplyValidatorPair(guest_addr, data_old, data_new, |
| 171 size, bundle_size, cpu_features); | 166 size, bundle_size, cpu_features); |
| 172 } | 167 } |
| 173 } | 168 } |
| 174 return status; | 169 return status; |
| 175 } | 170 } |
| OLD | NEW |