This patch removes the global variables who_p and who_e from the

kernel (sys task).  The main reason is that these would have to become
cpu local variables on SMP.  Once the system task is not a task but a
genuine part of the kernel there is even less reason to have these
extra variables as proc_ptr will already contain all neccessary
information. In addition converting who_e to the process pointer and
back again all the time will be avoided.

Although proc_ptr will contain all important information, accessing it
as a cpu local variable will be fairly expensive, hence the value
would be assigned to some on stack local variable. Therefore it is
better to add the 'caller' argument to the syscall handlers to pass
the value on stack anyway. It also clearly denotes on who's behalf is
the syscall being executed.

This patch also ANSIfies the syscall function headers.

Last but not least, it also fixes a potential bug in virtual_copy_f()
in case the check is disabled. So far the function in case of a
failure could possible reuse an old who_p in case this function had
not been called from the system task.

virtual_copy_f() takes the caller as a parameter too. In case the
checking is disabled, the caller must be NULL and non NULL if it is
enabled as we must be able to suspend the caller.
This commit is contained in:
Tomas Hruby 2010-02-03 09:04:48 +00:00
parent 144de8a7b3
commit cca24d06d8
44 changed files with 232 additions and 284 deletions

View file

@ -18,17 +18,16 @@ struct reg86u reg86;
/*===========================================================================* /*===========================================================================*
* do_int86 * * do_int86 *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_int86(m_ptr) PUBLIC int do_int86(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
data_copy(who_e, (vir_bytes) m_ptr->INT86_REG86, data_copy(caller->p_endpoint, (vir_bytes) m_ptr->INT86_REG86,
SYSTEM, (vir_bytes) &reg86, sizeof(reg86)); SYSTEM, (vir_bytes) &reg86, sizeof(reg86));
level0(int86); level0(int86);
/* Copy results back to the caller */ /* Copy results back to the caller */
data_copy(SYSTEM, (vir_bytes) &reg86, data_copy(SYSTEM, (vir_bytes) &reg86,
who_e, (vir_bytes) m_ptr->INT86_REG86, sizeof(reg86)); caller->p_endpoint, (vir_bytes) m_ptr->INT86_REG86, sizeof(reg86));
/* The BIOS call eats interrupts. Call get_randomness to generate some /* The BIOS call eats interrupts. Call get_randomness to generate some
* entropy. Normally, get_randomness is called from an interrupt handler. * entropy. Normally, get_randomness is called from an interrupt handler.

View file

@ -10,20 +10,20 @@
#include "../../system.h" #include "../../system.h"
#include "../../kernel.h" #include "../../kernel.h"
#include <minix/endpoint.h>
#include "proto.h" #include "proto.h"
/*===========================================================================* /*===========================================================================*
* do_iopenable * * do_iopenable *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_iopenable(m_ptr) PUBLIC int do_iopenable(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
int proc_nr; int proc_nr;
#if 1 /* ENABLE_USERPRIV && ENABLE_USERIOPL */ #if 1 /* ENABLE_USERPRIV && ENABLE_USERIOPL */
if (m_ptr->IO_ENDPT == SELF) { if (m_ptr->IO_ENDPT == SELF) {
proc_nr = who_p; proc_nr = _ENDPOINT_P(caller->p_endpoint);
} else if(!isokendpt(m_ptr->IO_ENDPT, &proc_nr)) } else if(!isokendpt(m_ptr->IO_ENDPT, &proc_nr))
return(EINVAL); return(EINVAL);
enable_iop(proc_addr(proc_nr)); enable_iop(proc_addr(proc_nr));

View file

@ -13,8 +13,7 @@
/*===========================================================================* /*===========================================================================*
* do_readbios * * do_readbios *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_readbios(m_ptr) PUBLIC int do_readbios(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
struct vir_addr src, dst; struct vir_addr src, dst;
@ -25,5 +24,5 @@ register message *m_ptr; /* pointer to request message */
src.proc_nr_e = NONE; src.proc_nr_e = NONE;
dst.proc_nr_e = m_ptr->m_source; dst.proc_nr_e = m_ptr->m_source;
return virtual_copy_vmcheck(&src, &dst, m_ptr->RDB_SIZE); return virtual_copy_vmcheck(caller, &src, &dst, m_ptr->RDB_SIZE);
} }

View file

@ -21,9 +21,7 @@
/*===========================================================================* /*===========================================================================*
* do_sdevio * * do_sdevio *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_sdevio( PUBLIC int do_sdevio(struct proc * caller, message *m_ptr)
register message *m_ptr /* pointer to request message */
)
{ {
vir_bytes newoffset; vir_bytes newoffset;
endpoint_t newep; endpoint_t newep;
@ -32,7 +30,6 @@ PUBLIC int do_sdevio(
long port = m_ptr->DIO_PORT; long port = m_ptr->DIO_PORT;
phys_bytes phys_buf; phys_bytes phys_buf;
int i, req_type, req_dir, size, nr_io_range; int i, req_type, req_dir, size, nr_io_range;
struct proc *rp;
struct priv *privp; struct priv *privp;
struct io_range *iorp; struct io_range *iorp;
struct proc *destproc; struct proc *destproc;
@ -55,7 +52,7 @@ PUBLIC int do_sdevio(
* that initiated the device I/O. Kernel processes, of course, are denied. * that initiated the device I/O. Kernel processes, of course, are denied.
*/ */
if (proc_nr_e == SELF) if (proc_nr_e == SELF)
proc_nr = who_p; proc_nr = _ENDPOINT_P(caller->p_endpoint);
else else
if(!isokendpt(proc_nr_e, &proc_nr)) if(!isokendpt(proc_nr_e, &proc_nr))
return(EINVAL); return(EINVAL);
@ -68,7 +65,7 @@ PUBLIC int do_sdevio(
/* Check for 'safe' variants. */ /* Check for 'safe' variants. */
if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) { if((m_ptr->DIO_REQUEST & _DIO_SAFEMASK) == _DIO_SAFE) {
/* Map grant address to physical address. */ /* Map grant address to physical address. */
if(verify_grant(proc_nr_e, who_e, if(verify_grant(proc_nr_e, caller->p_endpoint,
(vir_bytes) m_ptr->DIO_VEC_ADDR, (vir_bytes) m_ptr->DIO_VEC_ADDR,
count, count,
req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ, req_dir == _DIO_INPUT ? CPF_WRITE : CPF_READ,
@ -86,10 +83,10 @@ PUBLIC int do_sdevio(
return(EFAULT); return(EFAULT);
} }
} else { } else {
if(proc_nr != who_p) if(proc_nr != _ENDPOINT_P(caller->p_endpoint))
{ {
kprintf("do_sdevio: unsafe sdevio by %d in %d denied\n", kprintf("do_sdevio: unsafe sdevio by %d in %d denied\n",
who_e, proc_nr_e); caller->p_endpoint, proc_nr_e);
return EPERM; return EPERM;
} }
/* Get and check physical address. */ /* Get and check physical address. */
@ -110,8 +107,7 @@ PUBLIC int do_sdevio(
default: size= 4; break; /* Be conservative */ default: size= 4; break; /* Be conservative */
} }
rp= proc_addr(who_p); privp= priv(caller);
privp= priv(rp);
if (privp && privp->s_flags & CHECK_IO_PORT) if (privp && privp->s_flags & CHECK_IO_PORT)
{ {
port= m_ptr->DIO_PORT; port= m_ptr->DIO_PORT;

View file

@ -775,7 +775,8 @@ int vm_phys_memset(phys_bytes ph, u8_t c, phys_bytes bytes)
/*===========================================================================* /*===========================================================================*
* virtual_copy_f * * virtual_copy_f *
*===========================================================================*/ *===========================================================================*/
PUBLIC int virtual_copy_f(src_addr, dst_addr, bytes, vmcheck) PUBLIC int virtual_copy_f(caller, src_addr, dst_addr, bytes, vmcheck)
struct proc * caller;
struct vir_addr *src_addr; /* source virtual address */ struct vir_addr *src_addr; /* source virtual address */
struct vir_addr *dst_addr; /* destination virtual address */ struct vir_addr *dst_addr; /* destination virtual address */
vir_bytes bytes; /* # of bytes to copy */ vir_bytes bytes; /* # of bytes to copy */
@ -791,6 +792,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
struct proc *procs[2]; struct proc *procs[2];
NOREC_ENTER(virtualcopy); NOREC_ENTER(virtualcopy);
vmassert((vmcheck && caller) || (!vmcheck && !caller));
/* Check copy count. */ /* Check copy count. */
if (bytes <= 0) return(EDOM); if (bytes <= 0) return(EDOM);
@ -823,8 +826,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
phys_addr[i] = umap_local(p, seg_index, vir_addr[i]->offset, phys_addr[i] = umap_local(p, seg_index, vir_addr[i]->offset,
bytes); bytes);
else else
phys_addr[i] = umap_virtual(p, seg_index, vir_addr[i]->offset, phys_addr[i] = umap_virtual(p, seg_index,
bytes); vir_addr[i]->offset, bytes);
if(phys_addr[i] == 0) { if(phys_addr[i] == 0) {
kprintf("virtual_copy: map 0x%x failed for %s seg %d, " kprintf("virtual_copy: map 0x%x failed for %s seg %d, "
"offset %lx, len %d, i %d\n", "offset %lx, len %d, i %d\n",
@ -861,11 +864,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
if(vm_running) { if(vm_running) {
int r; int r;
struct proc *caller;
caller = proc_addr(who_p); if(caller && RTS_ISSET(caller, RTS_VMREQUEST)) {
if(RTS_ISSET(caller, RTS_VMREQUEST)) {
vmassert(caller->p_vmrequest.vmresult != VMSUSPEND); vmassert(caller->p_vmrequest.vmresult != VMSUSPEND);
RTS_LOCK_UNSET(caller, RTS_VMREQUEST); RTS_LOCK_UNSET(caller, RTS_VMREQUEST);
if(caller->p_vmrequest.vmresult != OK) { if(caller->p_vmrequest.vmresult != OK) {
@ -884,7 +884,7 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
phys_bytes lin; phys_bytes lin;
if(r != EFAULT_SRC && r != EFAULT_DST) if(r != EFAULT_SRC && r != EFAULT_DST)
minix_panic("lin_lin_copy failed", r); minix_panic("lin_lin_copy failed", r);
if(!vmcheck) { if(!vmcheck || !caller) {
NOREC_RETURN(virtualcopy, r); NOREC_RETURN(virtualcopy, r);
} }
@ -909,8 +909,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
#endif #endif
vmassert(proc_ptr->p_endpoint == SYSTEM); vmassert(proc_ptr->p_endpoint == SYSTEM);
vm_suspend(caller, target, lin, bytes, wr, VMSTYPE_KERNELCALL); vm_suspend(caller, target, lin, bytes, wr,
VMSTYPE_KERNELCALL);
NOREC_RETURN(virtualcopy, VMSUSPEND); NOREC_RETURN(virtualcopy, VMSUSPEND);
} }
@ -941,8 +941,7 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
/*===========================================================================* /*===========================================================================*
* data_copy * * data_copy *
*===========================================================================*/ *===========================================================================*/
PUBLIC int data_copy( PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr,
endpoint_t from_proc, vir_bytes from_addr,
endpoint_t to_proc, vir_bytes to_addr, endpoint_t to_proc, vir_bytes to_addr,
size_t bytes) size_t bytes)
{ {
@ -960,7 +959,7 @@ PUBLIC int data_copy(
/*===========================================================================* /*===========================================================================*
* data_copy_vmcheck * * data_copy_vmcheck *
*===========================================================================*/ *===========================================================================*/
PUBLIC int data_copy_vmcheck( PUBLIC int data_copy_vmcheck(struct proc * caller,
endpoint_t from_proc, vir_bytes from_addr, endpoint_t from_proc, vir_bytes from_addr,
endpoint_t to_proc, vir_bytes to_addr, endpoint_t to_proc, vir_bytes to_addr,
size_t bytes) size_t bytes)
@ -973,7 +972,7 @@ PUBLIC int data_copy_vmcheck(
src.proc_nr_e = from_proc; src.proc_nr_e = from_proc;
dst.proc_nr_e = to_proc; dst.proc_nr_e = to_proc;
return virtual_copy_vmcheck(&src, &dst, bytes); return virtual_copy_vmcheck(caller, &src, &dst, bytes);
} }
/*===========================================================================* /*===========================================================================*

View file

@ -42,8 +42,6 @@ EXTERN u32_t system_hz; /* HZ value */
EXTERN reg_t mon_ss, mon_sp; /* boot monitor stack */ EXTERN reg_t mon_ss, mon_sp; /* boot monitor stack */
EXTERN int mon_return; /* true if we can return to monitor */ EXTERN int mon_return; /* true if we can return to monitor */
EXTERN int do_serial_debug; EXTERN int do_serial_debug;
EXTERN endpoint_t who_e; /* message source endpoint */
EXTERN int who_p; /* message source proc */
EXTERN int sys_call_code; /* kernel call number in SYSTEM */ EXTERN int sys_call_code; /* kernel call number in SYSTEM */
EXTERN time_t boottime; EXTERN time_t boottime;
EXTERN char params_buffer[512]; /* boot monitor parameters */ EXTERN char params_buffer[512]; /* boot monitor parameters */

View file

@ -61,13 +61,13 @@ _PROTOTYPE( void sig_delay_done, (struct proc *rp) );
_PROTOTYPE( void sys_task, (void) ); _PROTOTYPE( void sys_task, (void) );
#define numap_local(proc_nr, vir_addr, bytes) \ #define numap_local(proc_nr, vir_addr, bytes) \
umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes)) umap_local(proc_addr(proc_nr), D, (vir_addr), (bytes))
_PROTOTYPE( phys_bytes umap_grant, (struct proc *, cp_grant_id_t, _PROTOTYPE( phys_bytes umap_grant, (struct proc *, cp_grant_id_t, vir_bytes));
vir_bytes));
_PROTOTYPE( void clear_endpoint, (struct proc *rc) ); _PROTOTYPE( void clear_endpoint, (struct proc *rc) );
_PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes)); _PROTOTYPE( phys_bytes umap_bios, (vir_bytes vir_addr, vir_bytes bytes));
/* system/do_newmap.c */ /* system/do_newmap.c */
_PROTOTYPE( int newmap, (struct proc *rp, struct mem_map *map_ptr) ); _PROTOTYPE( int newmap, (struct proc * caller, struct proc *rp,
struct mem_map *map_ptr));
/* system/do_vtimer.c */ /* system/do_vtimer.c */
_PROTOTYPE( void vtimer_check, (struct proc *rp) ); _PROTOTYPE( void vtimer_check, (struct proc *rp) );
@ -88,17 +88,18 @@ _PROTOTYPE( char *rtsflagstr, (int flags) );
_PROTOTYPE( char *miscflagstr, (int flags) ); _PROTOTYPE( char *miscflagstr, (int flags) );
/* system/do_safemap.c */ /* system/do_safemap.c */
_PROTOTYPE( int map_invoke_vm, (int req_type, _PROTOTYPE( int map_invoke_vm, (struct proc * caller, int req_type,
endpoint_t end_d, int seg_d, vir_bytes off_d, 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_s, int seg_s, vir_bytes off_s,
size_t size, int flag)); size_t size, int flag));
/* system/do_safecopy.c */ /* system/do_safecopy.c */
_PROTOTYPE( int verify_grant, (endpoint_t, endpoint_t, cp_grant_id_t, vir_bytes, _PROTOTYPE( int verify_grant, (endpoint_t, endpoint_t,
int, vir_bytes, vir_bytes *, endpoint_t *)); cp_grant_id_t, vir_bytes, int,
vir_bytes, vir_bytes *, endpoint_t *));
/* system/do_sysctl.c */ /* system/do_sysctl.c */
_PROTOTYPE( int do_sysctl, (message *m)); _PROTOTYPE( int do_sysctl, (struct proc * caller, message *m));
#if SPROFILE #if SPROFILE
/* profile.c */ /* profile.c */
@ -112,13 +113,17 @@ _PROTOTYPE( phys_bytes phys_copy, (phys_bytes source, phys_bytes dest,
phys_bytes count) ); phys_bytes count) );
_PROTOTYPE( void phys_copy_fault, (void)); _PROTOTYPE( void phys_copy_fault, (void));
_PROTOTYPE( void phys_copy_fault_in_kernel, (void)); _PROTOTYPE( void phys_copy_fault_in_kernel, (void));
#define virtual_copy(src, dst, bytes) virtual_copy_f(src, dst, bytes, 0) #define virtual_copy(src, dst, bytes) \
#define virtual_copy_vmcheck(src, dst, bytes) virtual_copy_f(src, dst, bytes, 1) virtual_copy_f(NULL, src, dst, bytes, 0)
_PROTOTYPE( int virtual_copy_f, (struct vir_addr *src, struct vir_addr *dst, #define virtual_copy_vmcheck(caller, src, dst, bytes) \
virtual_copy_f(caller, src, dst, bytes, 1)
_PROTOTYPE( int virtual_copy_f, (struct proc * caller,
struct vir_addr *src, struct vir_addr *dst,
vir_bytes bytes, int vmcheck) ); vir_bytes bytes, int vmcheck) );
_PROTOTYPE( int data_copy, (endpoint_t from, vir_bytes from_addr, _PROTOTYPE( int data_copy, (endpoint_t from, vir_bytes from_addr,
endpoint_t to, vir_bytes to_addr, size_t bytes)); endpoint_t to, vir_bytes to_addr, size_t bytes));
_PROTOTYPE( int data_copy_vmcheck, (endpoint_t from, vir_bytes from_addr, _PROTOTYPE( int data_copy_vmcheck, (struct proc *,
endpoint_t from, vir_bytes from_addr,
endpoint_t to, vir_bytes to_addr, size_t bytes)); endpoint_t to, vir_bytes to_addr, size_t bytes));
_PROTOTYPE( void alloc_segments, (struct proc *rp) ); _PROTOTYPE( void alloc_segments, (struct proc *rp) );
_PROTOTYPE( void vm_init, (struct proc *first) ); _PROTOTYPE( void vm_init, (struct proc *first) );
@ -128,8 +133,8 @@ _PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,
vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset)); vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset));
_PROTOTYPE( phys_bytes umap_remote, (struct proc* rp, int seg, _PROTOTYPE( phys_bytes umap_remote, (struct proc* rp, int seg,
vir_bytes vir_addr, vir_bytes bytes) ); vir_bytes vir_addr, vir_bytes bytes) );
_PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp, int seg, _PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
vir_bytes vir_addr, vir_bytes bytes) ); int seg, vir_bytes vir_addr, vir_bytes bytes) );
_PROTOTYPE( phys_bytes seg2phys, (U16_t) ); _PROTOTYPE( phys_bytes seg2phys, (U16_t) );
_PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern, _PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern,
phys_bytes count) ); phys_bytes count) );

View file

@ -50,7 +50,7 @@
* because the dummy is declared extern. If an illegal call is given, the * because the dummy is declared extern. If an illegal call is given, the
* array size will be negative and this won't compile. * array size will be negative and this won't compile.
*/ */
PUBLIC int (*call_vec[NR_SYS_CALLS])(message *m_ptr); PUBLIC int (*call_vec[NR_SYS_CALLS])(struct proc * caller, message *m_ptr);
char *callnames[NR_SYS_CALLS]; char *callnames[NR_SYS_CALLS];
#define map(call_nr, handler) \ #define map(call_nr, handler) \
@ -72,6 +72,8 @@ PUBLIC void sys_task()
register struct proc *caller_ptr; register struct proc *caller_ptr;
int s; int s;
int call_nr; int call_nr;
int who_p;
endpoint_t who_e;
/* Initialize the system task. */ /* Initialize the system task. */
initialize(); initialize();
@ -105,7 +107,8 @@ PUBLIC void sys_task()
result = ECALLDENIED; /* illegal message type */ result = ECALLDENIED; /* illegal message type */
} }
else { else {
result = (*call_vec[call_nr])(&m); /* handle the system call */ /* handle the system call */
result = (*call_vec[call_nr])(caller_ptr, &m);
} }
if(result == VMSUSPEND) { if(result == VMSUSPEND) {
@ -549,6 +552,7 @@ PRIVATE struct proc *vmrestart_check(message *m)
{ {
int type; int type;
struct proc *restarting; struct proc *restarting;
int who_p;
/* Anyone waiting to be vm-restarted? */ /* Anyone waiting to be vm-restarted? */
@ -589,4 +593,5 @@ PRIVATE struct proc *vmrestart_check(message *m)
minix_panic("strange restart type", type); minix_panic("strange restart type", type);
} }
minix_panic("fell out of switch", NO_NUM); minix_panic("fell out of switch", NO_NUM);
return NULL;
} }

View file

