From: Jorrit Herder Date: Tue, 26 Jul 2005 13:51:21 +0000 (+0000) Subject: Minor fixes and improvements for sys_call(). X-Git-Tag: v3.1.0~529 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.host.html?a=commitdiff_plain;h=a41eb700e8477e3ff7284aa2a2ee27762990e740;p=minix.git Minor fixes and improvements for sys_call(). --- diff --git a/kernel/ipc.h b/kernel/ipc.h index 5101507d6..7569473aa 100644 --- a/kernel/ipc.h +++ b/kernel/ipc.h @@ -14,26 +14,25 @@ * numbers are carefully defined so that it can easily be seen (based on * the bits that are on) which checks should be done in sys_call(). */ -#define ECHO 0 /* 0 0 0 0 1 (01) : echo a message */ -#define SEND 1 /* 0 0 0 1 1 (03) : blocking send */ -#define RECEIVE 2 /* 0 0 1 0 1 (05) : blocking receive */ -#define SENDREC 3 /* 0 0 1 1 1 (07) : SEND + RECEIVE */ -#define NOTIFY 4 /* temp */ -#define ALERT 5 /* 0 1 0 1 0 (10) : nonblocking notify */ - -/* The following definitions determine whether a calls message buffer and/ - * or destination processes should be validated. - */ -#define CHECK_PTR 0x01 /* 0 0 0 0 1 : validate message buffer */ -#define CHECK_DST 0x02 /* 0 0 0 1 0 : validate message destination */ -#define CHECK_SRC 0x04 /* 0 0 1 0 0 : validate message source */ +#define SEND 1 /* 0 0 0 1 : blocking send */ +#define RECEIVE 2 /* 0 0 1 0 : blocking receive */ +#define SENDREC 3 /* 0 0 1 1 : SEND + RECEIVE */ +#define ALERT 4 /* 0 1 0 0 : nonblocking notify */ +#define ECHO 8 /* 1 0 0 0 : echo a message */ + +#define NOTIFY 16 /* 1 0 0 0 0 : temp */ + +/* The following bit masks determine what checks that should be done. */ +#define CHECK_PTR 0x0B /* 1 0 1 1 : validate message buffer */ +#define CHECK_DST 0x05 /* 0 1 0 1 : validate message destination */ +#define CHECK_SRC 0x02 /* 0 0 1 0 : validate message source */ /* Call masks indicating which system calls (traps) a process can make. - * The values here are used for the processes in the boot image. + * System processes can do anything; user processes are highly restricted. */ #define EMPTY_MASK (0) #define FILLED_MASK (~0) -#define USER_CALL_MASK (1 << SENDREC) +#define USER_CALL_MASK ((1 << SENDREC) | (1 << ECHO)) /* Send masks determine to whom processes can send messages or notifications. * The values here are used for the processes in the boot image. We rely on diff --git a/kernel/priv.h b/kernel/priv.h index 26f05d880..8dc5ed686 100755 --- a/kernel/priv.h +++ b/kernel/priv.h @@ -18,9 +18,9 @@ struct priv { proc_nr_t s_proc_nr; /* number of associated process */ sys_id_t s_id; /* index of this system structure */ - char s_flags; /* PREEMTIBLE, BILLABLE, etc. */ + short s_flags; /* PREEMTIBLE, BILLABLE, etc. */ - char s_call_mask; /* allowed system call traps */ + short s_call_mask; /* allowed system call traps */ sys_map_t s_send_mask; /* allowed send destinations */ long s_sys_mask; /* allowed kernel calls */ diff --git a/kernel/proc.c b/kernel/proc.c index e404a8c29..8a01ef221 100755 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -135,7 +135,7 @@ message *m_ptr; /* pointer to message in the caller's space */ * anywhere in data or stack or gap. It will have to be made more elaborate * for machines which don't have the gap mapped. */ - if (function & SENDREC) { + if (function & CHECK_PTR) { vb = (vir_bytes) m_ptr; /* virtual clicks */ vlo = vb >> CLICK_SHIFT; /* bottom of message */ vhi = (vb + MESS_SIZE - 1) >> CLICK_SHIFT; /* top of message */ @@ -148,7 +148,7 @@ message *m_ptr; /* pointer to message in the caller's space */ * verify that the caller is allowed to send to the given destination and * that the destination is still alive. */ - if (function & SEND) { + if (function & CHECK_DST) { if (! get_sys_bit(priv(caller_ptr)->s_send_mask, nr_to_id(src_dst))) { kprintf("Warning, send_mask denied %d sending to %d\n", proc_nr(caller_ptr), src_dst); diff --git a/kernel/table.c b/kernel/table.c index 850dc230a..fd1a3ba1f 100755 --- a/kernel/table.c +++ b/kernel/table.c @@ -71,7 +71,7 @@ PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)]; PUBLIC struct system_image image[] = { { IDLE, idle_task, IDLE_F, IDLE_T, IDLE_Q, IDLE_S, EMPTY_MASK, EMPTY_MASK, "IDLE" }, { CLOCK, clock_task, TASK_F, SYS_T, TASK_Q, CLOCK_S, FILLED_MASK, SYSTEM_SEND_MASK, "CLOCK" }, - { SYSTEM, sys_task, TASK_F, SYS_T, TASK_Q, SYSTEM_S, FILLED_MASK, SYSTEM_SEND_MASK, "SYS" }, + { SYSTEM, sys_task, TASK_F, SYS_T, TASK_Q, SYSTEM_S, FILLED_MASK, SYSTEM_SEND_MASK, "SYSTEM" }, { HARDWARE, 0, TASK_F, SYS_T, TASK_Q, HARDWARE_S, EMPTY_MASK, SYSTEM_SEND_MASK, "KERNEL" }, { PM_PROC_NR, 0, SYS_F, SYS_T, 3, 0, FILLED_MASK, SERVER_SEND_MASK, "PM" }, { FS_PROC_NR, 0, SYS_F, SYS_T, 3, 0, FILLED_MASK, SERVER_SEND_MASK, "FS" }, diff --git a/kernel/type.h b/kernel/type.h index 684703abc..7edd5c5b0 100755 --- a/kernel/type.h +++ b/kernel/type.h @@ -17,7 +17,7 @@ struct system_image { char quantum; /* quantum (tick count) */ int priority; /* scheduling priority */ int stksize; /* stack size for tasks */ - char call_mask; /* allowed system calls */ + short call_mask; /* allowed system calls */ bitchunk_t send_mask; /* send mask protection */ char proc_name[P_NAME_LEN]; /* name in process table */ }; diff --git a/lib/i386/rts/_ipc.s b/lib/i386/rts/_ipc.s index f212f86b6..7eec5b08c 100755 --- a/lib/i386/rts/_ipc.s +++ b/lib/i386/rts/_ipc.s @@ -2,12 +2,12 @@ .define __echo, __alert, __send, __nb_send, __receive, __nb_receive, __sendrec, __notify ! See src/kernel/ipc.h for C definitions -ECHO = 0 SEND = 1 RECEIVE = 2 SENDREC = 3 + 32 ! flags 0x20 to request fresh answer -NOTIFY = 4 -ALERT = 5 +NOTIFY = 16 +ALERT = 4 +ECHO = 8 NB_SEND = 1 + 16 ! flags 0x10 to prevent blocking NB_RECEIVE = 2 + 16 ! flags 0x10 to prevent blocking SYSVEC = 33 ! trap to kernel @@ -99,7 +99,7 @@ __alert: mov ebp, esp push ebx mov eax, SRC_DST(ebp) ! ebx = destination - mov ecx, ALERT ! _echo(srcdest, ptr) + mov ecx, ALERT ! _alert(srcdst) int SYSVEC ! trap to the kernel pop ebx pop ebp diff --git a/servers/is/dmp_kernel.c b/servers/is/dmp_kernel.c index 82692d3ca..8f7bbffa1 100644 --- a/servers/is/dmp_kernel.c +++ b/servers/is/dmp_kernel.c @@ -182,24 +182,26 @@ PUBLIC void irqtab_dmp() *===========================================================================*/ PUBLIC void image_dmp() { - int i,j,r; + int m, i,j,r; struct system_image *ip; - char maskstr[NR_TASKS + NR_PROCS] = "mask"; + static char send_mask[BITCHUNK_BITS*2]; if ((r = sys_getimage(image)) != OK) { report("IS","warning: couldn't get copy of image table", r); return; } printf("Image table dump showing all processes included in system image.\n"); - printf("---name-- -nr- -flags- -q- ----pc- -stack- ------sendmask-------\n"); - for (i=0; isend_mask & (1<proc_name, ip->proc_nr, ip->flags, ip->priority, - (long)ip->initial_pc, ip->stksize, maskstr); + (long)ip->initial_pc, ip->stksize, send_mask); } printf("\n"); } @@ -323,7 +325,7 @@ PUBLIC void privileges_dmp() return; } - printf("\n--nr-id-name--- -flags- -sc- -send mask-\n"); + printf("\n--nr-id-name---- -flags- -traps- -send mask-\n"); for (rp = oldrp; rp < END_PROC_ADDR; rp++) { if (isemptyp(rp)) continue; @@ -337,7 +339,7 @@ PUBLIC void privileges_dmp() if (r == -1 && ! (rp->p_rts_flags & SLOT_FREE)) { sp = &priv[USER_PRIV_ID]; } - printf("(%02u) %-7.7s 0x%02x %02.2u ", + printf("(%02u) %-7.7s 0x%03x 0x%03.3x ", sp->s_id, rp->p_name, sp->s_flags, sp->s_call_mask );