Rewrite of boot process
KERNEL CHANGES: - The kernel only knows about privileges of kernel tasks and the root system process (now RS). - Kernel tasks and the root system process are the only processes that are made schedulable by the kernel at startup. All the other processes in the boot image don't get their privileges set at startup and are inhibited from running by the RTS_NO_PRIV flag. - Removed the assumption on the ordering of processes in the boot image table. System processes can now appear in any order in the boot image table. - Privilege ids can now be assigned both statically or dynamically. The kernel assigns static privilege ids to kernel tasks and the root system process. Each id is directly derived from the process number. - User processes now all share the static privilege id of the root user process (now INIT). - sys_privctl split: we have more calls now to let RS set privileges for system processes. SYS_PRIV_ALLOW / SYS_PRIV_DISALLOW are only used to flip the RTS_NO_PRIV flag and allow / disallow a process from running. SYS_PRIV_SET_SYS / SYS_PRIV_SET_USER are used to set privileges for a system / user process. - boot image table flags split: PROC_FULLVM is the only flag that has been moved out of the privilege flags and is still maintained in the boot image table. All the other privilege flags are out of the kernel now. RS CHANGES: - RS is the only user-space process who gets to run right after in-kernel startup. - RS uses the boot image table from the kernel and three additional boot image info table (priv table, sys table, dev table) to complete the initialization of the system. - RS checks that the entries in the priv table match the entries in the boot image table to make sure that every process in the boot image gets schedulable. - RS only uses static privilege ids to set privileges for system services in the boot image. - RS includes basic memory management support to allocate the boot image buffer dynamically during initialization. The buffer shall contain the executable image of all the system services we would like to restart after a crash. - First step towards decoupling between resource provisioning and resource requirements in RS: RS must know what resources it needs to restart a process and what resources it has currently available. This is useful to tradeoff reliability and resource consumption. When required resources are missing, the process cannot be restarted. In that case, in the future, a system flag will tell RS what to do. For example, if CORE_PROC is set, RS should trigger a system-wide panic because the system can no longer function correctly without a core system process. PM CHANGES: - The process tree built at initialization time is changed to have INIT as root with pid 0, RS child of INIT and all the system services children of RS. This is required to make RS in control of all the system services. - PM no longer registers labels for system services in the boot image. This is now part of RS's initialization process.
This commit is contained in:
101
kernel/table.c
101
kernel/table.c
@@ -22,6 +22,7 @@
|
||||
* include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c).
|
||||
*
|
||||
* Changes:
|
||||
* Nov 22, 2009 rewrite of privilege management (Cristiano Giuffrida)
|
||||
* Aug 02, 2005 set privileges and minimal boot image (Jorrit N. Herder)
|
||||
* Oct 17, 2004 updated above and tasktab comments (Jorrit N. Herder)
|
||||
* May 01, 2004 changed struct for system image (Jorrit N. Herder)
|
||||
@@ -43,97 +44,37 @@
|
||||
/* Stack space for all the task stacks. Declared as (char *) to align it. */
|
||||
#define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S))
|
||||
PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
|
||||
|
||||
/* Define flags for the various process types. */
|
||||
#define IDL_F (SYS_PROC | BILLABLE) /* idle task is not preemptible as we
|
||||
* don't want it to interfere with the
|
||||
* timer tick interrupt handler code.
|
||||
* Unlike other processes idle task is
|
||||
* handled in a special way and is
|
||||
* preempted always if timer tick occurs
|
||||
* and there is another runnable process
|
||||
*/
|
||||
#define TSK_F (SYS_PROC) /* kernel tasks */
|
||||
#define SRV_F (SYS_PROC | PREEMPTIBLE) /* system services */
|
||||
#define VM_F (SYS_PROC) /* vm */
|
||||
#define USR_F (BILLABLE | PREEMPTIBLE | PROC_FULLVM) /* user processes */
|
||||
#define SVM_F (SRV_F | PROC_FULLVM) /* servers with VM */
|
||||
|
||||
/* Define system call traps for the various process types. These call masks
|
||||
* determine what system call traps a process is allowed to make.
|
||||
*/
|
||||
#define TSK_T (1 << RECEIVE) /* clock and system */
|
||||
#define SRV_T (~0) /* system services */
|
||||
#define USR_T ((1 << SENDREC)) /* user processes */
|
||||
|
||||
/* 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
|
||||
* the boot image table itself to match the order of the process numbers, so
|
||||
* that the send mask that is defined here can be interpreted properly.
|
||||
* Privilege structure 0 is shared by user processes.
|
||||
*/
|
||||
#define s(n) (1 << (s_nr_to_id(n)))
|
||||
#define SRV_M (~0)
|
||||
#define SYS_M (~0)
|
||||
#define USR_M (s(PM_PROC_NR) | s(FS_PROC_NR) | s(RS_PROC_NR) | s(VM_PROC_NR))
|
||||
#define DRV_M (USR_M | s(SYSTEM) | s(DS_PROC_NR) | s(LOG_PROC_NR) | s(TTY_PROC_NR))
|
||||
|
||||
/* Define kernel calls that processes are allowed to make. This is not looking
|
||||
* very nice, but we need to define the access rights on a per call basis.
|
||||
* Note that the reincarnation server has all bits on, because it should
|
||||
* be allowed to distribute rights to services that it starts.
|
||||
*
|
||||
* Calls are unordered lists, converted by the kernel to bitmasks
|
||||
* once at runtime.
|
||||
*/
|
||||
#define FS_C SYS_KILL, SYS_VIRCOPY, SYS_SAFECOPYFROM, SYS_SAFECOPYTO, \
|
||||
SYS_VIRVCOPY, SYS_UMAP, SYS_GETINFO, SYS_EXIT, SYS_TIMES, SYS_SETALARM, \
|
||||
SYS_PRIVCTL, SYS_TRACE , SYS_SETGRANT, SYS_PROFBUF, SYS_SYSCTL
|
||||
#define DRV_C FS_C, SYS_SEGCTL, SYS_IRQCTL, SYS_INT86, SYS_DEVIO, \
|
||||
SYS_SDEVIO, SYS_VDEVIO, SYS_SETGRANT, SYS_PROFBUF, SYS_SYSCTL
|
||||
|
||||
PRIVATE int
|
||||
fs_c[] = { FS_C },
|
||||
pm_c[] = { SYS_ALL_CALLS },
|
||||
rs_c[] = { SYS_ALL_CALLS },
|
||||
ds_c[] = { SYS_ALL_CALLS },
|
||||
vm_c[] = { SYS_ALL_CALLS },
|
||||
drv_c[] = { DRV_C },
|
||||
usr_c[] = { SYS_SYSCTL },
|
||||
tty_c[] = { DRV_C, SYS_PHYSCOPY, SYS_ABORT, SYS_IOPENABLE,
|
||||
SYS_READBIOS },
|
||||
mem_c[] = { DRV_C, SYS_PHYSCOPY, SYS_PHYSVCOPY, SYS_IOPENABLE };
|
||||
/* Define boot process flags. */
|
||||
#define BVM_F (PROC_FULLVM) /* boot processes with VM */
|
||||
|
||||
/* The system image table lists all programs that are part of the boot image.
|
||||
* The order of the entries here MUST agree with the order of the programs
|
||||
* in the boot image and all kernel tasks must come first. Furthermore, the
|
||||
* order of the entries MUST agree with their process numbers. See above.
|
||||
* in the boot image and all kernel tasks must come first.
|
||||
*
|
||||
* Each entry provides the process number, flags, quantum size, scheduling
|
||||
* queue, allowed traps, ipc mask, and a name for the process table. The
|
||||
* initial program counter and stack size is also provided for kernel tasks.
|
||||
* queue, and a name for the process table. The initial program counter and
|
||||
* stack size is also provided for kernel tasks.
|
||||
*
|
||||
* Note: the quantum size must be positive in all cases!
|
||||
*/
|
||||
#define c(calls) calls, (sizeof(calls) / sizeof((calls)[0]))
|
||||
#define no_c { 0 }, 0
|
||||
|
||||
PUBLIC struct boot_image image[] = {
|
||||
/* process nr, pc,flags, qs, queue, stack, traps, ipcto, call, name */
|
||||
{IDLE, NULL,IDL_F, 0, 0, IDL_S, 0, 0, no_c,"idle" },
|
||||
{CLOCK,clock_task,TSK_F, 8, TASK_Q, TSK_S, TSK_T, 0, no_c,"clock" },
|
||||
{SYSTEM, sys_task,TSK_F, 8, TASK_Q, TSK_S, TSK_T, 0, no_c,"system"},
|
||||
{HARDWARE, 0,TSK_F, 8, TASK_Q, HRD_S, 0, 0, no_c,"kernel"},
|
||||
{PM_PROC_NR, 0,SRV_F, 32, 4, 0, SRV_T, SRV_M, c(pm_c),"pm" },
|
||||
{FS_PROC_NR, 0,SRV_F, 32, 5, 0, SRV_T, SRV_M, c(fs_c),"vfs" },
|
||||
{RS_PROC_NR, 0,SVM_F, 4, 4, 0, SRV_T, SYS_M, c(rs_c),"rs" },
|
||||
{MEM_PROC_NR, 0,SVM_F, 4, 3, 0, SRV_T, SYS_M,c(mem_c),"memory"},
|
||||
{LOG_PROC_NR, 0,SRV_F, 4, 2, 0, SRV_T, SYS_M,c(drv_c),"log" },
|
||||
{TTY_PROC_NR, 0,SVM_F, 4, 1, 0, SRV_T, SYS_M,c(tty_c),"tty" },
|
||||
{DS_PROC_NR, 0,SVM_F, 4, 4, 0, SRV_T, SYS_M, c(ds_c),"ds" },
|
||||
{MFS_PROC_NR, 0,SVM_F, 32, 5, 0, SRV_T, SRV_M, c(fs_c),"mfs" },
|
||||
{VM_PROC_NR, 0,VM_F, 32, 2, 0, SRV_T, SRV_M, c(vm_c),"vm" },
|
||||
{INIT_PROC_NR, 0,USR_F, 8, USER_Q, 0, USR_T, USR_M, c(usr_c),"init" },
|
||||
/* process nr, pc, flags, qs, queue, stack, name */
|
||||
{IDLE, NULL, 0, 0, 0, IDL_S, "idle" },
|
||||
{CLOCK,clock_task, 0, 8, TASK_Q, TSK_S, "clock" },
|
||||
{SYSTEM, sys_task, 0, 8, TASK_Q, TSK_S, "system"},
|
||||
{HARDWARE, 0, 0, 8, TASK_Q, HRD_S, "kernel"},
|
||||
{PM_PROC_NR, 0, 0, 32, 4, 0, "pm" },
|
||||
{FS_PROC_NR, 0, 0, 32, 5, 0, "vfs" },
|
||||
{RS_PROC_NR, 0, 0, 4, 4, 0, "rs" },
|
||||
{MEM_PROC_NR, 0, BVM_F, 4, 3, 0, "memory"},
|
||||
{LOG_PROC_NR, 0, BVM_F, 4, 2, 0, "log" },
|
||||
{TTY_PROC_NR, 0, BVM_F, 4, 1, 0, "tty" },
|
||||
{DS_PROC_NR, 0, BVM_F, 4, 4, 0, "ds" },
|
||||
{MFS_PROC_NR, 0, BVM_F, 32, 5, 0, "mfs" },
|
||||
{VM_PROC_NR, 0, 0, 32, 2, 0, "vm" },
|
||||
{INIT_PROC_NR, 0, BVM_F, 8, USER_Q, 0, "init" },
|
||||
};
|
||||
|
||||
/* Verify the size of the system image table at compile time. Also verify that
|
||||
|
||||
Reference in New Issue
Block a user