diff mbox series

[for-4.19,v2,1/3] xen/x86: account number of foreign mappings in the p2m

Message ID 20240508112323.38946-2-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series xen/x86: support foreign mappings for HVM/PVH | expand

Commit Message

Roger Pau Monné May 8, 2024, 11:23 a.m. UTC
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>
---
Changes since v1:
 - Drop max_gfn accounting.
---
 xen/arch/x86/include/asm/p2m.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jan Beulich May 14, 2024, 2:37 p.m. UTC | #1
On 08.05.2024 13:23, Roger Pau Monne wrote:
> 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>
Yet I think it shouldn't be committed (much) ahead of patch 3.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 111badf89a6e..107b9f260848 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -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: