Minor fixes and improvements for sys_call().

This commit is contained in:
Jorrit Herder 2005-07-26 13:51:21 +00:00
parent fd4b7f7a1d
commit a41eb700e8
7 changed files with 36 additions and 35 deletions

View File

@ -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 */
#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 */
/* 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 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

View File

@ -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 */

View File

@ -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);

View File

@ -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" },

View File

@ -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 */
};

View File

@ -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

View File

@ -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; i<NR_BOOT_PROCS; i++) {
ip = &image[i];
for (j=-NR_TASKS; j<INIT_PROC_NR+2; j++)
maskstr[j+NR_TASKS] = '0';
maskstr[j+NR_TASKS] = '\0';
printf("---name-- -nr- -flags- -q- ----pc- -stack- ----sendmask[0]-----\n");
for (m=0; m<NR_BOOT_PROCS; m++) {
ip = &image[m];
for (i=j=0; i < BITCHUNK_BITS; i++, j++) {
send_mask[j] = (ip->send_mask & (1<<i)) ? '1' : '0';
if (i % 8 == 7) send_mask[++j] = ' ';
}
send_mask[j] = '\0';
printf("%8s %4d 0x%02x %3d %7lu %7lu %s\n",
ip->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
);