| 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 /* | 7 /* |
| 8 * Checks that CPU ID features match instructions found in executable. | 8 * Checks that CPU ID features match instructions found in executable. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 | 13 |
| 14 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_cpu_checks.h" | 14 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/nc_cpu_checks.h" |
| 15 | 15 |
| 16 #include "native_client/src/shared/platform/nacl_log.h" | 16 #include "native_client/src/shared/platform/nacl_log.h" |
| 17 #include "native_client/src/trusted/validator/x86/nacl_cpuid.h" | 17 #include "native_client/src/trusted/validator/x86/nacl_cpuid.h" |
| 18 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_iter.h" | |
| 19 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state.h" | 18 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state.h" |
| 20 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal
.h" | 19 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_state_internal
.h" |
| 21 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" | 20 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" |
| 22 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter_
internal.h" | 21 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter_
internal.h" |
| 23 #include "native_client/src/trusted/validator/x86/nc_segment.h" | 22 #include "native_client/src/trusted/validator/x86/nc_segment.h" |
| 24 | 23 |
| 24 #include "native_client/src/trusted/validator/x86/decoder/nc_inst_iter_inl.c" |
| 25 |
| 25 typedef struct NaClCpuCheckState { | 26 typedef struct NaClCpuCheckState { |
| 26 /* The standard CPU features. */ | 27 /* The standard CPU features. */ |
| 27 CPUFeatures cpu_features; | 28 CPUFeatures cpu_features; |
| 28 /* Check that both f_CMOV and f_x87 is defined. */ | 29 /* Check that both f_CMOV and f_x87 is defined. */ |
| 29 Bool f_CMOV_and_x87; | 30 Bool f_CMOV_and_x87; |
| 30 /* Check that either f_MMX or f_SSE2 is defined. */ | 31 /* Check that either f_MMX or f_SSE2 is defined. */ |
| 31 Bool f_MMX_or_SSE2; | 32 Bool f_MMX_or_SSE2; |
| 32 } NaClCpuCheckState; | 33 } NaClCpuCheckState; |
| 33 | 34 |
| 34 NaClCpuCheckState* NaClCpuCheckMemoryCreate(NaClValidatorState* state) { | 35 NaClCpuCheckState* NaClCpuCheckMemoryCreate(NaClValidatorState* state) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 NACL_CHECK_FEATURE(f_SSE2, "SSE2"); | 165 NACL_CHECK_FEATURE(f_SSE2, "SSE2"); |
| 165 break; | 166 break; |
| 166 default: | 167 default: |
| 167 break; | 168 break; |
| 168 } | 169 } |
| 169 if (state->cur_inst->flags & NACL_IFLAG(LongMode)) { | 170 if (state->cur_inst->flags & NACL_IFLAG(LongMode)) { |
| 170 NACL_CHECK_FEATURE(f_LM, "LM"); | 171 NACL_CHECK_FEATURE(f_LM, "LM"); |
| 171 } | 172 } |
| 172 if (squash_me) { | 173 if (squash_me) { |
| 173 /* Replace all bytes with the stop instruction. */ | 174 /* Replace all bytes with the stop instruction. */ |
| 174 memset(NaClInstIterGetInstMemory(iter), kNaClFullStop, | 175 memset(NaClInstIterGetInstMemoryInline(iter), kNaClFullStop, |
| 175 NaClInstStateLength(inst_state)); | 176 NaClInstStateLength(inst_state)); |
| 176 } | 177 } |
| 177 } | 178 } |
| OLD | NEW |