[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/time: introduce helper to fetch Xen wallclock when running as a guest
commit 9f16d4e65342668a573e06b7517a4bc3ea8a65f2 Author: Roger Pau Monné <roger.pau@xxxxxxxxxx> AuthorDate: Mon Sep 9 13:41:16 2024 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Sep 9 13:41:16 2024 +0200 x86/time: introduce helper to fetch Xen wallclock when running as a guest Move the current code in get_wallclock_time() to fetch the Xen wallclock information from the shared page when running as a guest into a separate helper. No functional change intended. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/time.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index a97d784841..3c4cd1b595 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -787,6 +787,30 @@ static struct platform_timesource __initdata_cf_clobber plt_xen_timer = }; #endif +static unsigned long read_xen_wallclock(void) +{ +#ifdef CONFIG_XEN_GUEST + const struct shared_info *sh_info = XEN_shared_info; + uint32_t wc_version; + uint64_t wc_sec; + + ASSERT(xen_guest); + + do { + wc_version = sh_info->wc_version & ~1; + smp_rmb(); + + wc_sec = sh_info->wc_sec; + smp_rmb(); + } while ( wc_version != sh_info->wc_version ); + + return wc_sec + read_xen_timer() / 1000000000; +#else + ASSERT_UNREACHABLE(); + return 0; +#endif +} + #ifdef CONFIG_HYPERV_GUEST /************************************************************ * HYPER-V REFERENCE TSC @@ -1497,24 +1521,8 @@ void rtc_guest_write(unsigned int port, unsigned int data) static unsigned long get_wallclock_time(void) { -#ifdef CONFIG_XEN_GUEST if ( xen_guest ) - { - struct shared_info *sh_info = XEN_shared_info; - uint32_t wc_version; - uint64_t wc_sec; - - do { - wc_version = sh_info->wc_version & ~1; - smp_rmb(); - - wc_sec = sh_info->wc_sec; - smp_rmb(); - } while ( wc_version != sh_info->wc_version ); - - return wc_sec + read_xen_timer() / 1000000000; - } -#endif + return read_xen_wallclock(); return get_cmos_time(); } -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |