]> xenbits.xensource.com Git - xen.git/commitdiff
xen/x86: account number of foreign mappings in the p2m
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 29 May 2024 14:07:55 +0000 (16:07 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 29 May 2024 14:07:55 +0000 (16:07 +0200)
Such information will be needed in order to remove foreign mappings during
teardown for HVM guests.

Right now the introduced counter is not consumed.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
xen/arch/x86/include/asm/p2m.h

index 111badf89a6e55fbe0d5cc30854c973ba95f2344..107b9f260848af018fd9452b1470372b9f588ad4 100644 (file)
@@ -380,6 +380,9 @@ struct p2m_domain {
         unsigned int flags;
         unsigned long entry_count;
     } ioreq;
+
+    /* Number of foreign mappings. */
+    unsigned long      nr_foreign;
 #endif /* CONFIG_HVM */
 };
 
@@ -1049,6 +1052,8 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
         if ( !page_get_owner_and_reference(mfn_to_page(nfn)) )
             return -EBUSY;
 
+        p2m->nr_foreign++;
+
         break;
 
     default:
@@ -1069,6 +1074,7 @@ static inline int p2m_entry_modify(struct p2m_domain *p2m, p2m_type_t nt,
             return -EINVAL;
         }
         put_page(mfn_to_page(ofn));
+        p2m->nr_foreign--;
         break;
 
     default: