vm: Let SEF know about special mmapped regions.

Change-Id: I742529a6747ddd181937aa1a45264b87677c01c8
This commit is contained in:
Cristiano Giuffrida 2014-10-29 15:42:27 +01:00 committed by David van Moolenbroek
parent e3f3566e33
commit 162b8995bb
4 changed files with 51 additions and 1 deletions

View 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);

View 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 *
*===========================================================================*/

View 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;
}

View 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);
}
}
/*===========================================================================*