|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/7] gnttab: limit scope of transitive-only variables in acquire_grant_for_copy()
Especially their use outside of the transitive grant handling code can be
confusing. Two of the variables were merely used as aliases in the "needs
pin update" path, while one of them was purely used because it's available
in the "already pinned" case.
trans_{page_off,length} remain where they are: They're misnamed imo, and
would better be sub_page_{off,len}.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -2608,9 +2608,6 @@ acquire_grant_for_copy(
grant_status_t *status;
unsigned int shflags;
uint32_t old_pin;
- domid_t trans_domid;
- grant_ref_t trans_gref;
- struct domain *td;
mfn_t grant_mfn;
uint16_t trans_page_off;
uint16_t trans_length;
@@ -2662,6 +2659,10 @@ acquire_grant_for_copy(
old_pin = act->pin;
if ( sha2 && (shflags & GTF_type_mask) == GTF_transitive )
{
+ domid_t trans_domid;
+ grant_ref_t trans_gref;
+ struct domain *td;
+
if ( (!old_pin || (!readonly &&
!(old_pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask))))
&&
(rc = _set_status_v2(shah, status, rd, act, readonly, 0,
@@ -2803,8 +2804,6 @@ acquire_grant_for_copy(
readonly, 0, ldom)) != GNTST_okay )
goto unlock_out;
- td = rd;
- trans_gref = gref;
if ( !sha2 )
{
gfn = shared_entry_v1(rgt, gref).frame;
@@ -2841,16 +2840,16 @@ acquire_grant_for_copy(
act->is_sub_page = is_sub_page;
act->start = trans_page_off;
act->length = trans_length;
- act->src_domid = td->domain_id;
- act->trans_gref = trans_gref;
+ act->src_domid = rd->domain_id;
+ act->trans_gref = gref;
act->mfn = grant_mfn;
if ( is_sub_page )
atomic_inc(&rgt->nr_v2_ops);
}
else if ( !mfn_eq(act->mfn, grant_mfn) ||
- act->src_domid != td->domain_id ||
- act->trans_gref != trans_gref ||
+ act->src_domid != rd->domain_id ||
+ act->trans_gref != gref ||
(act->is_sub_page &&
(!is_sub_page ||
act->start != trans_page_off ||
@@ -2866,9 +2865,11 @@ acquire_grant_for_copy(
}
else
{
+ struct domain *d;
+
ASSERT(mfn_valid(act->mfn));
*page = mfn_to_page(act->mfn);
- td = page_get_owner_and_reference(*page);
+ d = page_get_owner_and_reference(*page);
/*
* act->pin being non-zero should guarantee the page to have a
* non-zero refcount and hence a valid owner (matching the one on
@@ -2877,9 +2878,9 @@ acquire_grant_for_copy(
* updates pin counts before obtaining page references, for
* example).
*/
- if ( td != rd || rd->is_dying )
+ if ( d != rd || rd->is_dying )
{
- if ( td )
+ if ( d )
put_page(*page);
*page = NULL;
rc = GNTST_bad_domain;
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |