[RFC PATCH v6 41/43] altp2m: Move altp2m_flush to common code

Rose Spangler posted 43 patches 3 months, 3 weeks ago
[RFC PATCH v6 41/43] altp2m: Move altp2m_flush to common code
Posted by Rose Spangler 3 months, 3 weeks ago
This commit moves the altp2m_flush function to common code. This makes it
possible to call in the common implementation of HVMOP_set_domain_state.

This commit contains only code movement, and no change in functionality is
intended.

This is commit 1/2 of the altp2m_flush phase.

Signed-off-by: Rose Spangler <Rose.Spangler@elektrobit.com>
---
v6: Introduced this patch.
---
 xen/arch/x86/include/asm/altp2m.h |  2 --
 xen/arch/x86/mm/altp2m.c          | 16 ----------------
 xen/common/altp2m.c               | 18 ++++++++++++++++++
 xen/include/xen/altp2m.h          |  5 +++++
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/include/asm/altp2m.h b/xen/arch/x86/include/asm/altp2m.h
index 02b5e1a11220..d11f20f1e790 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -82,8 +82,6 @@ static inline bool altp2m_view_is_visible(struct domain *d, unsigned int idx)
 /* Switch alternate p2m for a single vcpu */
 bool altp2m_switch_vcpu_by_id(struct vcpu *v, unsigned int idx);
 
-/* Flush all the alternate p2m's for a domain */
-void altp2m_flush(struct domain *d);
 
 /* Find an available alternate p2m and make it valid */
 int altp2m_init_next_available(struct domain *d, uint16_t *idx,
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 18f8a71f1682..de91d1e67709 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -253,22 +253,6 @@ void altp2m_reset_altp2m(struct domain *d, unsigned int idx,
     p2m_unlock(p2m);
 }
 
-void altp2m_flush(struct domain *d)
-{
-    unsigned int i;
-
-    altp2m_lock(d);
-
-    for ( i = 0; i < d->nr_altp2m; i++ )
-    {
-        altp2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE);
-        d->arch.altp2m_eptp[i] = mfn_x(INVALID_MFN);
-        d->arch.altp2m_visible_eptp[i] = mfn_x(INVALID_MFN);
-    }
-
-    altp2m_unlock(d);
-}
-
 int altp2m_activate_altp2m(struct domain *d, unsigned int idx,
                            p2m_access_t hvmmem_default_access)
 {
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index 929449b1b03c..0dd3ecf226fd 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -123,6 +123,24 @@ int altp2m_init_by_id(struct domain *d, unsigned int idx)
     return rc;
 }
 
+#ifdef CONFIG_X86
+void altp2m_flush(struct domain *d)
+{
+    unsigned int i;
+
+    altp2m_lock(d);
+
+    for ( i = 0; i < d->nr_altp2m; i++ )
+    {
+        altp2m_reset_altp2m(d, i, ALTP2M_DEACTIVATE);
+        d->arch.altp2m_eptp[i] = mfn_x(INVALID_MFN);
+        d->arch.altp2m_visible_eptp[i] = mfn_x(INVALID_MFN);
+    }
+
+    altp2m_unlock(d);
+}
+#endif
+
 /*
  * altp2m operations are envisioned as being used in several different
  * modes:
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index 8fc16346d95b..fa2c11f5432e 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -74,6 +74,11 @@ int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg);
 /* Make a specific alternate p2m valid */
 int altp2m_init_by_id(struct domain *d, unsigned int idx);
 
+#ifdef CONFIG_X86
+/* Flush all the alternate p2m's for a domain */
+void altp2m_flush(struct domain *d);
+#endif
+
 #else /* CONFIG_ALTP2M */
 
 static inline bool altp2m_active(const struct domain *d)
-- 
2.34.1