Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: src/trusted/service_runtime/sel_validate_image.c

Issue 9535001: Add validation caching interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Bugfix Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "native_client/src/shared/platform/nacl_log.h" 7 #include "native_client/src/shared/platform/nacl_log.h"
8 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 8 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
9 #include "native_client/src/trusted/validator/ncvalidate.h" 9 #include "native_client/src/trusted/validator/ncvalidate.h"
10 10
(...skipping 11 matching lines...) Expand all
22 case NaClValidationFailedSegmentationIssue: 22 case NaClValidationFailedSegmentationIssue:
23 default: 23 default:
24 return LOAD_VALIDATION_FAILED; 24 return LOAD_VALIDATION_FAILED;
25 } 25 }
26 } 26 }
27 27
28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, 28 int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr,
29 uint8_t *data, size_t size) { 29 uint8_t *data, size_t size) {
30 NaClValidationStatus status = NaClValidationSucceeded; 30 NaClValidationStatus status = NaClValidationSucceeded;
31 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; 31 enum NaClSBKind sb_kind = NACL_SB_DEFAULT;
32
33 NaClValidationCache *cache = nap->validation_cache;
34 void * cache_context = nap->validation_cache_context;
Mark Seaborn 2012/02/29 21:33:34 Spacing style
Nick Bray (chromium) 2012/02/29 22:58:09 Done.
35
32 if (nap->validator_stub_out_mode) { 36 if (nap->validator_stub_out_mode) {
37 /* Validation caching is currently incompatable with stubout. */
Mark Seaborn 2012/02/29 21:33:34 'incompatible'
Nick Bray (chromium) 2012/02/29 22:58:09 Done.
38 cache = NULL;
39 cache_context = NULL;
33 /* In stub out mode, we do two passes. The second pass acts as a 40 /* In stub out mode, we do two passes. The second pass acts as a
34 sanity check that bad instructions were indeed overwritten with 41 sanity check that bad instructions were indeed overwritten with
35 allowable HLTs. */ 42 allowable HLTs. */
36 status = NACL_SUBARCH_NAME(ApplyValidator, 43 status = NACL_SUBARCH_NAME(ApplyValidator,
37 NACL_TARGET_ARCH, 44 NACL_TARGET_ARCH,
38 NACL_TARGET_SUBARCH)( 45 NACL_TARGET_SUBARCH)(
39 sb_kind, 46 sb_kind,
40 NaClApplyValidationDoStubout, 47 NaClApplyValidationDoStubout,
41 guest_addr, data, size, 48 guest_addr, data, size,
42 nap->bundle_size, &nap->cpu_features); 49 nap->bundle_size, &nap->cpu_features,
50 cache, cache_context);
43 } 51 }
44 if (status == NaClValidationSucceeded) { 52 if (status == NaClValidationSucceeded) {
45 status = NACL_SUBARCH_NAME(ApplyValidator, 53 status = NACL_SUBARCH_NAME(ApplyValidator,
46 NACL_TARGET_ARCH, 54 NACL_TARGET_ARCH,
47 NACL_TARGET_SUBARCH)( 55 NACL_TARGET_SUBARCH)(
48 sb_kind, 56 sb_kind,
49 NaClApplyCodeValidation, 57 NaClApplyCodeValidation,
50 guest_addr, data, size, 58 guest_addr, data, size,
51 nap->bundle_size, &nap->cpu_features); 59 nap->bundle_size, &nap->cpu_features,
60 cache, cache_context);
52 } 61 }
53 return NaClValidateStatus(status); 62 return NaClValidateStatus(status);
54 } 63 }
55 64
56 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr, 65 int NaClValidateCodeReplacement(struct NaClApp *nap, uintptr_t guest_addr,
57 uint8_t *data_old, uint8_t *data_new, 66 uint8_t *data_old, uint8_t *data_new,
58 size_t size) { 67 size_t size) {
59 enum NaClSBKind sb_kind = NACL_SB_DEFAULT; 68 enum NaClSBKind sb_kind = NACL_SB_DEFAULT;
60 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE; 69 if (nap->validator_stub_out_mode) return LOAD_BAD_FILE;
61 70
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 NaClLog(LOG_ERROR, 121 NaClLog(LOG_ERROR,
113 "Run sel_ldr in debug mode to ignore validation failure.\n"); 122 "Run sel_ldr in debug mode to ignore validation failure.\n");
114 NaClLog(LOG_ERROR, 123 NaClLog(LOG_ERROR,
115 "Run ncval <module-name> for validation error details.\n"); 124 "Run ncval <module-name> for validation error details.\n");
116 rcode = LOAD_VALIDATION_FAILED; 125 rcode = LOAD_VALIDATION_FAILED;
117 } 126 }
118 } 127 }
119 } 128 }
120 return rcode; 129 return rcode;
121 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698