[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.9] xen/grant_table: Rework the prototype of _set_status* for lisibility
commit 84f81a8bb625862e48b8c51492f85b1ee891c196 Author: Julien Grall <julien.grall@xxxxxxx> AuthorDate: Mon Apr 29 15:05:17 2019 +0100 Commit: Julien Grall <julien.grall@xxxxxxx> CommitDate: Fri Jun 14 14:49:19 2019 +0100 xen/grant_table: Rework the prototype of _set_status* for lisibility It is not clear from the parameters name whether domid and gt_version correspond to the local or remote domain. A follow-up patch will make them more confusing. So rename domid (resp. gt_version) to ldomid (resp. rgt_version). At the same time re-order the parameters to hopefully make it more readable. This is part of XSA-295. Suggested-by: Jan Beulich <jbeulich@xxxxxxxx> Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx> --- xen/common/grant_table.c | 57 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 5b338e95ff..670ae8e3aa 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -545,11 +545,11 @@ static unsigned int nr_grant_entries(struct grant_table *gt) return 0; } -static int _set_status_v1(domid_t domid, +static int _set_status_v1(const grant_entry_header_t *shah, + struct active_grant_entry *act, int readonly, int mapflag, - grant_entry_header_t *shah, - struct active_grant_entry *act) + domid_t ldomid) { int rc = GNTST_okay; union grant_combo scombo, prev_scombo, new_scombo; @@ -584,11 +584,11 @@ static int _set_status_v1(domid_t domid, if ( !act->pin && (((scombo.shorts.flags & mask) != GTF_permit_access) || - (scombo.shorts.domid != domid)) ) + (scombo.shorts.domid != ldomid)) ) PIN_FAIL(done, GNTST_general_error, "Bad flags (%x) or dom (%d). (expected dom %d)\n", scombo.shorts.flags, scombo.shorts.domid, - domid); + ldomid); new_scombo = scombo; new_scombo.shorts.flags |= GTF_reading; @@ -617,12 +617,12 @@ done: return rc; } -static int _set_status_v2(domid_t domid, +static int _set_status_v2(const grant_entry_header_t *shah, + grant_status_t *status, + struct active_grant_entry *act, int readonly, int mapflag, - grant_entry_header_t *shah, - struct active_grant_entry *act, - grant_status_t *status) + domid_t ldomid) { int rc = GNTST_okay; union grant_combo scombo; @@ -648,10 +648,10 @@ static int _set_status_v2(domid_t domid, if ( !act->pin && ( (((flags & mask) != GTF_permit_access) && ((flags & mask) != GTF_transitive)) || - (id != domid)) ) + (id != ldomid)) ) PIN_FAIL(done, GNTST_general_error, "Bad flags (%x) or dom (%d). (expected dom %d, flags %x)\n", - flags, id, domid, mask); + flags, id, ldomid, mask); if ( readonly ) { @@ -678,7 +678,7 @@ static int _set_status_v2(domid_t domid, { if ( (((flags & mask) != GTF_permit_access) && ((flags & mask) != GTF_transitive)) || - (id != domid) || + (id != ldomid) || (!readonly && (flags & GTF_readonly)) ) { gnttab_clear_flag(_GTF_writing, status); @@ -686,7 +686,7 @@ static int _set_status_v2(domid_t domid, PIN_FAIL(done, GNTST_general_error, "Unstable flags (%x) or dom (%d). (expected dom %d) " "(r/w: %d)\n", - flags, id, domid, !readonly); + flags, id, ldomid, !readonly); } } else @@ -704,19 +704,19 @@ done: } -static int _set_status(unsigned gt_version, - domid_t domid, +static int _set_status(const grant_entry_header_t *shah, + grant_status_t *status, + unsigned rgt_version, + struct active_grant_entry *act, int readonly, int mapflag, - grant_entry_header_t *shah, - struct active_grant_entry *act, - grant_status_t *status) + domid_t ldomid) { - if (gt_version == 1) - return _set_status_v1(domid, readonly, mapflag, shah, act); + if ( rgt_version == 1 ) + return _set_status_v1(shah, act, readonly, mapflag, ldomid); else - return _set_status_v2(domid, readonly, mapflag, shah, act, status); + return _set_status_v2(shah, status, act, readonly, mapflag, ldomid); } static struct active_grant_entry *grant_map_exists(const struct domain *ld, @@ -884,9 +884,9 @@ __gnttab_map_grant_ref( (!(op->flags & GNTMAP_readonly) && !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask))) ) { - if ( (rc = _set_status(rgt->gt_version, ld->domain_id, - op->flags & GNTMAP_readonly, - 1, shah, act, status) ) != GNTST_okay ) + if ( (rc = _set_status(shah, status, rgt->gt_version, act, + op->flags & GNTMAP_readonly, 1, + ld->domain_id) != GNTST_okay) ) goto act_release_out; if ( !act->pin ) @@ -2258,8 +2258,8 @@ __acquire_grant_for_copy( { if ( (!old_pin || (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)))) && - (rc = _set_status_v2(ldom, readonly, 0, shah, act, - status)) != GNTST_okay ) + (rc = _set_status_v2(shah, status, act, readonly, 0, + ldom)) != GNTST_okay ) goto unlock_out; if ( !allow_transitive ) @@ -2357,9 +2357,8 @@ __acquire_grant_for_copy( else if ( !old_pin || (!readonly && !(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask))) ) { - if ( (rc = _set_status(rgt->gt_version, ldom, - readonly, 0, shah, act, - status) ) != GNTST_okay ) + if ( (rc = _set_status(shah, status, rgt->gt_version, act, + readonly, 0, ldom)) != GNTST_okay ) goto unlock_out; td = rd; -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.9 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |