From: Ben Gras Date: Tue, 6 Nov 2012 14:36:53 +0000 (+0100) Subject: kernel: some boottime sanitychecks X-Git-Tag: v3.2.1~237 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-keyfromlabel.html?a=commitdiff_plain;h=ba05f39d1ef91ae61ac91daec21c32ca252a9e97;p=minix.git kernel: some boottime sanitychecks . Check if we have the right number of boot modules . Check if the ELF parsing of VM actually succeeded Both these are root causes of less-than-obvious other errors/asserts a little further down the line; uncovered while experimenting with booting by iPXE, specifically (a) iPXE having a 8-multiboot-modules limit and (b) trying to boot a gzipped VM. --- diff --git a/include/minix/com.h b/include/minix/com.h index c71b1c3c0..8c3ade401 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -84,6 +84,7 @@ computation in macros.*/ #define INIT_PROC_NR ((endpoint_t) LAST_SPECIAL_PROC_NR) /* init -- goes multiuser */ +#define NR_BOOT_MODULES (INIT_PROC_NR+1) /* Root system process and root user process. */ #define ROOT_SYS_PROC_NR RS_PROC_NR diff --git a/kernel/arch/i386/protect.c b/kernel/arch/i386/protect.c index 8dc050220..a95397c48 100644 --- a/kernel/arch/i386/protect.c +++ b/kernel/arch/i386/protect.c @@ -419,7 +419,8 @@ void arch_boot_proc(struct boot_image *ip, struct proc *rp) execi.clearproc = NULL; /* parse VM ELF binary and alloc/map it into bootstrap pagetable */ - libexec_load_elf(&execi); + if(libexec_load_elf(&execi) != OK) + panic("VM loading failed"); /* Initialize the server stack pointer. Take it down three words * to give startup code something to use as "argc", "argv" and "envp". diff --git a/kernel/main.c b/kernel/main.c index 652f68f5b..45fbe2d4a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -143,6 +143,10 @@ void kmain(kinfo_t *local_cbi) proc_init(); + if(NR_BOOT_MODULES != kinfo.mbi.mods_count) + panic("expecting %d boot processes/modules, found %d", + NR_BOOT_MODULES, kinfo.mbi.mods_count); + /* Set up proc table entries for processes in boot image. */ for (i=0; i < NR_BOOT_PROCS; ++i) { int schedulable_proc;