From: Julien Grall Date: Mon, 16 Jul 2018 17:27:10 +0000 (+0100) Subject: xen/arm: p2m: Introduce a new variable removing_mapping in __p2m_set_entry X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~3408 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1cd5d824c716280db4b5799d9aa64ca2f0730f72;p=xen.git xen/arm: p2m: Introduce a new variable removing_mapping in __p2m_set_entry This is making the code slightly easier to understand. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e0904bcf1d..56b5474625 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -778,6 +778,8 @@ static int __p2m_set_entry(struct p2m_domain *p2m, unsigned int target = 3 - (page_order / LPAE_SHIFT); lpae_t *entry, *table, orig_pte; int rc; + /* A mapping is removed if the MFN is invalid. */ + bool removing_mapping = mfn_eq(smfn, INVALID_MFN); /* Convenience aliases */ const unsigned int offsets[4] = { @@ -803,9 +805,9 @@ static int __p2m_set_entry(struct p2m_domain *p2m, { /* * Don't try to allocate intermediate page table if the mapping - * is about to be removed (i.e mfn == INVALID_MFN). + * is about to be removed. */ - rc = p2m_next_level(p2m, mfn_eq(smfn, INVALID_MFN), + rc = p2m_next_level(p2m, removing_mapping, level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) { @@ -816,7 +818,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * when removing a mapping as it may not exist in the * page table. In this case, just ignore it. */ - rc = mfn_eq(smfn, INVALID_MFN) ? 0 : -ENOENT; + rc = removing_mapping ? 0 : -ENOENT; goto out; } else if ( rc != GUEST_TABLE_NORMAL_PAGE ) @@ -911,7 +913,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, if ( lpae_is_valid(orig_pte) ) p2m_remove_pte(entry, p2m->clean_pte); - if ( mfn_eq(smfn, INVALID_MFN) ) + if ( removing_mapping ) /* Flush can be deferred if the entry is removed */ p2m->need_flush |= !!lpae_is_valid(orig_pte); else