Index: sys/kern/kern_tc.c =================================================================== --- sys/kern/kern_tc.c (revision 277285) +++ sys/kern/kern_tc.c (working copy) @@ -1424,7 +1424,15 @@ (void)newtc->tc_get_timecount(newtc); timecounter = newtc; - timekeep_push_vdso(); + + /* + * The vdso timehands update is deferred until the next + * 'tc_windup()'. + * + * This is prudent given that 'timekeep_push_vdso()' does not + * use any locking and that it can be called in hard interrupt + * context via 'tc_windup()'. + */ return (0); } return (EINVAL); @@ -1982,7 +1990,6 @@ if (error != 0) return (error); vdso_th_enable = old_vdso_th_enable; - timekeep_push_vdso(); return (0); } SYSCTL_PROC(_kern_timecounter, OID_AUTO, fast_gettime, @@ -2002,7 +2009,7 @@ vdso_th->th_counter_mask = th->th_counter->tc_counter_mask; vdso_th->th_offset = th->th_offset; vdso_th->th_boottime = boottimebin; - enabled = cpu_fill_vdso_timehands(vdso_th); + enabled = cpu_fill_vdso_timehands(vdso_th, th->th_counter); if (!vdso_th_enable) enabled = 0; return (enabled); @@ -2024,7 +2031,7 @@ *(uint64_t *)&vdso_th32->th_offset.frac[0] = th->th_offset.frac; vdso_th32->th_boottime.sec = boottimebin.sec; *(uint64_t *)&vdso_th32->th_boottime.frac[0] = boottimebin.frac; - enabled = cpu_fill_vdso_timehands32(vdso_th32); + enabled = cpu_fill_vdso_timehands32(vdso_th32, th->th_counter); if (!vdso_th_enable) enabled = 0; return (enabled); Index: sys/kern/subr_dummy_vdso_tc.c =================================================================== --- sys/kern/subr_dummy_vdso_tc.c (revision 277285) +++ sys/kern/subr_dummy_vdso_tc.c (working copy) @@ -33,7 +33,7 @@ #include uint32_t -cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th) +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) { return (0); @@ -41,7 +41,8 @@ #ifdef COMPAT_FREEBSD32 uint32_t -cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) +cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32, + struct timecounter *tc) { return (0); Index: sys/sys/vdso.h =================================================================== --- sys/sys/vdso.h (revision 277285) +++ sys/sys/vdso.h (working copy) @@ -69,6 +69,8 @@ #ifdef _KERNEL +struct timecounter; + void timekeep_push_vdso(void); uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th); @@ -81,7 +83,8 @@ * global sysctl enable override is handled by machine-independed code * after cpu_fill_vdso_timehands() call is made. */ -uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th); +uint32_t cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc); #define VDSO_TH_NUM 4 @@ -110,7 +113,8 @@ }; uint32_t tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32); -uint32_t cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32); +uint32_t cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32, + struct timecounter *tc); #endif #endif Index: sys/x86/x86/tsc.c =================================================================== --- sys/x86/x86/tsc.c (revision 277285) +++ sys/x86/x86/tsc.c (working copy) @@ -720,21 +720,22 @@ } uint32_t -cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th) +cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) { - vdso_th->th_x86_shift = (int)(intptr_t)timecounter->tc_priv; + vdso_th->th_x86_shift = (int)(intptr_t)tc->tc_priv; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); - return (timecounter == &tsc_timecounter); + return (tc == &tsc_timecounter); } #ifdef COMPAT_FREEBSD32 uint32_t -cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32) +cpu_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32, + struct timecounter *tc) { - vdso_th32->th_x86_shift = (int)(intptr_t)timecounter->tc_priv; + vdso_th32->th_x86_shift = (int)(intptr_t)tc->tc_priv; bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); - return (timecounter == &tsc_timecounter); + return (tc == &tsc_timecounter); } #endif