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@suse.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Julien Grall committed 2019-06-14 14:27:32 +01:00
1 parent 5e1b9cb0f2
commit 863e74eb2c
1 file changed
+28 -29
+28 -29
View File
@@ -670,11 +670,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;
@@ -709,11 +709,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 d%d\n",
scombo.shorts.flags, scombo.shorts.domid,
domid);
ldomid);
new_scombo = scombo;
new_scombo.shorts.flags |= GTF_reading;
@@ -742,12 +742,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;
@@ -773,10 +773,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 d%d, flags %x\n",
flags, id, domid, mask);
flags, id, ldomid, mask);
if ( readonly )
{
@@ -803,14 +803,14 @@ 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);
gnttab_clear_flag(_GTF_reading, status);
PIN_FAIL(done, GNTST_general_error,
"Unstable flags (%x) or dom (%d); expected d%d (r/w: %d)\n",
flags, id, domid, !readonly);
flags, id, ldomid, !readonly);
}
}
else
@@ -828,19 +828,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,
@@ -1005,9 +1005,9 @@ 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 )
@@ -2459,8 +2459,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 )
@@ -2560,9 +2560,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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.