@ -36,161 +36,161 @@
#include "proc.h" #include "proc.h"
/* Default handler for unused kernel calls. */ /* Default handler for unused kernel calls. */
_PROTOTYPE( int do_unused, (message *m_ptr) ); _PROTOTYPE( int do_unused, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_exec, (message *m_ptr) ); _PROTOTYPE( int do_exec, (struct proc * caller, message *m_ptr) );
#if ! USE_EXEC #if ! USE_EXEC
#define do_exec do_unused #define do_exec do_unused
#endif #endif
_PROTOTYPE( int do_fork, (message *m_ptr) ); _PROTOTYPE( int do_fork, (struct proc * caller, message *m_ptr) );
#if ! USE_FORK #if ! USE_FORK
#define do_fork do_unused #define do_fork do_unused
#endif #endif
_PROTOTYPE( int do_newmap, (message *m_ptr) ); _PROTOTYPE( int do_newmap, (struct proc * caller, message *m_ptr) );
#if ! USE_NEWMAP #if ! USE_NEWMAP
#define do_newmap do_unused #define do_newmap do_unused
#endif #endif
_PROTOTYPE( int do_exit, (message *m_ptr) ); _PROTOTYPE( int do_exit, (struct proc * caller, message *m_ptr) );
#if ! USE_EXIT #if ! USE_EXIT
#define do_exit do_unused #define do_exit do_unused
#endif #endif
_PROTOTYPE( int do_trace, (message *m_ptr) ); _PROTOTYPE( int do_trace, (struct proc * caller, message *m_ptr) );
#if ! USE_TRACE #if ! USE_TRACE
#define do_trace do_unused #define do_trace do_unused
#endif #endif
_PROTOTYPE( int do_nice, (message *m_ptr) ); _PROTOTYPE( int do_nice, (struct proc * caller, message *m_ptr) );
#if ! USE_NICE #if ! USE_NICE
#define do_nice do_unused #define do_nice do_unused
#endif #endif
_PROTOTYPE( int do_runctl, (message *m_ptr) ); _PROTOTYPE( int do_runctl, (struct proc * caller, message *m_ptr) );
#if ! USE_RUNCTL #if ! USE_RUNCTL
#define do_runctl do_unused #define do_runctl do_unused
#endif #endif
_PROTOTYPE( int do_copy, (message *m_ptr) ); _PROTOTYPE( int do_copy, (struct proc * caller, message *m_ptr) );
#define do_vircopy do_copy #define do_vircopy do_copy
#if ! (USE_VIRCOPY || USE_PHYSCOPY) #if ! (USE_VIRCOPY || USE_PHYSCOPY)
#define do_copy do_unused #define do_copy do_unused
#endif #endif
_PROTOTYPE( int do_umap, (message *m_ptr) ); _PROTOTYPE( int do_umap, (struct proc * caller, message *m_ptr) );
#if ! USE_UMAP #if ! USE_UMAP
#define do_umap do_unused #define do_umap do_unused
#endif #endif
_PROTOTYPE( int do_memset, (message *m_ptr) ); _PROTOTYPE( int do_memset, (struct proc * caller, message *m_ptr) );
#if ! USE_MEMSET #if ! USE_MEMSET
#define do_memset do_unused #define do_memset do_unused
#endif #endif
_PROTOTYPE( int do_abort, (message *m_ptr) ); _PROTOTYPE( int do_abort, (struct proc * caller, message *m_ptr) );
#if ! USE_ABORT #if ! USE_ABORT
#define do_abort do_unused #define do_abort do_unused
#endif #endif
_PROTOTYPE( int do_getinfo, (message *m_ptr) ); _PROTOTYPE( int do_getinfo, (struct proc * caller, message *m_ptr) );
#if ! USE_GETINFO #if ! USE_GETINFO
#define do_getinfo do_unused #define do_getinfo do_unused
#endif #endif
_PROTOTYPE( int do_privctl, (message *m_ptr) ); _PROTOTYPE( int do_privctl, (struct proc * caller, message *m_ptr) );
#if ! USE_PRIVCTL #if ! USE_PRIVCTL
#define do_privctl do_unused #define do_privctl do_unused
#endif #endif
_PROTOTYPE( int do_segctl, (message *m_ptr) ); _PROTOTYPE( int do_segctl, (struct proc * caller, message *m_ptr) );
#if ! USE_SEGCTL #if ! USE_SEGCTL
#define do_segctl do_unused #define do_segctl do_unused
#endif #endif
_PROTOTYPE( int do_irqctl, (message *m_ptr) ); _PROTOTYPE( int do_irqctl, (struct proc * caller, message *m_ptr) );
#if ! USE_IRQCTL #if ! USE_IRQCTL
#define do_irqctl do_unused #define do_irqctl do_unused
#endif #endif
_PROTOTYPE( int do_devio, (message *m_ptr) ); _PROTOTYPE( int do_devio, (struct proc * caller, message *m_ptr) );
#if ! USE_DEVIO #if ! USE_DEVIO
#define do_devio do_unused #define do_devio do_unused
#endif #endif
_PROTOTYPE( int do_vdevio, (message *m_ptr) ); _PROTOTYPE( int do_vdevio, (struct proc * caller, message *m_ptr) );
#if ! USE_VDEVIO #if ! USE_VDEVIO
#define do_vdevio do_unused #define do_vdevio do_unused
#endif #endif
_PROTOTYPE( int do_int86, (message *m_ptr) ); _PROTOTYPE( int do_int86, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_sdevio, (message *m_ptr) ); _PROTOTYPE( int do_sdevio, (struct proc * caller, message *m_ptr) );
#if ! USE_SDEVIO #if ! USE_SDEVIO
#define do_sdevio do_unused #define do_sdevio do_unused
#endif #endif
_PROTOTYPE( int do_kill, (message *m_ptr) ); _PROTOTYPE( int do_kill, (struct proc * caller, message *m_ptr) );
#if ! USE_KILL #if ! USE_KILL
#define do_kill do_unused #define do_kill do_unused
#endif #endif
_PROTOTYPE( int do_getksig, (message *m_ptr) ); _PROTOTYPE( int do_getksig, (struct proc * caller, message *m_ptr) );
#if ! USE_GETKSIG #if ! USE_GETKSIG
#define do_getksig do_unused #define do_getksig do_unused
#endif #endif
_PROTOTYPE( int do_endksig, (message *m_ptr) ); _PROTOTYPE( int do_endksig, (struct proc * caller, message *m_ptr) );
#if ! USE_ENDKSIG #if ! USE_ENDKSIG
#define do_endksig do_unused #define do_endksig do_unused
#endif #endif
_PROTOTYPE( int do_sigsend, (message *m_ptr) ); _PROTOTYPE( int do_sigsend, (struct proc * caller, message *m_ptr) );
#if ! USE_SIGSEND #if ! USE_SIGSEND
#define do_sigsend do_unused #define do_sigsend do_unused
#endif #endif
_PROTOTYPE( int do_sigreturn, (message *m_ptr) ); _PROTOTYPE( int do_sigreturn, (struct proc * caller, message *m_ptr) );
#if ! USE_SIGRETURN #if ! USE_SIGRETURN
#define do_sigreturn do_unused #define do_sigreturn do_unused
#endif #endif
_PROTOTYPE( int do_times, (message *m_ptr) ); _PROTOTYPE( int do_times, (struct proc * caller, message *m_ptr) );
#if ! USE_TIMES #if ! USE_TIMES
#define do_times do_unused #define do_times do_unused
#endif #endif
_PROTOTYPE( int do_setalarm, (message *m_ptr) ); _PROTOTYPE( int do_setalarm, (struct proc * caller, message *m_ptr) );
#if ! USE_SETALARM #if ! USE_SETALARM
#define do_setalarm do_unused #define do_setalarm do_unused
#endif #endif
_PROTOTYPE( int do_stime, (message *m_ptr) ); _PROTOTYPE( int do_stime, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_vtimer, (message *m_ptr) ); _PROTOTYPE( int do_vtimer, (struct proc * caller, message *m_ptr) );
#if ! USE_VTIMER #if ! USE_VTIMER
#define do_vtimer do_unused #define do_vtimer do_unused
#endif #endif
_PROTOTYPE( int do_safecopy, (message *m_ptr) ); _PROTOTYPE( int do_safecopy, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_vsafecopy, (message *m_ptr) ); _PROTOTYPE( int do_vsafecopy, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_iopenable, (message *m_ptr) ); _PROTOTYPE( int do_iopenable, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_vmctl, (message *m_ptr) ); _PROTOTYPE( int do_vmctl, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_setgrant, (message *m_ptr) ); _PROTOTYPE( int do_setgrant, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_readbios, (message *m_ptr) ); _PROTOTYPE( int do_readbios, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_safemap, (message *m_ptr) ); _PROTOTYPE( int do_safemap, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_saferevmap, (message *m_ptr) ); _PROTOTYPE( int do_saferevmap, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_safeunmap, (message *m_ptr) ); _PROTOTYPE( int do_safeunmap, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_sprofile, (message *m_ptr) ); _PROTOTYPE( int do_sprofile, (struct proc * caller, message *m_ptr) );
#if ! SPROFILE #if ! SPROFILE
#define do_sprofile do_unused #define do_sprofile do_unused
#endif #endif
_PROTOTYPE( int do_cprofile, (message *m_ptr) ); _PROTOTYPE( int do_cprofile, (struct proc * caller, message *m_ptr) );
_PROTOTYPE( int do_profbuf, (message *m_ptr) ); _PROTOTYPE( int do_profbuf, (struct proc * caller, message *m_ptr) );
#endif /* SYSTEM_H */ #endif /* SYSTEM_H */

View file

@ -16,8 +16,7 @@
/*===========================================================================* /*===========================================================================*
* do_abort * * do_abort *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_abort(m_ptr) PUBLIC int do_abort(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_abort. MINIX is unable to continue. This can originate e.g. /* Handle sys_abort. MINIX is unable to continue. This can originate e.g.
* in the PM (normal abort or panic) or TTY (after CTRL-ALT-DEL). * in the PM (normal abort or panic) or TTY (after CTRL-ALT-DEL).
@ -31,7 +30,8 @@ message *m_ptr; /* pointer to request message */
int len; int len;
len = MIN(m_ptr->ABRT_MON_LEN, sizeof(paramsbuffer)-1); len = MIN(m_ptr->ABRT_MON_LEN, sizeof(paramsbuffer)-1);
if((p=data_copy(m_ptr->ABRT_MON_ENDPT, (vir_bytes) m_ptr->ABRT_MON_ADDR, if((p=data_copy(m_ptr->ABRT_MON_ENDPT,
(vir_bytes) m_ptr->ABRT_MON_ADDR,
SYSTEM, (vir_bytes) paramsbuffer, len)) != OK) { SYSTEM, (vir_bytes) paramsbuffer, len)) != OK) {
return p; return p;
} }

View file

