From: Ben Gras Date: Sat, 16 Jun 2012 18:42:27 +0000 (+0000) Subject: drop segments from safemap/safeunmap invocations X-Git-Tag: v3.2.1~536 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.png?a=commitdiff_plain;h=0e35eb0c6b90a411659e08052bfab5c258d4caba;p=minix.git drop segments from safemap/safeunmap invocations --- diff --git a/include/minix/com.h b/include/minix/com.h index ef9ad8f27..160728fef 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -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 */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 4635669ee..7bd68af2d 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -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, diff --git a/kernel/proto.h b/kernel/proto.h index b647f995d..7ceb06e25 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -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 */ diff --git a/kernel/system/do_safemap.c b/kernel/system/do_safemap.c index 20307e1d1..f9a28ec90 100644 --- a/kernel/system/do_safemap.c +++ b/kernel/system/do_safemap.c @@ -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; } diff --git a/lib/libsys/ds.c b/lib/libsys/ds.c index fc4245664..f5976d89f 100644 --- a/lib/libsys/ds.c +++ b/lib/libsys/ds.c @@ -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)) { diff --git a/lib/libsys/sys_safemap.c b/lib/libsys/sys_safemap.c index 2e346edaf..426b7d58a 100644 --- a/lib/libsys/sys_safemap.c +++ b/lib/libsys/sys_safemap.c @@ -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, ©_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, ©_mess)); } diff --git a/servers/ds/store.c b/servers/ds/store.c index 6e2de1974..580cbf98f 100644 --- a/servers/ds/store.c +++ b/servers/ds/store.c @@ -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");