OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 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 10 matching lines...) Expand all Loading... | |
21 case NaClValidationFailedCpuNotSupported: | 21 case NaClValidationFailedCpuNotSupported: |
22 case NaClValidationFailedSegmentationIssue: | 22 case NaClValidationFailedSegmentationIssue: |
23 default: | 23 default: |
24 return LOAD_VALIDATION_FAILED; | 24 return LOAD_VALIDATION_FAILED; |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, | 28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, |
29 uint8_t *data, size_t size) { | 29 uint8_t *data, size_t size) { |
30 NaClValidationStatus status = NaClValidationSucceeded; | 30 NaClValidationStatus status = NaClValidationSucceeded; |
31 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
Karl
2011/08/30 19:53:52
Again, I think this code is confusing build with t
| |
32 uintptr_t entry = nap->user_entry_pt ? | |
33 nap->user_entry_pt : nap->initial_entry_pt; | |
34 uint8_t thumb = entry & 1; | |
35 #endif | |
31 if (nap->validator_stub_out_mode) { | 36 if (nap->validator_stub_out_mode) { |
32 /* In stub out mode, we do two passes. The second pass acts as a | 37 /* In stub out mode, we do two passes. The second pass acts as a |
33 sanity check that bad instructions were indeed overwritten with | 38 sanity check that bad instructions were indeed overwritten with |
34 allowable HLTs. */ | 39 allowable HLTs. */ |
35 status = NACL_SUBARCH_NAME(ApplyValidator, | 40 status = NACL_SUBARCH_NAME(ApplyValidator, |
36 NACL_TARGET_ARCH, | 41 NACL_TARGET_ARCH, |
37 NACL_TARGET_SUBARCH)( | 42 NACL_TARGET_SUBARCH)( |
38 NaClApplyValidationDoStubout, | 43 NaClApplyValidationDoStubout, |
39 guest_addr, data, size, | 44 guest_addr, data, size, |
40 nap->bundle_size, TRUE); | 45 nap->bundle_size, TRUE |
46 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
47 , thumb | |
Karl
2011/08/30 19:53:52
Why is "thumb" needed. Isn't it already communicat
bsy
2011/09/01 00:30:00
stylistically speaking, conditionally adding an ac
jasonwkim
2011/09/16 20:09:16
Fixex
| |
48 #endif | |
49 ); | |
41 } | 50 } |
42 if (status == NaClValidationSucceeded) { | 51 if (status == NaClValidationSucceeded) { |
43 status = NACL_SUBARCH_NAME(ApplyValidator, | 52 status = NACL_SUBARCH_NAME(ApplyValidator, |
44 NACL_TARGET_ARCH, | 53 NACL_TARGET_ARCH, |
45 NACL_TARGET_SUBARCH)( | 54 NACL_TARGET_SUBARCH)( |
46 NaClApplyCodeValidation, | 55 NaClApplyCodeValidation, |
47 guest_addr, data, size, | 56 guest_addr, data, size, |
48 nap->bundle_size, TRUE); | 57 nap->bundle_size, TRUE |
58 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
59 , thumb | |
Karl
2011/08/30 19:53:52
Same question as above.
| |
60 #endif | |
61 ); | |
49 } | 62 } |
50 return NaClValidateStatus(status); | 63 return NaClValidateStatus(status); |
51 } | 64 } |
52 | 65 |
53 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, | 66 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, |
54 uint8_t *data_old, uint8_t *data_new, | 67 uint8_t *data_old, uint8_t *data_new, |
55 size_t size) { | 68 size_t size) { |
69 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
70 uintptr_t entry = nap->user_entry_pt ? | |
71 nap->user_entry_pt : nap->initial_entry_pt; | |
72 uint8_t thumb = entry & 1; | |
73 #endif | |
56 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE; | 74 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE; |
57 | 75 |
58 if ((guest_addr % nap->bundle_size) != 0 || | 76 if ((guest_addr % nap->bundle_size) != 0 || |
59 (size % nap->bundle_size) != 0) { | 77 (size % nap->bundle_size) != 0) { |
60 return LOAD_BAD_FILE; | 78 return LOAD_BAD_FILE; |
61 } | 79 } |
62 | |
63 return NaClValidateStatus( | 80 return NaClValidateStatus( |
64 NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, | 81 NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, |
65 NACL_TARGET_ARCH, | 82 NACL_TARGET_ARCH, |
66 NACL_TARGET_SUBARCH) | 83 NACL_TARGET_SUBARCH) |
67 (guest_addr, data_old, data_new, size, nap->bundle_size)); | 84 (guest_addr, data_old, data_new, size, nap->bundle_size |
85 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
86 , thumb | |
87 #endif | |
88 )); | |
68 } | 89 } |
69 | 90 |
70 int NaClCopyCode(struct NaClApp *nap, uintptr_t guest_addr, | 91 int NaClCopyCode(struct NaClApp *nap, uintptr_t guest_addr, |
71 uint8_t *data_old, uint8_t *data_new, | 92 uint8_t *data_old, uint8_t *data_new, |
72 size_t size) { | 93 size_t size) { |
94 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
95 uintptr_t entry = nap->user_entry_pt ? | |
96 nap->user_entry_pt : nap->initial_entry_pt; | |
97 uint8_t thumb = entry & 1; | |
98 #endif | |
73 return NaClValidateStatus( | 99 return NaClValidateStatus( |
74 NACL_SUBARCH_NAME(ApplyValidatorCopy, | 100 NACL_SUBARCH_NAME(ApplyValidatorCopy, |
75 NACL_TARGET_ARCH, | 101 NACL_TARGET_ARCH, |
76 NACL_TARGET_SUBARCH) | 102 NACL_TARGET_SUBARCH) |
77 (guest_addr, data_old, data_new, size, nap->bundle_size)); | 103 (guest_addr, data_old, data_new, size, nap->bundle_size |
104 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | |
105 , thumb | |
106 #endif | |
107 )); | |
78 } | 108 } |
79 | |
80 NaClErrorCode NaClValidateImage(struct NaClApp *nap) { | 109 NaClErrorCode NaClValidateImage(struct NaClApp *nap) { |
81 uintptr_t memp; | 110 uintptr_t memp; |
82 uintptr_t endp; | 111 uintptr_t endp; |
83 size_t regionsize; | 112 size_t regionsize; |
84 NaClErrorCode rcode; | 113 NaClErrorCode rcode; |
85 | 114 |
86 memp = nap->mem_start + NACL_TRAMPOLINE_END; | 115 memp = nap->mem_start + NACL_TRAMPOLINE_END; |
87 endp = nap->mem_start + nap->static_text_end; | 116 endp = nap->mem_start + nap->static_text_end; |
88 regionsize = endp - memp; | 117 regionsize = endp - memp; |
89 if (endp < memp) { | 118 if (endp < memp) { |
(...skipping 15 matching lines...) Expand all Loading... | |
105 NaClLog(LOG_ERROR, | 134 NaClLog(LOG_ERROR, |
106 "Run sel_ldr in debug mode to ignore validation failure.\n"); | 135 "Run sel_ldr in debug mode to ignore validation failure.\n"); |
107 NaClLog(LOG_ERROR, | 136 NaClLog(LOG_ERROR, |
108 "Run ncval <module-name> for validation error details.\n"); | 137 "Run ncval <module-name> for validation error details.\n"); |
109 rcode = LOAD_VALIDATION_FAILED; | 138 rcode = LOAD_VALIDATION_FAILED; |
110 } | 139 } |
111 } | 140 } |
112 } | 141 } |
113 return rcode; | 142 return rcode; |
114 } | 143 } |
OLD | NEW |