[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.14] update system time immediately when VCPUOP_register_vcpu_info



commit c3f25903696412b8847619ccd5e51886106b70ad
Author:     Dongli Zhang <dongli.zhang@xxxxxxxxxx>
AuthorDate: Fri Nov 19 09:39:09 2021 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Nov 19 09:39:09 2021 +0100

    update system time immediately when VCPUOP_register_vcpu_info
    
    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@xxxxxxxxxx>
    Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    master commit: b67f09721f136cc3a9afcb6a82466d1bd27aa6c0
    master date: 2021-11-03 10:19:06 +0100
---
 xen/arch/arm/time.c        | 5 +++++
 xen/common/domain.c        | 2 ++
 xen/include/asm-arm/time.h | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index b0021c2c69..620ac202f3 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -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;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index b556696c87..b7017e1c01 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1498,6 +1498,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;
     }
 
diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h
index 1b2c13614b..9b6f5a1bbe 100644
--- a/xen/include/asm-arm/time.h
+++ b/xen/include/asm-arm/time.h
@@ -66,6 +66,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:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.