On Tue, Jul 22, 2014 at 10:40:02PM +0100, Alexander Nasonov wrote: > Matt Thomas wrote: > > > > On Jul 22, 2014, at 2:27 PM, Alexander Nasonov <al...@yandex.ru> wrote: > > > I allocate with the X flag and it seems to work: > > > > > > /* in sljitExecAllocator.c */ > > > return (void *)uvm_km_alloc(module_map, size, > > > PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_ZERO | UVM_KMF_EXEC); > > > > ok. Then you need don't a hook for cache flushing > > > > pmap_protect(vm_map_pamp(module_map), va, size) will do that for you. > > At least for arm/mips/ppc/vax. (e.g. changing a writeable exec page > > to read-only automatically causes it exec cleaned). > > sljit allocates 64K exec chucks which are managed by a special allocator. > You need to run pmap_protect for each chunk. I think it's cheaper to > flush icache.
Wouldn't it be preferable to have *two* mappings for the code? One which is writeable and another which is executable? Joerg