[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/mm: get_page_from_l1e() is PV-or-shadow-only



commit a5c41f94d983637ddc3f13b08d11c3d4bb254382
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Sep 23 09:00:00 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Sep 23 10:00:43 2026 +0200

    x86/mm: get_page_from_l1e() is PV-or-shadow-only
    
    Otherwise the function is unreachable, violating MISRA C:2012 rule 2.1.
    With the function compiled out, its dedicated XSM hook also becomes
    unreachable, so it is similarly guarded.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/include/asm/mm.h | 7 +++++--
 xen/arch/x86/mm.c             | 4 ++++
 xen/include/xsm/dummy.h       | 2 ++
 xen/include/xsm/hooks.h       | 2 ++
 xen/xsm/flask/hooks.c         | 2 ++
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h
index 2254a7e3fe..aa515efbee 100644
--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -404,10 +404,13 @@ int  get_page_type(struct page_info *page, unsigned long 
type);
 int  put_page_type_preemptible(struct page_info *page);
 int  get_page_type_preemptible(struct page_info *page, unsigned long type);
 int  put_old_guest_table(struct vcpu *v);
-int  get_page_from_l1e(
-    l1_pgentry_t l1e, struct domain *l1e_owner, struct domain *pg_owner);
 void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner);
 
+#if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
+int get_page_from_l1e(
+    l1_pgentry_t l1e, struct domain *l1e_owner, struct domain *pg_owner);
+#endif
+
 static inline struct page_info *get_page_from_mfn(mfn_t mfn, struct domain *d)
 {
     struct page_info *page = mfn_to_page(mfn);
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index b158742408..452bbd59e3 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -795,6 +795,8 @@ bool is_memory_hole(mfn_t start, mfn_t end)
     return true;
 }
 
+#if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
+
 #ifndef NDEBUG
 struct mmio_emul_range_ctxt {
     const struct domain *d;
@@ -1037,6 +1039,8 @@ get_page_from_l1e(
     return -EBUSY;
 }
 
+#endif /* CONFIG_PV || CONFIG_SHADOW_PAGING */
+
 /*
  * The following flags are used to specify behavior of various get and
  * put commands.  The first is also stored in page->partial_flags to
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index 65df405dbf..6331859afa 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -701,12 +701,14 @@ static XSM_INLINE int xsm_update_va_mapping(
 
 #endif /* CONFIG_PV */
 
+#if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
 static XSM_INLINE int xsm_priv_mapping(
     XSM_DEFAULT_ARG struct domain *d, struct domain *t)
 {
     XSM_ASSERT_ACTION(XSM_TARGET);
     return xsm_default_action(action, d, t);
 }
+#endif
 
 static XSM_INLINE int xsm_ioport_permission(
     XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, bool allow)
diff --git a/xen/include/xsm/hooks.h b/xen/include/xsm/hooks.h
index 87cf6e5af6..a331f5f0e5 100644
--- a/xen/include/xsm/hooks.h
+++ b/xen/include/xsm/hooks.h
@@ -141,7 +141,9 @@ XSM_HOOK(int, mmu_update, struct domain *, struct domain *, 
struct domain *,
 XSM_HOOK(int, mmuext_op, struct domain *, struct domain *)
 XSM_HOOK(int, update_va_mapping, struct domain *, struct domain *, 
l1_pgentry_t)
 #endif /* CONFIG_PV */
+#if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
 XSM_HOOK(int, priv_mapping, struct domain *, struct domain *)
+#endif
 XSM_HOOK(int, ioport_permission, struct domain *, uint32_t, uint32_t, bool)
 XSM_HOOK(int, ioport_mapping, struct domain *, uint32_t, uint32_t, bool)
 XSM_HOOK(int, pmu_op, struct domain *, unsigned int)
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index 902857415b..d65ba0aeae 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -1829,10 +1829,12 @@ static int cf_check flask_update_va_mapping(
 
 #endif /* CONFIG_PV */
 
+#if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
 static int cf_check flask_priv_mapping(struct domain *d, struct domain *t)
 {
     return domain_has_perm(d, t, SECCLASS_MMU, MMU__TARGET_HACK);
 }
+#endif
 
 static int cf_check flask_pmu_op(struct domain *d, unsigned int op)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.