From: Tomas Hruby Date: Fri, 11 Jun 2010 08:16:10 +0000 (+0000) Subject: No linear addresses in message delivery X-Git-Tag: v3.1.8~456 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.html?a=commitdiff_plain;h=360de619c037df609ef7f5765e1092676a0e61b6;p=minix.git No linear addresses in message delivery - removes p_delivermsg_lin item from the process structure and code related to it - as the send part, the receive does not need to use the PHYS_COPY_CATCH() and umap_local() couple. - The address space of the target process is installed before delivermsg() is called. - unlike the linear address, the virtual address does not change when paging is turned on nor after fork(). --- diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index b465a8fa3..4f11d9e80 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -588,7 +588,7 @@ PRIVATE void vm_suspend(struct proc *caller, const struct proc *target, /*===========================================================================* * delivermsg * *===========================================================================*/ -int delivermsg(struct proc *rp) +PUBLIC void delivermsg(struct proc *rp) { phys_bytes addr; int r; @@ -596,26 +596,22 @@ int delivermsg(struct proc *rp) assert(rp->p_misc_flags & MF_DELIVERMSG); assert(rp->p_delivermsg.m_source != NONE); - assert(rp->p_delivermsg_lin); - assert(rp->p_delivermsg_lin == umap_local(rp, D, rp->p_delivermsg_vir, sizeof(message))); - - PHYS_COPY_CATCH(vir2phys(&rp->p_delivermsg), - rp->p_delivermsg_lin, sizeof(message), addr); - - if(addr) { - vm_suspend(rp, rp, rp->p_delivermsg_lin, sizeof(message), - VMSTYPE_DELIVERMSG); - r = VMSUSPEND; + if (copy_msg_to_user(rp, &rp->p_delivermsg, + (message *) rp->p_delivermsg_vir)) { + printf("WARNING wrong user pointer 0x%08x from " + "process %s / %d\n", + rp->p_delivermsg_vir, + rp->p_name, + rp->p_endpoint); + r = EFAULT; } else { /* Indicate message has been delivered; address is 'used'. */ rp->p_delivermsg.m_source = NONE; - rp->p_delivermsg_lin = 0; - rp->p_misc_flags &= ~MF_DELIVERMSG; r = OK; } - return r; + rp->p_reg.retreg = r; } PRIVATE char *flagstr(u32_t e, const int dir) @@ -1051,10 +1047,6 @@ PUBLIC int arch_enable_paging(struct proc * caller, const message * m_ptr) if (newmap(caller, caller, ep_data.mem_map) != OK) panic("arch_enable_paging: newmap failed"); - FIXLINMSG(caller); - assert(caller->p_delivermsg_lin == umap_local(caller, D, - caller->p_delivermsg_vir, sizeof(message))); - #ifdef CONFIG_APIC /* if local APIC is enabled */ if (lapic_addr) { diff --git a/kernel/proc.c b/kernel/proc.c index dc4eda719..809597dc4 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -159,13 +159,7 @@ check_misc_flags: else if (proc_ptr->p_misc_flags & MF_DELIVERMSG) { TRACE(VF_SCHEDULING, printf("delivering to %s / %d\n", proc_ptr->p_name, proc_ptr->p_endpoint);); - if(delivermsg(proc_ptr) == VMSUSPEND) { - TRACE(VF_SCHEDULING, - printf("suspending %s / %d\n", - proc_ptr->p_name, - proc_ptr->p_endpoint);); - assert(!proc_is_runnable(proc_ptr)); - } + delivermsg(proc_ptr); } else if (proc_ptr->p_misc_flags & MF_SC_DEFER) { /* Perform the system call that we deferred earlier. */ @@ -605,12 +599,10 @@ PUBLIC int mini_send( /*===========================================================================* * mini_receive * *===========================================================================*/ -PRIVATE int mini_receive( - register struct proc *caller_ptr, /* process trying to get message */ - endpoint_t src_e, /* which message source is wanted */ - message *m_ptr, /* pointer to message buffer */ - const int flags -) +PRIVATE int mini_receive(struct proc * caller_ptr, + int src_e, /* which message source is wanted */ + message * m_buff_usr, /* pointer to message buffer */ + const int flags) { /* A process or task wants to get a message. If a message is already queued, * acquire it and deblock the sender. If no message from the desired source @@ -620,18 +612,11 @@ PRIVATE int mini_receive( sys_map_t *map; bitchunk_t *chunk; int i, r, src_id, src_proc_nr, src_p; - phys_bytes linaddr; assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG)); - if(!(linaddr = umap_local(caller_ptr, D, (vir_bytes) m_ptr, - sizeof(message)))) { - return EFAULT; - } - /* This is where we want our message. */ - caller_ptr->p_delivermsg_lin = linaddr; - caller_ptr->p_delivermsg_vir = (vir_bytes) m_ptr; + caller_ptr->p_delivermsg_vir = (vir_bytes) m_buff_usr; if(src_e == ANY) src_p = ANY; else diff --git a/kernel/proc.h b/kernel/proc.h index d84f17aec..544fd8a62 100644 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -56,7 +56,6 @@ struct proc { message p_sendmsg; /* Message from this process if SENDING */ message p_delivermsg; /* Message for this process if MF_DELIVERMSG */ vir_bytes p_delivermsg_vir; /* Virtual addr this proc wants message at */ - vir_bytes p_delivermsg_lin; /* Linear addr this proc wants message at */ /* If handler functions detect a process wants to do something with * memory that isn't present, VM has to fix it. Until it has asked diff --git a/kernel/proto.h b/kernel/proto.h index 727d987c9..b727eab22 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -176,7 +176,7 @@ _PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p)); _PROTOTYPE( int vm_contiguous, (const struct proc *targetproc, vir_bytes vir_buf, size_t count)); _PROTOTYPE( void proc_stacktrace, (struct proc *proc) ); _PROTOTYPE( int vm_lookup, (const struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent)); -_PROTOTYPE( int delivermsg, (struct proc *target)); +_PROTOTYPE( void delivermsg, (struct proc *target)); _PROTOTYPE( void arch_do_syscall, (struct proc *proc) ); _PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr, phys_bytes *len, int *flags)); diff --git a/kernel/system/do_exec.c b/kernel/system/do_exec.c index e6fe9892f..85aaf1a3b 100644 --- a/kernel/system/do_exec.c +++ b/kernel/system/do_exec.c @@ -29,7 +29,6 @@ PUBLIC int do_exec(struct proc * caller, message * m_ptr) if(rp->p_misc_flags & MF_DELIVERMSG) { rp->p_misc_flags &= ~MF_DELIVERMSG; - rp->p_delivermsg_lin = 0; } /* Save command name for debugging, ps(1) output, etc. */ diff --git a/kernel/system/do_fork.c b/kernel/system/do_fork.c index 302e7262b..4a1180cc6 100644 --- a/kernel/system/do_fork.c +++ b/kernel/system/do_fork.c @@ -109,7 +109,6 @@ PUBLIC int do_fork(struct proc * caller, message * m_ptr) /* Install new map */ r = newmap(caller, rpc, map_ptr); - FIXLINMSG(rpc); /* Don't schedule process in VM mode until it has a new pagetable. */ if(m_ptr->PR_FORK_FLAGS & PFF_VMINHIBIT) { diff --git a/kernel/vm.h b/kernel/vm.h index 43461e68f..404537338 100644 --- a/kernel/vm.h +++ b/kernel/vm.h @@ -7,8 +7,6 @@ #define EFAULT_SRC (-995) #define EFAULT_DST (-994) -#define FIXLINMSG(prp) { prp->p_delivermsg_lin = umap_local(prp, D, prp->p_delivermsg_vir, sizeof(message)); } - #define PHYS_COPY_CATCH(src, dst, size, a) { \ catch_pagefaults++; \ a = phys_copy(src, dst, size); \