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

[PATCH v2 1/1] xen: update system time immediately when VCPUOP_register_vcpu_info


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
  • Date: Mon, 25 Oct 2021 10:35:23 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cDImQC0g3WWbNeSuHjh5Voz2pA2wuCtC5/LKbSnoOEw=; b=n4F/gBmdhfpd96i5TqXQ3c1KBx3R8XoPiPO0IL7xk+JiccisZ42XVuPXBLgDosF3uhPqsU2Al9esLD8frlXES957MvgcFx59sKw7+NBoFvNq5wLsYAwpeoQW07/HKJQh0Mpv0Xs28nyJ4vY4OGZ8QAU6RAUJSM3LtWf6RvtLsrhbkEmEB/rbyDrnd+xclnOKeHdmlighb538UdlPocw7bv+3b9gOPmhYXj6HapcTIYLX/5VyC9nptoAmXtOPXZobOElc+7HAMDWdr52Kq3/+l6mrQWW8pYvsO50/hFnhHJwP7fCnt2Pj3rKtB7Z3m/kfrAstv+Q/2ckqpDoAADr89Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8Y8hPWActoieUdB5z3GRtDt4X5tzri1Qw55rSS8+54l5ZKBa6F3mrVWLkP7JicownskJJ0EFOUJ3dzFo+vQZUxL8dEcfx+dEyoJpz7Ck0ApECietDFfFXBIwjyWkWhki784T3fs1rXW6UbxAyfH2U24AG+dA4ueyaRJlZ7RKiWBCC+xdzLhIkeQ2SsRX5LFgb6uQq5Y9DMLBL0Szng5+1q6d5sk3Zyg65R0NtuQZuAIBl8YNX22UX/e0dEFh0GFEzYfM1J03IKr3g50h6w9Qv5fExOYN+Rv8wbuIlW7Y7VfPUw1DGyBC4UUREzvsSthfIY89QU9dOkaMusxkkLL4A==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=oracle.com;
  • Cc: sstabellini@xxxxxxxxxx, julien@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, iwj@xxxxxxxxxxxxxx, jbeulich@xxxxxxxx, wl@xxxxxxx, joe.jin@xxxxxxxxxx
  • Delivery-date: Mon, 25 Oct 2021 17:35:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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
Cc: Joe Jin <joe.jin@xxxxxxxxxx>
Signed-off-by: Dongli Zhang <dongli.zhang@xxxxxxxxxx>
---
Changed since v1:
  - Implement force_update_vcpu_system_time() for ARM
    (suggested by Jan Beulich)
    While I have tested ARM compilation with aarch64-linux-gnu-gcc, I did
    not test on ARM platform.

 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 7dbd363537..dec53b5f7d 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 8b53c49d1e..d71fcab88c 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -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;
     }
 
diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h
index 6b8fd839dd..4b401c1110 100644
--- a/xen/include/asm-arm/time.h
+++ b/xen/include/asm-arm/time.h
@@ -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:
-- 
2.17.1




 


Rackspace

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