| 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 /* Implement the ApplyValidatorVerbosely API for the x86-64 architecture. */ | 7 /* Implement the ApplyValidatorVerbosely API for the x86-64 architecture. */ |
| 8 | 8 |
| 9 #include "native_client/src/trusted/validator/ncvalidate.h" | 9 #include "native_client/src/trusted/validator/ncvalidate.h" |
| 10 | 10 |
| 11 #include "native_client/src/shared/platform/nacl_log.h" | 11 #include "native_client/src/shared/platform/nacl_log.h" |
| 12 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" | 12 #include "native_client/src/trusted/validator/x86/ncval_reg_sfi/ncvalidate_iter.
h" |
| 13 #include "native_client/src/trusted/validator/x86/ncval_seg_sfi/ncdecode_verbose
.h" | 13 #include "native_client/src/trusted/validator/x86/ncval_seg_sfi/ncdecode_verbose
.h" |
| 14 #include "native_client/src/trusted/validator/x86/64/ncvalidate.h" | 14 #include "native_client/src/trusted/validator/x86/64/ncvalidate.h" |
| 15 #include <assert.h> | 15 #include <assert.h> |
| 16 | 16 |
| 17 /* Be sure the correct compile flags are defined for this. */ | 17 /* Be sure the correct compile flags are defined for this. */ |
| 18 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 | 18 #if NACL_ARCH(NACL_TARGET_ARCH) != NACL_x86 |
| 19 # error("Can't compile, target is for x86-64") | 19 # error("Can't compile, target is for x86-64") |
| 20 #else | 20 #else |
| 21 # if NACL_TARGET_SUBARCH != 64 | 21 # if NACL_TARGET_SUBARCH != 64 |
| 22 # error("Can't compile, target is for x86-64") | 22 # error("Can't compile, target is for x86-64") |
| 23 # endif | 23 # endif |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 static NaClValidationStatus NaClApplyValidatorVerbosely_x86_64( | 26 static NaClValidationStatus NaClApplyValidatorVerbosely_x86_64( |
| 27 uintptr_t guest_addr, | 27 uintptr_t guest_addr, |
| 28 uint8_t *data, | 28 uint8_t *data, |
| 29 size_t size, | 29 size_t size, |
| 30 int bundle_size, | |
| 31 const NaClCPUFeaturesX86 *cpu_features) { | 30 const NaClCPUFeaturesX86 *cpu_features) { |
| 32 struct NaClValidatorState *vstate; | 31 struct NaClValidatorState *vstate; |
| 33 NaClValidationStatus status = | 32 NaClValidationStatus status = |
| 34 NaClValidatorSetup_x86_64(guest_addr, size, bundle_size, FALSE, | 33 NaClValidatorSetup_x86_64(guest_addr, size, FALSE, cpu_features, &vstate); |
| 35 cpu_features, &vstate); | |
| 36 if (status != NaClValidationSucceeded) return status; | 34 if (status != NaClValidationSucceeded) return status; |
| 37 NaClValidatorStateSetLogVerbosity(vstate, LOG_ERROR); | 35 NaClValidatorStateSetLogVerbosity(vstate, LOG_ERROR); |
| 38 NaClValidatorStateSetMaxReportedErrors(vstate, -1); /* Report all errors. */ | 36 NaClValidatorStateSetMaxReportedErrors(vstate, -1); /* Report all errors. */ |
| 39 NaClValidatorStateSetErrorReporter(vstate, &kNaClVerboseErrorReporter); | 37 NaClValidatorStateSetErrorReporter(vstate, &kNaClVerboseErrorReporter); |
| 40 NaClValidateSegment(data, guest_addr, size, vstate); | 38 NaClValidateSegment(data, guest_addr, size, vstate); |
| 41 status = | 39 status = |
| 42 NaClValidatesOk(vstate) ? NaClValidationSucceeded : NaClValidationFailed; | 40 NaClValidatesOk(vstate) ? NaClValidationSucceeded : NaClValidationFailed; |
| 43 NaClValidatorStateDestroy(vstate); | 41 NaClValidatorStateDestroy(vstate); |
| 44 return status; | 42 return status; |
| 45 } | 43 } |
| 46 | 44 |
| 47 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, x86, 64) | 45 NaClValidationStatus NACL_SUBARCH_NAME(ApplyValidatorVerbosely, x86, 64) |
| 48 (enum NaClSBKind sb_kind, | 46 (enum NaClSBKind sb_kind, |
| 49 uintptr_t guest_addr, | 47 uintptr_t guest_addr, |
| 50 uint8_t *data, | 48 uint8_t *data, |
| 51 size_t size, | 49 size_t size, |
| 52 int bundle_size, | |
| 53 const NaClCPUFeaturesX86 *cpu_features) { | 50 const NaClCPUFeaturesX86 *cpu_features) { |
| 54 NaClValidationStatus status = NaClValidationFailedNotImplemented; | |
| 55 assert(NACL_SB_DEFAULT == sb_kind); | 51 assert(NACL_SB_DEFAULT == sb_kind); |
| 56 if (bundle_size == 16 || bundle_size == 32) { | 52 |
| 57 if (!NaClArchSupported(cpu_features)) | 53 if (!NaClArchSupported(cpu_features)) |
| 58 return NaClValidationFailedCpuNotSupported; | 54 return NaClValidationFailedCpuNotSupported; |
| 59 status = NaClApplyValidatorVerbosely_x86_64( | 55 |
| 60 guest_addr, data, size, bundle_size, cpu_features); | 56 return NaClApplyValidatorVerbosely_x86_64( |
| 61 } | 57 guest_addr, data, size, cpu_features); |
| 62 return status; | |
| 63 } | 58 } |
| OLD | NEW |