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

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


  • To: Julien Grall <julien@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 29 Oct 2021 16:16:34 +0200
  • 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=2oTJ6W23QdVUOafx/bi+G+TCm9+9zHxj5wEeDKO78bk=; b=X/IXvSW30Byva2LT/IXzIDNFHzyRj1v2U2kiTYldSRLXXfpzdWru7Y4SpAClL5KG3fmX9tHv4020mITovc+9pP0bAbQpzUAbxLupQVE2/7f/LH8EKh0MuIwun9WZxnFG3B/49gR4wYVn0YUTs9JjnesVtEl2Oh6DGDzj24vHt8V2LVmPPiqCT39tU1ArkZgoghsOLgKLu6KXIyMlrAZg0KfTpAGyzm7/URHmM7BSZ1wjVrKZPfpP50fHZDSRvTCSo6IekcBijd2bu4b6YLUduT8nb7s9mnSXCDChm5CnjLqBdihQRXZBINFd5X/DE8PWj5KPYWPzK/8ewAB37SLPEg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BdTwtUC/ZxdiKt81lzv/CTifD+Q3fYDZkI7IgrWAKYkTW1E9sJUY3EKx2Vaao7TBtsXjQ/YSIpthZXyHx4ds9zBsPgdGoMq9wSRYQmKr6qufvdWtVtyLyvVf4GuVVMAevc5BuUHqPJVOK7ntxoiMFaFdHRdrvsq0TAW/j3JlZdC4JeGvg502KLX2xkTkv71m9I7P+QulvPqhEXFouJIhbz8ImyMBFT7Id0RzpwxmNxA465PyC4+/Tax4zQc/0qR9oQ0THBeR0WFVH6T5Dq7ib/UgNtpELR9ExJBD/qV8UpHmNx80uQXLAC+G7vjzGQg0/22qFmeAv34O2WXrZZJiEw==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, 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>
  • Delivery-date: Fri, 29 Oct 2021 14:17:05 +0000
  • Ironport-data: A9a23:LhPjTqDhQI2OTRVW/3Xlw5YqxClBgxIJ4kV8jS/XYbTApGgr1DYHy 2sZW2iDa/6LamChftF0ao238ExXv8DQztJmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLGs1hxZH1c+EX5500M7wYbVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/0miXrdooy cVxrY3zEy4Jbpadkc4ATEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHvqSuYUFg25YasZmAafaZ 8w6bQVWTS/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 RMHa4i3gVQSY6eMjHUO+xmQTtFZtMppVX2Uc43htgNvsbwy2aun3Mmb4RF+ct7wphAO+SRha1k rHsQKRODap4gjAqjlu2lVcX0
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 29, 2021 at 02:25:22PM +0100, Julien Grall wrote:
> On 29/10/2021 12:04, Roger Pau Monné wrote:
> > Hello,
> 
> Hi Roger,
> 
> > On Fri, Oct 29, 2021 at 11:01:29AM +0100, Julien Grall wrote:
> > > 
> > > 
> > > On 29/10/2021 10:41, Roger Pau Monné wrote:
> > > > On Fri, Oct 29, 2021 at 09:58:55AM +0100, Julien Grall wrote:
> > > > > On 29/10/2021 08:59, Roger Pau Monne wrote:
> > > > > > diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> > > > > > index e510395d08..f94f0f272c 100644
> > > > > > --- a/xen/common/grant_table.c
> > > > > > +++ b/xen/common/grant_table.c
> > > > > > @@ -53,6 +53,7 @@ struct grant_table {
> > > > > >         percpu_rwlock_t       lock;
> > > > > >         /* Lock protecting the maptrack limit */
> > > > > >         spinlock_t            maptrack_lock;
> > > > > > +    unsigned int          max_version;
> > > > > >         /*
> > > > > >          * Defaults to v1.  May be changed with 
> > > > > > GNTTABOP_set_version.  All other
> > > > > >          * values are invalid.
> > > > > > @@ -1917,11 +1918,33 @@ 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 == XEN_DOMCTL_GRANT_version_default )
> > > > > > +        max_grant_version = opt_gnttab_max_version;
> > > > > > +    if ( !max_grant_version )
> > > > > > +    {
> > > > > > +        dprintk(XENLOG_INFO, "%pd: invalid grant table version 0 
> > > > > > requested\n",
> > > > > > +                d);
> > > > > > +        return -EINVAL;
> > > > > > +    }
> > > > > > +    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;
> > > > > > +    }
> > > > > > +    if ( unlikely(max_page >= PFN_DOWN(TB(16))) && is_pv_domain(d) 
> > > > > > &&
> > > > > 
> > > > >   From my understanding, the limit for the grant table v1 is based on 
> > > > > the page
> > > > > granularity used and the size of the fields.
> > > > > 
> > > > > So the limit you add is valid for 4KB but not 16KB/64KB. Therefore, I 
> > > > > think
> > > > > it would be better to use:
> > > > > 
> > > > > 'max_page >= (1U << 32)'
> > > > 
> > > > I'm slightly confused. Isn't Xen always using a 4KB page granularity,
> > > 
> > > Yes. We only support 4KB today. But most of Xen is agnostic to the page
> > > granularity. I have actually started to look to allow 64KB/16KB page
> > > granularity for Xen on Arm in my spare time.
> > > 
> > > > and that also applies to the grant table entries?
> > > The page granularity for the hypercall interface is whatever the page
> > > granularity Xen is using. So...
> > 
> > I've somehow assumed that the current hypercall ABI was strictly tied
> > to 4KB pages, as that's for example already hardcoded in Linux
> > as XEN_PAGE_SIZE.
> 
> It is a mess. Before, XEN_PAGE_SIZE was introduced, we were assuming that
> Linux and Xen were using the same page granularity.
> 
> When I introduced the support to run guest with 16KB and 64KB, then we
> decided to introduce the define. Looking back at the decision, this was a
> mistake and we should have introduced an hypercall to fetch the ABI
> granularity instead.
> 
> > 
> > > > 
> > > > I don't think it's possible to use correctly use a 16KB or 64KB page
> > > > as an entry for the grant table, as Xen assumes those to always be 4KB
> > > > based.
> > > 
> > > ... if you build Xen with 16KB, then the grant table entries will be using
> > > 16KB.
> > > 
> > > So I would like to avoid making the assumption that we are always using 
> > > 4KB.
> > > That said, the worse that can happen is a spurious message. So this is 
> > > more
> > > to get an accurate check.
> > 
> > I don't have strong objections to using max_page >> 32, it might even
> > be clearer than checking against TB(16).

FWIW, I've changed the check to use >> 32 and limited it to
CONFIG_64BIT, since on 32bit arches max_page will be a 32bit value.

Thanks, Roger.



 


Rackspace

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