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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 18 Jun 2021 16:05:03 +0100
  • 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-SenderADCheck; bh=ZDjMWsaj6Rl70hTYyswO6JVzleQNxKz4HMeMONl6Ui0=; b=La1KwRCHkkei5z6elRlEI4BrTpiHivrsf4kBzIG9KaiC9XXJGk/4oeNS2YICu/wzxXXWQctPQJL+GaniVSTC17T0frvWxNRTKxJL9D476TnRWicYnAY+6cSrzfiDpwbkq/QIVx5AJDWwIU2GN4GnnE8hiFqXhZIMMiTxRQxD2WDyFb1nPDsRyJSgfiOjrXC4XuKU5058laeQktiO+OagzYtksjPN+IXE73M2dQC/0pYzlAZ7ZnmDBbW29OJOjMT4vHUixMP9pDNLPRGJb7i0bz8D7C9NLIDubvz5ob5PdnxceSZSwSB9V0qk4Ykd1oqSzNRgDgQZx6FACPApOp56dA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frNp4RJglU7NZyCmDo2/6p7wV1KmVn3+/1e2fLFHDT9tAhtkreRyPimWrk0EyF2c7rZGvSinZi9b5LmOAg+k5o0pwnO7iBjLp9jMswqSKWuFDC2Qw2faRKMkIMr2eTDyUbDrcm1nqeIdTDTehviGTr5ryUIx9jMvCVL5BHVgi5aQT18dBsCC1b2xKJt7ptKRvtuY/68V5LNmO6gwzvfF2ozrHIMMEEKwHosv5/n+IGmGr0NqKdoeSYasz3HS1O8DS/sjbjoYtzxG/nQdjafjJe2ZYacEa/gdQlt9hxtMbSLyoCaQxaL/clwEMy0EbhVZtwOyhZJ+ALGs6sbN/1ADFQ==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Fri, 18 Jun 2021 15:05:23 +0000
  • Ironport-hdrordr: A9a23:iT97XavLAIBTcfL2Ypm0hmqH7skDS9V00zEX/kB9WHVpm6yj/f xG785rrSMc7wxhI03I+OrwX5VoJEmwyXcb2/hyAV7PZmjbUQiTXeVfBOnZsljd8kTFn4Y3us ldmsNFeb7N5C1B/L/HCWeDc+rIuOP3lpxAWt2z80tQ
  • Ironport-sdr: RpjsP+j61I9W94Ea/15K25cc/RsRilGUnpYrONBTDqrR1nM9vfFAqcKRPJVNqALAJhu6x5EgWR yEkFPDxgH7fG050xMjt5xORvmmK+UqXSE1y4G0YcSLrUgwalePPtMozHhSUMny+LdVz2gExRNo zVrCS3ed09mvZu7LyCcJZT0R/icS1s2IcRP1WRnQ2JxU/9PaKM2hxT7dXRzUNGtvMW7rTMAoAc FHGlSIn6CJlmYsAWUOubGaDhMxSFuVkv0vG+OvQapP1Xb2r639klfjZsfAmYiWLgDyZ6HuuybT +Ms=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18/06/2021 11:24, Jan Beulich wrote:
> Some sub-functions, XENMEM_maximum_gpfn 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>
>
> --- 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) )

This is very fragile.  I spent a while coming up with

    __builtin_types_compatible_p(
        typeof(ioctl) *,
        long (*)(int, unsigned long, ...));

(which does work if you change int for long), just to realise that this
won't actually help.  I'm suck on trying to see whether
privcmd_hypercall_t has a result member.

> +    {
> +        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 )

Wouldn't this be clearer as > -4095 ?

~Andrew

> +            {
> +                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®.