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

Re: [PATCH for-4.16 v5] gnttab: allow setting max version per-domain


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 4 Nov 2021 10:16:33 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gKKk0XoB4XQUp49SgpGlaWSDRxe1hJkXB8hf87pfg0Y=; b=Yudn4HsE3uhSJ2lhvOsF16Q4dlj741AAqnq2ZuUHmjoApCSfC7NXsy3VrLcYbFTliJP7pw/HcyQ3UZUiUp+jQcoPnAKzKpViXGmy23AsnL1GJdT7l2ac4E5I9aqCi/fIbIVEWksMifAjZLHYlWNrO3fwmTcY7lCkr0gZ5tGcAEBVr2Q7c6G2/MmPPQc8ViRWPIYrH8SrOLjp41fvjwI7UK1M0JjKhnwmjiON4zJSQmBTfZPIea28t+VLo6bDEoi0gMM5E5Pv5v98Ih37cBBVo7PuDyz+PFy2lS7dAgv67Wj7BIBGWpTnW3EKd6lw0juRawt5sdSyFeq6dJpgRT7W5w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SHxwfaTxYyAEvhminN5EECqSzMDiwNhNRNK8ibJOsbKrhb7vA8W+QTfVAysA0tDpitp49wlXqJSDTZVbyO3TdfTZtQ8nJVkyxrNLajV7/kuapdvGOl33addY49MRWST/bKNYVazDlZjKIyRtPP6UuWyAFdAjJvzDjHxszS3ld57Vm4yNLbMxag1ly8IRxwwtVwMLnbRW2Mbe0gDLM6uSfp2xwBKaC2vmtVJx2bhj2pQZ6D/aCoYiLY0i22gL/aO4WqRdrEtnkE8I2YItToBDdWUT89jrJJ1LT1Q68M6lqRgluy1lZFccqmME+0D4rtvyAhtyJlHpBQZ4oHQeJWbVAw==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 04 Nov 2021 09:16:53 +0000
  • Ironport-data: A9a23:y2Hd56P4mspPS5PvrR31kcFynXyQoLVcMsEvi/4bfWQNrUp0hWdSy GUcXj2GOvzcMWb8Lt0nbtni90IO7ZHRzNdlTgto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6bUsxNbVU8En540Eo/w7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozeAjo9Tk dltj7ybcydyJLfPosI9QQYNRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YvNrick5atHiIasUu216zCGfBvEjKXzGa/iVvYICgW1q7ixINb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28Se6Hj6Dh7XmCkPUZLAK/RNx9DvBJL+uLkZxFU xkEZ7+hSmExK/MtexSngBTecfs5kyYRuD3UwuaHtLeTuB7zeJZ187WTwTFFY6Gth5ctlK3UDX5 eVCdNzeDX+RocU8DqzKEaxa3
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Nov 04, 2021 at 09:55:03AM +0100, Jan Beulich wrote:
> On 03.11.2021 15:57, Roger Pau Monne wrote:
> > --- a/tools/libs/light/libxl_create.c
> > +++ b/tools/libs/light/libxl_create.c
> > @@ -454,6 +454,28 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
> >          libxl_defbool_setdefault(&b_info->nested_hvm,               false);
> >      }
> >  
> > +    if (b_info->max_grant_version == LIBXL_MAX_GRANT_DEFAULT) {
> > +        libxl_physinfo info;
> > +
> > +        rc = libxl_get_physinfo(CTX, &info);
> > +        if (rc) {
> > +            LOG(ERROR, "failed to get hypervisor info");
> > +            return rc;
> > +        }
> > +
> > +        if (info.cap_gnttab_v2)
> > +            b_info->max_grant_version = 2;
> > +        else if (info.cap_gnttab_v1)
> > +            b_info->max_grant_version = 1;
> > +        else
> > +            /* No grant table support reported */
> > +            b_info->max_grant_version = 0;
> > +    } else if (b_info->max_grant_version & ~XEN_DOMCTL_GRANT_version_mask) 
> > {
> 
> Aren't you introducing a dependency of a stable library on an unstable
> interface here? I'm surprised this even builds, as I didn't expect
> libxl sources to include domctl.h in the first place.

libxl API is stable, but not it's ABI, and libxl strictly depends and
uses domctl. See for example libxl__domain_make and it's usage of
xen_domctl_createdomain.

I think the usage here of XEN_DOMCTL_GRANT_version_mask is fine.

> > @@ -219,6 +220,13 @@ static void parse_global_config(const char *configfile,
> >      else if (e != ESRCH)
> >          exit(1);
> >  
> > +    e = xlu_cfg_get_bounded_long (config, "max_grant_version", 0,
> > +                                  INT_MAX, &l, 1);
> > +    if (!e)
> > +        max_grant_version = l;
> > +    else if (e != ESRCH)
> > +        exit(1);
> 
> Would be kind of nice if out-of-range values were detected and
> reported right here, rather than causing puzzling errors at domain
> creation. But I have no idea whether doing so would be inconsistent
> with the processing of other global settings.

Hm, it could be done but doesn't seem to be common. AFAICT
parse_global_config just reads the values from the config file,
whether those values are sane doesn't seem to be implemented there.

> > @@ -1917,11 +1918,26 @@ active_alloc_failed:
> >  }
> >  
> >  int grant_table_init(struct domain *d, int max_grant_frames,
> > -                     int max_maptrack_frames)
> > +                     int max_maptrack_frames, unsigned int options)
> >  {
> >      struct grant_table *gt;
> > +    unsigned int max_grant_version = options & 
> > XEN_DOMCTL_GRANT_version_mask;
> >      int ret = -ENOMEM;
> >  
> > +    if ( !max_grant_version )
> > +    {
> > +        dprintk(XENLOG_INFO, "%pd: invalid grant table version 0 
> > requested\n",
> > +                d);
> > +        return -EINVAL;
> > +    }
> 
> Wouldn't 0 rather be the most natural way to request no gnttab at all
> for a domain? (Arguably making things work that way could be left to
> a future change.)

Indeed, but that's not part of this change. I will post an updated
version of the grant disabling patch separately, as I don't think
that's 4.16 material.

> > +    if ( max_grant_version > opt_gnttab_max_version )
> > +    {
> > +        dprintk(XENLOG_INFO,
> > +                "%pd: requested grant version (%u) greater than supported 
> > (%u)\n",
> > +                d, max_grant_version, opt_gnttab_max_version);
> > +        return -EINVAL;
> > +    }
> > +
> >      /* Default to maximum value if no value was specified */
> >      if ( max_grant_frames < 0 )
> >          max_grant_frames = opt_max_grant_frames;
> 
> Neither here nor in domain_create() you check that the other bits of
> "options" are zero.

Right, will add.

> > @@ -69,7 +69,8 @@ int gnttab_acquire_resource(
> >  
> >  static inline int grant_table_init(struct domain *d,
> >                                     int max_grant_frames,
> > -                                   int max_maptrack_frames)
> > +                                   int max_maptrack_frames,
> > +                                   unsigned int options)
> >  {
> >      return 0;
> >  }
> 
> While arbitrary table size requests may be okay to ignore here, I'm
> unsure about the max-version: Requesting v3 is surely an error in any
> event; I'd even be inclined to suggest requesting v1 or v2 is as
> well. Adding such a check here looks like it would be compatible with
> all the other adjustments you're making.

I think if the grant table is disabled at build time we should only
accept version 0 as valid here.

Thanks, Roger.



 


Rackspace

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