]> Zhao Yanbai Git Server - minix.git/commitdiff
vm: Let SEF know about special mmapped regions. 03/3103/2
authorCristiano Giuffrida <giuffrida@cs.vu.nl>
Wed, 29 Oct 2014 14:42:27 +0000 (15:42 +0100)
committerDavid van Moolenbroek <david@minix3.org>
Wed, 16 Sep 2015 15:31:40 +0000 (15:31 +0000)
Change-Id: I742529a6747ddd181937aa1a45264b87677c01c8

minix/include/minix/sef.h
minix/lib/libsys/sef_llvm.c
minix/lib/libsys/vm_map_phys.c
minix/servers/vm/main.c

index 28a63b903bc1c45d59995467eeaff05ae2a1e5bd..395bc803fb9fa98c5fb01912b0d8d4d6d6bb0b6a 100644 (file)
@@ -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);
index 38cc5368943510103749ca6d97a43d7510fe2e05..15cf4236e2195066344aacd90c8f60892c2de3f3 100644 (file)
@@ -1,6 +1,7 @@
 #include "syslib.h"
 #include <assert.h>
 #include <unistd.h>
+#include <sys/mman.h>
 #include <minix/sysutil.h>
 
 /* 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                         *
  *===========================================================================*/
index 40b59f8583a259ebbeefaa507d9b85081b2bfe02..0a2131388ac65db00751efff75be777664c744b6 100644 (file)
@@ -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;
 }
index 3e20a2da70278308e0f7bc75f539578d451be67e..6f314fcc14ec27f6004d39b775d84556f055b334 100644 (file)
@@ -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);
+       }
 }
 
 /*===========================================================================*