Message ID | 1502800232-26670-7-git-send-email-andrew.cooper3@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 15.08.17 at 14:30, <andrew.cooper3@citrix.com> wrote: > Remove the opencoded rcu_lock_domain_by_any_id(). Drop the PIN_FAIL()s and > return GNTST_* values directly. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> with one optional extra request: > --- a/xen/common/grant_table.c > +++ b/xen/common/grant_table.c > @@ -2390,28 +2390,21 @@ struct gnttab_copy_buf { > bool_t have_type; > }; > > -static int gnttab_copy_lock_domain(domid_t domid, unsigned int gref_flag, > +static int gnttab_copy_lock_domain(domid_t domid, bool is_gref, > struct gnttab_copy_buf *buf) > { > - int rc; > + /* Only DOMID_SELF may reference via frame. */ > + if ( domid != DOMID_SELF && !is_gref ) > + return GNTST_permission_denied; > > - if ( domid != DOMID_SELF && !gref_flag ) > - PIN_FAIL(out, GNTST_permission_denied, > - "only allow copy-by-mfn for DOMID_SELF.\n"); > + buf->domain = rcu_lock_domain_by_any_id(domid); > > - if ( domid == DOMID_SELF ) > - buf->domain = rcu_lock_current_domain(); > - else > - { > - buf->domain = rcu_lock_domain_by_id(domid); > - if ( buf->domain == NULL ) > - PIN_FAIL(out, GNTST_bad_domain, "couldn't find %d\n", domid); > - } > + if ( buf->domain == NULL ) Use ! here? Jan
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 615a8b4..38e470a 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2390,28 +2390,21 @@ struct gnttab_copy_buf { bool_t have_type; }; -static int gnttab_copy_lock_domain(domid_t domid, unsigned int gref_flag, +static int gnttab_copy_lock_domain(domid_t domid, bool is_gref, struct gnttab_copy_buf *buf) { - int rc; + /* Only DOMID_SELF may reference via frame. */ + if ( domid != DOMID_SELF && !is_gref ) + return GNTST_permission_denied; - if ( domid != DOMID_SELF && !gref_flag ) - PIN_FAIL(out, GNTST_permission_denied, - "only allow copy-by-mfn for DOMID_SELF.\n"); + buf->domain = rcu_lock_domain_by_any_id(domid); - if ( domid == DOMID_SELF ) - buf->domain = rcu_lock_current_domain(); - else - { - buf->domain = rcu_lock_domain_by_id(domid); - if ( buf->domain == NULL ) - PIN_FAIL(out, GNTST_bad_domain, "couldn't find %d\n", domid); - } + if ( buf->domain == NULL ) + return GNTST_bad_domain; buf->ptr.domid = domid; - rc = GNTST_okay; - out: - return rc; + + return GNTST_okay; } static void gnttab_copy_unlock_domains(struct gnttab_copy_buf *src,
Remove the opencoded rcu_lock_domain_by_any_id(). Drop the PIN_FAIL()s and return GNTST_* values directly. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: George Dunlap <George.Dunlap@eu.citrix.com> CC: Jan Beulich <JBeulich@suse.com> CC: Stefano Stabellini <sstabellini@kernel.org> CC: Tim Deegan <tim@xen.org> CC: Wei Liu <wei.liu2@citrix.com> --- xen/common/grant_table.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)