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

[PATCH v2 4/6] libxc: use multicall for memory-op on Linux (and Solaris)


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 22 Jun 2021 17:19:04 +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-SenderADCheck; bh=PwPksR3zOXlIg4DjGCbrhutFiluGq2C63mB3WLwPcfg=; b=a8mBeyHUwTDt1boieaUJo9i4xWpV30HOBBCh4Kb3FT2DhvMKpbrpGw7gmKqyYcF3SIHZF+n3GnrJjm+AGcStdIv1a4dvFiwUPrZ8+HnIcrhJ4JXoJll+OOFYtU1ZDIeIdTanE6CadO/XeBB0HncyP0/LBe+w2c4bCL2O3EsDCQX/SsfpFjsG5EcbtlP/HCPRdsVoVWqmc9yfpTc/Q5jIOFJl8JP7/59H+McreytCRCpA+cGnc07dXu+9cX3FZh0h+5ARqey6bHVA4P82vGIrdZ3VrzXAxUkboGAxI5A80QAG+GTnZIXzGeMxiECpfUcYZspfoq1lbGh2C79J8dJWaQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OoF6GGcQ0TodynqEUwR3HXb+4LvimWVBOX/LWgojfN4MABHmlIwTimmPclQeJB6KFsM8RV/Acxr35rJJTsr84zgTSvDpTEeHFYLVA/EIdN701YpzshuR3ZBweWPlfNDo+gl3O67h8omnrRo0MfU2RlFeFOfdrYYywOmr6ilM/vUjhS+m5jmTxS7cotbD8vsk1BNNl6rIqNdAiCCSbK3GSwM3CfpHMgkklyIw2CkU0YlLxjOUGuQdtSbxzyy6w8RwHkTeHX8k0Q8y64+cIUST3pRiOgaAVmwSVfqzdjGT3tOTWKEkm2UH822obVXs8l35i4wshaPX8jfR19pvl3xkag==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Tue, 22 Jun 2021 15:19:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Some sub-functions, XENMEM_maximum_gpfn and XENMEM_maximum_ram_page in
particular, can return values requiring more than 31 bits to represent.
Hence we cannot issue the hypercall directly when the return value of
ioctl() is used to propagate this value (note that this is not the case
for the BSDs, and MiniOS already wraps all hypercalls in a multicall).

Suggested-by: Jürgen Groß <jgross@xxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>

--- a/tools/libs/ctrl/xc_private.c
+++ b/tools/libs/ctrl/xc_private.c
@@ -337,8 +337,47 @@ long do_memory_op(xc_interface *xch, int
         goto out1;
     }
 
-    ret = xencall2(xch->xcall, __HYPERVISOR_memory_op,
-                   cmd, HYPERCALL_BUFFER_AS_ARG(arg));
+#if defined(__linux__) || defined(__sun__)
+    /*
+     * Some sub-ops return values which don't fit in "int". On platforms
+     * without a specific hypercall return value field in the privcmd
+     * interface structure, issue the request as a single-element multicall,
+     * to be able to capture the full return value.
+     */
+    if ( sizeof(long) > sizeof(int) )
+    {
+        multicall_entry_t multicall = {
+            .op = __HYPERVISOR_memory_op,
+            .args[0] = cmd,
+            .args[1] = HYPERCALL_BUFFER_AS_ARG(arg),
+        }, *call = &multicall;
+        DECLARE_HYPERCALL_BOUNCE(call, sizeof(*call),
+                                 XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+
+        if ( xc_hypercall_bounce_pre(xch, call) )
+        {
+            PERROR("Could not bounce buffer for memory_op hypercall");
+            goto out1;
+        }
+
+        ret = do_multicall_op(xch, HYPERCALL_BUFFER(call), 1);
+
+        xc_hypercall_bounce_post(xch, call);
+
+        if ( !ret )
+        {
+            ret = multicall.result;
+            if ( multicall.result > ~0xfffUL )
+            {
+                errno = -ret;
+                ret = -1;
+            }
+        }
+    }
+    else
+#endif
+        ret = xencall2L(xch->xcall, __HYPERVISOR_memory_op,
+                        cmd, HYPERCALL_BUFFER_AS_ARG(arg));
 
     xc_hypercall_bounce_post(xch, arg);
  out1:




 


Rackspace

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