From: Cristiano Giuffrida Date: Wed, 29 Oct 2014 14:42:27 +0000 (+0100) Subject: vm: Let SEF know about special mmapped regions. X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F03%2F3103%2F2;p=minix.git vm: Let SEF know about special mmapped regions. Change-Id: I742529a6747ddd181937aa1a45264b87677c01c8 --- diff --git a/minix/include/minix/sef.h b/minix/include/minix/sef.h index 28a63b903..395bc803f 100644 --- a/minix/include/minix/sef.h +++ b/minix/include/minix/sef.h @@ -364,6 +364,8 @@ size_t sef_llvm_state_table_size(void); void sef_llvm_stack_refs_save(char *stack_buff); void sef_llvm_stack_refs_restore(char *stack_buff); int sef_llvm_state_transfer(sef_init_info_t *info); +int sef_llvm_add_special_mem_region(void *addr, size_t len, const char* name); +int sef_llvm_del_special_mem_region_by_addr(void *addr); int sef_llvm_ltckpt_enabled(void); int sef_llvm_get_ltckpt_offset(void); diff --git a/minix/lib/libsys/sef_llvm.c b/minix/lib/libsys/sef_llvm.c index 38cc53689..15cf4236e 100644 --- a/minix/lib/libsys/sef_llvm.c +++ b/minix/lib/libsys/sef_llvm.c @@ -1,6 +1,7 @@ #include "syslib.h" #include #include +#include #include /* Stack refs definitions. */ @@ -128,6 +129,30 @@ int sef_llvm_state_transfer(sef_init_info_t *info) return _magic_state_transfer(info); } +/*===========================================================================* + * sef_llvm_add_special_mem_region * + *===========================================================================*/ +int sef_llvm_add_special_mem_region(void *addr, size_t len, const char* name) +{ + extern int __attribute__((weak)) st_add_special_mmapped_region(void *addr, + size_t len, char* name); + if (!st_add_special_mmapped_region) + return 0; + return st_add_special_mmapped_region(addr, len, (char*) name); +} + +/*===========================================================================* + * sef_llvm_del_special_mem_region_by_addr * + *===========================================================================*/ +int sef_llvm_del_special_mem_region_by_addr(void *addr) +{ + extern int __attribute__((weak)) st_del_special_mmapped_region_by_addr( + void *addr); + if (!st_del_special_mmapped_region_by_addr) + return 0; + return st_del_special_mmapped_region_by_addr(addr); +} + /*===========================================================================* * sef_llvm_ltckpt_enabled * *===========================================================================*/ diff --git a/minix/lib/libsys/vm_map_phys.c b/minix/lib/libsys/vm_map_phys.c index 40b59f858..0a2131388 100644 --- a/minix/lib/libsys/vm_map_phys.c +++ b/minix/lib/libsys/vm_map_phys.c @@ -20,6 +20,12 @@ vm_map_phys(endpoint_t who, void *phaddr, size_t len) if (r != OK) return MAP_FAILED; + r = sef_llvm_add_special_mem_region(m.m_lsys_vm_map_phys.reply, + len, NULL); + if(r < 0) { + printf("vm_map_phys: add_special_mem_region failed: %d\n", r); + } + return m.m_lsys_vm_map_phys.reply; } @@ -27,10 +33,20 @@ int vm_unmap_phys(endpoint_t who, void *vaddr, size_t len) { message m; + int r; memset(&m, 0, sizeof(m)); m.m_lsys_vm_unmap_phys.ep = who; m.m_lsys_vm_unmap_phys.vaddr = vaddr; - return _taskcall(VM_PROC_NR, VM_UNMAP_PHYS, &m); + r = _taskcall(VM_PROC_NR, VM_UNMAP_PHYS, &m); + + if(r != OK) return r; + + r = sef_llvm_del_special_mem_region_by_addr(vaddr); + if(r < 0) { + printf("vm_map_phys: del_special_mem_region failed: %d\n", r); + } + + return OK; } diff --git a/minix/servers/vm/main.c b/minix/servers/vm/main.c index 3e20a2da7..6f314fcc1 100644 --- a/minix/servers/vm/main.c +++ b/minix/servers/vm/main.c @@ -519,6 +519,13 @@ void init_vm(void) /* Mark VM instances. */ num_vm_instances = 1; vmproc[VM_PROC_NR].vm_flags |= VMF_VM_INSTANCE; + + /* Let SEF know about VM mmapped regions. */ + s = sef_llvm_add_special_mem_region((void*)VM_OWN_HEAPBASE, + VM_OWN_MMAPTOP-VM_OWN_HEAPBASE, "%MMAP_ALL"); + if(s < 0) { + printf("VM: st_add_special_mmapped_region failed %d\n", s); + } } /*===========================================================================*