[PATCH v2 11/14] XSM: convert remaining event channel hooks
Jan Beulich <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <[email protected]> |
Make them follow the standard scheme, i.e. taking xsm_default_t as first argument at call sites. This way they can be covered by the recently introduced hook machinery. While there, uniformly convert struct evtchn chn[] notation to pointer form, as the (nicer) array representation is harder to make usable with the hooks.h logic. Signed-off-by: Jan Beulich <[email protected]> --- v2: New. --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -159,7 +159,7 @@ static void free_evtchn_bucket(struct do if ( !bucket ) return; - xsm_free_security_evtchns(bucket, EVTCHNS_PER_BUCKET); + xsm_free_security_evtchns(XSM_HOOK, bucket, EVTCHNS_PER_BUCKET); xfree(bucket); } @@ -172,7 +172,7 @@ static struct evtchn *alloc_evtchn_bucke if ( !chn ) goto err; - if ( xsm_alloc_security_evtchns(chn, EVTCHNS_PER_BUCKET) ) + if ( xsm_alloc_security_evtchns(XSM_HOOK, chn, EVTCHNS_PER_BUCKET) ) goto err; for ( i = 0; i < EVTCHNS_PER_BUCKET; i++ ) @@ -297,7 +297,7 @@ void evtchn_free(struct domain *d, struc chn->notify_vcpu_id = 0; chn->xen_consumer = 0; - xsm_evtchn_close_post(chn); + xsm_evtchn_close_post(XSM_HOOK, chn); } static int evtchn_get_port(struct domain *d, evtchn_port_t port) @@ -1779,7 +1779,7 @@ static void domain_dump_evtchn_info(stru break; } - ssid = xsm_show_security_evtchn(d, chn); + ssid = xsm_show_security_evtchn(XSM_HOOK, d, chn); if (ssid) { printk(" Z=%s\n", ssid); xfree(ssid); --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -311,8 +311,10 @@ static XSM_INLINE int xsm_evtchn_interdo return xsm_default_action(action, d1, d2); } -static XSM_INLINE void xsm_evtchn_close_post(struct evtchn *chn) -{} +static XSM_INLINE void xsm_evtchn_close_post(XSM_DEFAULT_ARG struct evtchn *chn) +{ + XSM_ASSERT_ACTION(XSM_HOOK); +} static XSM_INLINE int xsm_evtchn_send( XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn) @@ -336,18 +338,22 @@ static XSM_INLINE int xsm_evtchn_reset( } static XSM_INLINE int xsm_alloc_security_evtchns( - struct evtchn chn[], unsigned int nr) + XSM_DEFAULT_ARG struct evtchn *chn, unsigned int nr) { + XSM_ASSERT_ACTION(XSM_HOOK); return 0; } static XSM_INLINE void xsm_free_security_evtchns( - struct evtchn chn[], unsigned int nr) -{} + XSM_DEFAULT_ARG struct evtchn *chn, unsigned int nr) +{ + XSM_ASSERT_ACTION(XSM_HOOK); +} static XSM_INLINE char *xsm_show_security_evtchn( - struct domain *d, const struct evtchn *chn) + XSM_DEFAULT_ARG struct domain *d, const struct evtchn *chn) { + XSM_ASSERT_ACTION(XSM_HOOK); return NULL; } --- a/xen/include/xsm/hooks.h +++ b/xen/include/xsm/hooks.h @@ -34,6 +34,11 @@ XSM_HOOK(int, evtchn_interdomain, struct XSM_HOOK(int, evtchn_send, struct domain *, struct evtchn *) XSM_HOOK(int, evtchn_status, struct domain *, struct evtchn *) XSM_HOOK(int, evtchn_reset, struct domain *, struct domain *) +XSM_HOOK(void, evtchn_close_post, struct evtchn *) +XSM_HOOK(int, alloc_security_evtchns, struct evtchn *, unsigned int) +XSM_HOOK(void, free_security_evtchns, struct evtchn *, unsigned int) +XSM_HOOK(pchar_t, show_security_evtchn, struct domain *, + const struct evtchn *) #ifdef CONFIG_GRANT_TABLE XSM_HOOK(int, grant_mapref, struct domain *, struct domain *, uint32_t) --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -21,6 +21,9 @@ /* policy magic number (defined by XSM_MAGIC) */ typedef uint32_t xsm_magic_t; +/* Auxiliary type(s) for use in hook definitions. */ +typedef char *pchar_t; + #ifdef CONFIG_XSM_FLASK #define XSM_MAGIC 0xf97cff8cU #else @@ -76,13 +79,8 @@ struct xsm_ops { #include "hooks.h" - void (*evtchn_close_post)(struct evtchn *chn); - int (*alloc_security_domain)(struct domain *d); void (*free_security_domain)(struct domain *d); - int (*alloc_security_evtchns)(struct evtchn chn[], unsigned int nr); - void (*free_security_evtchns)(struct evtchn chn[], unsigned int nr); - char *(*show_security_evtchn)(struct domain *d, const struct evtchn *chn); char *(*show_irq_sid)(int irq); }; @@ -104,8 +102,9 @@ static inline void xsm_security_domainin alternative_vcall(xsm_ops.security_domaininfo, d, info); } -#define XSM_ALT_void alternative_vcall -#define XSM_ALT_int return alternative_call +#define XSM_ALT_void alternative_vcall +#define XSM_ALT_int return alternative_call +#define XSM_ALT_pchar_t return alternative_call #define XSM_HOOK0(rtype, name) \ static inline rtype xsm_ ## name(xsm_default_t def) \ @@ -150,11 +149,6 @@ static inline rtype xsm_ ## name( \ #include "hooks.h" -static inline void xsm_evtchn_close_post(struct evtchn *chn) -{ - alternative_vcall(xsm_ops.evtchn_close_post, chn); -} - static inline int xsm_alloc_security_domain(struct domain *d) { return alternative_call(xsm_ops.alloc_security_domain, d); @@ -165,24 +159,6 @@ static inline void xsm_free_security_dom alternative_vcall(xsm_ops.free_security_domain, d); } -static inline int xsm_alloc_security_evtchns( - struct evtchn *chn, unsigned int nr) -{ - return alternative_call(xsm_ops.alloc_security_evtchns, chn, nr); -} - -static inline void xsm_free_security_evtchns( - struct evtchn *chn, unsigned int nr) -{ - alternative_vcall(xsm_ops.free_security_evtchns, chn, nr); -} - -static inline char *xsm_show_security_evtchn( - struct domain *d, const struct evtchn *chn) -{ - return alternative_call(xsm_ops.show_security_evtchn, d, chn); -} - static inline char *xsm_show_irq_sid(int irq) { return alternative_call(xsm_ops.show_irq_sid, irq); --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -26,13 +26,8 @@ static const struct xsm_ops __initconst_ #include <xsm/hooks.h> - .evtchn_close_post = xsm_evtchn_close_post, - .alloc_security_domain = xsm_alloc_security_domain, .free_security_domain = xsm_free_security_domain, - .alloc_security_evtchns = xsm_alloc_security_evtchns, - .free_security_evtchns = xsm_free_security_evtchns, - .show_security_evtchn = xsm_show_security_evtchn, .show_irq_sid = xsm_show_irq_sid, }; --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1915,13 +1915,8 @@ static const struct xsm_ops __initconst_ #include <xsm/hooks.h> - .evtchn_close_post = flask_evtchn_close_post, - .alloc_security_domain = flask_domain_alloc_security, .free_security_domain = flask_domain_free_security, - .alloc_security_evtchns = flask_alloc_security_evtchns, - .free_security_evtchns = flask_free_security_evtchns, - .show_security_evtchn = flask_show_security_evtchn, .show_irq_sid = flask_show_irq_sid, };