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

[PATCH v4 4/9] x86: update GADDR based secondary time area


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 28 Sep 2023 09:15:51 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=+s4DsrfFOHtuNkr1T98TjoML0TVrNHd1UjKvdCbUR0U=; b=bMSubdvkgcWfmCe9chRcwCNNKuVDfwi11y23lgtZKaWK6vZ7wcNCMnOkM4k7jZjgT6dAyB0DQi7YDlTAv5BJTfEYvw4Xtw4VDRi4V+KDX1nHe5d6Ipa9zEEwxOnwiC5ArrKjwnE+gGa984rb8ODGaR8snt6y+52+wbbRzjlbQPGy3M0g90Euy9XZTRDgG67/gL2pBW539EcF9zT/8zotT3n/NBsj8iztwLHuV6jmqBwednAfnyi8EZEdA4W5Y572JsqiKbwNWsCCPn/HQMN6IM1a3OjXeUeXAhCuj7Cv6QSQzzE5yUDDuYz5tDuoxqpUaxZNYmiqGUg3P1y/sKtkeQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ak/6LZXoGblaIYV1cb9K7e4Cjj7CbkKgr+dJxzx4e4bnDmAmRrZxJJ/5g3B+oZ7KQw/OTku7OO2l48MdWM2L/bhd8zV7oE/XhA7ljKFQSk3d1MBwuSz5iz2CJaWuhqEUwP1GywiuMUCW5ceSQBPT3zgZF5LPEeevkX5eEyzrLUnrL6sRcWKmQUCojbqgoYPyPHRlWPwNfKHiRbNvVAN6YHAz9Lt1YJWfnYFyKcXHiHwCmqAURgWPq1vYVRCOeaCYF2dZOoeZ3pfuY2nNefZEUTklQ9bSiYO7TWKzAIuF9qAW7rNbYDkNuH7e/MXfscdDyYZZpyhdegGILfxaQV8UnQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Thu, 28 Sep 2023 07:15:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1566,12 +1566,34 @@ static void __update_vcpu_system_time(st
         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;
 




 


Rackspace

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