|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 4/7] xen/p2m: move xenmem_access_to_p2m_access() to common p2m.c
Memory access and ALTP2M are two seperate features, while both depending on
helper xenmem_access_to_p2m_access(). So it betters lives in common p2m.c,
other than mem_access.c which will be compiled out when VM_EVENT=n && ALTP2M=y.
Coding style has been corrected at the same time.
Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v3 -> v4:
- new commit
---
xen/arch/x86/mm/mem_access.c | 36 ----------------------------------
xen/arch/x86/mm/p2m.c | 38 ++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index e6b609064c..e55e53f44c 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -298,42 +298,6 @@ static int set_mem_access(struct domain *d, struct
p2m_domain *p2m,
return rc;
}
-bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
- xenmem_access_t xaccess,
- p2m_access_t *paccess)
-{
- static const p2m_access_t memaccess[] = {
-#define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac
- ACCESS(n),
- ACCESS(r),
- ACCESS(w),
- ACCESS(rw),
- ACCESS(x),
- ACCESS(rx),
- ACCESS(wx),
- ACCESS(rwx),
- ACCESS(rx2rw),
- ACCESS(n2rwx),
- ACCESS(r_pw),
-#undef ACCESS
- };
-
- switch ( xaccess )
- {
- case 0 ... ARRAY_SIZE(memaccess) - 1:
- xaccess = array_index_nospec(xaccess, ARRAY_SIZE(memaccess));
- *paccess = memaccess[xaccess];
- break;
- case XENMEM_access_default:
- *paccess = p2m->default_access;
- break;
- default:
- return false;
- }
-
- return true;
-}
-
/*
* Set access type for a region of gfns.
* If gfn == INVALID_GFN, sets the default access type.
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index e2a00a0efd..f2bf5ef8d3 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2189,6 +2189,44 @@ void p2m_log_dirty_range(struct domain *d, unsigned long
begin_pfn,
guest_flush_tlb_mask(d, d->dirty_cpumask);
}
+bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
+ xenmem_access_t xaccess,
+ p2m_access_t *paccess)
+{
+ static const p2m_access_t memaccess[] = {
+#define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac
+ ACCESS(n),
+ ACCESS(r),
+ ACCESS(w),
+ ACCESS(rw),
+ ACCESS(x),
+ ACCESS(rx),
+ ACCESS(wx),
+ ACCESS(rwx),
+ ACCESS(rx2rw),
+ ACCESS(n2rwx),
+ ACCESS(r_pw),
+#undef ACCESS
+ };
+
+ switch ( xaccess )
+ {
+ case 0 ... ARRAY_SIZE(memaccess) - 1:
+ xaccess = array_index_nospec(xaccess, ARRAY_SIZE(memaccess));
+ *paccess = memaccess[xaccess];
+ break;
+
+ case XENMEM_access_default:
+ *paccess = p2m->default_access;
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
/*
* Local variables:
* mode: C
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |