Fix the Xen TOD update when the hypervisor wall clock is nudged.
The "wall clock" in the current code is actually the hypervisor start time. The time of day is the "start time" plus the hypervisor "uptime". Large enough bumps in the dom0 clock lead to a hypervisor "bump" which is implemented as a bump in the start time, not the uptime. The clock.c routines were reading in the hypervisor start time and then using this as the TOD. This meant that any hypervisor time bump would cause the FreeBSD DomU to set its TOD to the hypervisor start time, rather than the actual TOD. This fix is a bit hacky and some reshuffling should be done later on to clarify what is going on. I've left the wall clock code alone. (The code which updates shadow_tv and shadow_tv_version.) A new routine adds the uptime to the shadow_tv, which is then used to update the TOD. I've included some debugging so it is obvious when the clock is nudged. PR: 135008
This commit is contained in:
parent
7d18ff9a2b
commit
fd27593538
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193033
@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/xen/xenfunc.h>
|
#include <machine/xen/xenfunc.h>
|
||||||
#include <xen/interface/vcpu.h>
|
#include <xen/interface/vcpu.h>
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
|
#include <machine/xen/xen_clock_util.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
|
* 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
|
||||||
@ -236,6 +237,15 @@ static void update_wallclock(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_uptime_to_wallclock(void)
|
||||||
|
{
|
||||||
|
struct timespec ut;
|
||||||
|
|
||||||
|
xen_fetch_uptime(&ut);
|
||||||
|
timespecadd(&shadow_tv, &ut);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reads a consistent set of time-base values from Xen, into a shadow data
|
* Reads a consistent set of time-base values from Xen, into a shadow data
|
||||||
* area. Must be called with the xtime_lock held for writing.
|
* area. Must be called with the xtime_lock held for writing.
|
||||||
@ -331,7 +341,9 @@ clkintr(void *arg)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
|
if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
|
||||||
|
printf("[XEN] hypervisor wallclock nudged; nudging TOD.\n");
|
||||||
update_wallclock();
|
update_wallclock();
|
||||||
|
add_uptime_to_wallclock();
|
||||||
tc_setclock(&shadow_tv);
|
tc_setclock(&shadow_tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,6 +554,7 @@ domu_inittodr(time_t base)
|
|||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
update_wallclock();
|
update_wallclock();
|
||||||
|
add_uptime_to_wallclock();
|
||||||
|
|
||||||
RTC_LOCK;
|
RTC_LOCK;
|
||||||
|
|
||||||
@ -591,6 +604,7 @@ domu_resettodr(void)
|
|||||||
op.u.settime.system_time = shadow->system_timestamp;
|
op.u.settime.system_time = shadow->system_timestamp;
|
||||||
HYPERVISOR_dom0_op(&op);
|
HYPERVISOR_dom0_op(&op);
|
||||||
update_wallclock();
|
update_wallclock();
|
||||||
|
add_uptime_to_wallclock();
|
||||||
} else if (independent_wallclock) {
|
} else if (independent_wallclock) {
|
||||||
/* notyet */
|
/* notyet */
|
||||||
;
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user