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 uint8_t 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) ( |
Karl
2011/08/30 19:53:52
I would have two functions here, one for each suba
| |
68 NaClApplyValidationKind kind, | 73 NaClApplyValidationKind kind, |
69 uintptr_t guest_addr, | 74 uintptr_t guest_addr, |
70 uint8_t *data, | 75 uint8_t *data, |
71 size_t size, | 76 size_t size, |
72 int bundle_size, | 77 int bundle_size, |
73 Bool local_cpu) { | 78 Bool local_cpu, |
79 uint8_t thumb) { | |
74 NaClValidationStatus status = NaClValidationFailedNotImplemented; | 80 NaClValidationStatus status = NaClValidationFailedNotImplemented; |
75 UNREFERENCED_PARAMETER(local_cpu); | 81 UNREFERENCED_PARAMETER(local_cpu); |
76 if (bundle_size == 16) { | 82 if (bundle_size == 16) { |
77 if (kind == NaClApplyCodeValidation) { | 83 if (kind == NaClApplyCodeValidation) { |
78 status = ((0 == NCValidateSegment(data, guest_addr, size)) | 84 status = ((0 == NCValidateSegment(data, guest_addr, size, thumb)) |
79 ? NaClValidationSucceeded : NaClValidationFailed); | 85 ? NaClValidationSucceeded : NaClValidationFailed); |
80 } | 86 } |
81 } | 87 } |
82 return status; | 88 return status; |
83 } | 89 } |
84 | 90 |
85 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) | 91 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, arm, 32) |
Karl
2011/08/30 19:53:52
Same here, and ApplyValidatorCopy below.
| |
86 (uintptr_t guest_addr, | 92 (uintptr_t guest_addr, |
87 uint8_t *data_old, | 93 uint8_t *data_old, |
88 uint8_t *data_new, | 94 uint8_t *data_new, |
89 size_t size, | 95 size_t size, |
90 int bundle_size) { | 96 int bundle_size, |
97 uint8_t thumb) { | |
91 UNREFERENCED_PARAMETER(guest_addr); | 98 UNREFERENCED_PARAMETER(guest_addr); |
92 UNREFERENCED_PARAMETER(data_old); | 99 UNREFERENCED_PARAMETER(data_old); |
93 UNREFERENCED_PARAMETER(data_new); | 100 UNREFERENCED_PARAMETER(data_new); |
94 UNREFERENCED_PARAMETER(size); | 101 UNREFERENCED_PARAMETER(size); |
95 UNREFERENCED_PARAMETER(bundle_size); | 102 UNREFERENCED_PARAMETER(bundle_size); |
103 UNREFERENCED_PARAMETER(thumb); | |
96 return NaClValidationFailedNotImplemented; | 104 return NaClValidationFailedNotImplemented; |
97 } | 105 } |
98 | 106 |
99 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, arm, 32) | 107 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, arm, 32) |
100 (uintptr_t guest_addr, | 108 (uintptr_t guest_addr, |
101 uint8_t *data_old, | 109 uint8_t *data_old, |
102 uint8_t *data_new, | 110 uint8_t *data_new, |
103 size_t size, | 111 size_t size, |
104 int bundle_size) { | 112 int bundle_size, |
113 uint8_t thumb) { | |
105 UNREFERENCED_PARAMETER(guest_addr); | 114 UNREFERENCED_PARAMETER(guest_addr); |
106 UNREFERENCED_PARAMETER(data_old); | 115 UNREFERENCED_PARAMETER(data_old); |
107 UNREFERENCED_PARAMETER(data_new); | 116 UNREFERENCED_PARAMETER(data_new); |
108 UNREFERENCED_PARAMETER(size); | 117 UNREFERENCED_PARAMETER(size); |
109 UNREFERENCED_PARAMETER(bundle_size); | 118 UNREFERENCED_PARAMETER(bundle_size); |
119 UNREFERENCED_PARAMETER(thumb); | |
110 return NaClValidationFailedNotImplemented; | 120 return NaClValidationFailedNotImplemented; |
111 } | 121 } |
112 | 122 |
113 EXTERN_C_END | 123 EXTERN_C_END |
OLD | NEW |