@ -19,8 +19,7 @@
/*===========================================================================* /*===========================================================================*
* do_copy * * do_copy *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_copy(m_ptr) PUBLIC int do_copy(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_vircopy() and sys_physcopy(). Copy data using virtual or /* Handle sys_vircopy() and sys_physcopy(). Copy data using virtual or
* physical addressing. Although a single handler function is used, there * physical addressing. Although a single handler function is used, there
@ -86,7 +85,8 @@ register message *m_ptr; /* pointer to request message */
if (bytes != (phys_bytes) (vir_bytes) bytes) return(E2BIG); if (bytes != (phys_bytes) (vir_bytes) bytes) return(E2BIG);
/* Now try to make the actual virtual copy. */ /* Now try to make the actual virtual copy. */
return( virtual_copy_vmcheck(&vir_addr[_SRC_], &vir_addr[_DST_], bytes) ); return( virtual_copy_vmcheck(caller, &vir_addr[_SRC_],
&vir_addr[_DST_], bytes) );
} }
#endif /* (USE_VIRCOPY || USE_PHYSCOPY) */ #endif /* (USE_VIRCOPY || USE_PHYSCOPY) */

View file

@ -19,8 +19,7 @@
/*===========================================================================* /*===========================================================================*
* do_cprofile * * do_cprofile *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_cprofile(m_ptr) PUBLIC int do_cprofile(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
int proc_nr, i; int proc_nr, i;
phys_bytes len; phys_bytes len;

View file

@ -17,11 +17,8 @@
/*===========================================================================* /*===========================================================================*
* do_devio * * do_devio *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_devio( PUBLIC int do_devio(struct proc * caller, message * m_ptr)
register message *m_ptr /* pointer to request message */
)
{ {
struct proc *rp;
struct priv *privp; struct priv *privp;
port_t port; port_t port;
struct io_range *iorp; struct io_range *iorp;
@ -39,8 +36,7 @@ PUBLIC int do_devio(
default: size= 4; break; /* Be conservative */ default: size= 4; break; /* Be conservative */
} }
rp= proc_addr(who_p); privp= priv(caller);
privp= priv(rp);
if (!privp) if (!privp)
{ {
kprintf("no priv structure!\n"); kprintf("no priv structure!\n");

View file

@ -13,8 +13,7 @@
/*===========================================================================* /*===========================================================================*
* do_endksig * * do_endksig *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_endksig(m_ptr) PUBLIC int do_endksig(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Finish up after a kernel type signal, caused by a SYS_KILL message or a /* Finish up after a kernel type signal, caused by a SYS_KILL message or a
* call to cause_sig by a task. This is called by the PM after processing a * call to cause_sig by a task. This is called by the PM after processing a

View file

@ -16,8 +16,7 @@
/*===========================================================================* /*===========================================================================*
* do_exec * * do_exec *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_exec(m_ptr) PUBLIC int do_exec(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */ /* Handle sys_exec(). A process has done a successful EXEC. Patch it up. */
register struct proc *rp; register struct proc *rp;
@ -34,7 +33,7 @@ register message *m_ptr; /* pointer to request message */
} }
/* Save command name for debugging, ps(1) output, etc. */ /* Save command name for debugging, ps(1) output, etc. */
if(data_copy(who_e, (vir_bytes) m_ptr->PR_NAME_PTR, if(data_copy(caller->p_endpoint, (vir_bytes) m_ptr->PR_NAME_PTR,
SYSTEM, (vir_bytes) rp->p_name, (phys_bytes) P_NAME_LEN - 1) != OK) SYSTEM, (vir_bytes) rp->p_name, (phys_bytes) P_NAME_LEN - 1) != OK)
strncpy(rp->p_name, "<unset>", P_NAME_LEN); strncpy(rp->p_name, "<unset>", P_NAME_LEN);

View file

@ -16,8 +16,7 @@ FORWARD _PROTOTYPE( void clear_proc, (register struct proc *rc));
/*===========================================================================* /*===========================================================================*
* do_exit * * do_exit *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_exit(m_ptr) PUBLIC int do_exit(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_exit. A user process has exited or a system process requests /* Handle sys_exit. A user process has exited or a system process requests
* to exit. Only the PM can request other process slots to be cleared. * to exit. Only the PM can request other process slots to be cleared.
@ -28,7 +27,7 @@ message *m_ptr; /* pointer to request message */
int exit_e; int exit_e;
/* Determine what process exited. User processes are handled here. */ /* Determine what process exited. User processes are handled here. */
if (PM_PROC_NR == who_p) { if (PM_PROC_NR == caller->p_endpoint) {
if (m_ptr->PR_ENDPT != SELF) { /* PM tries to exit self */ if (m_ptr->PR_ENDPT != SELF) { /* PM tries to exit self */
if(!isokendpt(m_ptr->PR_ENDPT, &exit_e)) /* get exiting process */ if(!isokendpt(m_ptr->PR_ENDPT, &exit_e)) /* get exiting process */
return EINVAL; return EINVAL;
@ -38,7 +37,7 @@ message *m_ptr; /* pointer to request message */
} }
/* The PM or some other system process requested to be exited. */ /* The PM or some other system process requested to be exited. */
clear_proc(proc_addr(who_p)); clear_proc(caller);
return(EDONTREPLY); return(EDONTREPLY);
} }

View file

@ -20,8 +20,7 @@
/*===========================================================================* /*===========================================================================*
* do_fork * * do_fork *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_fork(m_ptr) PUBLIC int do_fork(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_fork(). PR_ENDPT has forked. The child is PR_SLOT. */ /* Handle sys_fork(). PR_ENDPT has forked. The child is PR_SLOT. */
#if (_MINIX_CHIP == _CHIP_INTEL) #if (_MINIX_CHIP == _CHIP_INTEL)
@ -101,7 +100,7 @@ register message *m_ptr; /* pointer to request message */
m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir; m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir;
/* Install new map */ /* Install new map */
r = newmap(rpc, map_ptr); r = newmap(caller, rpc, map_ptr);
FIXLINMSG(rpc); FIXLINMSG(rpc);
/* Don't schedule process in VM mode until it has a new pagetable. */ /* Don't schedule process in VM mode until it has a new pagetable. */

View file

@ -20,8 +20,7 @@
/*===========================================================================* /*===========================================================================*
* do_getinfo * * do_getinfo *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_getinfo(m_ptr) PUBLIC int do_getinfo(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Request system information to be copied to caller's address space. This /* Request system information to be copied to caller's address space. This
* call simply copies entire data structures to the caller. * call simply copies entire data structures to the caller.
@ -29,12 +28,9 @@ register message *m_ptr; /* pointer to request message */
size_t length; size_t length;
vir_bytes src_vir; vir_bytes src_vir;
int nr_e, nr, r; int nr_e, nr, r;
struct proc *caller;
int wipe_rnd_bin = -1; int wipe_rnd_bin = -1;
struct exec e_hdr; struct exec e_hdr;
caller = proc_addr(who_p);
/* Set source address and length based on request type. */ /* Set source address and length based on request type. */
switch (m_ptr->I_REQUEST) { switch (m_ptr->I_REQUEST) {
case GET_MACHINE: { case GET_MACHINE: {
@ -79,7 +75,7 @@ register message *m_ptr; /* pointer to request message */
} }
case GET_PROC: { case GET_PROC: {
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ? nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
who_e : m_ptr->I_VAL_LEN2_E; caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */ if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
length = sizeof(struct proc); length = sizeof(struct proc);
src_vir = (vir_bytes) proc_addr(nr); src_vir = (vir_bytes) proc_addr(nr);
@ -87,7 +83,7 @@ register message *m_ptr; /* pointer to request message */
} }
case GET_PRIV: { case GET_PRIV: {
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ? nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
who_e : m_ptr->I_VAL_LEN2_E; caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */ if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
length = sizeof(struct priv); length = sizeof(struct priv);
src_vir = (vir_bytes) priv_addr(nr_to_id(nr)); src_vir = (vir_bytes) priv_addr(nr_to_id(nr));
@ -188,7 +184,7 @@ register message *m_ptr; /* pointer to request message */
/* Try to make the actual copy for the requested data. */ /* Try to make the actual copy for the requested data. */
if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG); if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG);
r = data_copy_vmcheck(SYSTEM, src_vir, who_e, r = data_copy_vmcheck(caller, SYSTEM, src_vir, caller->p_endpoint,
(vir_bytes) m_ptr->I_VAL_PTR, length); (vir_bytes) m_ptr->I_VAL_PTR, length);
if(r != OK) return r; if(r != OK) return r;

View file

@ -15,8 +15,7 @@
/*===========================================================================* /*===========================================================================*
* do_getksig * * do_getksig *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_getksig(m_ptr) PUBLIC int do_getksig(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* PM is ready to accept signals and repeatedly does a kernel call to get /* PM is ready to accept signals and repeatedly does a kernel call to get
* one. Find a process with pending signals. If no signals are available, * one. Find a process with pending signals. If no signals are available,

View file

@ -20,8 +20,7 @@ FORWARD _PROTOTYPE(int generic_handler, (irq_hook_t *hook));
/*===========================================================================* /*===========================================================================*
* do_irqctl * * do_irqctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_irqctl(m_ptr) PUBLIC int do_irqctl(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Dismember the request message. */ /* Dismember the request message. */
int irq_vec; int irq_vec;
@ -30,7 +29,6 @@ register message *m_ptr; /* pointer to request message */
int r = OK; int r = OK;
int i; int i;
irq_hook_t *hook_ptr; irq_hook_t *hook_ptr;
struct proc *rp;
struct priv *privp; struct priv *privp;
/* Hook identifiers start at 1 and end at NR_IRQ_HOOKS. */ /* Hook identifiers start at 1 and end at NR_IRQ_HOOKS. */
@ -61,8 +59,7 @@ register message *m_ptr; /* pointer to request message */
/* Check if IRQ line is acceptable. */ /* Check if IRQ line is acceptable. */
if (irq_vec < 0 || irq_vec >= NR_IRQ_VECTORS) return(EINVAL); if (irq_vec < 0 || irq_vec >= NR_IRQ_VECTORS) return(EINVAL);
rp= proc_addr(who_p); privp= priv(caller);
privp= priv(rp);
if (!privp) if (!privp)
{ {
kprintf("do_irqctl: no priv structure!\n"); kprintf("do_irqctl: no priv structure!\n");

View file

@ -14,8 +14,7 @@
/*===========================================================================* /*===========================================================================*
* do_kill * * do_kill *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_kill(m_ptr) PUBLIC int do_kill(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_kill(). Cause a signal to be sent to a process. The PM is the /* Handle sys_kill(). Cause a signal to be sent to a process. The PM is the
* central server where all signals are processed and handler policies can * central server where all signals are processed and handler policies can

View file

@ -14,8 +14,7 @@
/*===========================================================================* /*===========================================================================*
* do_memset * * do_memset *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_memset(m_ptr) PUBLIC int do_memset(struct proc * caller, message * m_ptr)
register message *m_ptr;
{ {
/* Handle sys_memset(). This writes a pattern into the specified memory. */ /* Handle sys_memset(). This writes a pattern into the specified memory. */
unsigned char c = m_ptr->MEM_PATTERN; unsigned char c = m_ptr->MEM_PATTERN;

View file

@ -13,11 +13,10 @@
/*===========================================================================* /*===========================================================================*
* do_newmap * * do_newmap *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_newmap(m_ptr) PUBLIC int do_newmap(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_newmap(). Fetch the memory map. */ /* Handle sys_newmap(). Fetch the memory map. */
register struct proc *rp; /* process whose map is to be loaded */ struct proc *rp; /* process whose map is to be loaded */
struct mem_map *map_ptr; /* virtual address of map inside caller */ struct mem_map *map_ptr; /* virtual address of map inside caller */
int proc_nr; int proc_nr;
@ -26,20 +25,18 @@ message *m_ptr; /* pointer to request message */
if (iskerneln(proc_nr)) return(EPERM); if (iskerneln(proc_nr)) return(EPERM);
rp = proc_addr(proc_nr); rp = proc_addr(proc_nr);
return newmap(rp, map_ptr); return newmap(caller, rp, map_ptr);
} }
/*===========================================================================* /*===========================================================================*
* newmap * * newmap *
*===========================================================================*/ *===========================================================================*/
PUBLIC int newmap(rp, map_ptr) PUBLIC int newmap(struct proc *caller, struct proc *rp, struct mem_map *map_ptr)
struct proc *rp; /* process whose map is to be loaded */
struct mem_map *map_ptr; /* virtual address of map inside caller */
{ {
int r; int r;
/* Fetch the memory map. */ /* Fetch the memory map. */
if((r=data_copy(who_e, (vir_bytes) map_ptr, if((r=data_copy(caller->p_endpoint, (vir_bytes) map_ptr,
SYSTEM, (vir_bytes) rp->p_memmap, sizeof(rp->p_memmap))) != OK) { SYSTEM, (vir_bytes) rp->p_memmap, sizeof(rp->p_memmap))) != OK) {
kprintf("newmap: data_copy failed! (%d)\n", r); kprintf("newmap: data_copy failed! (%d)\n", r);
return r; return r;

View file

@ -14,7 +14,7 @@
/*===========================================================================* /*===========================================================================*
* do_nice * * do_nice *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_nice(message *m_ptr) PUBLIC int do_nice(struct proc * caller, message * m_ptr)
{ {
/* Change process priority or stop the process. */ /* Change process priority or stop the process. */
int proc_nr, pri, new_q ; int proc_nr, pri, new_q ;

View file

@ -11,20 +11,19 @@
#include "../ipc.h" #include "../ipc.h"
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <minix/endpoint.h>
#if USE_PRIVCTL #if USE_PRIVCTL
/*===========================================================================* /*===========================================================================*
* do_privctl * * do_privctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_privctl(m_ptr) PUBLIC int do_privctl(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_privctl(). Update a process' privileges. If the process is not /* Handle sys_privctl(). Update a process' privileges. If the process is not
* yet a system process, make sure it gets its own privilege structure. * yet a system process, make sure it gets its own privilege structure.
*/ */
register struct proc *caller_ptr; struct proc *rp;
register struct proc *rp;
int proc_nr; int proc_nr;
int priv_id; int priv_id;
int ipc_to_m, kcalls; int ipc_to_m, kcalls;
@ -39,9 +38,8 @@ message *m_ptr; /* pointer to request message */
* running by the RTS_NO_PRIV flag. This flag is set when a privileged process * running by the RTS_NO_PRIV flag. This flag is set when a privileged process
* forks. * forks.
*/ */
caller_ptr = proc_addr(who_p); if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM);
if (! (priv(caller_ptr)->s_flags & SYS_PROC)) return(EPERM); if(m_ptr->CTL_ENDPT == SELF) proc_nr = _ENDPOINT_P(caller->p_endpoint);
if(m_ptr->CTL_ENDPT == SELF) proc_nr = who_p;
else if(!isokendpt(m_ptr->CTL_ENDPT, &proc_nr)) return(EINVAL); else if(!isokendpt(m_ptr->CTL_ENDPT, &proc_nr)) return(EINVAL);
rp = proc_addr(proc_nr); rp = proc_addr(proc_nr);
@ -72,7 +70,7 @@ message *m_ptr; /* pointer to request message */
if (m_ptr->CTL_ARG_PTR) if (m_ptr->CTL_ARG_PTR)
{ {
/* Copy privilege structure from caller */ /* Copy privilege structure from caller */
if((r=data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR, if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &priv, sizeof(priv))) != OK) SYSTEM, (vir_bytes) &priv, sizeof(priv))) != OK)
return r; return r;
@ -93,7 +91,7 @@ message *m_ptr; /* pointer to request message */
return(i); return(i);
} }
priv_id = priv(rp)->s_id; /* backup privilege id */ priv_id = priv(rp)->s_id; /* backup privilege id */
*priv(rp) = *priv(caller_ptr); /* copy from caller */ *priv(rp) = *priv(caller); /* copy from caller */
priv(rp)->s_id = priv_id; /* restore privilege id */ priv(rp)->s_id = priv_id; /* restore privilege id */
priv(rp)->s_proc_nr = proc_nr; /* reassociate process nr */ priv(rp)->s_proc_nr = proc_nr; /* reassociate process nr */
@ -227,7 +225,7 @@ message *m_ptr; /* pointer to request message */
#endif #endif
/* Get the I/O range */ /* Get the I/O range */
data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR, data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &io_range, sizeof(io_range)); SYSTEM, (vir_bytes) &io_range, sizeof(io_range));
priv(rp)->s_flags |= CHECK_IO_PORT; /* Check I/O accesses */ priv(rp)->s_flags |= CHECK_IO_PORT; /* Check I/O accesses */
i= priv(rp)->s_nr_io_range; i= priv(rp)->s_nr_io_range;
@ -249,7 +247,7 @@ message *m_ptr; /* pointer to request message */
return EPERM; return EPERM;
/* Get the memory range */ /* Get the memory range */
if((r=data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR, if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &mem_range, sizeof(mem_range))) != OK) SYSTEM, (vir_bytes) &mem_range, sizeof(mem_range))) != OK)
return r; return r;
priv(rp)->s_flags |= CHECK_MEM; /* Check memory mappings */ priv(rp)->s_flags |= CHECK_MEM; /* Check memory mappings */
@ -271,7 +269,7 @@ message *m_ptr; /* pointer to request message */
if (!(priv(rp)->s_flags & SYS_PROC)) if (!(priv(rp)->s_flags & SYS_PROC))
return EPERM; return EPERM;
data_copy(who_e, (vir_bytes) m_ptr->CTL_ARG_PTR, data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR,
SYSTEM, (vir_bytes) &irq, sizeof(irq)); SYSTEM, (vir_bytes) &irq, sizeof(irq));
priv(rp)->s_flags |= CHECK_IRQ; /* Check IRQs */ priv(rp)->s_flags |= CHECK_IRQ; /* Check IRQs */

