| 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 #include "native_client/src/shared/platform/nacl_log.h" | 7 #include "native_client/src/shared/platform/nacl_log.h" |
| 8 #include "native_client/src/trusted/service_runtime/sel_ldr.h" | 8 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 9 #include "native_client/src/trusted/validator/ncvalidate.h" | 9 #include "native_client/src/trusted/validator/ncvalidate.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (nap->validator_stub_out_mode) { | 64 if (nap->validator_stub_out_mode) { |
| 65 /* Validation caching is currently incompatible with stubout. */ | 65 /* Validation caching is currently incompatible with stubout. */ |
| 66 cache = NULL; | 66 cache = NULL; |
| 67 /* In stub out mode, we do two passes. The second pass acts as a | 67 /* In stub out mode, we do two passes. The second pass acts as a |
| 68 sanity check that bad instructions were indeed overwritten with | 68 sanity check that bad instructions were indeed overwritten with |
| 69 allowable HLTs. */ | 69 allowable HLTs. */ |
| 70 status = NACL_SUBARCH_NAME(ApplyValidator, | 70 status = NACL_SUBARCH_NAME(ApplyValidator, |
| 71 NACL_TARGET_ARCH, | 71 NACL_TARGET_ARCH, |
| 72 NACL_TARGET_SUBARCH)( | 72 NACL_TARGET_SUBARCH)( |
| 73 sb_kind, | 73 sb_kind, |
| 74 NaClApplyValidationDoStubout, | |
| 75 guest_addr, data, size, | 74 guest_addr, data, size, |
| 76 nap->bundle_size, | 75 nap->bundle_size, |
| 76 TRUE, /* stub out */ |
| 77 FALSE, /* text is not read-only */ | 77 FALSE, /* text is not read-only */ |
| 78 &nap->cpu_features, | 78 &nap->cpu_features, |
| 79 cache); | 79 cache); |
| 80 } | 80 } |
| 81 if (status == NaClValidationSucceeded) { | 81 if (status == NaClValidationSucceeded) { |
| 82 /* Fixed feature CPU mode implies read-only */ |
| 83 int readonly_text = nap->fixed_feature_cpu_mode; |
| 82 status = NACL_SUBARCH_NAME(ApplyValidator, | 84 status = NACL_SUBARCH_NAME(ApplyValidator, |
| 83 NACL_TARGET_ARCH, | 85 NACL_TARGET_ARCH, |
| 84 NACL_TARGET_SUBARCH)( | 86 NACL_TARGET_SUBARCH)( |
| 85 sb_kind, | 87 sb_kind, |
| 86 NaClApplyCodeValidation, | |
| 87 guest_addr, data, size, | 88 guest_addr, data, size, |
| 88 nap->bundle_size, | 89 nap->bundle_size, |
| 89 nap->fixed_feature_cpu_mode, | 90 FALSE, /* do not stub out */ |
| 91 readonly_text, |
| 90 &nap->cpu_features, | 92 &nap->cpu_features, |
| 91 cache); | 93 cache); |
| 92 } | 94 } |
| 93 return NaClValidateStatus(status); | 95 return NaClValidateStatus(status); |
| 94 } | 96 } |
| 95 | 97 |
| 96 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, | 98 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, |
| 97 uint8_t *data_old, uint8_t *data_new, | 99 uint8_t *data_old, uint8_t *data_new, |
| 98 size_t size) { | 100 size_t size) { |
| 99 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; | 101 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 NaClLog(LOG_ERROR, | 161 NaClLog(LOG_ERROR, |
| 160 "Run sel_ldr in debug mode to ignore validation failure.\n"); | 162 "Run sel_ldr in debug mode to ignore validation failure.\n"); |
| 161 NaClLog(LOG_ERROR, | 163 NaClLog(LOG_ERROR, |
| 162 "Run ncval <module-name> for validation error details.\n"); | 164 "Run ncval <module-name> for validation error details.\n"); |
| 163 rcode = LOAD_VALIDATION_FAILED; | 165 rcode = LOAD_VALIDATION_FAILED; |
| 164 } | 166 } |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 return rcode; | 169 return rcode; |
| 168 } | 170 } |
| OLD | NEW |