Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 /* The call to the validator failed, due to not enough memory. */ | 56 /* The call to the validator failed, due to not enough memory. */ |
| 57 NaClValidationFailedOutOfMemory, | 57 NaClValidationFailedOutOfMemory, |
| 58 /* The call to the validator failed, due to it not being implemented yet. */ | 58 /* The call to the validator failed, due to it not being implemented yet. */ |
| 59 NaClValidationFailedNotImplemented, | 59 NaClValidationFailedNotImplemented, |
| 60 /* The call to the validator failed, because the CPU is not supported. */ | 60 /* The call to the validator failed, because the CPU is not supported. */ |
| 61 NaClValidationFailedCpuNotSupported, | 61 NaClValidationFailedCpuNotSupported, |
| 62 /* The call to the validator failed, due to segment alignment issues. */ | 62 /* The call to the validator failed, due to segment alignment issues. */ |
| 63 NaClValidationFailedSegmentationIssue | 63 NaClValidationFailedSegmentationIssue |
| 64 } NaClValidationStatus; | 64 } NaClValidationStatus; |
| 65 | 65 |
| 66 /* Defines possible ways that validation can be applied. */ | |
| 67 typedef enum NaClApplyValidationKind { | |
| 68 /* This applies the validator. Returns the resulting status | |
| 69 * of the validation of a code segment. | |
| 70 * Typically used for sel_ldr. | |
| 71 */ | |
| 72 NaClApplyCodeValidation, | |
| 73 /* This applies the validator silently, stubbing out instructions | |
| 74 * that may not validate with a suitable halt instruction. | |
| 75 * Note: The return status of NaClValidationSucceeded in this case | |
| 76 * does not necessarily imply that all illegal instructions have | |
| 77 * been stubbed out. It is the responsability of the caller to | |
| 78 * call the validator a second time to see if the stubbed code | |
| 79 * is valid. Typically used as the first step of a stubout tool | |
| 80 * (either in sel_ldr or command-line tool). | |
| 81 */ | |
| 82 NaClApplyValidationDoStubout, | |
| 83 /* This applies the validator, reporting errors as needed by | |
| 84 * ncval_annotate. That is, messages of the form: | |
| 85 * VALIDATOR: XXXXXX: Message | |
| 86 * where XXXXXX is an instruction address, and Message is | |
| 87 * an error message. ncval_annotate will then use this | |
| 88 * information to print out the corresponding instruction | |
| 89 * using objdump, with the corresponding error message. Returns | |
| 90 * the resulting status of the validation of a code segment. | |
| 91 * Typically used to generate input for ncval_annotate. | |
| 92 */ | |
| 93 NaClApplyValidationAnnotator | |
| 94 } NaClApplyValidationKind; | |
| 95 | |
| 96 /* 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 |
| 97 * validator where performance is critical. | 67 * validator where performance is critical. |
| 98 * Parameters are: | 68 * Parameters are: |
| 99 * kind - The way the validator should be applied. | |
| 100 * local_cpu: True if local cpu rules should be applied. | 69 * local_cpu: True if local cpu rules should be applied. |
| 101 * Otherwise, assume no cpu specific rules. | 70 * Otherwise, assume no cpu specific rules. |
| 102 * 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 |
| 103 * code segment. Typically, this is the corresponding addresss that | 72 * code segment. Typically, this is the corresponding addresss that |
| 104 * will be used by objdump. | 73 * will be used by objdump. |
| 105 * data - The contents of the code segment to be validated. | 74 * data - The contents of the code segment to be validated. |
| 106 * size - The size of the code segment to be validated. | 75 * size - The size of the code segment to be validated. |
| 107 * bundle_size - The number of bytes in a code bundle. | 76 * bundle_size - The number of bytes in a code bundle. |
| 77 * stubout_mode - If the validator should stub out illegal instructions. | |
|
Mark Seaborn
2012/04/10 19:04:09
'If' -> 'Whether'
'illegal' -> 'forbidden'/'disal
Nick Bray (chromium)
2012/04/10 19:12:40
Done.
| |
| 78 * This applies the validator silently, stubbing out instructions that | |
| 79 * may not validate with a suitable halt instruction. Note: The return | |
| 80 * status of NaClValidationSucceeded in this case does not necessarily | |
| 81 * imply that all illegal instructions have been stubbed out. It is | |
| 82 * the responsability of the caller to call the validator a second | |
|
Mark Seaborn
2012/04/10 19:04:09
'responsibility'
Nick Bray (chromium)
2012/04/10 19:12:40
Done.
| |
| 83 * time to see if the stubbed code is valid. Typically used as the | |
| 84 * first step of a stubout tool (either in sel_ldr or command-line | |
| 85 * tool). | |
| 108 * readonly_text - If code should be considered read-only. | 86 * readonly_text - If code should be considered read-only. |
| 109 * cpu_features - The CPU features to support while validating. | 87 * cpu_features - The CPU features to support while validating. |
| 110 * cache - Pointer to NaCl validation cache. | 88 * cache - Pointer to NaCl validation cache. |
| 111 */ | 89 */ |
| 112 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, | 90 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidator, |
| 113 NACL_TARGET_ARCH, | 91 NACL_TARGET_ARCH, |
| 114 NACL_TARGET_SUBARCH)( | 92 NACL_TARGET_SUBARCH)( |
| 115 enum NaClSBKind sb_kind, | 93 enum NaClSBKind sb_kind, |
| 116 NaClApplyValidationKind kind, | |
| 117 uintptr_t guest_addr, | 94 uintptr_t guest_addr, |
| 118 uint8_t *data, | 95 uint8_t *data, |
| 119 size_t size, | 96 size_t size, |
| 120 int bundle_size, | 97 int bundle_size, |
| 98 int stubout_mode, | |
| 121 int readonly_text, | 99 int readonly_text, |
| 122 const NaClCPUFeatures *cpu_features, | 100 const NaClCPUFeatures *cpu_features, |
| 123 struct NaClValidationCache *cache); | 101 struct NaClValidationCache *cache); |
| 124 | 102 |
| 125 /* Applies the validator, as used in a command-line tool to report issues. | 103 /* Applies the validator, as used in a command-line tool to report issues. |
| 126 * Note: This is intentionally separated from ApplyValidator, since it need | 104 * Note: This is intentionally separated from ApplyValidator, since it need |
| 127 * not be performance critical. | 105 * not be performance critical. |
| 128 * Parameters are: | 106 * Parameters are: |
| 129 * kind - The way the validator should be applied. | |
| 130 * local_cpu: True if local cpu rules should be applied. | 107 * local_cpu: True if local cpu rules should be applied. |
| 131 * Otherwise, assume no cpu specific rules. | 108 * Otherwise, assume no cpu specific rules. |
| 132 * guest_addr - The virtual pc to assume with the beginning address of the | 109 * guest_addr - The virtual pc to assume with the beginning address of the |
| 133 * code segment. Typically, this is the corresponding addresss that | 110 * code segment. Typically, this is the corresponding addresss that |
| 134 * will be used by objdump. | 111 * will be used by objdump. |
| 135 * data - The contents of the code segment to be validated. | 112 * data - The contents of the code segment to be validated. |
| 136 * size - The size of the code segment to be validated. | 113 * size - The size of the code segment to be validated. |
| 137 * bundle_size - The number of bytes in a code bundle. | 114 * bundle_size - The number of bytes in a code bundle. |
| 138 * cpu_features - The CPU features to support while validating. | 115 * cpu_features - The CPU features to support while validating. |
| 139 */ | 116 */ |
| 140 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, | 117 extern NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, |
| 141 NACL_TARGET_ARCH, | 118 NACL_TARGET_ARCH, |
| 142 NACL_TARGET_SUBARCH)( | 119 NACL_TARGET_SUBARCH)( |
| 143 enum NaClSBKind sb_kind, | 120 enum NaClSBKind sb_kind, |
| 144 NaClApplyValidationKind kind, | |
| 145 uintptr_t guest_addr, | 121 uintptr_t guest_addr, |
| 146 uint8_t *data, | 122 uint8_t *data, |
| 147 size_t size, | 123 size_t size, |
| 148 int bundle_size, | 124 int bundle_size, |
| 149 const NaClCPUFeatures *cpu_features); | 125 const NaClCPUFeatures *cpu_features); |
| 150 | 126 |
| 151 /* Applies validator to new code segment, assuming that it was updated | 127 /* Applies validator to new code segment, assuming that it was updated |
| 152 * from the previously validated old code segment. Assumes that instruction | 128 * from the previously validated old code segment. Assumes that instruction |
| 153 * sizes are the same. Only allows changes in branches that don't change | 129 * sizes are the same. Only allows changes in branches that don't change |
| 154 * instruction sizes. | 130 * instruction sizes. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 uintptr_t guest_addr, | 173 uintptr_t guest_addr, |
| 198 uint8_t *data_old, | 174 uint8_t *data_old, |
| 199 uint8_t *data_new, | 175 uint8_t *data_new, |
| 200 size_t size, | 176 size_t size, |
| 201 int bundle_size, | 177 int bundle_size, |
| 202 const NaClCPUFeatures *cpu_features); | 178 const NaClCPUFeatures *cpu_features); |
| 203 | 179 |
| 204 EXTERN_C_END | 180 EXTERN_C_END |
| 205 | 181 |
| 206 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ */ | 182 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NCVALIDATE_H__ */ |
| OLD | NEW |