View file

@ -14,8 +14,7 @@
/*===========================================================================* /*===========================================================================*
* do_profbuf * * do_profbuf *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_profbuf(m_ptr) PUBLIC int do_profbuf(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* This kernel call is used by profiled system processes when Call /* This kernel call is used by profiled system processes when Call
* Profiling is enabled. It is called on the first execution of procentry. * Profiling is enabled. It is called on the first execution of procentry.
@ -35,7 +34,7 @@ register message *m_ptr; /* pointer to request message */
rp = proc_addr(proc_nr); rp = proc_addr(proc_nr);
cprof_proc_info[cprof_procs_no].endpt = who_e; cprof_proc_info[cprof_procs_no].endpt = caller->p_endpoint;
cprof_proc_info[cprof_procs_no].name = rp->p_name; cprof_proc_info[cprof_procs_no].name = rp->p_name;
cprof_proc_info[cprof_procs_no].ctl_v = (vir_bytes) m_ptr->PROF_CTL_PTR; cprof_proc_info[cprof_procs_no].ctl_v = (vir_bytes) m_ptr->PROF_CTL_PTR;

View file

@ -14,7 +14,7 @@
/*===========================================================================* /*===========================================================================*
* do_runctl * * do_runctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_runctl(message *m_ptr) PUBLIC int do_runctl(struct proc * caller, message * m_ptr)
{ {
/* Control a process's RTS_PROC_STOP flag. Used for process management. /* Control a process's RTS_PROC_STOP flag. Used for process management.
* If the process is queued sending a message or stopped for system call * If the process is queued sending a message or stopped for system call

View file

@ -25,7 +25,8 @@
#define USE_COW_SAFECOPY 0 #define USE_COW_SAFECOPY 0
FORWARD _PROTOTYPE(int safecopy, (endpoint_t, endpoint_t, cp_grant_id_t, int, int, size_t, vir_bytes, vir_bytes, int)); FORWARD _PROTOTYPE(int safecopy, (struct proc *, endpoint_t, endpoint_t,
cp_grant_id_t, int, int, size_t, vir_bytes, vir_bytes, int));
#define HASGRANTTABLE(gr) \ #define HASGRANTTABLE(gr) \
(!RTS_ISSET(gr, RTS_NO_PRIV) && priv(gr) && priv(gr)->s_grant_table > 0) (!RTS_ISSET(gr, RTS_NO_PRIV) && priv(gr) && priv(gr)->s_grant_table > 0)
@ -217,8 +218,9 @@ endpoint_t *e_granter; /* new granter (magic grants) */
/*===========================================================================* /*===========================================================================*
* safecopy * * safecopy *
*===========================================================================*/ *===========================================================================*/
PRIVATE int safecopy(granter, grantee, grantid, src_seg, dst_seg, bytes, PRIVATE int safecopy(caller, granter, grantee, grantid, src_seg, dst_seg, bytes,
g_offset, addr, access) g_offset, addr, access)
struct proc * caller;
endpoint_t granter, grantee; endpoint_t granter, grantee;
cp_grant_id_t grantid; cp_grant_id_t grantid;
int src_seg, dst_seg; int src_seg, dst_seg;
@ -232,8 +234,10 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE
static vir_bytes v_offset; static vir_bytes v_offset;
endpoint_t new_granter, *src, *dst; endpoint_t new_granter, *src, *dst;
struct proc *granter_p; struct proc *granter_p;
vir_bytes size;
int r; int r;
#if USE_COW_SAFECOPY
vir_bytes size;
#endif
/* See if there is a reasonable grant table. */ /* See if there is a reasonable grant table. */
if(!(granter_p = endpoint_lookup(granter))) return EINVAL; if(!(granter_p = endpoint_lookup(granter))) return EINVAL;
@ -286,13 +290,13 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE
/* Give up on COW immediately when offsets are not aligned /* Give up on COW immediately when offsets are not aligned
* or we are copying less than a page. * or we are copying less than a page.
*/ */
return virtual_copy_vmcheck(&v_src, &v_dst, bytes); return virtual_copy_vmcheck(caller, &v_src, &v_dst, bytes);
} }
if((size = v_offset % CLICK_SIZE) != 0) { if((size = v_offset % CLICK_SIZE) != 0) {
/* Normal copy for everything before the first page boundary. */ /* Normal copy for everything before the first page boundary. */
size = CLICK_SIZE - size; size = CLICK_SIZE - size;
r = virtual_copy_vmcheck(&v_src, &v_dst, size); r = virtual_copy_vmcheck(caller, &v_src, &v_dst, size);
if(r != OK) if(r != OK)
return r; return r;
v_src.offset += size; v_src.offset += size;
@ -314,22 +318,21 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE
} }
if(bytes != 0) { if(bytes != 0) {
/* Normal copy for everything after the last page boundary. */ /* Normal copy for everything after the last page boundary. */
r = virtual_copy_vmcheck(&v_src, &v_dst, bytes); r = virtual_copy_vmcheck(caller, &v_src, &v_dst, bytes);
if(r != OK) if(r != OK)
return r; return r;
} }
return OK; return OK;
#else #else
return virtual_copy_vmcheck(&v_src, &v_dst, bytes); return virtual_copy_vmcheck(caller, &v_src, &v_dst, bytes);
#endif #endif
} }
/*===========================================================================* /*===========================================================================*
* do_safecopy * * do_safecopy *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_safecopy(m_ptr) PUBLIC int do_safecopy(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
static int access, src_seg, dst_seg; static int access, src_seg, dst_seg;
@ -344,16 +347,15 @@ register message *m_ptr; /* pointer to request message */
access = CPF_WRITE; access = CPF_WRITE;
} else minix_panic("Impossible system call nr. ", sys_call_code); } else minix_panic("Impossible system call nr. ", sys_call_code);
return safecopy(m_ptr->SCP_FROM_TO, who_e, m_ptr->SCP_GID, return safecopy(caller, m_ptr->SCP_FROM_TO, caller->p_endpoint,
src_seg, dst_seg, m_ptr->SCP_BYTES, m_ptr->SCP_OFFSET, m_ptr->SCP_GID, src_seg, dst_seg, m_ptr->SCP_BYTES,
(vir_bytes) m_ptr->SCP_ADDRESS, access); m_ptr->SCP_OFFSET, (vir_bytes) m_ptr->SCP_ADDRESS, access);
} }
/*===========================================================================* /*===========================================================================*
* do_vsafecopy * * do_vsafecopy *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_vsafecopy(m_ptr) PUBLIC int do_vsafecopy(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
static struct vscp_vec vec[SCPVEC_NR]; static struct vscp_vec vec[SCPVEC_NR];
static struct vir_addr src, dst; static struct vir_addr src, dst;
@ -361,7 +363,7 @@ register message *m_ptr; /* pointer to request message */
size_t bytes; size_t bytes;
/* Set vector copy parameters. */ /* Set vector copy parameters. */
src.proc_nr_e = who_e; src.proc_nr_e = caller->p_endpoint;
src.offset = (vir_bytes) m_ptr->VSCP_VEC_ADDR; src.offset = (vir_bytes) m_ptr->VSCP_VEC_ADDR;
src.segment = dst.segment = D; src.segment = dst.segment = D;
dst.proc_nr_e = SYSTEM; dst.proc_nr_e = SYSTEM;
@ -372,7 +374,7 @@ register message *m_ptr; /* pointer to request message */
bytes = els * sizeof(struct vscp_vec); bytes = els * sizeof(struct vscp_vec);
/* Obtain vector of copies. */ /* Obtain vector of copies. */
if((r=virtual_copy_vmcheck(&src, &dst, bytes)) != OK) if((r=virtual_copy_vmcheck(caller, &src, &dst, bytes)) != OK)
return r; return r;
/* Perform safecopies. */ /* Perform safecopies. */
@ -387,12 +389,13 @@ register message *m_ptr; /* pointer to request message */
granter = vec[i].v_from; granter = vec[i].v_from;
} else { } else {
kprintf("vsafecopy: %d: element %d/%d: no SELF found\n", kprintf("vsafecopy: %d: element %d/%d: no SELF found\n",
who_e, i, els); caller->p_endpoint, i, els);
return EINVAL; return EINVAL;
} }
/* Do safecopy for this element. */ /* Do safecopy for this element. */
if((r=safecopy(granter, who_e, vec[i].v_gid, D, D, if((r=safecopy(caller, granter, caller->p_endpoint,
vec[i].v_gid, D, D,
vec[i].v_bytes, vec[i].v_offset, vec[i].v_bytes, vec[i].v_offset,
vec[i].v_addr, access)) != OK) { vec[i].v_addr, access)) != OK) {
return r; return r;

View file

@ -115,17 +115,17 @@ static int clear_info(struct map_info_s *p)
/*===========================================================================* /*===========================================================================*
* map_invoke_vm * * map_invoke_vm *
*===========================================================================*/ *===========================================================================*/
PUBLIC int map_invoke_vm(int req_type, /* VMPTYPE_... COWMAP, SMAP, SUNMAP */ PUBLIC 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_d, int seg_d, vir_bytes off_d,
endpoint_t end_s, int seg_s, vir_bytes off_s, endpoint_t end_s, int seg_s, vir_bytes off_s,
size_t size, int flag) size_t size, int flag)
{ {
struct proc *caller, *src, *dst; struct proc *src, *dst;
phys_bytes lin_src, lin_dst; phys_bytes lin_src, lin_dst;
src = endpoint_lookup(end_s); src = endpoint_lookup(end_s);
dst = endpoint_lookup(end_d); dst = endpoint_lookup(end_d);
caller = endpoint_lookup(who_e);
lin_src = umap_local(src, seg_s, off_s, size); lin_src = umap_local(src, seg_s, off_s, size);
lin_dst = umap_local(dst, seg_d, off_d, size); lin_dst = umap_local(dst, seg_d, off_d, size);
@ -170,8 +170,7 @@ PUBLIC int map_invoke_vm(int req_type, /* VMPTYPE_... COWMAP, SMAP, SUNMAP */
/*===========================================================================* /*===========================================================================*
* do_safemap * * do_safemap *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_safemap(m_ptr) PUBLIC int do_safemap(struct proc * caller, message * m_ptr)
register message *m_ptr;
{ {
endpoint_t grantor = m_ptr->SMAP_EP; endpoint_t grantor = m_ptr->SMAP_EP;
cp_grant_id_t gid = m_ptr->SMAP_GID; cp_grant_id_t gid = m_ptr->SMAP_GID;
@ -199,42 +198,42 @@ register message *m_ptr;
*/ */
if(flag != 0) if(flag != 0)
access |= CPF_WRITE; access |= CPF_WRITE;
r = verify_grant(grantor, who_e, gid, bytes, access, r = verify_grant(grantor, caller->p_endpoint, gid, bytes, access,
offset, &offset_result, &new_grantor); offset, &offset_result, &new_grantor);
if(r != OK) { if(r != OK) {
kprintf("verify_grant for gid %d from %d to %d failed: %d\n", kprintf("verify_grant for gid %d from %d to %d failed: %d\n",
gid, grantor, who_e, r); gid, grantor, caller->p_endpoint, r);
return r; return r;
} }
/* Add map info. */ /* Add map info. */
r = add_info(new_grantor, who_e, gid, offset, offset_result, seg, r = add_info(new_grantor, caller->p_endpoint, gid, offset,
address, bytes); offset_result, seg, address, bytes);
if(r != OK) if(r != OK)
return r; return r;
/* Invoke VM. */ /* Invoke VM. */
return map_invoke_vm(VMPTYPE_SMAP, return map_invoke_vm(caller, VMPTYPE_SMAP,
who_e, seg, address, new_grantor, D, offset_result, bytes,flag); caller->p_endpoint, seg, address, new_grantor, D, offset_result, bytes,flag);
} }
/*===========================================================================* /*===========================================================================*
* safeunmap * * safeunmap *
*===========================================================================*/ *===========================================================================*/
PRIVATE int safeunmap(struct map_info_s *p) PRIVATE int safeunmap(struct proc * caller, struct map_info_s *p)
{ {
vir_bytes offset_result; vir_bytes offset_result;
endpoint_t new_grantor; endpoint_t new_grantor;
int r; int r;
r = verify_grant(p->grantor, p->grantee, p->gid, p->bytes, CPF_MAP, r = verify_grant(p->grantor, p->grantee, p->gid, p->bytes,
p->offset, &offset_result, &new_grantor); CPF_MAP, p->offset, &offset_result, &new_grantor);
if(r != OK) { if(r != OK) {
kprintf("safeunmap: error in verify_grant.\n"); kprintf("safeunmap: error in verify_grant.\n");
return r; return r;
} }
r = map_invoke_vm(VMPTYPE_SUNMAP, r = map_invoke_vm(caller, VMPTYPE_SUNMAP,
p->grantee, p->seg, p->address, p->grantee, p->seg, p->address,
new_grantor, D, offset_result, new_grantor, D, offset_result,
p->bytes, 0); p->bytes, 0);
@ -249,16 +248,15 @@ PRIVATE int safeunmap(struct map_info_s *p)
/*===========================================================================* /*===========================================================================*
* do_saferevmap * * do_saferevmap *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_saferevmap(m_ptr) PUBLIC int do_saferevmap(struct proc * caller, message * m_ptr)
register message *m_ptr;
{ {
struct map_info_s *p; struct map_info_s *p;
int flag = m_ptr->SMAP_FLAG; int flag = m_ptr->SMAP_FLAG;
int arg = m_ptr->SMAP_GID; /* gid or address_Dseg */ int arg = m_ptr->SMAP_GID; /* gid or address_Dseg */
int r; int r;
while((p = get_revoke_info(who_e, flag, arg)) != NULL) { while((p = get_revoke_info(caller->p_endpoint, flag, arg)) != NULL) {
if((r = safeunmap(p)) != OK) if((r = safeunmap(caller, p)) != OK)
return r; return r;
} }
return OK; return OK;
@ -267,16 +265,15 @@ register message *m_ptr;
/*===========================================================================* /*===========================================================================*
* do_safeunmap * * do_safeunmap *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_safeunmap(m_ptr) PUBLIC int do_safeunmap(struct proc * caller, message * m_ptr)
register message *m_ptr;
{ {
vir_bytes address = m_ptr->SMAP_ADDRESS; vir_bytes address = m_ptr->SMAP_ADDRESS;
int seg = (int)m_ptr->SMAP_SEG; int seg = (int)m_ptr->SMAP_SEG;
struct map_info_s *p; struct map_info_s *p;
int r; int r;
while((p = get_unmap_info(who_e, seg, address)) != NULL) { while((p = get_unmap_info(caller->p_endpoint, seg, address)) != NULL) {
if((r = safeunmap(p)) != OK) if((r = safeunmap(caller, p)) != OK)
return r; return r;
} }
return OK; return OK;

View file

@ -15,8 +15,7 @@
/*===========================================================================* /*===========================================================================*
* do_segctl * * do_segctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_segctl(m_ptr) PUBLIC int do_segctl(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Return a segment selector and offset that can be used to reach a physical /* Return a segment selector and offset that can be used to reach a physical
* address, for use by a driver doing memory I/O in the A0000 - DFFFF range. * address, for use by a driver doing memory I/O in the A0000 - DFFFF range.
@ -24,26 +23,24 @@ register message *m_ptr; /* pointer to request message */
u32_t selector; u32_t selector;
vir_bytes offset; vir_bytes offset;
int i, index; int i, index;
register struct proc *rp;
phys_bytes phys = (phys_bytes) m_ptr->SEG_PHYS; phys_bytes phys = (phys_bytes) m_ptr->SEG_PHYS;
vir_bytes size = (vir_bytes) m_ptr->SEG_SIZE; vir_bytes size = (vir_bytes) m_ptr->SEG_SIZE;
int result; int result;
/* First check if there is a slot available for this segment. */ /* First check if there is a slot available for this segment. */
rp = proc_addr(who_p);
index = -1; index = -1;
for (i=0; i < NR_REMOTE_SEGS; i++) { for (i=0; i < NR_REMOTE_SEGS; i++) {
if (! rp->p_priv->s_farmem[i].in_use) { if (! caller->p_priv->s_farmem[i].in_use) {
index = i; index = i;
rp->p_priv->s_farmem[i].in_use = TRUE; caller->p_priv->s_farmem[i].in_use = TRUE;
rp->p_priv->s_farmem[i].mem_phys = phys; caller->p_priv->s_farmem[i].mem_phys = phys;
rp->p_priv->s_farmem[i].mem_len = size; caller->p_priv->s_farmem[i].mem_len = size;
break; break;
} }
} }
if (index < 0) return(ENOSPC); if (index < 0) return(ENOSPC);
offset = alloc_remote_segment(&selector, &rp->p_seg, offset = alloc_remote_segment(&selector, &caller->p_seg,
i, phys, size, USER_PRIVILEGE); i, phys, size, USER_PRIVILEGE);
result = OK; result = OK;

View file

@ -18,11 +18,9 @@ FORWARD _PROTOTYPE( void cause_alarm, (timer_t *tp) );
/*===========================================================================* /*===========================================================================*
* do_setalarm * * do_setalarm *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_setalarm(m_ptr) PUBLIC int do_setalarm(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* A process requests a synchronous alarm, or wants to cancel its alarm. */ /* A process requests a synchronous alarm, or wants to cancel its alarm. */
register struct proc *rp; /* pointer to requesting process */
long exp_time; /* expiration time for this alarm */ long exp_time; /* expiration time for this alarm */
int use_abs_time; /* use absolute or relative time */ int use_abs_time; /* use absolute or relative time */
timer_t *tp; /* the process' timer structure */ timer_t *tp; /* the process' timer structure */
@ -31,11 +29,10 @@ message *m_ptr; /* pointer to request message */
/* Extract shared parameters from the request message. */ /* Extract shared parameters from the request message. */
exp_time = m_ptr->ALRM_EXP_TIME; /* alarm's expiration time */ exp_time = m_ptr->ALRM_EXP_TIME; /* alarm's expiration time */
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */ use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */
rp = proc_addr(who_p); if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM);
if (! (priv(rp)->s_flags & SYS_PROC)) return(EPERM);
/* Get the timer structure and set the parameters for this alarm. */ /* Get the timer structure and set the parameters for this alarm. */
tp = &(priv(rp)->s_alarm_timer); tp = &(priv(caller)->s_alarm_timer);
tmr_arg(tp)->ta_int = m_ptr->m_source; tmr_arg(tp)->ta_int = m_ptr->m_source;
tp->tmr_func = cause_alarm; tp->tmr_func = cause_alarm;

View file

@ -12,20 +12,15 @@
/*===========================================================================* /*===========================================================================*
* do_setgrant * * do_setgrant *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_setgrant(m_ptr) PUBLIC int do_setgrant(struct proc * caller, message * m_ptr)
message *m_ptr;
{ {
struct proc *rp;
int r; int r;
/* Who wants to set a parameter? */
rp = proc_addr(who_p);
/* Copy grant table set in priv. struct. */ /* Copy grant table set in priv. struct. */
if (RTS_ISSET(rp, RTS_NO_PRIV) || !(priv(rp))) { if (RTS_ISSET(caller, RTS_NO_PRIV) || !(priv(caller))) {
r = EPERM; r = EPERM;
} else { } else {
_K_SET_GRANT_TABLE(rp, _K_SET_GRANT_TABLE(caller,
(vir_bytes) m_ptr->SG_ADDR, (vir_bytes) m_ptr->SG_ADDR,
m_ptr->SG_SIZE); m_ptr->SG_SIZE);
r = OK; r = OK;

View file

@ -17,8 +17,7 @@
/*===========================================================================* /*===========================================================================*
* do_sigreturn * * do_sigreturn *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_sigreturn(m_ptr) PUBLIC int do_sigreturn(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* POSIX style signals require sys_sigreturn to put things in order before /* POSIX style signals require sys_sigreturn to put things in order before
* the signalled process can resume execution * the signalled process can resume execution

View file

@ -18,8 +18,7 @@
/*===========================================================================* /*===========================================================================*
* do_sigsend * * do_sigsend *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_sigsend(m_ptr) PUBLIC int do_sigsend(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_sigsend, POSIX-style signal handling. */ /* Handle sys_sigsend, POSIX-style signal handling. */
@ -37,8 +36,9 @@ message *m_ptr; /* pointer to request message */
rp = proc_addr(proc_nr); rp = proc_addr(proc_nr);
/* Get the sigmsg structure into our address space. */ /* Get the sigmsg structure into our address space. */
if((r=data_copy_vmcheck(who_e, (vir_bytes) m_ptr->SIG_CTXT_PTR, if((r=data_copy_vmcheck(caller, caller->p_endpoint,
SYSTEM, (vir_bytes) &smsg, (phys_bytes) sizeof(struct sigmsg))) != OK) (vir_bytes) m_ptr->SIG_CTXT_PTR, SYSTEM, (vir_bytes) &smsg,
(phys_bytes) sizeof(struct sigmsg))) != OK)
return r; return r;
/* Compute the user stack pointer where sigcontext will be stored. */ /* Compute the user stack pointer where sigcontext will be stored. */
@ -57,7 +57,7 @@ message *m_ptr; /* pointer to request message */
sc.sc_flags = 0 | rp->p_misc_flags & MF_FPU_INITIALIZED; sc.sc_flags = 0 | rp->p_misc_flags & MF_FPU_INITIALIZED;
/* Copy the sigcontext structure to the user's stack. */ /* Copy the sigcontext structure to the user's stack. */
if((r=data_copy_vmcheck(SYSTEM, (vir_bytes) &sc, m_ptr->SIG_ENDPT, if((r=data_copy_vmcheck(caller, SYSTEM, (vir_bytes) &sc, m_ptr->SIG_ENDPT,
(vir_bytes) scp, (vir_bytes) sizeof(struct sigcontext))) != OK) (vir_bytes) scp, (vir_bytes) sizeof(struct sigcontext))) != OK)
return r; return r;
@ -106,7 +106,7 @@ message *m_ptr; /* pointer to request message */
fr.sf_retadr = (void (*)()) smsg.sm_sigreturn; fr.sf_retadr = (void (*)()) smsg.sm_sigreturn;
/* Copy the sigframe structure to the user's stack. */ /* Copy the sigframe structure to the user's stack. */
if((r=data_copy_vmcheck(SYSTEM, (vir_bytes) &fr, if((r=data_copy_vmcheck(caller, SYSTEM, (vir_bytes) &fr,
m_ptr->SIG_ENDPT, (vir_bytes) frp, m_ptr->SIG_ENDPT, (vir_bytes) frp,
(vir_bytes) sizeof(struct sigframe))) != OK) (vir_bytes) sizeof(struct sigframe))) != OK)
return r; return r;
@ -119,8 +119,6 @@ message *m_ptr; /* pointer to request message */
rp->p_misc_flags &= ~MF_FPU_INITIALIZED; rp->p_misc_flags &= ~MF_FPU_INITIALIZED;
if(!RTS_ISSET(rp, RTS_PROC_STOP)) { if(!RTS_ISSET(rp, RTS_PROC_STOP)) {
struct proc *caller;
caller = proc_addr(who_p);
kprintf("system: warning: sigsend a running process\n"); kprintf("system: warning: sigsend a running process\n");
kprintf("caller stack: "); kprintf("caller stack: ");
proc_stacktrace(caller); proc_stacktrace(caller);

View file

@ -23,8 +23,7 @@ PRIVATE vir_bytes sprof_info_addr_vir;
/*===========================================================================* /*===========================================================================*
* do_sprofile * * do_sprofile *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_sprofile(m_ptr) PUBLIC int do_sprofile(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
int proc_nr; int proc_nr;

View file

@ -12,8 +12,7 @@
/*===========================================================================* /*===========================================================================*
* do_stime * * do_stime *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_stime(m_ptr) PUBLIC int do_stime(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
boottime= m_ptr->T_BOOTTIME; boottime= m_ptr->T_BOOTTIME;
return(OK); return(OK);

View file

@ -12,16 +12,12 @@
/*===========================================================================* /*===========================================================================*
* do_sysctl * * do_sysctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_sysctl(m_ptr) PUBLIC int do_sysctl(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
vir_bytes len, buf; vir_bytes len, buf;
static char mybuf[DIAG_BUFSIZE]; static char mybuf[DIAG_BUFSIZE];
struct proc *caller;
int s, i, proc_nr; int s, i, proc_nr;
caller = proc_addr(who_p);
switch (m_ptr->SYSCTL_CODE) { switch (m_ptr->SYSCTL_CODE) {
case SYSCTL_CODE_DIAG: case SYSCTL_CODE_DIAG:
buf = (vir_bytes) m_ptr->SYSCTL_ARG1; buf = (vir_bytes) m_ptr->SYSCTL_ARG1;
@ -31,7 +27,8 @@ register message *m_ptr; /* pointer to request message */
caller->p_endpoint, len); caller->p_endpoint, len);
return EINVAL; return EINVAL;
} }
if((s=data_copy_vmcheck(who_e, buf, SYSTEM, (vir_bytes) mybuf, len)) != OK) { if((s=data_copy_vmcheck(caller, caller->p_endpoint, buf, SYSTEM,
(vir_bytes) mybuf, len)) != OK) {
kprintf("do_sysctl: diag for %d: len %d: copy failed: %d\n", kprintf("do_sysctl: diag for %d: len %d: copy failed: %d\n",
caller->p_endpoint, len, s); caller->p_endpoint, len, s);
return s; return s;

View file

@ -18,8 +18,7 @@
/*===========================================================================* /*===========================================================================*
* do_times * * do_times *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_times(m_ptr) PUBLIC int do_times(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Handle sys_times(). Retrieve the accounting information. */ /* Handle sys_times(). Retrieve the accounting information. */
register struct proc *rp; register struct proc *rp;

View file

@ -16,8 +16,7 @@
/*==========================================================================* /*==========================================================================*
* do_trace * * do_trace *
*==========================================================================*/ *==========================================================================*/
PUBLIC int do_trace(m_ptr) PUBLIC int do_trace(struct proc * caller, message * m_ptr)
register message *m_ptr;
{ {
/* Handle the debugging commands supported by the ptrace system call /* Handle the debugging commands supported by the ptrace system call
* The commands are: * The commands are:
@ -61,7 +60,8 @@ register message *m_ptr;
toaddr.offset = (addr); \ toaddr.offset = (addr); \
fromaddr.segment = D; \ fromaddr.segment = D; \
toaddr.segment = (seg); \ toaddr.segment = (seg); \
if((r=virtual_copy_vmcheck(&fromaddr, &toaddr, length)) != OK) { \ if((r=virtual_copy_vmcheck(caller, &fromaddr, \
&toaddr, length)) != OK) { \
printf("Can't copy in sys_trace: %d\n", r);\ printf("Can't copy in sys_trace: %d\n", r);\
return r;\ return r;\
} \ } \
@ -76,7 +76,8 @@ register message *m_ptr;
toaddr.offset = (myaddr); \ toaddr.offset = (myaddr); \
fromaddr.segment = (seg); \ fromaddr.segment = (seg); \
toaddr.segment = D; \ toaddr.segment = D; \
if((r=virtual_copy_vmcheck(&fromaddr, &toaddr, length)) != OK) { \ if((r=virtual_copy_vmcheck(caller, &fromaddr, \
&toaddr, length)) != OK) { \
printf("Can't copy in sys_trace: %d\n", r);\ printf("Can't copy in sys_trace: %d\n", r);\
return r;\ return r;\
} \ } \

View file

@ -11,13 +11,14 @@
#include "../system.h" #include "../system.h"
#include <minix/endpoint.h>
#if USE_UMAP #if USE_UMAP
/*==========================================================================* /*==========================================================================*
* do_umap * * do_umap *
*==========================================================================*/ *==========================================================================*/
PUBLIC int do_umap(m_ptr) PUBLIC int do_umap(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Map virtual address to physical, for non-kernel processes. */ /* Map virtual address to physical, for non-kernel processes. */
int seg_type = m_ptr->CP_SRC_SPACE & SEGMENT_TYPE; int seg_type = m_ptr->CP_SRC_SPACE & SEGMENT_TYPE;
@ -28,20 +29,16 @@ register message *m_ptr; /* pointer to request message */
int proc_nr, r; int proc_nr, r;
int naughty = 0; int naughty = 0;
phys_bytes phys_addr = 0, lin_addr = 0; phys_bytes phys_addr = 0, lin_addr = 0;
int caller_pn; struct proc *targetpr;
struct proc *targetpr, *caller;
/* Verify process number. */ /* Verify process number. */
if (endpt == SELF) if (endpt == SELF)
proc_nr = who_p; proc_nr = _ENDPOINT_P(caller->p_endpoint);
else else
if (! isokendpt(endpt, &proc_nr)) if (! isokendpt(endpt, &proc_nr))
return(EINVAL); return(EINVAL);
targetpr = proc_addr(proc_nr); targetpr = proc_addr(proc_nr);
okendpt(who_e, &caller_pn);
caller = proc_addr(caller_pn);
/* See which mapping should be made. */ /* See which mapping should be made. */
switch(seg_type) { switch(seg_type) {
case LOCAL_SEG: case LOCAL_SEG:
@ -110,7 +107,8 @@ register message *m_ptr; /* pointer to request message */
m_ptr->CP_DST_ADDR = phys_addr; m_ptr->CP_DST_ADDR = phys_addr;
if(naughty || phys_addr == 0) { if(naughty || phys_addr == 0) {
kprintf("kernel: umap 0x%x done by %d / %s, pc 0x%lx, 0x%lx -> 0x%lx\n", kprintf("kernel: umap 0x%x done by %d / %s, pc 0x%lx, 0x%lx -> 0x%lx\n",
seg_type, who_e, caller->p_name, caller->p_reg.pc, offset, phys_addr); seg_type, caller->p_endpoint, caller->p_name,
caller->p_reg.pc, offset, phys_addr);
kprintf("caller stack: "); kprintf("caller stack: ");
proc_stacktrace(caller); proc_stacktrace(caller);
} }

View file

@ -7,10 +7,10 @@
/*===========================================================================* /*===========================================================================*
* do_unused * * do_unused *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_unused(m) PUBLIC int do_unused(struct proc * caller, message * m_ptr)
message *m; /* pointer to request message */
{ {
kprintf("SYSTEM: got unused request %d from %d\n", m->m_type, m->m_source); kprintf("SYSTEM: got unused request %d from %d\n",
m_ptr->m_type, m_ptr->m_source);
return(EBADREQUEST); /* illegal message type */ return(EBADREQUEST); /* illegal message type */
} }

View file

@ -23,8 +23,7 @@ PRIVATE pvl_pair_t *pvl = (pvl_pair_t *) vdevio_buf;
/*===========================================================================* /*===========================================================================*
* do_vdevio * * do_vdevio *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_vdevio(m_ptr) PUBLIC int do_vdevio(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
/* Perform a series of device I/O on behalf of a non-kernel process. The /* Perform a series of device I/O on behalf of a non-kernel process. The
* I/O addresses and I/O values are fetched from and returned to some buffer * I/O addresses and I/O values are fetched from and returned to some buffer
@ -38,7 +37,6 @@ register message *m_ptr; /* pointer to request message */
port_t port; port_t port;
int i, j, io_size, nr_io_range; int i, j, io_size, nr_io_range;
int io_dir, io_type; int io_dir, io_type;
struct proc *rp;
struct priv *privp; struct priv *privp;
struct io_range *iorp; struct io_range *iorp;
int r; int r;
@ -68,12 +66,11 @@ register message *m_ptr; /* pointer to request message */
if (bytes > sizeof(vdevio_buf)) return(E2BIG); if (bytes > sizeof(vdevio_buf)) return(E2BIG);
/* Copy (port,value)-pairs from user. */ /* Copy (port,value)-pairs from user. */
if((r=data_copy(who_e, (vir_bytes) m_ptr->DIO_VEC_ADDR, if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->DIO_VEC_ADDR,
SYSTEM, (vir_bytes) vdevio_buf, bytes)) != OK) SYSTEM, (vir_bytes) vdevio_buf, bytes)) != OK)
return r; return r;
rp= proc_addr(who_p); privp= priv(caller);
privp= priv(rp);
if (privp && (privp->s_flags & CHECK_IO_PORT)) if (privp && (privp->s_flags & CHECK_IO_PORT))
{ {
/* Check whether the I/O is allowed */ /* Check whether the I/O is allowed */
@ -173,7 +170,7 @@ register message *m_ptr; /* pointer to request message */
/* Almost done, copy back results for input requests. */ /* Almost done, copy back results for input requests. */
if (io_in) if (io_in)
if((r=data_copy(SYSTEM, (vir_bytes) vdevio_buf, if((r=data_copy(SYSTEM, (vir_bytes) vdevio_buf,
who_e, (vir_bytes) m_ptr->DIO_VEC_ADDR, caller->p_endpoint, (vir_bytes) m_ptr->DIO_VEC_ADDR,
(phys_bytes) bytes)) != OK) (phys_bytes) bytes)) != OK)
return r; return r;
return(OK); return(OK);

View file

@ -15,8 +15,7 @@
/*===========================================================================* /*===========================================================================*
* do_vmctl * * do_vmctl *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_vmctl(m_ptr) PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
register message *m_ptr; /* pointer to request message */
{ {
int proc_nr; int proc_nr;
endpoint_t ep = m_ptr->SVMCTL_WHO; endpoint_t ep = m_ptr->SVMCTL_WHO;
@ -171,7 +170,7 @@ register message *m_ptr; /* pointer to request message */
unlock; unlock;
return err; return err;
} }
if(newmap(p, (struct mem_map *) m_ptr->SVMCTL_VALUE) != OK) if(newmap(caller, p, (struct mem_map *) m_ptr->SVMCTL_VALUE) != OK)
minix_panic("do_vmctl: newmap failed", NO_NUM); minix_panic("do_vmctl: newmap failed", NO_NUM);
FIXLINMSG(p); FIXLINMSG(p);
vmassert(p->p_delivermsg_lin); vmassert(p->p_delivermsg_lin);

View file

@ -18,11 +18,9 @@
/*===========================================================================* /*===========================================================================*
* do_vtimer * * do_vtimer *
*===========================================================================*/ *===========================================================================*/
PUBLIC int do_vtimer(m_ptr) PUBLIC int do_vtimer(struct proc * caller, message * m_ptr)
message *m_ptr; /* pointer to request message */
{ {
/* Set and/or retrieve the value of one of a process' virtual timers. */ /* Set and/or retrieve the value of one of a process' virtual timers. */
struct proc *rrp; /* pointer to requesting process */
struct proc *rp; /* pointer to process the timer belongs to */ struct proc *rp; /* pointer to process the timer belongs to */
register int pt_flag; /* the misc on/off flag for the req.d timer */ register int pt_flag; /* the misc on/off flag for the req.d timer */
register clock_t *pt_left; /* pointer to the process' ticks-left field */ register clock_t *pt_left; /* pointer to the process' ticks-left field */
@ -30,8 +28,7 @@ message *m_ptr; /* pointer to request message */
int proc_nr, proc_nr_e; int proc_nr, proc_nr_e;
/* The requesting process must be privileged. */ /* The requesting process must be privileged. */
rrp = proc_addr(who_p); if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM);
if (! (priv(rrp)->s_flags & SYS_PROC)) return(EPERM);
if (m_ptr->VT_WHICH != VT_VIRTUAL && m_ptr->VT_WHICH != VT_PROF) if (m_ptr->VT_WHICH != VT_VIRTUAL && m_ptr->VT_WHICH != VT_PROF)
return(EINVAL); return(EINVAL);