|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 30/43] arm/altp2m: Add altp2m view validity/visibility indicator
From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
This commit adds the altp2m_view_state enum, which indicates whether an
altp2m view is invalid, visible, or invisible. The altp2m_state array is
comprised of altp2m_view_state values, where each entry corresponds to the
altp2m view with the same entry. This is analogous to the altp2m_eptp and
altp2m_visible_eptp arrays on x86.
This addition is necessary to tell whether an altp2m is valid, in addition
to whether it is visible. Since all altp2m views are allocated up-front
during p2m initialization, there must be an additional mechanism to
determine whether an altp2m view is valid. Since the implementation of
HVMOP_altp2m_set_visibility also needs an additional mechanism to determine
whether a view is visible, it makes sense to combine altp2m view validity
and visibility into a single mechanism. Therefore, the altp2m_state array
is used to track both view validitity and visibility.
This is commit 1/5 of the altp2m view validity/visibility phase.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
In the v4/v5 patch series, view validity was determined by simply
checking if the altp2m p2m_domain pointer is NULL. This isn't possible
in the v6 patch series, since altp2m views are allocated up-front
during altp2m_init.
Since the altp2m_view_state enum definition has to be available in
asm/domain.h, this commit removes the sched.h dependency from altp2m.h.
Unfortunately, this means that it's not possible to have static inline
functions in altp2m.h which need a complete definition of arch_domain
and arch_vcpu. If there would be a better place to put the
altp2m_view_state definition, feedback would be appreciated.
---
xen/arch/arm/altp2m.c | 13 +++++++++++++
xen/arch/arm/include/asm/altp2m.h | 23 +++++++++++++----------
xen/arch/arm/include/asm/domain.h | 4 ++++
xen/arch/arm/mmu/p2m.c | 14 +++++++++++++-
4 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 339f82835caf..e741648ff5a1 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -5,6 +5,8 @@
* Copyright (c) 2016 Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
*/
+#include <xen/sched.h>
+
#include <asm/p2m.h>
/* Check to see if vcpu should be switched to a different p2m. */
@@ -14,6 +16,17 @@ void altp2m_check(struct vcpu *v, uint16_t idx)
BUG();
}
+/* Alternate p2m VCPU */
+uint16_t altp2m_vcpu_idx(const struct vcpu *v)
+{
+ return v->arch.ap2m_idx;
+}
+
+void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx)
+{
+ v->arch.ap2m_idx = idx;
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/arch/arm/include/asm/altp2m.h
b/xen/arch/arm/include/asm/altp2m.h
index f001e022a213..05beb7f698a7 100644
--- a/xen/arch/arm/include/asm/altp2m.h
+++ b/xen/arch/arm/include/asm/altp2m.h
@@ -9,7 +9,10 @@
#ifndef __ASM_ARM_ALTP2M_H
#define __ASM_ARM_ALTP2M_H
-#include <xen/sched.h>
+#include <xen/mem_access.h>
+
+struct domain;
+struct vcpu;
#ifdef CONFIG_ALTP2M
@@ -24,15 +27,15 @@ static inline bool altp2m_supported(void)
#define altp2m_unlock(d) spin_unlock(&(d)->arch.altp2m_lock)
/* Alternate p2m VCPU */
-static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
-{
- return v->arch.ap2m_idx;
-}
-
-static inline void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx)
-{
- v->arch.ap2m_idx = idx;
-}
+uint16_t altp2m_vcpu_idx(const struct vcpu *v);
+void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx);
+
+/* The current state of an altp2m view */
+enum altp2m_view_state {
+ ALTP2M_INVALID,
+ ALTP2M_VISIBLE,
+ ALTP2M_INVISIBLE,
+};
#else /* CONFIG_ALTP2M */
diff --git a/xen/arch/arm/include/asm/domain.h
b/xen/arch/arm/include/asm/domain.h
index 4d497a21b648..28533b08db1f 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -3,6 +3,7 @@
#include <xen/cache.h>
#include <xen/timer.h>
+#include <asm/altp2m.h>
#include <asm/page.h>
#include <asm/p2m.h>
#include <asm/suspend.h>
@@ -135,6 +136,9 @@ struct arch_domain
* concurrently.
*/
spinlock_t altp2m_lock;
+
+ /* Validity/visibility of altp2m views */
+ enum altp2m_view_state *altp2m_state;
#endif
} __cacheline_aligned;
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index 04d17e787259..7c23995f8074 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -1494,6 +1494,8 @@ int p2m_teardown(struct domain *d)
d->altp2m_active = false;
+ FREE_XENHEAP_PAGE(d->arch.altp2m_state);
+
for ( i = 0; i < d->nr_altp2m; i++ )
{
rc = p2m_teardown_one(d->altp2m_p2m[i]);
@@ -1617,7 +1619,7 @@ struct p2m_domain *p2m_init_one(struct domain *d)
static int p2m_init_altp2m(struct domain *d)
{
#ifdef CONFIG_ALTP2M
- int rc;
+ int rc, i;
rc = altp2m_init(d);
if ( rc )
@@ -1626,6 +1628,16 @@ static int p2m_init_altp2m(struct domain *d)
return rc;
}
+ if ( (d->arch.altp2m_state = alloc_xenheap_page()) == NULL )
+ {
+ return -ENOMEM;
+ }
+
+ for ( i = 0; i < d->nr_altp2m; i++ )
+ {
+ d->arch.altp2m_state[i] = ALTP2M_INVALID;
+ }
+
d->altp2m_active = false;
#endif
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |