From 3270f9602d394d17f9adf4adce54b5f2a06c9c5f Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 22 Jun 2026 10:05:57 +0200 Subject: [PATCH] XSM: guard .sysctl() and .readconsole() hooks Leaving the hook pointers in struct xsm_ops when !SYSCTL would lead to the BUG_ON() in xsm_fixup_ops() triggering for respectively configured hypervisors. While moving the #ifdef for the corresponding xsm_*() wrappers, also move those for xsm_page_offline() (where the hook pointer field already is suitably guarded). Fixes: c9eabaa03a68 ("xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL") Fixes: bddd9af6049f ("xen/sysctl: wrap around XEN_SYSCTL_readconsole") Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Daniel P. Smith Release-Acked-by: Oleskii Kurochko --- xen/include/xsm/xsm.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index fb622c62ce..89823abbf8 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -61,8 +61,10 @@ struct xsm_ops { #endif int (*set_target)(struct domain *d, struct domain *e); int (*domctl)(struct domain *d, struct xen_domctl *op); +#ifdef CONFIG_SYSCTL int (*sysctl)(int cmd); int (*readconsole)(uint32_t clear); +#endif int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id2); int (*evtchn_interdomain)(struct domain *d1, struct evtchn *chn1, @@ -248,23 +250,17 @@ static inline int xsm_domctl(xsm_default_t def, struct domain *d, return alternative_call(xsm_ops.domctl, d, op); } +#ifdef CONFIG_SYSCTL static inline int xsm_sysctl(xsm_default_t def, int cmd) { -#ifdef CONFIG_SYSCTL return alternative_call(xsm_ops.sysctl, cmd); -#else - return -EOPNOTSUPP; -#endif } static inline int xsm_readconsole(xsm_default_t def, uint32_t clear) { -#ifdef CONFIG_SYSCTL return alternative_call(xsm_ops.readconsole, clear); -#else - return -EOPNOTSUPP; -#endif } +#endif static inline int xsm_evtchn_unbound( xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2) @@ -558,14 +554,12 @@ static inline int xsm_resource_setup_misc(xsm_default_t def) return alternative_call(xsm_ops.resource_setup_misc); } +#ifdef CONFIG_SYSCTL static inline int xsm_page_offline(xsm_default_t def, uint32_t cmd) { -#ifdef CONFIG_SYSCTL return alternative_call(xsm_ops.page_offline, cmd); -#else - return -EOPNOTSUPP; -#endif } +#endif static inline int xsm_hypfs_op(xsm_default_t def) {