Drop the inner scope that was left from earlier if/else removal. Take
the opportunity and make the paging_unlock() invocation common to
success and error paths, though.
Signed-off-by: Jan Beulich
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -110,49 +110,43 @@ static int write_p2m_entry(struct p2m_do
unsigned int level)
{
struct domain *d = p2m->domain;
-
+unsigned int oflags;
+mfn_t omfn;
+int rc;
+
+paging_lock(d);
+
+if ( p2m->write_p2m_entry_pre && gfn != gfn_x(INVALID_GFN) )
+p2m->write_p2m_entry_pre(d, gfn, *p, new, level);
+
+oflags = l1e_get_flags(*p);
+omfn = l1e_get_mfn(*p);
+
+rc = p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
+ p2m_flags_to_type(oflags), l1e_get_mfn(new),
+ omfn, level);
+if ( !rc )
{
-unsigned int oflags;
-mfn_t omfn;
-int rc;
-
-paging_lock(d);
-
-if ( p2m->write_p2m_entry_pre && gfn != gfn_x(INVALID_GFN) )
-p2m->write_p2m_entry_pre(d, gfn, *p, new, level);
-
-oflags = l1e_get_flags(*p);
-omfn = l1e_get_mfn(*p);
-
-rc = p2m_entry_modify(p2m, p2m_flags_to_type(l1e_get_flags(new)),
- p2m_flags_to_type(oflags), l1e_get_mfn(new),
- omfn, level);
-if ( rc )
-{
-paging_unlock(d);
-return rc;
-}
-
safe_write_pte(p, new);
if ( p2m->write_p2m_entry_post )
p2m->write_p2m_entry_post(p2m, oflags);
+}
-paging_unlock(d);
+paging_unlock(d);
-if ( nestedhvm_enabled(d) && !p2m_is_nestedp2m(p2m) &&
- (oflags & _PAGE_PRESENT) &&
- !p2m_get_hostp2m(d)->defer_nested_flush &&
- /*
- * We are replacing a valid entry so we need to flush nested p2ms,
- * unless the only change is an increase in access rights.
- */
- (!mfn_eq(omfn, l1e_get_mfn(new)) ||
- !perms_strictly_increased(oflags, l1e_get_flags(new))) )
-p2m_flush_nestedp2m(d);
-}
+if ( !rc && nestedhvm_enabled(d) && !p2m_is_nestedp2m(p2m) &&
+ (oflags & _PAGE_PRESENT) &&
+ !p2m_get_hostp2m(d)->defer_nested_flush &&
+ /*
+ * We are replacing a valid entry so we need to flush nested p2ms,
+ * unless the only change is an increase in access rights.
+ */
+ (!mfn_eq(omfn, l1e_get_mfn(new)) ||
+ !perms_strictly_increased(oflags, l1e_get_flags(new))) )
+p2m_flush_nestedp2m(d);
-return 0;
+return rc;
}
// Find the next level's P2M entry, checking for out-of-range gfn's...