mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 01:55:19 +01:00
Update the vdso timehands only via tc_windup().
Prior to this change CLOCK_MONOTONIC could go backwards when the timecounter hardware was changed via 'sysctl kern.timecounter.hardware'. This happened because the vdso timehands update was missing the special treatment in tc_windup() when changing timecounters. Reviewed by: kib
This commit is contained in:
parent
eaf6610dd7
commit
d1b1b60065
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277406
@ -1424,7 +1424,15 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
|
||||
(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 @@ sysctl_fast_gettime(SYSCTL_HANDLER_ARGS)
|
||||
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 @@ tc_fill_vdso_timehands(struct vdso_timehands *vdso_th)
|
||||
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 @@ tc_fill_vdso_timehands32(struct vdso_timehands32 *vdso_th32)
|
||||
*(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);
|
||||
|
@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/vdso.h>
|
||||
|
||||
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 @@ cpu_fill_vdso_timehands(struct vdso_timehands *vdso_th)
|
||||
|
||||
#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);
|
||||
|
@ -69,6 +69,8 @@ int __vdso_gettimekeep(struct vdso_timekeep **tk);
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct timecounter;
|
||||
|
||||
void timekeep_push_vdso(void);
|
||||
|
||||
uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th);
|
||||
@ -81,7 +83,8 @@ uint32_t tc_fill_vdso_timehands(struct vdso_timehands *vdso_th);
|
||||
* 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 @@ struct vdso_timekeep32 {
|
||||
};
|
||||
|
||||
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
|
||||
|
@ -720,21 +720,22 @@ tsc_get_timecount_low_mfence(struct timecounter *tc)
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user