DescriptionDynamic loading: Fill pages with halts only when they are needed
This will save memory and improve startup time.
Pages from the dyncode shared memory segment are mapped as
unreadable/non-executable to start with. When a page is needed, we
fill it with halt instructions and then make it accessible (readable
and executable) by untrusted code.
We maintain a bitmap of pages that have been allocated in this way.
We track allocations at 64k granularity, even though we could use 4k
on Unix, so that the observable behaviour on Linux/Mac is the same as
on Windows. Also it makes the bitmap a bit smaller (512 bytes for a
256MB dynamic code area). Although we could use a list of ranges,
using a bitmap is simpler.
Specific changes:
* nacl_desc_imc_shm.c: Move the check for PROT_NONE into the
Windows-specific code (win/nacl_shm.cc). We need PROT_NONE on
Unix, and it works fine there.
* sel_ldr_standard.c: Re-order the setup so that NaClAppLoadFile()'s
NaCl_mprotect() call does not undo the PROT_NONE/PAGE_NOACCESS
permissions we carefully set up in nacl_text.c. Similarly, remove
the NaCl_mprotect() call in sel_addrspace.c that was undoing the
damage that NaClAppLoadFile() did.
* Add a test that checks that unallocated dynamic code pages are
inaccessible.
Note that on Windows, this change only saves RAM, not swap space.
Since we do not yet pass SEC_RESERVE to CreateFileMapping() in
nacl_shm.cc, we are still reserving swap space for the whole dynamic
code area. This can be fixed but it involves some trickier code on
Windows.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=503
TEST=run_dynamic_load_test
Committed: http://src.chromium.org/viewvc/native_client?view=rev&revision=5481
Patch Set 1 #
Total comments: 2
Patch Set 2 : Fix log messages #Messages
Total messages: 8 (0 generated)
|