|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v6 31/43] altp2m: Add altp2m_view_is_{valid,visible}
From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
This commit adds arch independent helper functions to determine whether a
view is valid or visible. This makes it possible to determine whether a
view is valid and/or visible in common altp2m routines (namely,
altp2m_init_by_id).
This is commit 2/5 of the altp2m view validity/visibility phase.
Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
Signed-off-by: Aqib Javaid <Aqib.Javaid@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
These functions could be used to replace the equivalent calls in x86
code if that would be preferred. For now, they are only used in common
code.
The altp2m_view_is_valid function also has overlap with the
altp2m_is_ept_valid function, but that function has an additional
ASSERT and check that idx < d->nr_altp2m, so I wasn't sure if that
function should be repurposed for this. If renaming that function
instead of introducing a new function on x86 would be preferred, then I
can do that.
Additionally, these functions don't have bounds checks since the
functions are intended to replace code which don't have bounds checks
currently. Bounds checks could be added here if that would be
preferred.
---
xen/arch/arm/altp2m.c | 10 ++++++++++
xen/arch/arm/include/asm/altp2m.h | 3 +++
xen/arch/x86/include/asm/altp2m.h | 10 ++++++++++
3 files changed, 23 insertions(+)
diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index e741648ff5a1..0e19e197e826 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -27,6 +27,16 @@ void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx)
v->arch.ap2m_idx = idx;
}
+bool altp2m_view_is_valid(struct domain *d, unsigned int idx)
+{
+ return d->arch.altp2m_state[array_index_nospec(idx, d->nr_altp2m)] !=
ALTP2M_INVALID;
+}
+
+bool altp2m_view_is_visible(struct domain *d, unsigned int idx)
+{
+ return d->arch.altp2m_state[array_index_nospec(idx, d->nr_altp2m)] ==
ALTP2M_VISIBLE;
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/arch/arm/include/asm/altp2m.h
b/xen/arch/arm/include/asm/altp2m.h
index 05beb7f698a7..fbe66ad5536d 100644
--- a/xen/arch/arm/include/asm/altp2m.h
+++ b/xen/arch/arm/include/asm/altp2m.h
@@ -30,6 +30,9 @@ static inline bool altp2m_supported(void)
uint16_t altp2m_vcpu_idx(const struct vcpu *v);
void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx);
+bool altp2m_view_is_valid(struct domain *d, unsigned int idx);
+bool altp2m_view_is_visible(struct domain *d, unsigned int idx);
+
/* The current state of an altp2m view */
enum altp2m_view_state {
ALTP2M_INVALID,
diff --git a/xen/arch/x86/include/asm/altp2m.h
b/xen/arch/x86/include/asm/altp2m.h
index 43dd5d2acd9c..56ae19b24b42 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -65,6 +65,16 @@ static inline void altp2m_set_vcpu_idx(struct vcpu *v,
unsigned int idx)
vcpu_altp2m(v).p2midx = idx;
}
+static inline bool altp2m_view_is_valid(struct domain *d, unsigned int idx)
+{
+ return d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] !=
mfn_x(INVALID_MFN);
+}
+
+static inline bool altp2m_view_is_visible(struct domain *d, unsigned int idx)
+{
+ return d->arch.altp2m_visible_eptp[array_index_nospec(idx, MAX_EPTP)] !=
mfn_x(INVALID_MFN);
+}
+
/*
* Alternate p2m: shadow p2m tables used for alternate memory views
*/
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |