c5b309ff07
Main changes: - COW optimization for safecopy. - safemap, a grant-based interface for sharing memory regions between processes. - Integration with safemap and complete rework of DS, supporting new data types natively (labels, memory ranges, memory mapped ranges). - For further information: http://wiki.minix3.org/en/SummerOfCode2009/MemoryGrants Additional changes not included in the original Wu's branch: - Fixed unhandled case in VM when using COW optimization for safecopy in case of a block that has already been shared as SMAP. - Better interface and naming scheme for sys_saferevmap and ds_retrieve_map calls. - Better input checking in syslib: check for page alignment when creating memory mapping grants. - DS notifies subscribers when an entry is deleted. - Documented the behavior of indirect grants in case of memory mapping. - Test suite in /usr/src/test/safeperf|safecopy|safemap|ds/* reworked and extended. - Minor fixes and general cleanup. - TO-DO: Grant ids should be generated and managed the way endpoints are to make sure grant slots are never misreused.
72 lines
2.1 KiB
C
72 lines
2.1 KiB
C
|
|
#include "syslib.h"
|
|
|
|
#include <minix/safecopies.h>
|
|
|
|
/*===========================================================================*
|
|
* sys_safemap *
|
|
*===========================================================================*/
|
|
PUBLIC int sys_safemap(endpoint_t grantor, cp_grant_id_t grant,
|
|
vir_bytes grant_offset, vir_bytes my_address,
|
|
size_t bytes, int my_seg, int writable)
|
|
{
|
|
/* Map a block of data for which the other process has previously
|
|
* granted permission.
|
|
*/
|
|
|
|
message copy_mess;
|
|
|
|
copy_mess.SMAP_EP = grantor;
|
|
copy_mess.SMAP_GID = grant;
|
|
copy_mess.SMAP_OFFSET = grant_offset;
|
|
copy_mess.SMAP_SEG = (void*) my_seg;
|
|
copy_mess.SMAP_ADDRESS = my_address;
|
|
copy_mess.SMAP_BYTES = bytes;
|
|
copy_mess.SMAP_FLAG = writable;
|
|
|
|
return(_taskcall(SYSTASK, SYS_SAFEMAP, ©_mess));
|
|
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* sys_saferevmap_gid *
|
|
*===========================================================================*/
|
|
PUBLIC int sys_saferevmap_gid(cp_grant_id_t grant)
|
|
{
|
|
/* Grantor revokes safemap by grant id. */
|
|
message copy_mess;
|
|
|
|
copy_mess.SMAP_FLAG = 1;
|
|
copy_mess.SMAP_GID = grant;
|
|
|
|
return(_taskcall(SYSTASK, SYS_SAFEREVMAP, ©_mess));
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* sys_saferevmap_addr *
|
|
*===========================================================================*/
|
|
PUBLIC int sys_saferevmap_addr(vir_bytes addr)
|
|
{
|
|
/* Grantor revokes safemap by address. */
|
|
message copy_mess;
|
|
|
|
copy_mess.SMAP_FLAG = 0;
|
|
copy_mess.SMAP_GID = addr;
|
|
|
|
return(_taskcall(SYSTASK, SYS_SAFEREVMAP, ©_mess));
|
|
}
|
|
|
|
/*===========================================================================*
|
|
* sys_safeunmap *
|
|
*===========================================================================*/
|
|
PUBLIC int sys_safeunmap(int my_seg, vir_bytes my_address)
|
|
{
|
|
/* Requestor unmaps safemap. */
|
|
message copy_mess;
|
|
|
|
copy_mess.SMAP_SEG = (void*) my_seg;
|
|
copy_mess.SMAP_ADDRESS = my_address;
|
|
|
|
return(_taskcall(SYSTASK, SYS_SAFEUNMAP, ©_mess));
|
|
}
|
|
|