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

[PATCH 2/2][4.17?] x86: wire up VCPUOP_register_vcpu_time_memory_area for 32-bit guests


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 29 Sep 2022 11:51:40 +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=8ZUSWYGYKpp/n4o39lEQC3Rdxp/5hH97CjYq0VBAQYI=; b=ZOEXnSHTYYlljHNAOFp1HZw3fC+tb1hwHh8uqZ2P6IBZIlF7nREOJp1i50PDN/dqUH2YsU+HA/PPcguk0dnfIZw1pZPcoYUuHVloWzyWD8dZ6fruXT/5MFzb8LavI/rCRvCDOqnGsm5rxW0ix8FKipaPFePtU2Xwd1rNdiQgRDS/rp4dGYL0pQYzjSNYh8ApDn7llrjvCfIWsoQbGPYP5KP85aYir/RQbsdNr0kvNmgEO9pIQVjvgxGgF1kTxuLckOduJACnjmDwqeB4+8SZlp+GR8TWSk+0wf3tybxCdmTfFu8Ss1O6bIUA0ZGSfpbidSpQIPUAFIRMBKpeOotznA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Um44iDY80XmzcMlLtS6N8A0ynJTcsxm9wFfNc4LWo3RWm+/INPezGtBGjM7F45kpxJw4IvRNHW7I5XDhx5F+/vsHV33RfEVe38hbGRKZUUxSy20QirwOeYwbM2Dyg6hkI7RyXj7FKWH+tp56rZUWZ4wTzRlXlrz+Y/6peN5o0FExo3S80Fh368MSHqno2z9PeMO8zZz+idiNmMjEReQ5E9wD7cLphLvg4Um9R00bmzqQF+gx23GVxvgg/nvTyaOMBuUANMwK1spiO8pTg+2jZhQ/UE744wE+p2b8Mb3hd5O+eQW9FuntZo+2VMhjQOA9FVv9F5+eJdn9YcQzIgG//g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Thu, 29 Sep 2022 09:51:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Forever sinced its introduction VCPUOP_register_vcpu_time_memory_area
was available only to native domains. Linux, for example, would attempt
to use it irrespective of guest bitness (including in its so called
PVHVM mode) as long as it finds XEN_PVCLOCK_TSC_STABLE_BIT set (which we
set only for clocksource=tsc, which in turn needs engaging via command
line option).

Fixes: a5d39947cb89 ("Allow guests to register secondary vcpu_time_info")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Is it actually correct for us to do cross-vCPU updates of the area here
(and also in the native counterpart as well as for runstate area
updates)? The virtual address may be valid for the given vCPU only, but
may be mapped to something else on the current vCPU (yet we only deal
with it not being mapped at all). Note how HVM code already calls
update_vcpu_system_time() only when v == current.

I'm surprised by Linux not using the secondary area in a broader
fashion. But I'm also surprised that they would only ever register an
area for vCPU 0.

--- a/xen/arch/x86/x86_64/domain.c
+++ b/xen/arch/x86/x86_64/domain.c
@@ -58,6 +58,26 @@ compat_vcpu_op(int cmd, unsigned int vcp
         break;
     }
 
+    case VCPUOP_register_vcpu_time_memory_area:
+    {
+        struct compat_vcpu_register_time_memory_area area = { .addr.p = 0 };
+
+        rc = -EFAULT;
+        if ( copy_from_guest(&area.addr.h, arg, 1) )
+            break;
+
+        if ( area.addr.h.c != area.addr.p ||
+             !compat_handle_okay(area.addr.h, 1) )
+            break;
+
+        rc = 0;
+        guest_from_compat_handle(v->arch.time_info_guest, area.addr.h);
+
+        force_update_vcpu_system_time(v);
+
+        break;
+    }
+
     case VCPUOP_send_nmi:
     case VCPUOP_get_physid:
         rc = do_vcpu_op(cmd, vcpuid, arg);




 


Rackspace

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