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/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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 problems_ = true; | 40 problems_ = true; |
41 } | 41 } |
42 virtual bool should_continue() { | 42 virtual bool should_continue() { |
43 return !problems_; | 43 return !problems_; |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 EXTERN_C_BEGIN | 47 EXTERN_C_BEGIN |
48 | 48 |
49 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size) { | 49 int NCValidateSegment(uint8_t *mbase, uint32_t vbase, size_t size, |
| 50 bool thumb) { |
| 51 nacl_arm_dec::RegisterList roRegs = Register(9); |
| 52 if (thumb) { |
| 53 roRegs = nacl_arm_dec::kRegisterListNothing; |
| 54 } |
50 SfiValidator validator( | 55 SfiValidator validator( |
51 16, // bytes per bundle | 56 16, // bytes per bundle |
52 1U * 1024 * 1024 * 1024, // bytes of code space | 57 1U * 1024 * 1024 * 1024, // bytes of code space |
53 1U * 1024 * 1024 * 1024, // bytes of data space | 58 1U * 1024 * 1024 * 1024, // bytes of data space |
54 Register(9), // read only register(s) | 59 roRegs, // read only register(s) |
55 kRegisterStack); // data addressing register(s) | 60 kRegisterStack, // data addressing register(s) |
56 | 61 thumb); |
57 EarlyExitProblemSink sink; | 62 EarlyExitProblemSink sink; |
58 | 63 |
59 vector<CodeSegment> segments; | 64 vector<CodeSegment> segments; |
60 segments.push_back(CodeSegment(mbase, vbase, size)); | 65 segments.push_back(CodeSegment(mbase, vbase, size)); |
61 | 66 |
62 bool success = validator.validate(segments, &sink); | 67 bool success = validator.validate(segments, &sink); |
63 if (!success) return 2; // for compatibility with old validator | 68 if (!success) return 2; // for compatibility with old validator |
64 return 0; | 69 return 0; |
65 } | 70 } |
66 | 71 |
67 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, arm, 32) ( | 72 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, arm, 32) ( |
68 enum NaClSBKind sb_kind, | 73 enum NaClSBKind sb_kind, |
69 NaClApplyValidationKind kind, | 74 NaClApplyValidationKind kind, |
70 uintptr_t guest_addr, | 75 uintptr_t guest_addr, |
71 uint8_t *data, | 76 uint8_t *data, |
72 size_t size, | 77 size_t size, |
73 int bundle_size, | 78 int bundle_size, |
74 Bool local_cpu) { | 79 Bool local_cpu) { |
75 NaClValidationStatus status = NaClValidationFailedNotImplemented; | 80 NaClValidationStatus status = NaClValidationFailedNotImplemented; |
76 UNREFERENCED_PARAMETER(local_cpu); | 81 UNREFERENCED_PARAMETER(local_cpu); |
77 UNREFERENCED_PARAMETER(sb_kind); | 82 |
78 if (bundle_size == 16) { | 83 if (bundle_size == 16) { |
79 if (kind == NaClApplyCodeValidation) { | 84 if (kind == NaClApplyCodeValidation) { |
80 status = ((0 == NCValidateSegment(data, guest_addr, size)) | 85 status = ((0 == NCValidateSegment(data, guest_addr, size, |
| 86 sb_kind == NACL_SB_ARM_THUMB2)) |
81 ? NaClValidationSucceeded : NaClValidationFailed); | 87 ? NaClValidationSucceeded : NaClValidationFailed); |
82 } | 88 } |
83 } | 89 } |
84 return status; | 90 return status; |
85 } | 91 } |
86 | 92 |
87 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) | 93 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) |
88 (enum NaClSBKind sb_kind, | 94 (enum NaClSBKind sb_kind, |
89 uintptr_t guest_addr, | 95 uintptr_t guest_addr, |
90 uint8_t *data_old, | 96 uint8_t *data_old, |
(...skipping 19 matching lines...) Expand all Loading... |
110 UNREFERENCED_PARAMETER(sb_kind); | 116 UNREFERENCED_PARAMETER(sb_kind); |
111 UNREFERENCED_PARAMETER(guest_addr); | 117 UNREFERENCED_PARAMETER(guest_addr); |
112 UNREFERENCED_PARAMETER(data_old); | 118 UNREFERENCED_PARAMETER(data_old); |
113 UNREFERENCED_PARAMETER(data_new); | 119 UNREFERENCED_PARAMETER(data_new); |
114 UNREFERENCED_PARAMETER(size); | 120 UNREFERENCED_PARAMETER(size); |
115 UNREFERENCED_PARAMETER(bundle_size); | 121 UNREFERENCED_PARAMETER(bundle_size); |
116 return NaClValidationFailedNotImplemented; | 122 return NaClValidationFailedNotImplemented; |
117 } | 123 } |
118 | 124 |
119 EXTERN_C_END | 125 EXTERN_C_END |
OLD | NEW |