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