|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 14/43] altp2m: Move altp2m_{init,teardown} to common code
From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
This commit moves the init and teardown routines into common code. The
functions are gated by CONFIG_X86, so there is effectively no difference
despite common code normally being compiled for ARM.
This commit contains only renames/code movement, and no functional change is
intended.
This is commit 3/12 of the altp2m_init/altp2m_teardown routines phase.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
---
xen/arch/x86/include/asm/altp2m.h | 8 -----
xen/arch/x86/mm/altp2m.c | 45 ----------------------------
xen/arch/x86/mm/p2m-basic.c | 1 +
xen/common/altp2m.c | 49 +++++++++++++++++++++++++++++++
xen/include/xen/altp2m.h | 13 ++++++++
5 files changed, 63 insertions(+), 53 deletions(-)
diff --git a/xen/arch/x86/include/asm/altp2m.h
b/xen/arch/x86/include/asm/altp2m.h
index 7cff40beb7c6..13017525a62f 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -97,12 +97,6 @@ static inline bool altp2m_set_altp2m(struct vcpu *v,
unsigned int idx)
return true;
}
-/* Initialize altp2m views */
-int altp2m_init(struct domain *d);
-
-/* Free altp2m views */
-void altp2m_teardown(struct domain *d);
-
/* Switch alternate p2m for a single vcpu */
bool altp2m_switch_vcpu_by_id(struct vcpu *v, unsigned int idx);
@@ -184,8 +178,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. */
-int altp2m_init(struct domain *d);
-void altp2m_teardown(struct domain *d);
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);
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 371bf3f0b8d4..46374373848d 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -123,51 +123,6 @@ void altp2m_vcpu_disable_ve(struct vcpu *v)
}
}
-int altp2m_init(struct domain *d)
-{
- unsigned int i;
- struct p2m_domain *p2m;
- struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
-
- altp2m_lock_init(d);
- d->altp2m_p2m = xvzalloc_array(struct p2m_domain *, d->nr_altp2m);
-
- if ( !d->altp2m_p2m )
- return -ENOMEM;
-
- for ( i = 0; i < d->nr_altp2m; i++ )
- {
- d->altp2m_p2m[i] = p2m = p2m_init_one(d);
- if ( p2m == NULL )
- {
- altp2m_teardown(d);
- return -ENOMEM;
- }
- p2m->p2m_class = p2m_alternate;
- p2m->access_required = hostp2m->access_required;
- _atomic_set(&p2m->active_vcpus, 0);
- }
-
- return 0;
-}
-
-void altp2m_teardown(struct domain *d)
-{
- unsigned int i;
- struct p2m_domain *p2m;
-
- for ( i = 0; i < d->nr_altp2m; i++ )
- {
- if ( !d->altp2m_p2m[i] )
- continue;
- p2m = d->altp2m_p2m[i];
- d->altp2m_p2m[i] = NULL;
- p2m_free_one(p2m);
- }
-
- XVFREE(d->altp2m_p2m);
-}
-
int altp2m_get_effective_entry(struct p2m_domain *ap2m, gfn_t gfn, mfn_t *mfn,
p2m_type_t *t, p2m_access_t *a,
bool prepopulate)
diff --git a/xen/arch/x86/mm/p2m-basic.c b/xen/arch/x86/mm/p2m-basic.c
index 433e7d08b78f..67cef5d2b6ef 100644
--- a/xen/arch/x86/mm/p2m-basic.c
+++ b/xen/arch/x86/mm/p2m-basic.c
@@ -11,6 +11,7 @@
* Parts based on earlier work by Michael A Fetterman, Ian Pratt et al.
*/
+#include <xen/altp2m.h>
#include <xen/event.h>
#include <xen/types.h>
#include <asm/altp2m.h>
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index 3a3283f0860a..cda653b713f0 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -2,8 +2,10 @@
#include <xen/altp2m.h>
#include <xen/guest_access.h>
#include <xen/vm_event.h>
+#include <xen/xvmalloc.h>
#include <asm/altp2m.h>
+#include <asm/p2m.h>
#include <public/hvm/params.h>
@@ -13,6 +15,53 @@
#include <asm/hvm/nestedhvm.h>
#endif
+#if CONFIG_X86
+int altp2m_init(struct domain *d)
+{
+ unsigned int i;
+ struct p2m_domain *p2m;
+ struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
+
+ altp2m_lock_init(d);
+ d->altp2m_p2m = xvzalloc_array(struct p2m_domain *, d->nr_altp2m);
+
+ if ( !d->altp2m_p2m )
+ return -ENOMEM;
+
+ for ( i = 0; i < d->nr_altp2m; i++ )
+ {
+ d->altp2m_p2m[i] = p2m = p2m_init_one(d);
+ if ( p2m == NULL )
+ {
+ altp2m_teardown(d);
+ return -ENOMEM;
+ }
+ p2m->p2m_class = p2m_alternate;
+ p2m->access_required = hostp2m->access_required;
+ _atomic_set(&p2m->active_vcpus, 0);
+ }
+
+ return 0;
+}
+
+void altp2m_teardown(struct domain *d)
+{
+ unsigned int i;
+ struct p2m_domain *p2m;
+
+ for ( i = 0; i < d->nr_altp2m; i++ )
+ {
+ if ( !d->altp2m_p2m[i] )
+ continue;
+ p2m = d->altp2m_p2m[i];
+ d->altp2m_p2m[i] = NULL;
+ p2m_free_one(p2m);
+ }
+
+ XVFREE(d->altp2m_p2m);
+}
+#endif /* CONFIG_X86 */
+
/*
* 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 be627152668a..85ef22c2b29e 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -8,6 +8,19 @@
#include <public/hvm/hvm_op.h>
+/*
+ * Common alternate p2m declarations that need to be visible
+ * regardless of CONFIG_ALTP2M
+ */
+
+#ifdef CONFIG_X86
+/* Initialize altp2m views */
+int altp2m_init(struct domain *d);
+
+/* Free altp2m views */
+void altp2m_teardown(struct domain *d);
+#endif
+
#ifdef CONFIG_ALTP2M
/* Alternate p2m HVM on/off per domain */
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |