|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen/p2m: move xenmem_access_to_p2m_access() to common p2m.c
commit 0288e87afca2b0602e625577d559929339943846
Author: Penny Zheng <Penny.Zheng@xxxxxxx>
AuthorDate: Thu Jan 15 17:28:39 2026 +0800
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jan 19 10:06:10 2026 +0100
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.
Guard xenmem_access_to_p2m_access() with VM_EVENT || ALTP2M, otherwise it
will become unreachable when both VM_EVENT=n and ALTP2M=n, and hence
violating Misra rule 2.1.
Also move declaration from xen/mem_access.h to x86'es one, requiring to also
move the inclusion point and condition of asm/mem_access.h there.
An extra blank line is inserted after each case-block to correct coding
style at the same time.
Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Acked-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
---
xen/arch/x86/include/asm/mem_access.h | 5 +++++
xen/arch/x86/mm/mem_access.c | 36 -------------------------------
xen/arch/x86/mm/p2m.c | 40 +++++++++++++++++++++++++++++++++++
xen/include/xen/mem_access.h | 11 +++-------
4 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/xen/arch/x86/include/asm/mem_access.h
b/xen/arch/x86/include/asm/mem_access.h
index 257ed33de1..84af05a8c6 100644
--- a/xen/arch/x86/include/asm/mem_access.h
+++ b/xen/arch/x86/include/asm/mem_access.h
@@ -34,6 +34,11 @@ bool p2m_mem_access_emulate_check(struct vcpu *v,
/* Sanity check for mem_access hardware support */
bool p2m_mem_access_sanity_check(const struct domain *d);
+struct p2m_domain;
+bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
+ xenmem_access_t xaccess,
+ p2m_access_t *paccess);
+
#endif /*__ASM_X86_MEM_ACCESS_H__ */
/*
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 759f3273d3..8d34357bcb 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2203,6 +2203,46 @@ void p2m_log_dirty_range(struct domain *d, unsigned long
begin_pfn,
guest_flush_tlb_mask(d, d->dirty_cpumask);
}
+#if defined(CONFIG_VM_EVENT) || defined(CONFIG_ALTP2M)
+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;
+}
+#endif /* VM_EVENT || ALTP2M */
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/xen/mem_access.h b/xen/include/xen/mem_access.h
index 4de651038d..998ec680d4 100644
--- a/xen/include/xen/mem_access.h
+++ b/xen/include/xen/mem_access.h
@@ -33,10 +33,6 @@
*/
struct vm_event_st;
-#ifdef CONFIG_VM_EVENT
-#include <asm/mem_access.h>
-#endif
-
/*
* Additional access types, which are used to further restrict
* the permissions given my the p2m_type_t memory type. Violations
@@ -73,10 +69,9 @@ typedef enum {
/* NOTE: Assumed to be only 4 bits right now on x86. */
} p2m_access_t;
-struct p2m_domain;
-bool xenmem_access_to_p2m_access(const struct p2m_domain *p2m,
- xenmem_access_t xaccess,
- p2m_access_t *paccess);
+#if defined(CONFIG_VM_EVENT) || defined(CONFIG_ALTP2M)
+#include <asm/mem_access.h>
+#endif
/*
* Set access type for a region of gfns.
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |