[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH v6 24/43] altp2m: Move altp2m_{get,set}_altp2m to common code



From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>

This commit moves the altp2m_get_altp2m and altp2m_set_altp2m functions to
the common code. This make sit possible to use them in other common
routines (namely, altp2m_vcpu_{initialise,destroy}).

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

This is commit 1/4 of the altp2m_{get,set}_altp2m phase.

Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
---
 xen/arch/x86/include/asm/altp2m.h | 35 -------------------------
 xen/arch/x86/include/asm/domain.h |  2 --
 xen/common/altp2m.c               |  1 -
 xen/include/xen/altp2m.h          | 43 +++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/xen/arch/x86/include/asm/altp2m.h 
b/xen/arch/x86/include/asm/altp2m.h
index 13017525a62f..a1b078783b3e 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -64,39 +64,6 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
  * Alternate p2m: shadow p2m tables used for alternate memory views
  */
 
-/* get current alternate p2m table */
-static inline struct p2m_domain *altp2m_get_altp2m(struct vcpu *v)
-{
-    unsigned int index = vcpu_altp2m(v).p2midx;
-
-    if ( index == INVALID_ALTP2M )
-        return NULL;
-
-    BUG_ON(index >= v->domain->nr_altp2m);
-
-    return v->domain->altp2m_p2m[index];
-}
-
-/* set current alternate p2m table */
-static inline bool altp2m_set_altp2m(struct vcpu *v, unsigned int idx)
-{
-    struct p2m_domain *orig;
-
-    BUG_ON(idx >= v->domain->nr_altp2m);
-
-    if ( idx == vcpu_altp2m(v).p2midx )
-        return false;
-
-    orig = altp2m_get_altp2m(v);
-    BUG_ON(!orig);
-    atomic_dec(&orig->active_vcpus);
-
-    vcpu_altp2m(v).p2midx = idx;
-    atomic_inc(&v->domain->altp2m_p2m[idx]->active_vcpus);
-
-    return true;
-}
-
 /* Switch alternate p2m for a single vcpu */
 bool altp2m_switch_vcpu_by_id(struct vcpu *v, unsigned int idx);
 
@@ -178,8 +145,6 @@ static inline int _altp2m_get_effective_entry(struct 
p2m_domain *ap2m,
         _altp2m_get_effective_entry(ap2m, gfn, mfn, t, a)
 
 /* Only declaration is needed. DCE will optimise it out when linking. */
-struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
-bool altp2m_set_altp2m(struct vcpu *v, unsigned int idx);
 uint16_t altp2m_vcpu_idx(const struct vcpu *v);
 void altp2m_vcpu_initialise(struct vcpu *v);
 void altp2m_vcpu_destroy(struct vcpu *v);
diff --git a/xen/arch/x86/include/asm/domain.h 
b/xen/arch/x86/include/asm/domain.h
index f8038087e612..72460e38f581 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -277,8 +277,6 @@ struct paging_vcpu {
 #define MAX_NR_ALTP2M   MAX_EPTP
 #define MAX_NESTEDP2M   10
 
-#define INVALID_ALTP2M  0xffff
-
 struct p2m_domain;
 struct time_scale {
     int shift;
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index 989d8bdcb923..a731ad7cdab8 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -5,7 +5,6 @@
 #include <xen/xvmalloc.h>
 
 #include <asm/altp2m.h>
-#include <asm/p2m.h>
 
 #include <public/hvm/params.h>
 
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index 238c7a935586..58e74be6deb0 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -8,6 +8,10 @@
 
 #include <public/hvm/hvm_op.h>
 
+#include <asm/p2m.h>
+
+#define INVALID_ALTP2M  0xffff
+
 /*
  * Common alternate p2m declarations that need to be visible
  * regardless of CONFIG_ALTP2M
@@ -27,6 +31,41 @@ static inline bool altp2m_active(const struct domain *d)
     return d->altp2m_active;
 }
 
+#ifdef CONFIG_X86
+/* get current alternate p2m table */
+static inline struct p2m_domain *altp2m_get_altp2m(struct vcpu *v)
+{
+    unsigned int index = vcpu_altp2m(v).p2midx;
+
+    if ( index == INVALID_ALTP2M )
+        return NULL;
+
+    BUG_ON(index >= v->domain->nr_altp2m);
+
+    return v->domain->altp2m_p2m[index];
+}
+
+/* set current alternate p2m table */
+static inline bool altp2m_set_altp2m(struct vcpu *v, unsigned int idx)
+{
+    struct p2m_domain *orig;
+
+    BUG_ON(idx >= v->domain->nr_altp2m);
+
+    if ( idx == vcpu_altp2m(v).p2midx )
+        return false;
+
+    orig = altp2m_get_altp2m(v);
+    BUG_ON(!orig);
+    atomic_dec(&orig->active_vcpus);
+
+    vcpu_altp2m(v).p2midx = idx;
+    atomic_inc(&v->domain->altp2m_p2m[idx]->active_vcpus);
+
+    return true;
+}
+#endif
+
 int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg);
 
 #else /* CONFIG_ALTP2M */
@@ -41,6 +80,10 @@ static inline int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) 
arg)
     return -EOPNOTSUPP;
 }
 
+/* Only declaration is needed. DCE will optimise it out when linking. */
+struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
+bool altp2m_set_altp2m(struct vcpu *v, unsigned int idx);
+
 #endif /* CONFIG_ALTP2M */
 
 #endif /* __XEN_ALTP2M_H__ */
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.