OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2013 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/trusted/service_runtime/sys_memory.h" | 7 #include "native_client/src/trusted/service_runtime/sys_memory.h" |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 uintptr_t endaddr; | 260 uintptr_t endaddr; |
261 int mapping_code; | 261 int mapping_code; |
262 uintptr_t map_result; | 262 uintptr_t map_result; |
263 int holding_app_lock; | 263 int holding_app_lock; |
264 struct nacl_abi_stat stbuf; | 264 struct nacl_abi_stat stbuf; |
265 size_t alloc_rounded_length; | 265 size_t alloc_rounded_length; |
266 nacl_off64_t file_size; | 266 nacl_off64_t file_size; |
267 nacl_off64_t file_bytes; | 267 nacl_off64_t file_bytes; |
268 nacl_off64_t host_rounded_file_bytes; | 268 nacl_off64_t host_rounded_file_bytes; |
269 size_t alloc_rounded_file_bytes; | 269 size_t alloc_rounded_file_bytes; |
| 270 uint32_t val_flags; |
270 | 271 |
271 holding_app_lock = 0; | 272 holding_app_lock = 0; |
272 ndp = NULL; | 273 ndp = NULL; |
273 | 274 |
274 allowed_flags = (NACL_ABI_MAP_FIXED | NACL_ABI_MAP_SHARED | 275 allowed_flags = (NACL_ABI_MAP_FIXED | NACL_ABI_MAP_SHARED |
275 | NACL_ABI_MAP_PRIVATE | NACL_ABI_MAP_ANONYMOUS); | 276 | NACL_ABI_MAP_PRIVATE | NACL_ABI_MAP_ANONYMOUS); |
276 | 277 |
277 usraddr = (uintptr_t) start; | 278 usraddr = (uintptr_t) start; |
278 | 279 |
279 if (0 != (flags & ~allowed_flags)) { | 280 if (0 != (flags & ~allowed_flags)) { |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 (void *) NULL, | 715 (void *) NULL, |
715 length, | 716 length, |
716 NACL_ABI_PROT_READ | NACL_ABI_PROT_WRITE, | 717 NACL_ABI_PROT_READ | NACL_ABI_PROT_WRITE, |
717 NACL_ABI_MAP_PRIVATE, | 718 NACL_ABI_MAP_PRIVATE, |
718 offset); | 719 offset); |
719 if (NaClPtrIsNegErrno(&image_sys_addr)) { | 720 if (NaClPtrIsNegErrno(&image_sys_addr)) { |
720 map_result = image_sys_addr; | 721 map_result = image_sys_addr; |
721 goto cleanup; | 722 goto cleanup; |
722 } | 723 } |
723 | 724 |
| 725 val_flags = nap->pnacl_mode ? DISABLE_NONTEMPORALS : 0; |
724 /* Ask validator / validation cache */ | 726 /* Ask validator / validation cache */ |
725 NaClMetadataFromNaClDescCtor(&metadata, ndp); | 727 NaClMetadataFromNaClDescCtor(&metadata, ndp); |
726 validator_status = NACL_FI("MMAP_FORCE_MMAP_VALIDATION_FAIL", | 728 validator_status = NACL_FI("MMAP_FORCE_MMAP_VALIDATION_FAIL", |
727 (*nap->validator-> | 729 (*nap->validator-> |
728 Validate)(usraddr, | 730 Validate)(usraddr, |
729 (uint8_t *) image_sys_addr, | 731 (uint8_t *) image_sys_addr, |
730 length, | 732 length, |
731 0, /* stubout_mode: no */ | 733 0, /* stubout_mode: no */ |
| 734 val_flags, |
732 1, /* readonly_text: yes */ | 735 1, /* readonly_text: yes */ |
733 nap->cpu_features, | 736 nap->cpu_features, |
734 &metadata, | 737 &metadata, |
735 nap->validation_cache), | 738 nap->validation_cache), |
736 NaClValidationFailed); | 739 NaClValidationFailed); |
737 NaClLog(3, "NaClSysMmap: prot_exec, validator_status %d\n", | 740 NaClLog(3, "NaClSysMmap: prot_exec, validator_status %d\n", |
738 validator_status); | 741 validator_status); |
739 NaClMetadataDtor(&metadata); | 742 NaClMetadataDtor(&metadata); |
740 | 743 |
741 if (NaClValidationSucceeded == validator_status) { | 744 if (NaClValidationSucceeded == validator_status) { |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 size_t length, | 1368 size_t length, |
1366 int prot) { | 1369 int prot) { |
1367 struct NaClApp *nap = natp->nap; | 1370 struct NaClApp *nap = natp->nap; |
1368 | 1371 |
1369 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " | 1372 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " |
1370 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", | 1373 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", |
1371 (uintptr_t) natp, (uintptr_t) start, length, prot); | 1374 (uintptr_t) natp, (uintptr_t) start, length, prot); |
1372 | 1375 |
1373 return NaClSysMprotectInternal(nap, start, length, prot); | 1376 return NaClSysMprotectInternal(nap, start, length, prot); |
1374 } | 1377 } |
OLD | NEW |