All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Roger Pau Monne <roger.pau@citrix.com>, xen-devel@lists.xenproject.org
Cc: Wei Liu <wl@xen.org>, Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Juergen Gross <jgross@suse.com>,
	Christian Lindig <christian.lindig@citrix.com>,
	David Scott <dave@recoil.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Ian Jackson <iwj@xenproject.org>
Subject: Re: [PATCH for-4.16 v4] gnttab: allow setting max version per-domain
Date: Fri, 29 Oct 2021 09:58:55 +0100	[thread overview]
Message-ID: <2e198e53-e3fb-4ea6-0c44-f326b5e5f5fc@xen.org> (raw)
In-Reply-To: <20211029075956.1260-1-roger.pau@citrix.com>

Hi Roger,

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)'

Furthermore, it would add a comment explaining where this limit comes from.

Lastly, did you check the compiler wouldn't throw an error on arm32?

> +         max_grant_version < 2 )
> +        dprintk(XENLOG_INFO,
> +                "%pd: host memory above 16Tb and grant table v2 disabled\n",
> +                d);

I would switch this one to a printk().

Cheers,

-- 
Julien Grall


  reply	other threads:[~2021-10-29  8:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29  7:59 [PATCH for-4.16 v4] gnttab: allow setting max version per-domain Roger Pau Monne
2021-10-29  8:58 ` Julien Grall [this message]
2021-10-29  9:41   ` Roger Pau Monné
2021-10-29 10:01     ` Julien Grall
2021-10-29 11:04       ` Roger Pau Monné
2021-10-29 13:25         ` Julien Grall
2021-10-29 14:16           ` Roger Pau Monné
2021-10-29 16:39 ` Andrew Cooper
2021-10-29 17:37   ` [PATCH for-4.16 1/2] tools/golang: Regenerate bindings Andrew Cooper
2021-11-01 10:42     ` Ian Jackson
2021-10-29 17:38   ` [PATCH for-4.16 2/2] xen: Report grant table v1/v2 capabilities to the toolstack Andrew Cooper
2021-10-30 11:20     ` Roger Pau Monné
2021-11-02 12:12       ` Jan Beulich
2021-11-02 14:14       ` Andrew Cooper
2021-11-01 10:01     ` Christian Lindig
2021-11-04 12:07     ` Ian Jackson
2021-11-04 14:02     ` Roger Pau Monné
2021-10-30  7:53   ` [PATCH for-4.16 v4] gnttab: allow setting max version per-domain Roger Pau Monné
2021-11-01 10:45     ` [PATCH for-4.16 v4] gnttab: allow setting max version per-domain [and 1 more messages] Ian Jackson
2021-11-02 14:34     ` [PATCH for-4.16 v4] gnttab: allow setting max version per-domain Andrew Cooper
2021-11-02 15:00       ` Julien Grall
2021-11-02 15:54         ` Andrew Cooper
2021-11-02 15:42       ` Roger Pau Monné
2021-11-02 12:19 ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e198e53-e3fb-4ea6-0c44-f326b5e5f5fc@xen.org \
    --to=julien@xen.org \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.