From: Antonio Huete Jimenez Date: Mon, 8 Oct 2012 14:28:20 +0000 (+0200) Subject: vkernel - Properly initialize pool tokens. X-Git-Tag: v3.2.0~2 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/0f85165cc636da905f7031428e4e8fc59f13c7ea vkernel - Properly initialize pool tokens. * There was no call to init_locks() in vkernel's initialization code, so provide one. * As pool tokens weren't initialized, the attempt to copy its t_desc in lwkt_getalltokens() resulted in a panic. This should be fixed now. * Add a KASSERT() so that uninitialized tokens will panic the system. Suggested by: swildner --- diff --git a/sys/kern/lwkt_token.c b/sys/kern/lwkt_token.c index e56e6c92b0..83eada4a0e 100644 --- a/sys/kern/lwkt_token.c +++ b/sys/kern/lwkt_token.c @@ -468,6 +468,7 @@ lwkt_getalltokens(thread_t td, int spinning) * Otherwise we failed to acquire all the tokens. * Release whatever we did get. */ + KASSERT(tok->t_desc, ("token %p is not initialized", tok)); strncpy(td->td_gd->gd_cnt.v_token_name, tok->t_desc, sizeof(td->td_gd->gd_cnt.v_token_name) - 1); diff --git a/sys/platform/vkernel/platform/init.c b/sys/platform/vkernel/platform/init.c index 6acae97ed8..2091c4a4d0 100644 --- a/sys/platform/vkernel/platform/init.c +++ b/sys/platform/vkernel/platform/init.c @@ -134,6 +134,7 @@ static void cleanpid(void); static int unix_connect(const char *path); static void usage_err(const char *ctl, ...); static void usage_help(_Bool); +static void init_locks(void); static int save_ac; static char **save_av; @@ -501,6 +502,26 @@ init_sys_memory(char *imageFile) physmem = Maxmem; } +/* + * Initialize pool tokens and other necessary locks + */ +static void +init_locks(void) +{ + +#ifdef SMP + /* + * Get the initial mplock with a count of 1 for the BSP. + * This uses a LOGICAL cpu ID, ie BSP == 0. + */ + cpu_get_initial_mplock(); +#endif + + /* our token pool needs to work early */ + lwkt_token_pool_init(); + +} + /* * Initialize kernel memory. This reserves kernel virtual memory by using * MAP_VPAGETABLE @@ -739,14 +760,7 @@ init_vkernel(void) mi_proc0init(&gd->mi, proc0paddr); lwp0.lwp_md.md_regs = &proc0_tf; - /*init_locks();*/ -#ifdef SMP - /* - * Get the initial mplock with a count of 1 for the BSP. - * This uses a LOGICAL cpu ID, ie BSP == 0. - */ - cpu_get_initial_mplock(); -#endif + init_locks(); cninit(); rand_initialize(); #if 0 /* #ifdef DDB */ diff --git a/sys/platform/vkernel64/platform/init.c b/sys/platform/vkernel64/platform/init.c index a8c984db2c..92a1bcd5cd 100644 --- a/sys/platform/vkernel64/platform/init.c +++ b/sys/platform/vkernel64/platform/init.c @@ -131,6 +131,7 @@ static void cleanpid(void); static int unix_connect(const char *path); static void usage_err(const char *ctl, ...); static void usage_help(_Bool); +static void init_locks(void); static int save_ac; static char **save_av; @@ -675,6 +676,28 @@ init_globaldata(void) tls_set_gs(&CPU_prvspace[0], sizeof(struct privatespace)); } + +/* + * Initialize pool tokens and other necessary locks + */ +static void +init_locks(void) +{ + +#ifdef SMP + /* + * Get the initial mplock with a count of 1 for the BSP. + * This uses a LOGICAL cpu ID, ie BSP == 0. + */ + cpu_get_initial_mplock(); +#endif + + /* our token pool needs to work early */ + lwkt_token_pool_init(); + +} + + /* * Initialize very low level systems including thread0, proc0, etc. */ @@ -700,14 +723,7 @@ init_vkernel(void) mi_proc0init(&gd->mi, proc0paddr); lwp0.lwp_md.md_regs = &proc0_tf; - /*init_locks();*/ -#ifdef SMP - /* - * Get the initial mplock with a count of 1 for the BSP. - * This uses a LOGICAL cpu ID, ie BSP == 0. - */ - cpu_get_initial_mplock(); -#endif + init_locks(); cninit(); rand_initialize(); #if 0 /* #ifdef DDB */