[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 05/10] x86: update GADDR based secondary time area
- To: xen-devel@xxxxxxxxxxxxxxxxxxxx, henry.wang@xxxxxxx
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Mon, 2 Oct 2023 17:11:22 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=wNopSXtZurBZ4E6tSOFy4W/8WMqlD6/cPCnqWUU/QCI=; b=QPJMyL7Wf5ideIxR2c/73Jhlxu9PK0JNHVks6e14fNJ6WXU5IyRz38VZHzbHiEiBTj9W7hlCCWhix0dBDP+44t1un4dvfhnnZDo0oSaQlRlv//pen+EuWM2tYiEwornLtEjvnSY4bnvne34TWpVCHI0jYWa3nw0Q0TMMbtZFdd3C2/S82uYBmCAhNifMKNAwvQYzlB9shf46xzGk+UdASKNHa9UyRfX0LaVa5alqizKNzcwC1ZV4UK7diTJmcXZMewQIvSCNfM6CgyLYVWLB5wmzx3QrZihVdCaui0rWaWBAZR/Qg/hwTqgo/YHaBz8YQqZGWpa5vKm84m89lRPWhg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NY6LluRR+YdsfBBV7azOTAqzl1Xpvr76iY0t8iRumJqdlJpzEVBUE+n03DuexmEUEyPgreX2GNi12IL3kjmSiuU7f4EJxPC2Wj1MDL4bYarje1WoNBtSzOXmaqcFsXfW8CST/KeF538OyoBs3NXV7ptHiU4ehSEheyl/DQwtQdyzuQUTVj+Vr5IK9frKvFtA+0IWfof6VXhQGqcQ7a/WOuugqesPmnF6jfI0fNgdABF9qX3vBMolyZLs9cGwyIYd+iNhEB8UIXYVnauIsZ/80LWw1HDCAH6ke/1lM0Qo+MisrJvFeqBn9X1bpQnMISyrKS+OxCuZbv4yOTqCHPCouQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 02 Oct 2023 15:12:22 +0000
- Ironport-data: A9a23:V6/kJqBZY46umBVW/xviw5YqxClBgxIJ4kV8jS/XYbTApD1xgjUCy mQeDT2HOPmDNGX3ed8ga4/lph5Q7J+ExoU2QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsMpvlDs15K6p4WtA5ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw/N1TWGp36 r8kBBs0KUrdlb2cm+OqRbw57igjBJGD0II3nFhFlGicIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI+uxuvDG7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqC7317+fzXmTtIQ6FpGA8O8zv2Wq/U9JEQFKdwqBnsC5lRvrMz5YA wlOksY0loAi+UruQtTjUhmQpH+fogVaS9dWC/c96gyG1uzT+QnxLmgJSCRQLsMvssAeTCYvk FSOmrvBBzZirbmUQnK17aqPoHW5Pi19BXAGTT8JS00C+daLnW0ophfGT9ImHKvriNTwQGj02 2rT83F4gKgPh8kW0an95UrAnz+nupnOSEgy+xnTWWWmqAh+YeZJerCV1LQS1t4YRK7xc7VLl CNsdxS2hAzWMaywqQ==
- Ironport-hdrordr: A9a23:ffj3m6rL0fAhDsLfZzA91joaV5oveYIsimQD101hICG9E/b1qy nKpp8mPHDP5wr5NEtPpTnjAsm9qALnlKKdiLN5Vd3OYOCMghrKEGgN1/qH/xTQXwH46+5Bxe NBXsFFebrN5IFB/KTHCd+DYrMd/OU=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: Jan Beulich <jbeulich@xxxxxxxx>
Before adding a new vCPU operation to register the secondary time area
by guest-physical address, add code to actually keep such areas up-to-
date.
Note that pages aren't marked dirty when written to (matching the
handling of space mapped by map_vcpu_info()), on the basis that the
registrations are lost anyway across migration (or would need re-
populating at the target for transparent migration). Plus the contents
of the areas in question have to be deemed volatile in the first place
(so saving a "most recent" value is pretty meaningless even for e.g.
snapshotting).
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/arch/x86/time.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index af40a9993c81..332d2d79aeae 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1566,12 +1566,34 @@ static void __update_vcpu_system_time(struct vcpu *v,
int force)
v->arch.pv.pending_system_time = _u;
}
+static void write_time_guest_area(struct vcpu_time_info *map,
+ const struct vcpu_time_info *src)
+{
+ /* 1. Update userspace version. */
+ write_atomic(&map->version, src->version);
+ smp_wmb();
+
+ /* 2. Update all other userspace fields. */
+ *map = *src;
+
+ /* 3. Update userspace version again. */
+ smp_wmb();
+ write_atomic(&map->version, version_update_end(src->version));
+}
+
bool update_secondary_system_time(struct vcpu *v,
struct vcpu_time_info *u)
{
XEN_GUEST_HANDLE(vcpu_time_info_t) user_u = v->arch.time_info_guest;
+ struct vcpu_time_info *map = v->arch.time_guest_area.map;
struct guest_memory_policy policy = { .nested_guest_mode = false };
+ if ( map )
+ {
+ write_time_guest_area(map, u);
+ return true;
+ }
+
if ( guest_handle_is_null(user_u) )
return true;
--
2.42.0
|