]> xenbits.xensource.com Git - xen.git/commitdiff
update system time immediately when VCPUOP_register_vcpu_info
authorDongli Zhang <dongli.zhang@oracle.com>
Wed, 3 Nov 2021 09:19:06 +0000 (10:19 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 3 Nov 2021 09:19:06 +0000 (10:19 +0100)
The guest may access the pv vcpu_time_info immediately after
VCPUOP_register_vcpu_info. This is to borrow the idea of
VCPUOP_register_vcpu_time_memory_area, where the
force_update_vcpu_system_time() is called immediately when the new memory
area is registered.

Otherwise, we may observe clock drift at the VM side if the VM accesses
the clocksource immediately after VCPUOP_register_vcpu_info().

Reference: https://lists.xenproject.org/archives/html/xen-devel/2021-10/msg00571.html
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/arch/arm/time.c
xen/common/domain.c
xen/include/asm-arm/time.h

index 7dbd363537eb394a279e2b172d8d825ff6ca62e0..dec53b5f7d53a208dcd471a478b0088dd2879518 100644 (file)
@@ -351,6 +351,11 @@ void update_vcpu_system_time(struct vcpu *v)
     /* XXX update shared_info->wc_* */
 }
 
+void force_update_vcpu_system_time(struct vcpu *v)
+{
+    update_vcpu_system_time(v);
+}
+
 void domain_set_time_offset(struct domain *d, int64_t time_offset_seconds)
 {
     d->time_offset.seconds = time_offset_seconds;
index 8b53c49d1ef21b344ca8ebe99d4d1bb14d41e908..d71fcab88c5fb5c7fd905b0f6e2b372d9a784786 100644 (file)
@@ -1704,6 +1704,8 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
         rc = map_vcpu_info(v, info.mfn, info.offset);
         domain_unlock(d);
 
+        force_update_vcpu_system_time(v);
+
         break;
     }
 
index 6b8fd839ddca77861521eec9e2a85bff28ee502e..4b401c1110e7a2580298c182b16ab2071a8c6ca0 100644 (file)
@@ -105,6 +105,8 @@ extern uint64_t ns_to_ticks(s_time_t ns);
 
 void preinit_xen_time(void);
 
+void force_update_vcpu_system_time(struct vcpu *v);
+
 #endif /* __ARM_TIME_H__ */
 /*
  * Local variables: