aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/mm
diff options
context:
space:
mode:
authorTim Deegan <tim@xen.org>2013-03-07 14:08:24 +0000
committerTim Deegan <tim@xen.org>2013-03-14 10:36:01 +0000
commit1ab3eea9d8873cb0c60e59d55a89c2f1842a5063 (patch)
tree41492733267fd1e612ffc570f23491b2bce5402a /xen/arch/x86/mm
parent6524455339349779c553af949b81d3d46f051797 (diff)
downloadxen-1ab3eea9d8873cb0c60e59d55a89c2f1842a5063.tar.gz
xen-1ab3eea9d8873cb0c60e59d55a89c2f1842a5063.tar.bz2
xen-1ab3eea9d8873cb0c60e59d55a89c2f1842a5063.zip
x86/mem_sharing: check for errors in p2m->set_entry().
This call ought always to succeed. Assert that it does rather than ignoring the return value. Signed-off-by: Tim Deegan <tim@xen.org> Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Acked-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/mm')
-rw-r--r--xen/arch/x86/mm/mem_sharing.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 1caa9000fc..0364bb048e 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1273,6 +1273,8 @@ int relinquish_shared_pages(struct domain *d)
p2m_access_t a;
p2m_type_t t;
mfn_t mfn;
+ int set_rc;
+
if ( atomic_read(&d->shr_pages) == 0 )
break;
mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL);
@@ -1281,10 +1283,12 @@ int relinquish_shared_pages(struct domain *d)
/* Does not fail with ENOMEM given the DESTROY flag */
BUG_ON(__mem_sharing_unshare_page(d, gfn,
MEM_SHARING_DESTROY_GFN));
- /* Clear out the p2m entry so no one else may try to
- * unshare */
- p2m->set_entry(p2m, gfn, _mfn(0), PAGE_ORDER_4K,
- p2m_invalid, p2m_access_rwx);
+ /* Clear out the p2m entry so no one else may try to
+ * unshare. Must succeed: we just read the old entry and
+ * we hold the p2m lock. */
+ set_rc = p2m->set_entry(p2m, gfn, _mfn(0), PAGE_ORDER_4K,
+ p2m_invalid, p2m_access_rwx);
+ ASSERT(set_rc != 0);
count++;
}