This commit makes the altp2m_flush compatible with ARM by replacing the
x86-specific set view visibility code with the architecture independent
altp2m_set_view_visibility locked.
This is commit 2/2 of the altp2m_flush phase.
Signed-off-by: Rose Spangler <Rose.Spangler@elektrobit.com>
---
v6: Introduced this patch.
There is a small amount of additional overhead introduced on x86 by
replacing these direct array sets with calls to
altp2m_set_view_visibility_locked. That function also calls
altp2m_is_eptp_valid, which performs additional checks, and also bounds
the array sets with array_index_nospec, which isn't technically
necessary here since we can be certain that the array set will be less
than nr_altp2m. This could be resolved by introducing another
altp2m_set_view_visibility variant (ex.
altp2m_set_view_visibility_unchecked?) which would replace usages of
altp2m_set_view_visibility_locked, but I'm not sure if the overhead is
enough to matter here.
---
xen/common/altp2m.c | 5 +----
xen/include/xen/altp2m.h | 2 --
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index 0dd3ecf226fd..d980ebed08ab 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -123,7 +123,6 @@ 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;
@@ -133,13 +132,11 @@ void altp2m_flush(struct domain *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_set_view_visibility_locked(d, i, 0);
}
altp2m_unlock(d);
}
-#endif
/*
* altp2m operations are envisioned as being used in several different
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index fa2c11f5432e..5222c24ef418 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -74,10 +74,8 @@ 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 */
--
2.34.1