Chromium Code Reviews| Index: src/trusted/service_runtime/sel_validate_image.c |
| diff --git a/src/trusted/service_runtime/sel_validate_image.c b/src/trusted/service_runtime/sel_validate_image.c |
| index 1875ac1fe572aa87474d385ae73c5e5968472472..d0d135523256de5007cea1c273c7fd3a989da55b 100644 |
| --- a/src/trusted/service_runtime/sel_validate_image.c |
| +++ b/src/trusted/service_runtime/sel_validate_image.c |
| @@ -27,11 +27,21 @@ static int NaClValidateStatus(NaClValidationStatus status) { |
| } |
| } |
| +typedef NaClValidationStatus (*ValidateFunc) (enum NaClSBKind, |
|
Nick Bray
2012/04/19 23:11:08
FYI, removing SBKind is next on my hit list - but
pasko-google - do not use
2012/04/20 14:30:38
not a problem
|
| + uintptr_t, uint8_t*, size_t, int, int, const NaClCPUFeatures*, |
| + struct NaClValidationCache*); |
| + |
| int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, |
| uint8_t *data, size_t size) { |
| NaClValidationStatus status = NaClValidationSucceeded; |
| enum NaClSBKind sb_kind = NACL_SB_DEFAULT; |
| - |
| + const ValidateFunc cur_validate_func = NACL_SUBARCH_NAME(ApplyValidator, |
| + NACL_TARGET_ARCH, |
| + NACL_TARGET_SUBARCH); |
| + const ValidateFunc dfa_validate_func = NACL_SUBARCH_NAME(ApplyDfaValidator, |
|
Nick Bray
2012/04/19 23:11:08
Don't stub this out on ARM, just ifdef out the ref
pasko-google - do not use
2012/04/20 14:30:38
across all trusted code I do not see a single #ifd
|
| + NACL_TARGET_ARCH, |
| + NACL_TARGET_SUBARCH); |
| + ValidateFunc validate_func = cur_validate_func; |
| struct NaClValidationCache *cache = nap->validation_cache; |
| if (size < kMinimumCachedCodeSize) { |
| @@ -61,34 +71,33 @@ int NaClValidateCode(struct NaClApp *nap, uintptr_t guest_addr, |
| "stub_out_mode and fixed_feature_cpu_mode are incompatible\n"); |
| return LOAD_VALIDATION_FAILED; |
| } |
| + |
| + if (nap->enable_dfa_validator) { |
|
Nick Bray
2012/04/19 23:11:08
Move this up to keep the validate_func selection g
pasko-google - do not use
2012/04/20 14:30:38
For the grouping I'd better move the validate_func
|
| + validate_func = dfa_validate_func; |
| + } |
| + |
| if (nap->validator_stub_out_mode) { |
| /* Validation caching is currently incompatible with stubout. */ |
| cache = NULL; |
| /* In stub out mode, we do two passes. The second pass acts as a |
| sanity check that bad instructions were indeed overwritten with |
| allowable HLTs. */ |
| - status = NACL_SUBARCH_NAME(ApplyValidator, |
| - NACL_TARGET_ARCH, |
| - NACL_TARGET_SUBARCH)( |
| - sb_kind, |
| - guest_addr, data, size, |
| - TRUE, /* stub out */ |
| - FALSE, /* text is not read-only */ |
| - &nap->cpu_features, |
| - cache); |
| + status = validate_func(sb_kind, |
| + guest_addr, data, size, |
| + TRUE, /* stub out */ |
| + FALSE, /* text is not read-only */ |
| + &nap->cpu_features, |
| + cache); |
| } |
| if (status == NaClValidationSucceeded) { |
| - /* Fixed feature CPU mode implies read-only */ |
| + /* Fixed feature CPU mode implies read-only. */ |
| int readonly_text = nap->fixed_feature_cpu_mode; |
| - status = NACL_SUBARCH_NAME(ApplyValidator, |
| - NACL_TARGET_ARCH, |
| - NACL_TARGET_SUBARCH)( |
| - sb_kind, |
| - guest_addr, data, size, |
| - FALSE, /* do not stub out */ |
| - readonly_text, |
| - &nap->cpu_features, |
| - cache); |
| + status = validate_func(sb_kind, |
| + guest_addr, data, size, |
| + FALSE, /* do not stub out */ |
| + readonly_text, |
| + &nap->cpu_features, |
| + cache); |
| } |
| return NaClValidateStatus(status); |
| } |