x86/p2m: add PoD accounting to set_typed_p2m_entry()
authorJan Beulich <jbeulich@suse.com>
Wed, 23 Sep 2015 09:14:05 +0000 (11:14 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 23 Sep 2015 09:14:05 +0000 (11:14 +0200)
While neither PoD together with pass-through nor PVH are currently
supported we still shouldn't leave in place such latent issues.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/p2m.c

index e1d930a0af513365ac3f3bb7cb4b6f16fd6b165c..87b6a160269611416a84458284d0ed505062d688 100644 (file)
@@ -926,11 +926,19 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
     P2M_DEBUG("set %d %lx %lx\n", gfn_p2mt, gfn, mfn_x(mfn));
     rc = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, gfn_p2mt,
                        access);
-    gfn_unlock(p2m, gfn, 0);
     if ( rc )
         gdprintk(XENLOG_ERR,
                  "p2m_set_entry failed! mfn=%08lx rc:%d\n",
                  mfn_x(get_gfn_query_unlocked(p2m->domain, gfn, &ot)), rc);
+    else if ( p2m_is_pod(ot) )
+    {
+        pod_lock(p2m);
+        p2m->pod.entry_count--;
+        BUG_ON(p2m->pod.entry_count < 0);
+        pod_unlock(p2m);
+    }
+    gfn_unlock(p2m, gfn, 0);
+
     return rc;
 }