| 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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ | 7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ |
| 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ | 8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ |
| 9 | 9 |
| 10 /* Defines the API to the native client validation code. | 10 /* Defines the API to the native client validation code. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 /* Applies the validator, as defined by sel_ldr. That is, run the | 66 /* Applies the validator, as defined by sel_ldr. That is, run the |
| 67 * validator where performance is critical. | 67 * validator where performance is critical. |
| 68 * Parameters are: | 68 * Parameters are: |
| 69 * local_cpu: True if local cpu rules should be applied. | 69 * local_cpu: True if local cpu rules should be applied. |
| 70 * Otherwise, assume no cpu specific rules. | 70 * Otherwise, assume no cpu specific rules. |
| 71 * guest_addr - The virtual pc to assume with the beginning address of the | 71 * guest_addr - The virtual pc to assume with the beginning address of the |
| 72 * code segment. Typically, this is the corresponding addresss that | 72 * code segment. Typically, this is the corresponding addresss that |
| 73 * will be used by objdump. | 73 * will be used by objdump. |
| 74 * data - The contents of the code segment to be validated. | 74 * data - The contents of the code segment to be validated. |
| 75 * size - The size of the code segment to be validated. | 75 * size - The size of the code segment to be validated. |
| 76 * bundle_size - The number of bytes in a code bundle. | |
| 77 * stubout_mode - Whether the validator should stub out disallowed | 76 * stubout_mode - Whether the validator should stub out disallowed |
| 78 * instructions. This applies the validator silently, stubbing out | 77 * instructions. This applies the validator silently, stubbing out |
| 79 * instructions that may not validate with a suitable halt | 78 * instructions that may not validate with a suitable halt |
| 80 * instruction. Note: The return status of NaClValidationSucceeded in | 79 * instruction. Note: The return status of NaClValidationSucceeded in |
| 81 * this case does not necessarily imply that all illegal instructions | 80 * this case does not necessarily imply that all illegal instructions |
| 82 * have been stubbed out. It is the responsibility of the caller to | 81 * have been stubbed out. It is the responsibility of the caller to |
| 83 * call the validator a second time to see if the stubbed code is | 82 * call the validator a second time to see if the stubbed code is |
| 84 * valid. Typically used as the first step of a stubout tool (either | 83 * valid. Typically used as the first step of a stubout tool (either |
| 85 * in sel_ldr or command-line tool). | 84 * in sel_ldr or command-line tool). |
| 86 * readonly_text - If code should be considered read-only. | 85 * readonly_text - If code should be considered read-only. |
| 87 * cpu_features - The CPU features to support while validating. | 86 * cpu_features - The CPU features to support while validating. |
| 88 * cache - Pointer to NaCl validation cache. | 87 * cache - Pointer to NaCl validation cache. |
| 89 */ | 88 */ |
| 90 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, | 89 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, |
| 91 NACL_TARGET_ARCH, | 90 NACL_TARGET_ARCH, |
| 92 NACL_TARGET_SUBARCH)( | 91 NACL_TARGET_SUBARCH)( |
| 93 enum NaClSBKind sb_kind, | 92 enum NaClSBKind sb_kind, |
| 94 uintptr_t guest_addr, | 93 uintptr_t guest_addr, |
| 95 uint8_t *data, | 94 uint8_t *data, |
| 96 size_t size, | 95 size_t size, |
| 97 int bundle_size, | |
| 98 int stubout_mode, | 96 int stubout_mode, |
| 99 int readonly_text, | 97 int readonly_text, |
| 100 const NaClCPUFeatures *cpu_features, | 98 const NaClCPUFeatures *cpu_features, |
| 101 struct NaClValidationCache *cache); | 99 struct NaClValidationCache *cache); |
| 102 | 100 |
| 103 /* Applies the validator, as used in a command-line tool to report issues. | 101 /* Applies the validator, as used in a command-line tool to report issues. |
| 104 * Note: This is intentionally separated from ApplyValidator, since it need | 102 * Note: This is intentionally separated from ApplyValidator, since it need |
| 105 * not be performance critical. | 103 * not be performance critical. |
| 106 * Parameters are: | 104 * Parameters are: |
| 107 * local_cpu: True if local cpu rules should be applied. | 105 * local_cpu: True if local cpu rules should be applied. |
| 108 * Otherwise, assume no cpu specific rules. | 106 * Otherwise, assume no cpu specific rules. |
| 109 * guest_addr - The virtual pc to assume with the beginning address of the | 107 * guest_addr - The virtual pc to assume with the beginning address of the |
| 110 * code segment. Typically, this is the corresponding addresss that | 108 * code segment. Typically, this is the corresponding addresss that |
| 111 * will be used by objdump. | 109 * will be used by objdump. |
| 112 * data - The contents of the code segment to be validated. | 110 * data - The contents of the code segment to be validated. |
| 113 * size - The size of the code segment to be validated. | 111 * size - The size of the code segment to be validated. |
| 114 * bundle_size - The number of bytes in a code bundle. | |
| 115 * cpu_features - The CPU features to support while validating. | 112 * cpu_features - The CPU features to support while validating. |
| 116 */ | 113 */ |
| 117 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, | 114 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, |
| 118 NACL_TARGET_ARCH, | 115 NACL_TARGET_ARCH, |
| 119 NACL_TARGET_SUBARCH)( | 116 NACL_TARGET_SUBARCH)( |
| 120 enum NaClSBKind sb_kind, | 117 enum NaClSBKind sb_kind, |
| 121 uintptr_t guest_addr, | 118 uintptr_t guest_addr, |
| 122 uint8_t *data, | 119 uint8_t *data, |
| 123 size_t size, | 120 size_t size, |
| 124 int bundle_size, | |
| 125 const NaClCPUFeatures *cpu_features); | 121 const NaClCPUFeatures *cpu_features); |
| 126 | 122 |
| 127 /* Applies validator to new code segment, assuming that it was updated | 123 /* Applies validator to new code segment, assuming that it was updated |
| 128 * from the previously validated old code segment. Assumes that instruction | 124 * from the previously validated old code segment. Assumes that instruction |
| 129 * sizes are the same. Only allows changes in branches that don't change | 125 * sizes are the same. Only allows changes in branches that don't change |
| 130 * instruction sizes. | 126 * instruction sizes. |
| 131 * Parameters are: | 127 * Parameters are: |
| 132 * guest_addr - The virtual pc to assume with the beginning address of the | 128 * guest_addr - The virtual pc to assume with the beginning address of the |
| 133 * code segment. Typically, this is the corresponding addresss that | 129 * code segment. Typically, this is the corresponding addresss that |
| 134 * will be used by objdump. | 130 * will be used by objdump. |
| 135 * data_old - The contents of the original code segment. | 131 * data_old - The contents of the original code segment. |
| 136 * data_new - The contents of the new code segment that should be validated. | 132 * data_new - The contents of the new code segment that should be validated. |
| 137 * size - The size of the passed code segments. | 133 * size - The size of the passed code segments. |
| 138 * bundle_size - The number of bytes in a code bundle. | |
| 139 * cpu_features - The CPU features to support while validating. | 134 * cpu_features - The CPU features to support while validating. |
| 140 */ | 135 */ |
| 141 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, | 136 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCodeReplacement, |
| 142 NACL_TARGET_ARCH, | 137 NACL_TARGET_ARCH, |
| 143 NACL_TARGET_SUBARCH)( | 138 NACL_TARGET_SUBARCH)( |
| 144 enum NaClSBKind sb_kind, | 139 enum NaClSBKind sb_kind, |
| 145 uintptr_t guest_addr, | 140 uintptr_t guest_addr, |
| 146 uint8_t *data_old, | 141 uint8_t *data_old, |
| 147 uint8_t *data_new, | 142 uint8_t *data_new, |
| 148 size_t size, | 143 size_t size, |
| 149 int bundle_size, | |
| 150 const NaClCPUFeatures *cpu_features); | 144 const NaClCPUFeatures *cpu_features); |
| 151 | 145 |
| 152 /* Runs the validator to copy code from an existing code segment to a new | 146 /* Runs the validator to copy code from an existing code segment to a new |
| 153 * code segment. | 147 * code segment. |
| 154 * | 148 * |
| 155 * Note: Current implementations uses the instruction decoders, which may | 149 * Note: Current implementations uses the instruction decoders, which may |
| 156 * require that the code segment match native client rules. | 150 * require that the code segment match native client rules. |
| 157 * | 151 * |
| 158 * Parameters are: | 152 * Parameters are: |
| 159 * guest_addr - The virtual pc to assume with the beginning address of the | 153 * guest_addr - The virtual pc to assume with the beginning address of the |
| 160 * code segment. Typically, this is the corresponding addresss that | 154 * code segment. Typically, this is the corresponding addresss that |
| 161 * will be used by objdump. | 155 * will be used by objdump. |
| 162 * data_old - The contents of the original code segment. | 156 * data_old - The contents of the original code segment. |
| 163 * data_new - The addres of the new code segment for which the original | 157 * data_new - The addres of the new code segment for which the original |
| 164 * code segment should be copied into. | 158 * code segment should be copied into. |
| 165 * size - The size of the passed code segments. | 159 * size - The size of the passed code segments. |
| 166 * bundle_size - The number of bytes in a code bundle. | |
| 167 * cpu_features - The CPU features to support while validating. | 160 * cpu_features - The CPU features to support while validating. |
| 168 */ | 161 */ |
| 169 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, | 162 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorCopy, |
| 170 NACL_TARGET_ARCH, | 163 NACL_TARGET_ARCH, |
| 171 NACL_TARGET_SUBARCH)( | 164 NACL_TARGET_SUBARCH)( |
| 172 enum NaClSBKind sb_kind, | 165 enum NaClSBKind sb_kind, |
| 173 uintptr_t guest_addr, | 166 uintptr_t guest_addr, |
| 174 uint8_t *data_old, | 167 uint8_t *data_old, |
| 175 uint8_t *data_new, | 168 uint8_t *data_new, |
| 176 size_t size, | 169 size_t size, |
| 177 int bundle_size, | |
| 178 const NaClCPUFeatures *cpu_features); | 170 const NaClCPUFeatures *cpu_features); |
| 179 | 171 |
| 180 EXTERN_C_END | 172 EXTERN_C_END |
| 181 | 173 |
| 182 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ */ | 174 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ */ |
| OLD | NEW |