drop segments from safemap/safeunmap invocations

This commit is contained in:
Ben Gras 2012-06-16 18:42:27 +00:00
parent 7750657783
commit 0e35eb0c6b
7 changed files with 25 additions and 29 deletions

View file

@ -573,11 +573,12 @@
#define SMAP_EP m2_i1
#define SMAP_GID m2_i2
#define SMAP_OFFSET m2_i3
#define SMAP_SEG m2_p1
#define SMAP_ADDRESS m2_l1
#define SMAP_BYTES m2_l2
#define SMAP_FLAG m2_s1
#define SMAP_SEG_OBSOLETE m2_p1
/* Field names for SYS_SPROF, _CPROF, _PROFBUF. */
#define PROF_ACTION m7_i1 /* start/stop/reset/get */
#define PROF_MEM_SIZE m7_i2 /* available memory for data */

View file

@ -158,11 +158,10 @@ int sys_memset(endpoint_t who, unsigned long pattern,
/* Grant-based map functions. */
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);
grant_offset, vir_bytes my_address, size_t bytes, int writable);
int sys_saferevmap_gid(cp_grant_id_t grant);
int sys_saferevmap_addr(vir_bytes addr);
int sys_safeunmap(int my_seg, vir_bytes my_address);
int sys_safeunmap(vir_bytes my_address);
int sys_vumap(endpoint_t endpt, struct vumap_vir *vvec,
int vcount, size_t offset, int access, struct vumap_phys *pvec,

View file

@ -135,7 +135,7 @@ void hook_ipc_clear(struct proc *proc);
/* system/do_safemap.c */
int map_invoke_vm(struct proc * caller, int req_type, endpoint_t end_d,
int seg_d, vir_bytes off_d, endpoint_t end_s, int seg_s, vir_bytes
vir_bytes off_d, endpoint_t end_s, vir_bytes
off_s, size_t size, int flag);
/* system/do_safecopy.c */

View file

@ -5,7 +5,6 @@
* SMAP_EP endpoint of the grantor
* SMAP_GID grant id
* SMAP_OFFSET offset of the grant space
* SMAP_SEG segment
* SMAP_ADDRESS address
* SMAP_BYTES bytes to be copied
* SMAP_FLAG access, writable map or not?
@ -32,7 +31,6 @@ struct map_info_s {
/* Grantee. */
endpoint_t grantee;
int seg;
vir_bytes address;
/* Length. */
@ -47,7 +45,7 @@ static struct map_info_s map_info[MAX_MAP_INFO];
*===========================================================================*/
static int add_info(endpoint_t grantor, endpoint_t grantee, cp_grant_id_t gid,
vir_bytes offset, vir_bytes address_Dseg,
int seg, vir_bytes address, vir_bytes bytes)
vir_bytes address, vir_bytes bytes)
{
int i;
@ -64,7 +62,6 @@ static int add_info(endpoint_t grantor, endpoint_t grantee, cp_grant_id_t gid,
map_info[i].gid = gid;
map_info[i].address_Dseg = address_Dseg;
map_info[i].offset = offset;
map_info[i].seg = seg;
map_info[i].address = address;
map_info[i].bytes = bytes;
@ -91,14 +88,13 @@ static struct map_info_s *get_revoke_info(endpoint_t grantor, int flag, int arg)
/*===========================================================================*
* get_unmap_info *
*===========================================================================*/
static struct map_info_s *get_unmap_info(endpoint_t grantee, int seg,
static struct map_info_s *get_unmap_info(endpoint_t grantee,
vir_bytes address)
{
int i;
for(i = 0; i < MAX_MAP_INFO; i++) {
if(map_info[i].flag == 1
&& map_info[i].grantee == grantee
&& map_info[i].seg == seg
&& map_info[i].address == address)
return &map_info[i];
}
@ -119,8 +115,8 @@ static void clear_info(struct map_info_s *p)
*===========================================================================*/
int map_invoke_vm(struct proc * caller,
int req_type, /* VMPTYPE_... COWMAP, SMAP, SUNMAP */
endpoint_t end_d, int seg_d, vir_bytes off_d,
endpoint_t end_s, int seg_s, vir_bytes off_s,
endpoint_t end_d, vir_bytes off_d,
endpoint_t end_s, vir_bytes off_s,
size_t size, int flag)
{
struct proc *src, *dst;
@ -129,8 +125,8 @@ int map_invoke_vm(struct proc * caller,
src = endpoint_lookup(end_s);
dst = endpoint_lookup(end_d);
lin_src = umap_local(src, seg_s, off_s, size);
lin_dst = umap_local(dst, seg_d, off_d, size);
lin_src = umap_local(src, D, off_s, size);
lin_dst = umap_local(dst, D, off_d, size);
if(lin_src == 0 || lin_dst == 0) {
printf("map_invoke_vm: error in umap_local.\n");
return EINVAL;
@ -178,7 +174,6 @@ int do_safemap(struct proc * caller, message * m_ptr)
endpoint_t grantor = m_ptr->SMAP_EP;
cp_grant_id_t gid = (cp_grant_id_t) m_ptr->SMAP_GID;
vir_bytes offset = (vir_bytes) m_ptr->SMAP_OFFSET;
int seg = (int) m_ptr->SMAP_SEG;
vir_bytes address = (vir_bytes) m_ptr->SMAP_ADDRESS;
vir_bytes bytes = (vir_bytes) m_ptr->SMAP_BYTES;
int flag = m_ptr->SMAP_FLAG;
@ -211,13 +206,13 @@ int do_safemap(struct proc * caller, message * m_ptr)
/* Add map info. */
r = add_info(new_grantor, caller->p_endpoint, gid, offset,
offset_result, seg, address, bytes);
offset_result, address, bytes);
if(r != OK)
return r;
/* Invoke VM. */
return map_invoke_vm(caller, VMPTYPE_SMAP,
caller->p_endpoint, seg, address, new_grantor, D, offset_result, bytes,flag);
caller->p_endpoint, address, new_grantor, offset_result, bytes,flag);
}
/*===========================================================================*
@ -237,8 +232,8 @@ static int safeunmap(struct proc * caller, struct map_info_s *p)
}
r = map_invoke_vm(caller, VMPTYPE_SUNMAP,
p->grantee, p->seg, p->address,
new_grantor, D, offset_result,
p->grantee, p->address,
new_grantor, offset_result,
p->bytes, 0);
clear_info(p);
if(r != OK) {
@ -271,11 +266,10 @@ int do_saferevmap(struct proc * caller, message * m_ptr)
int do_safeunmap(struct proc * caller, message * m_ptr)
{
vir_bytes address = (vir_bytes) m_ptr->SMAP_ADDRESS;
int seg = (int)m_ptr->SMAP_SEG;
struct map_info_s *p;
int r;
while((p = get_unmap_info(caller->p_endpoint, seg, address)) != NULL) {
while((p = get_unmap_info(caller->p_endpoint, address)) != NULL) {
if((r = safeunmap(caller, p)) != OK)
return r;
}

View file

@ -194,7 +194,7 @@ int ds_retrieve_map(const char *ds_name, char *vaddr, size_t *length,
*length = (size_t) m.DS_VAL_LEN;
*length = (size_t) CLICK_FLOOR(*length);
r = sys_safemap(DS_PROC_NR, m.DS_VAL, 0,
(vir_bytes)vaddr, *length, D, 0);
(vir_bytes)vaddr, *length, 0);
/* Copy mapped memory range or a snapshot. */
} else if(flags & (DSMF_COPY_MAPPED|DSMF_COPY_SNAPSHOT)) {

View file

@ -8,7 +8,7 @@
*===========================================================================*/
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)
size_t bytes, int writable)
{
/* Map a block of data for which the other process has previously
* granted permission.
@ -19,11 +19,12 @@ int sys_safemap(endpoint_t grantor, cp_grant_id_t grant,
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;
copy_mess.SMAP_SEG_OBSOLETE = (void *) D;
return(_kernel_call(SYS_SAFEMAP, &copy_mess));
}
@ -59,14 +60,15 @@ int sys_saferevmap_addr(vir_bytes addr)
/*===========================================================================*
* sys_safeunmap *
*===========================================================================*/
int sys_safeunmap(int my_seg, vir_bytes my_address)
int sys_safeunmap(vir_bytes my_address)
{
/* Requestor unmaps safemap. */
message copy_mess;
copy_mess.SMAP_SEG = (void*) my_seg;
copy_mess.SMAP_ADDRESS = my_address;
copy_mess.SMAP_SEG_OBSOLETE = (void *) D;
return(_kernel_call(SYS_SAFEUNMAP, &copy_mess));
}

View file

@ -374,7 +374,7 @@ int do_publish(message *m_ptr)
/* Map memory. */
r = sys_safemap(m_ptr->m_source, (cp_grant_id_t) m_ptr->DS_VAL, 0,
(vir_bytes) dsp->u.map.data, length, D, 0);
(vir_bytes) dsp->u.map.data, length, 0);
if(r != OK) {
printf("DS: publish: memory map/copy failed from %d: %d\n",
m_ptr->m_source, r);
@ -696,7 +696,7 @@ int do_delete(message *m_ptr)
break;
case DSF_TYPE_MAP:
/* Unmap the mapped data. */
r = sys_safeunmap(D, (vir_bytes)dsp->u.map.data);
r = sys_safeunmap((vir_bytes)dsp->u.map.data);
if(r != OK)
printf("DS: sys_safeunmap failed. Grant already revoked?\n");