xsm: refactoring xsm hooks
v3 cover xsm: refactoring xsm hooks
Based on feedback from 2021 Xen Developers Summit the xsm-roles RFC patch set is being split into two separate patch sets. This is the first patch set and is focused purely on the clean up and refactoring of the XSM hooks.
This patch set refactors the xsm_ops wrapper hooks to use the alternative_call infrastructure. Then proceeds to move and realign the headers to simplify the unnecessarily complicated header inclusions, remove the facad of being able to enable/disable XSM, and simplify the XSM hooks down to a single interface and implementation. The remainder of the changes are clean up and removing no longer necessary abstractions.
v2:
- restructured the patches, breaking them up as needed
- incorporate Andrew Cooper's alternative call common code
- change XSM module registration, removing register_xsm
- incoporate KConfig recommendations
- reworded commit messages
- incorporate macro expansion recommendations
- misc clean-up fallout from recommendations
v3:
- renamed struct xsm_operations to struct xsm_ops
- flask and silo ops structs made __initconst
- fixed misplacement of __init on flask/silo_init
- lots of coding style alignment
- further clean up from FLASK_DISABLE removal
- addressed commit message comments
- removed missed guard around alternative-call include
- reworked approach to XSM hooks, merging the two interfaces instead of dropping one
Andrew Cooper (1):
xen: Implement xen/alternative-call.h for use in common code
Daniel P. Smith (6):
xsm: remove the ability to disable flask
xsm: refactor xsm_ops handling
xsm: convert xsm_ops hook calls to alternative call
xsm: decouple xsm header inclusion selection
xsm: drop generic event channel labeling exclusion
xsm: removing facade that XSM can be enabled/disabled
xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 50 +- xen/include/public/xsm/flask_op.h | 2 +- xen/include/xen/alternative-call.h | 63 ++ xen/include/xen/sched.h | 4 - xen/include/xsm/dummy.h | 711 +---------------- xen/include/xsm/xsm-core.h | 247 ++++++ xen/include/xsm/xsm.h | 1145 +++++++++++++++++----------- xen/xsm/Makefile | 3 +- xen/xsm/dummy.c | 160 ---- xen/xsm/flask/flask_op.c | 30 - xen/xsm/flask/hooks.c | 12 +- xen/xsm/silo.c | 23 +- xen/xsm/xsm_core.c | 72 +- 14 files changed, 1083 insertions(+), 1440 deletions(-) create mode 100644 xen/include/xen/alternative-call.h create mode 100644 xen/include/xsm/xsm-core.h delete mode 100644 xen/xsm/dummy.c
Signature · 1 line
2.20.1
PATCH v3 1/7 xen: Implement xen/alternative-call.h for use in common code
From: Andrew Cooper <[email protected]>
The alternative call infrastructure is x86-only for now, but the common iommu code has a variant and more common code wants to use the infrastructure.
Introduce CONFIG_ALTERNATIVE_CALL and a conditional implemetnation so common code can use the optimisation when available, without requiring all architectures to implement no-op stubs.
Write some documentation, which was thus far entirely absent, covering the requirements for an architecture to implement this optimsiation, and how to use the infrastructure in general code.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bob Eshleman <[email protected]>
CC: Alistair Francis <[email protected]>
CC: Connor Davis <[email protected]>
CC: Daniel P. Smith <[email protected]>
v3:
* Drop __alt_call_maybe_initconst
This is a pre-requisite to "xsm: refactor xsm_ops handling" to avoid breaking the ARM build.
Build test for the XSM code:
diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 5eab21e1b168..592074e8f41c 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -195,6 +195,16 @@ bool __init has_xsm_magic(paddr_t start)
}
#endif +#include <xen/alternative-call.h>
+struct foo {
+ int (*bar)(void *);
+} foo __alt_call_maybe_initdata;
+
+int test_alternative_call(void)
+{
+ return alternative_call(foo.bar, NULL);
+}
+
int __init register_xsm(struct xsm_operations *ops)
{
if ( verify(ops) )
--- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 ++ xen/include/xen/alternative-call.h | 63 ++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 xen/include/xen/alternative-call.h
xen/arch/x86/Kconfig +1 -0
@@ -6,6 +6,7 @@ config X86 def_bool y select ACPI select ACPI_LEGACY_TABLES_LOOKUP + select ALTERNATIVE_CALL select ARCH_SUPPORTS_INT128 select CORE_PARKING select HAS_ALTERNATIVE
xen/common/Kconfig +3 -0
@@ -22,6 +22,9 @@ config GRANT_TABLE If unsure, say Y. +config ALTERNATIVE_CALL + bool + config HAS_ALTERNATIVE bool
xen/include/xen/alternative-call.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v3 2/7 xsm: remove the ability to disable flask
In reply to Daniel P. SmithOn Linux when SELinux is put into permissive mode the descretionary access controls are still in place. Whereas for Xen when the enforcing state of flask is set to permissive, all operations for all domains would succeed, i.e. it does not fall back to the default access controls. To provide a means to mimic a similar but not equivalent behavior, a flask op is present to allow a one-time switch back to the default access controls, aka the "dummy policy".
This patch removes this flask op to enforce a consistent XSM usage model that a reboot of Xen is required to change the XSM policy module in use.
--- xen/include/public/xsm/flask_op.h | 2 +- xen/xsm/flask/flask_op.c | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-)
xen/include/public/xsm/flask_op.h +1 -1
@@ -188,7 +188,7 @@ struct xen_flask_op {#define FLASK_SETBOOL 12#define FLASK_COMMITBOOLS 13#define FLASK_MLS 14 -#define FLASK_DISABLE 15 +#define FLASK_DISABLE 15/* No longer implemented */ #define FLASK_GETAVC_THRESHOLD 16#define FLASK_SETAVC_THRESHOLD 17#define FLASK_AVC_HASHSTATS 18
xen/xsm/flask/flask_op.c +0 -30
@@ -223,32 +223,6 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)#ifndef COMPAT -static int flask_disable (void ) -{ -static int flask_disabled =0 ; - -if ( ss_initialized ) - { -/* Not permitted after initial policy load. */ -return -EINVAL ; - } - -if ( flask_disabled ) - { -/* Only do this once. */ -return -EINVAL ; - } - -printk ("Flask: Disabled at runtime.\n" ); - - flask_disabled =1 ; - -/* Reset xsm_ops to the original module. */ - xsm_ops = &dummy_xsm_ops; - -return 0 ; -} -static int flask_security_setavc_threshold (struct xen_flask_setavc_threshold *arg) {int rv =0 ;
@@ -698,10 +672,6 @@ ret_t do_flask_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) u_flask_op) rv = flask_mls_enabled;break ; -case FLASK_DISABLE : - rv =flask_disable (); -break ; -case FLASK_GETAVC_THRESHOLD : rv = avc_cache_threshold;break ;
Signature · 1 line
2.20.1
PATCH v3 3/7 xsm: refactor xsm_ops handling
In reply to Daniel P. SmithThis renames the struct xsm_operations to the shorter struct xsm_ops and converts the global xsm_ops from being a pointer to an explicit instance. As part of this conversion, it reworks the XSM modules init function to return their xsm_ops struct which is copied in to the global xsm_ops instance.
--- xen/include/xsm/xsm.h | 221 +++++++++++++++++++++--------------------- xen/xsm/dummy.c | 4 +- xen/xsm/flask/hooks.c | 12 +-- xen/xsm/silo.c | 7 +- xen/xsm/xsm_core.c | 72 +++++++------- 5 files changed, 161 insertions(+), 155 deletions(-)
xen/include/xsm/xsm.h +112 -109
@@ -43,7 +43,7 @@ enum xsm_default { };typedef enum xsm_default xsm_default_t ; -struct xsm_operations { +struct xsm_ops {void (*security_domaininfo) (struct domain *d,struct xen_domctl_getdomaininfo *info);int (*domain_create) (struct domain *d,u32 ssidref);
@@ -191,295 +191,295 @@ struct xsm_operations {#ifdef CONFIG_XSM -extern struct xsm_operations *xsm_ops; +extern struct xsm_ops xsm_ops;#ifndef XSM_NO_WRAPPERS static inline void xsm_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info) { - xsm_ops->security_domaininfo (d, info); + xsm_ops.security_domaininfo (d, info); }static inline int xsm_domain_create (xsm_default_t def,struct domain *d,u32 ssidref) { -return xsm_ops->domain_create (d, ssidref); +return xsm_ops.domain_create (d, ssidref); }static inline int xsm_getdomaininfo (xsm_default_t def,struct domain *d) { -return xsm_ops->getdomaininfo (d); +return xsm_ops.getdomaininfo (d); }static inline int xsm_domctl_scheduler_op (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops->domctl_scheduler_op (d, cmd); +return xsm_ops.domctl_scheduler_op (d, cmd); }static inline int xsm_sysctl_scheduler_op (xsm_default_t def,int cmd) { -return xsm_ops->sysctl_scheduler_op (cmd); +return xsm_ops.sysctl_scheduler_op (cmd); }static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) { -return xsm_ops->set_target (d, e); +return xsm_ops.set_target (d, e); }static inline int xsm_domctl (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops->domctl (d, cmd); +return xsm_ops.domctl (d, cmd); }static inline int xsm_sysctl (xsm_default_t def,int cmd) { -return xsm_ops->sysctl (cmd); +return xsm_ops.sysctl (cmd); }static inline int xsm_readconsole (xsm_default_t def,uint32_t clear) { -return xsm_ops->readconsole (clear); +return xsm_ops.readconsole (clear); }static inline int xsm_evtchn_unbound (xsm_default_t def,struct domain *d1,struct evtchn *chn,domid_t id2) { -return xsm_ops->evtchn_unbound (d1, chn, id2); +return xsm_ops.evtchn_unbound (d1, chn, id2); }static inline int xsm_evtchn_interdomain (xsm_default_t def,struct domain *d1,struct evtchn *chan1,struct domain *d2,struct evtchn *chan2) { -return xsm_ops->evtchn_interdomain (d1, chan1, d2, chan2); +return xsm_ops.evtchn_interdomain (d1, chan1, d2, chan2); }static inline void xsm_evtchn_close_post (struct evtchn *chn) { - xsm_ops->evtchn_close_post (chn); + xsm_ops.evtchn_close_post (chn); }static inline int xsm_evtchn_send (xsm_default_t def,struct domain *d,struct evtchn *chn) { -return xsm_ops->evtchn_send (d, chn); +return xsm_ops.evtchn_send (d, chn); }static inline int xsm_evtchn_status (xsm_default_t def,struct domain *d,struct evtchn *chn) { -return xsm_ops->evtchn_status (d, chn); +return xsm_ops.evtchn_status (d, chn); }static inline int xsm_evtchn_reset (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->evtchn_reset (d1, d2); +return xsm_ops.evtchn_reset (d1, d2); }static inline int xsm_grant_mapref (xsm_default_t def,struct domain *d1,struct domain *d2,uint32_t flags) { -return xsm_ops->grant_mapref (d1, d2, flags); +return xsm_ops.grant_mapref (d1, d2, flags); }static inline int xsm_grant_unmapref (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->grant_unmapref (d1, d2); +return xsm_ops.grant_unmapref (d1, d2); }static inline int xsm_grant_setup (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->grant_setup (d1, d2); +return xsm_ops.grant_setup (d1, d2); }static inline int xsm_grant_transfer (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->grant_transfer (d1, d2); +return xsm_ops.grant_transfer (d1, d2); }static inline int xsm_grant_copy (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->grant_copy (d1, d2); +return xsm_ops.grant_copy (d1, d2); }static inline int xsm_grant_query_size (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->grant_query_size (d1, d2); +return xsm_ops.grant_query_size (d1, d2); }static inline int xsm_alloc_security_domain (struct domain *d) { -return xsm_ops->alloc_security_domain (d); +return xsm_ops.alloc_security_domain (d); }static inline void xsm_free_security_domain (struct domain *d) { - xsm_ops->free_security_domain (d); + xsm_ops.free_security_domain (d); }static inline int xsm_alloc_security_evtchns (struct evtchn chn[],unsigned int nr) { -return xsm_ops->alloc_security_evtchns (chn, nr); +return xsm_ops.alloc_security_evtchns (chn, nr); }static inline void xsm_free_security_evtchns (struct evtchn chn[],unsigned int nr) { - xsm_ops->free_security_evtchns (chn, nr); + xsm_ops.free_security_evtchns (chn, nr); }static inline char *xsm_show_security_evtchn (struct domain *d,const struct evtchn *chn) { -return xsm_ops->show_security_evtchn (d, chn); +return xsm_ops.show_security_evtchn (d, chn); }static inline int xsm_init_hardware_domain (xsm_default_t def,struct domain *d) { -return xsm_ops->init_hardware_domain (d); +return xsm_ops.init_hardware_domain (d); }static inline int xsm_get_pod_target (xsm_default_t def,struct domain *d) { -return xsm_ops->get_pod_target (d); +return xsm_ops.get_pod_target (d); }static inline int xsm_set_pod_target (xsm_default_t def,struct domain *d) { -return xsm_ops->set_pod_target (d); +return xsm_ops.set_pod_target (d); }static inline int xsm_memory_exchange (xsm_default_t def,struct domain *d) { -return xsm_ops->memory_exchange (d); +return xsm_ops.memory_exchange (d); }static inline int xsm_memory_adjust_reservation (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->memory_adjust_reservation (d1, d2); +return xsm_ops.memory_adjust_reservation (d1, d2); }static inline int xsm_memory_stat_reservation (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->memory_stat_reservation (d1, d2); +return xsm_ops.memory_stat_reservation (d1, d2); }static inline int xsm_memory_pin_page (xsm_default_t def,struct domain *d1,struct domain *d2,struct page_info *page) { -return xsm_ops->memory_pin_page (d1, d2, page); +return xsm_ops.memory_pin_page (d1, d2, page); }static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->add_to_physmap (d1, d2); +return xsm_ops.add_to_physmap (d1, d2); }static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->remove_from_physmap (d1, d2); +return xsm_ops.remove_from_physmap (d1, d2); }static inline int xsm_map_gmfn_foreign (xsm_default_t def,struct domain *d,struct domain *t) { -return xsm_ops->map_gmfn_foreign (d, t); +return xsm_ops.map_gmfn_foreign (d, t); }static inline int xsm_claim_pages (xsm_default_t def,struct domain *d) { -return xsm_ops->claim_pages (d); +return xsm_ops.claim_pages (d); }static inline int xsm_console_io (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops->console_io (d, cmd); +return xsm_ops.console_io (d, cmd); }static inline int xsm_profile (xsm_default_t def,struct domain *d,int op) { -return xsm_ops->profile (d, op); +return xsm_ops.profile (d, op); }static inline int xsm_kexec (xsm_default_t def) { -return xsm_ops->kexec (); +return xsm_ops.kexec (); }static inline int xsm_schedop_shutdown (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops->schedop_shutdown (d1, d2); +return xsm_ops.schedop_shutdown (d1, d2); }static inline char *xsm_show_irq_sid (int irq) { -return xsm_ops->show_irq_sid (irq); +return xsm_ops.show_irq_sid (irq); }static inline int xsm_map_domain_pirq (xsm_default_t def,struct domain *d) { -return xsm_ops->map_domain_pirq (d); +return xsm_ops.map_domain_pirq (d); }static inline int xsm_map_domain_irq (xsm_default_t def,struct domain *d,int irq,void *data) { -return xsm_ops->map_domain_irq (d, irq, data); +return xsm_ops.map_domain_irq (d, irq, data); }static inline int xsm_unmap_domain_pirq (xsm_default_t def,struct domain *d) { -return xsm_ops->unmap_domain_pirq (d); +return xsm_ops.unmap_domain_pirq (d); }static inline int xsm_unmap_domain_irq (xsm_default_t def,struct domain *d,int irq,void *data) { -return xsm_ops->unmap_domain_irq (d, irq, data); +return xsm_ops.unmap_domain_irq (d, irq, data); }static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -return xsm_ops->bind_pt_irq (d, bind); +return xsm_ops.bind_pt_irq (d, bind); }static inline int xsm_unbind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -return xsm_ops->unbind_pt_irq (d, bind); +return xsm_ops.unbind_pt_irq (d, bind); }static inline int xsm_irq_permission (xsm_default_t def,struct domain *d,int pirq,uint8_t allow) { -return xsm_ops->irq_permission (d, pirq, allow); +return xsm_ops.irq_permission (d, pirq, allow); }static inline int xsm_iomem_permission (xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -return xsm_ops->iomem_permission (d, s, e, allow); +return xsm_ops.iomem_permission (d, s, e, allow); }static inline int xsm_iomem_mapping (xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -return xsm_ops->iomem_mapping (d, s, e, allow); +return xsm_ops.iomem_mapping (d, s, e, allow); }static inline int xsm_pci_config_permission (xsm_default_t def,struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access) { -return xsm_ops->pci_config_permission (d, machine_bdf, start, end, access); +return xsm_ops.pci_config_permission (d, machine_bdf, start, end, access); }#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI )static inline int xsm_get_device_group (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops->get_device_group (machine_bdf); +return xsm_ops.get_device_group (machine_bdf); }static inline int xsm_assign_device (xsm_default_t def,struct domain *d,uint32_t machine_bdf) { -return xsm_ops->assign_device (d, machine_bdf); +return xsm_ops.assign_device (d, machine_bdf); }static inline int xsm_deassign_device (xsm_default_t def,struct domain *d,uint32_t machine_bdf) { -return xsm_ops->deassign_device (d, machine_bdf); +return xsm_ops.deassign_device (d, machine_bdf); }#endif /* HAS_PASSTHROUGH && HAS_PCI) */
@@ -487,240 +487,240 @@ static inline int xsm_deassign_device(xsm_default_t def, struct domain *d, uint3static inline int xsm_assign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) { -return xsm_ops->assign_dtdevice (d, dtpath); +return xsm_ops.assign_dtdevice (d, dtpath); }static inline int xsm_deassign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) { -return xsm_ops->deassign_dtdevice (d, dtpath); +return xsm_ops.deassign_dtdevice (d, dtpath); }#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ static inline int xsm_resource_plug_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops->resource_plug_pci (machine_bdf); +return xsm_ops.resource_plug_pci (machine_bdf); }static inline int xsm_resource_unplug_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops->resource_unplug_pci (machine_bdf); +return xsm_ops.resource_unplug_pci (machine_bdf); }static inline int xsm_resource_plug_core (xsm_default_t def) { -return xsm_ops->resource_plug_core (); +return xsm_ops.resource_plug_core (); }static inline int xsm_resource_unplug_core (xsm_default_t def) { -return xsm_ops->resource_unplug_core (); +return xsm_ops.resource_unplug_core (); }static inline int xsm_resource_setup_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops->resource_setup_pci (machine_bdf); +return xsm_ops.resource_setup_pci (machine_bdf); }static inline int xsm_resource_setup_gsi (xsm_default_t def,int gsi) { -return xsm_ops->resource_setup_gsi (gsi); +return xsm_ops.resource_setup_gsi (gsi); }static inline int xsm_resource_setup_misc (xsm_default_t def) { -return xsm_ops->resource_setup_misc (); +return xsm_ops.resource_setup_misc (); }static inline int xsm_page_offline (xsm_default_t def,uint32_t cmd) { -return xsm_ops->page_offline (cmd); +return xsm_ops.page_offline (cmd); }static inline int xsm_hypfs_op (xsm_default_t def) { -return xsm_ops->hypfs_op (); +return xsm_ops.hypfs_op (); }static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) { -return xsm_ops->do_xsm_op (op); +return xsm_ops.do_xsm_op (op); }#ifdef CONFIG_COMPAT static inline int xsm_do_compat_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) { -return xsm_ops->do_compat_op (op); +return xsm_ops.do_compat_op (op); }#endif static inline int xsm_hvm_param (xsm_default_t def,struct domain *d,unsigned long op) { -return xsm_ops->hvm_param (d, op); +return xsm_ops.hvm_param (d, op); }static inline int xsm_hvm_control (xsm_default_t def,struct domain *d,unsigned long op) { -return xsm_ops->hvm_control (d, op); +return xsm_ops.hvm_control (d, op); }static inline int xsm_hvm_param_altp2mhvm (xsm_default_t def,struct domain *d) { -return xsm_ops->hvm_param_altp2mhvm (d); +return xsm_ops.hvm_param_altp2mhvm (d); }static inline int xsm_hvm_altp2mhvm_op (xsm_default_t def,struct domain *d,uint64_t mode,uint32_t op) { -return xsm_ops->hvm_altp2mhvm_op (d, mode, op); +return xsm_ops.hvm_altp2mhvm_op (d, mode, op); }static inline int xsm_get_vnumainfo (xsm_default_t def,struct domain *d) { -return xsm_ops->get_vnumainfo (d); +return xsm_ops.get_vnumainfo (d); }static inline int xsm_vm_event_control (xsm_default_t def,struct domain *d,int mode,int op) { -return xsm_ops->vm_event_control (d, mode, op); +return xsm_ops.vm_event_control (d, mode, op); }#ifdef CONFIG_MEM_ACCESS static inline int xsm_mem_access (xsm_default_t def,struct domain *d) { -return xsm_ops->mem_access (d); +return xsm_ops.mem_access (d); }#endif #ifdef CONFIG_MEM_PAGING static inline int xsm_mem_paging (xsm_default_t def,struct domain *d) { -return xsm_ops->mem_paging (d); +return xsm_ops.mem_paging (d); }#endif #ifdef CONFIG_MEM_SHARING static inline int xsm_mem_sharing (xsm_default_t def,struct domain *d) { -return xsm_ops->mem_sharing (d); +return xsm_ops.mem_sharing (d); }#endif static inline int xsm_platform_op (xsm_default_t def,uint32_t op) { -return xsm_ops->platform_op (op); +return xsm_ops.platform_op (op); }#ifdef CONFIG_X86 static inline int xsm_do_mca (xsm_default_t def) { -return xsm_ops->do_mca (); +return xsm_ops.do_mca (); }static inline int xsm_shadow_control (xsm_default_t def,struct domain *d,uint32_t op) { -return xsm_ops->shadow_control (d, op); +return xsm_ops.shadow_control (d, op); }static inline int xsm_mem_sharing_op (xsm_default_t def,struct domain *d,struct domain *cd,int op) { -return xsm_ops->mem_sharing_op (d, cd, op); +return xsm_ops.mem_sharing_op (d, cd, op); }static inline int xsm_apic (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops->apic (d, cmd); +return xsm_ops.apic (d, cmd); }static inline int xsm_memtype (xsm_default_t def,uint32_t access) { -return xsm_ops->memtype (access); +return xsm_ops.memtype (access); }static inline int xsm_machine_memory_map (xsm_default_t def) { -return xsm_ops->machine_memory_map (); +return xsm_ops.machine_memory_map (); }static inline int xsm_domain_memory_map (xsm_default_t def,struct domain *d) { -return xsm_ops->domain_memory_map (d); +return xsm_ops.domain_memory_map (d); }static inline int xsm_mmu_update (xsm_default_t def,struct domain *d,struct domain *t,struct domain *f,uint32_t flags) { -return xsm_ops->mmu_update (d, t, f, flags); +return xsm_ops.mmu_update (d, t, f, flags); }static inline int xsm_mmuext_op (xsm_default_t def,struct domain *d,struct domain *f) { -return xsm_ops->mmuext_op (d, f); +return xsm_ops.mmuext_op (d, f); }static inline int xsm_update_va_mapping (xsm_default_t def,struct domain *d,struct domain *f,l1_pgentry_t pte) { -return xsm_ops->update_va_mapping (d, f, pte); +return xsm_ops.update_va_mapping (d, f, pte); }static inline int xsm_priv_mapping (xsm_default_t def,struct domain *d,struct domain *t) { -return xsm_ops->priv_mapping (d, t); +return xsm_ops.priv_mapping (d, t); }static inline int xsm_ioport_permission (xsm_default_t def,struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -return xsm_ops->ioport_permission (d, s, e, allow); +return xsm_ops.ioport_permission (d, s, e, allow); }static inline int xsm_ioport_mapping (xsm_default_t def,struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -return xsm_ops->ioport_mapping (d, s, e, allow); +return xsm_ops.ioport_mapping (d, s, e, allow); }static inline int xsm_pmu_op (xsm_default_t def,struct domain *d,unsigned int op) { -return xsm_ops->pmu_op (d, op); +return xsm_ops.pmu_op (d, op); }#endif /* CONFIG_X86 */ static inline int xsm_dm_op (xsm_default_t def,struct domain *d) { -return xsm_ops->dm_op (d); +return xsm_ops.dm_op (d); }static inline int xsm_xen_version (xsm_default_t def,uint32_t op) { -return xsm_ops->xen_version (op); +return xsm_ops.xen_version (op); }static inline int xsm_domain_resource_map (xsm_default_t def,struct domain *d) { -return xsm_ops->domain_resource_map (d); +return xsm_ops.domain_resource_map (d); }#ifdef CONFIG_ARGO static inline int xsm_argo_enable (const struct domain *d) { -return xsm_ops->argo_enable (d); +return xsm_ops.argo_enable (d); }static inline int xsm_argo_register_single_source (const struct domain *d,const struct domain *t) { -return xsm_ops->argo_register_single_source (d, t); +return xsm_ops.argo_register_single_source (d, t); }static inline int xsm_argo_register_any_source (const struct domain *d) { -return xsm_ops->argo_register_any_source (d); +return xsm_ops.argo_register_any_source (d); }static inline int xsm_argo_send (const struct domain *d,const struct domain *t) { -return xsm_ops->argo_send (d, t); +return xsm_ops.argo_send (d, t); }#endif /* CONFIG_ARGO */
@@ -747,16 +747,16 @@ extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);extern bool has_xsm_magic (paddr_t );#endif -extern int register_xsm (struct xsm_operations *ops); - -extern struct xsm_operations dummy_xsm_ops; -extern void xsm_fixup_ops (struct xsm_operations *ops); +extern void xsm_fixup_ops (struct xsm_ops *ops);#ifdef CONFIG_XSM_FLASK -extern void flask_init (const void *policy_buffer,size_t policy_size); +extern const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size);#else -static inline void flask_init (const void *policy_buffer,size_t policy_size) +static inline struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size) { +return NULL ; }#endif
@@ -766,9 +766,12 @@ extern const unsigned int xsm_flask_init_policy_size;#endif #ifdef CONFIG_XSM_SILO -extern void silo_init (void ); +extern const struct xsm_ops *silo_init (void );#else -static inline void silo_init (void ) {} +static inline struct xsm_ops *silo_init (void ) +{ +return NULL ; +}#endif #else /* CONFIG_XSM */
xen/xsm/dummy.c +1 -3
@@ -13,15 +13,13 @@#define XSM_NO_WRAPPERS #include <xsm/dummy.h> -struct xsm_operations dummy_xsm_ops; -#define set_to_dummy_if_null (ops, function) \ do { \ if ( !ops->function ) \ ops->function = xsm_##function; \ } while (0) -void __init xsm_fixup_ops (struct xsm_operations *ops) +void __init xsm_fixup_ops (struct xsm_ops *ops) {set_to_dummy_if_null (ops, security_domaininfo);set_to_dummy_if_null (ops, domain_create);
xen/xsm/flask/hooks.c +6 -6
@@ -1745,7 +1745,7 @@ static int flask_argo_send(const struct domain *d, const struct domain *t)long do_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op);int compat_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op); -static struct xsm_operations flask_ops = { +static const struct xsm_ops __initconst flask_ops = { .security_domaininfo = flask_security_domaininfo, .domain_create = flask_domain_create, .getdomaininfo = flask_getdomaininfo,
@@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {#endif }; -void __init flask_init (const void *policy_buffer,size_t policy_size) +const struct xsm_ops *__init flask_init (const void *policy_buffer, +size_t policy_size) {int ret = -ENOENT ;
@@ -1891,7 +1892,7 @@ void __init flask_init(const void *policy_buffer, size_t policy_size) {case FLASK_BOOTPARAM_DISABLED :printk (XENLOG_INFO "Flask: Disabled at boot.\n" ); -return ; +return NULL ;case FLASK_BOOTPARAM_PERMISSIVE : flask_enforcing =0 ;
@@ -1908,9 +1909,6 @@ void __init flask_init(const void *policy_buffer, size_t policy_size)avc_init (); -if (register_xsm (&flask_ops) ) -panic ("Flask: Unable to register with XSM\n" ); -if ( policy_size && flask_bootparam !=FLASK_BOOTPARAM_LATELOAD ) ret =security_load_policy (policy_buffer, policy_size);
@@ -1923,6 +1921,8 @@ void __init flask_init(const void *policy_buffer, size_t policy_size)printk (XENLOG_INFO "Flask: Starting in enforcing mode.\n" ); else printk(XENLOG_INFO "Flask: Starting in permissive mode.\n"); + +return &flask_ops; }/*
xen/xsm/silo.c +3 -4
@@ -100,7 +100,7 @@ static int silo_argo_send(const struct domain *d1, const struct domain *d2)#endif -static struct xsm_operations silo_xsm_ops = { +static const struct xsm_ops __initconst silo_xsm_ops = { .evtchn_unbound = silo_evtchn_unbound, .evtchn_interdomain = silo_evtchn_interdomain, .grant_mapref = silo_grant_mapref,
@@ -112,12 +112,11 @@ static struct xsm_operations silo_xsm_ops = {#endif }; -void __init silo_init (void ) +const struct xsm_ops *__init silo_init (void ) {printk ("Initialising XSM SILO mode\n" ); -if (register_xsm (&silo_xsm_ops) ) -panic ("SILO: Unable to register with XSM\n" ); +return &silo_xsm_ops; }/*
xen/xsm/xsm_core.c +39 -33
118 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v3 4/7 xsm: convert xsm_ops hook calls to alternative call
In reply to Daniel P. SmithTo reduce retpolines convert all the pointer function calls of the xsm_ops hooks over to the alternative_call infrastructure.
--- xen/include/xsm/xsm.h | 193 +++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 96 deletions(-)
xen/include/xsm/xsm.h +97 -96
@@ -15,6 +15,7 @@#ifndef __XSM_H__#define __XSM_H__ +#include <xen/alternative-call.h> #include <xen/sched.h> #include <xen/multiboot.h>
@@ -198,288 +199,288 @@ extern struct xsm_ops xsm_ops;static inline void xsm_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info) { - xsm_ops.security_domaininfo (d, info); +alternative_vcall (xsm_ops.security_domaininfo, d, info); }static inline int xsm_domain_create (xsm_default_t def,struct domain *d,u32 ssidref) { -return xsm_ops.domain_create (d, ssidref); +return alternative_call (xsm_ops.domain_create, d, ssidref); }static inline int xsm_getdomaininfo (xsm_default_t def,struct domain *d) { -return xsm_ops.getdomaininfo (d); +return alternative_call (xsm_ops.getdomaininfo, d); }static inline int xsm_domctl_scheduler_op (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops.domctl_scheduler_op (d, cmd); +return alternative_call (xsm_ops.domctl_scheduler_op, d, cmd); }static inline int xsm_sysctl_scheduler_op (xsm_default_t def,int cmd) { -return xsm_ops.sysctl_scheduler_op (cmd); +return alternative_call (xsm_ops.sysctl_scheduler_op, cmd); }static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) { -return xsm_ops.set_target (d, e); +return alternative_call (xsm_ops.set_target, d, e); }static inline int xsm_domctl (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops.domctl (d, cmd); +return alternative_call (xsm_ops.domctl, d, cmd); }static inline int xsm_sysctl (xsm_default_t def,int cmd) { -return xsm_ops.sysctl (cmd); +return alternative_call (xsm_ops.sysctl, cmd); }static inline int xsm_readconsole (xsm_default_t def,uint32_t clear) { -return xsm_ops.readconsole (clear); +return alternative_call (xsm_ops.readconsole, clear); }static inline int xsm_evtchn_unbound (xsm_default_t def,struct domain *d1,struct evtchn *chn,domid_t id2) { -return xsm_ops.evtchn_unbound (d1, chn, id2); +return alternative_call (xsm_ops.evtchn_unbound, d1, chn, id2); }static inline int xsm_evtchn_interdomain (xsm_default_t def,struct domain *d1,struct evtchn *chan1,struct domain *d2,struct evtchn *chan2) { -return xsm_ops.evtchn_interdomain (d1, chan1, d2, chan2); +return alternative_call (xsm_ops.evtchn_interdomain, d1, chan1, d2, chan2); }static inline void xsm_evtchn_close_post (struct evtchn *chn) { - xsm_ops.evtchn_close_post (chn); +alternative_vcall (xsm_ops.evtchn_close_post, chn); }static inline int xsm_evtchn_send (xsm_default_t def,struct domain *d,struct evtchn *chn) { -return xsm_ops.evtchn_send (d, chn); +return alternative_call (xsm_ops.evtchn_send, d, chn); }static inline int xsm_evtchn_status (xsm_default_t def,struct domain *d,struct evtchn *chn) { -return xsm_ops.evtchn_status (d, chn); +return alternative_call (xsm_ops.evtchn_status, d, chn); }static inline int xsm_evtchn_reset (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.evtchn_reset (d1, d2); +return alternative_call (xsm_ops.evtchn_reset, d1, d2); }static inline int xsm_grant_mapref (xsm_default_t def,struct domain *d1,struct domain *d2,uint32_t flags) { -return xsm_ops.grant_mapref (d1, d2, flags); +return alternative_call (xsm_ops.grant_mapref, d1, d2, flags); }static inline int xsm_grant_unmapref (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.grant_unmapref (d1, d2); +return alternative_call (xsm_ops.grant_unmapref, d1, d2); }static inline int xsm_grant_setup (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.grant_setup (d1, d2); +return alternative_call (xsm_ops.grant_setup, d1, d2); }static inline int xsm_grant_transfer (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.grant_transfer (d1, d2); +return alternative_call (xsm_ops.grant_transfer, d1, d2); }static inline int xsm_grant_copy (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.grant_copy (d1, d2); +return alternative_call (xsm_ops.grant_copy, d1, d2); }static inline int xsm_grant_query_size (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.grant_query_size (d1, d2); +return alternative_call (xsm_ops.grant_query_size, d1, d2); }static inline int xsm_alloc_security_domain (struct domain *d) { -return xsm_ops.alloc_security_domain (d); +return alternative_call (xsm_ops.alloc_security_domain, d); }static inline void xsm_free_security_domain (struct domain *d) { - xsm_ops.free_security_domain (d); +alternative_vcall (xsm_ops.free_security_domain, d); }static inline int xsm_alloc_security_evtchns (struct evtchn chn[],unsigned int nr) { -return xsm_ops.alloc_security_evtchns (chn, nr); +return alternative_call (xsm_ops.alloc_security_evtchns, chn, nr); }static inline void xsm_free_security_evtchns (struct evtchn chn[],unsigned int nr) { - xsm_ops.free_security_evtchns (chn, 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 xsm_ops.show_security_evtchn (d, chn); +return alternative_call (xsm_ops.show_security_evtchn, d, chn); }static inline int xsm_init_hardware_domain (xsm_default_t def,struct domain *d) { -return xsm_ops.init_hardware_domain (d); +return alternative_call (xsm_ops.init_hardware_domain, d); }static inline int xsm_get_pod_target (xsm_default_t def,struct domain *d) { -return xsm_ops.get_pod_target (d); +return alternative_call (xsm_ops.get_pod_target, d); }static inline int xsm_set_pod_target (xsm_default_t def,struct domain *d) { -return xsm_ops.set_pod_target (d); +return alternative_call (xsm_ops.set_pod_target, d); }static inline int xsm_memory_exchange (xsm_default_t def,struct domain *d) { -return xsm_ops.memory_exchange (d); +return alternative_call (xsm_ops.memory_exchange, d); }static inline int xsm_memory_adjust_reservation (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.memory_adjust_reservation (d1, d2); +return alternative_call (xsm_ops.memory_adjust_reservation, d1, d2); }static inline int xsm_memory_stat_reservation (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.memory_stat_reservation (d1, d2); +return alternative_call (xsm_ops.memory_stat_reservation, d1, d2); }static inline int xsm_memory_pin_page (xsm_default_t def,struct domain *d1,struct domain *d2,struct page_info *page) { -return xsm_ops.memory_pin_page (d1, d2, page); +return alternative_call (xsm_ops.memory_pin_page, d1, d2, page); }static inline int xsm_add_to_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.add_to_physmap (d1, d2); +return alternative_call (xsm_ops.add_to_physmap, d1, d2); }static inline int xsm_remove_from_physmap (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.remove_from_physmap (d1, d2); +return alternative_call (xsm_ops.remove_from_physmap, d1, d2); }static inline int xsm_map_gmfn_foreign (xsm_default_t def,struct domain *d,struct domain *t) { -return xsm_ops.map_gmfn_foreign (d, t); +return alternative_call (xsm_ops.map_gmfn_foreign, d, t); }static inline int xsm_claim_pages (xsm_default_t def,struct domain *d) { -return xsm_ops.claim_pages (d); +return alternative_call (xsm_ops.claim_pages, d); }static inline int xsm_console_io (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops.console_io (d, cmd); +return alternative_call (xsm_ops.console_io, d, cmd); }static inline int xsm_profile (xsm_default_t def,struct domain *d,int op) { -return xsm_ops.profile (d, op); +return alternative_call (xsm_ops.profile, d, op); }static inline int xsm_kexec (xsm_default_t def) { -return xsm_ops.kexec (); +return alternative_call (xsm_ops.kexec); }static inline int xsm_schedop_shutdown (xsm_default_t def,struct domain *d1,struct domain *d2) { -return xsm_ops.schedop_shutdown (d1, d2); +return alternative_call (xsm_ops.schedop_shutdown, d1, d2); }static inline char *xsm_show_irq_sid (int irq) { -return xsm_ops.show_irq_sid (irq); +return alternative_call (xsm_ops.show_irq_sid, irq); }static inline int xsm_map_domain_pirq (xsm_default_t def,struct domain *d) { -return xsm_ops.map_domain_pirq (d); +return alternative_call (xsm_ops.map_domain_pirq, d); }static inline int xsm_map_domain_irq (xsm_default_t def,struct domain *d,int irq,void *data) { -return xsm_ops.map_domain_irq (d, irq, data); +return alternative_call (xsm_ops.map_domain_irq, d, irq, data); }static inline int xsm_unmap_domain_pirq (xsm_default_t def,struct domain *d) { -return xsm_ops.unmap_domain_pirq (d); +return alternative_call (xsm_ops.unmap_domain_pirq, d); }static inline int xsm_unmap_domain_irq (xsm_default_t def,struct domain *d,int irq,void *data) { -return xsm_ops.unmap_domain_irq (d, irq, data); +return alternative_call (xsm_ops.unmap_domain_irq, d, irq, data); }static inline int xsm_bind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -return xsm_ops.bind_pt_irq (d, bind); +return alternative_call (xsm_ops.bind_pt_irq, d, bind); }static inline int xsm_unbind_pt_irq (xsm_default_t def,struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -return xsm_ops.unbind_pt_irq (d, bind); +return alternative_call (xsm_ops.unbind_pt_irq, d, bind); }static inline int xsm_irq_permission (xsm_default_t def,struct domain *d,int pirq,uint8_t allow) { -return xsm_ops.irq_permission (d, pirq, allow); +return alternative_call (xsm_ops.irq_permission, d, pirq, allow); }static inline int xsm_iomem_permission (xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -return xsm_ops.iomem_permission (d, s, e, allow); +return alternative_call (xsm_ops.iomem_permission, d, s, e, allow); }static inline int xsm_iomem_mapping (xsm_default_t def,struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -return xsm_ops.iomem_mapping (d, s, e, allow); +return alternative_call (xsm_ops.iomem_mapping, d, s, e, allow); }static inline int xsm_pci_config_permission (xsm_default_t def,struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access) { -return xsm_ops.pci_config_permission (d, machine_bdf, start, end, access); +return alternative_call (xsm_ops.pci_config_permission, d, machine_bdf, start, end, access); }#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI )static inline int xsm_get_device_group (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops.get_device_group (machine_bdf); +return alternative_call (xsm_ops.get_device_group, machine_bdf); }static inline int xsm_assign_device (xsm_default_t def,struct domain *d,uint32_t machine_bdf) { -return xsm_ops.assign_device (d, machine_bdf); +return alternative_call (xsm_ops.assign_device, d, machine_bdf); }static inline int xsm_deassign_device (xsm_default_t def,struct domain *d,uint32_t machine_bdf) { -return xsm_ops.deassign_device (d, machine_bdf); +return alternative_call (xsm_ops.deassign_device, d, machine_bdf); }#endif /* HAS_PASSTHROUGH && HAS_PCI) */
@@ -487,60 +488,60 @@ static inline int xsm_deassign_device(xsm_default_t def, struct domain *d, uint3static inline int xsm_assign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) { -return xsm_ops.assign_dtdevice (d, dtpath); +return alternative_call (xsm_ops.assign_dtdevice, d, dtpath); }static inline int xsm_deassign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) { -return xsm_ops.deassign_dtdevice (d, dtpath); +return alternative_call (xsm_ops.deassign_dtdevice, d, dtpath); }#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ static inline int xsm_resource_plug_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops.resource_plug_pci (machine_bdf); +return alternative_call (xsm_ops.resource_plug_pci, machine_bdf); }static inline int xsm_resource_unplug_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops.resource_unplug_pci (machine_bdf); +return alternative_call (xsm_ops.resource_unplug_pci, machine_bdf); }static inline int xsm_resource_plug_core (xsm_default_t def) { -return xsm_ops.resource_plug_core (); +return alternative_call (xsm_ops.resource_plug_core); }static inline int xsm_resource_unplug_core (xsm_default_t def) { -return xsm_ops.resource_unplug_core (); +return alternative_call (xsm_ops.resource_unplug_core); }static inline int xsm_resource_setup_pci (xsm_default_t def,uint32_t machine_bdf) { -return xsm_ops.resource_setup_pci (machine_bdf); +return alternative_call (xsm_ops.resource_setup_pci, machine_bdf); }static inline int xsm_resource_setup_gsi (xsm_default_t def,int gsi) { -return xsm_ops.resource_setup_gsi (gsi); +return alternative_call (xsm_ops.resource_setup_gsi, gsi); }static inline int xsm_resource_setup_misc (xsm_default_t def) { -return xsm_ops.resource_setup_misc (); +return alternative_call (xsm_ops.resource_setup_misc); }static inline int xsm_page_offline (xsm_default_t def,uint32_t cmd) { -return xsm_ops.page_offline (cmd); +return alternative_call (xsm_ops.page_offline, cmd); }static inline int xsm_hypfs_op (xsm_default_t def) { -return xsm_ops.hypfs_op (); +return alternative_call (xsm_ops.hypfs_op); }static inline long xsm_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op)
@@ -557,105 +558,105 @@ static inline int xsm_do_compat_op (XEN_GUEST_HANDLE_PARAM(xsm_op_t) op)static inline int xsm_hvm_param (xsm_default_t def,struct domain *d,unsigned long op) { -return xsm_ops.hvm_param (d, op); +return alternative_call (xsm_ops.hvm_param, d, op); }static inline int xsm_hvm_control (xsm_default_t def,struct domain *d,unsigned long op) { -return xsm_ops.hvm_control (d, op); +return alternative_call (xsm_ops.hvm_control, d, op); }static inline int xsm_hvm_param_altp2mhvm (xsm_default_t def,struct domain *d) { -return xsm_ops.hvm_param_altp2mhvm (d); +return alternative_call (xsm_ops.hvm_param_altp2mhvm, d); }static inline int xsm_hvm_altp2mhvm_op (xsm_default_t def,struct domain *d,uint64_t mode,uint32_t op) { -return xsm_ops.hvm_altp2mhvm_op (d, mode, op); +return alternative_call (xsm_ops.hvm_altp2mhvm_op, d, mode, op); }static inline int xsm_get_vnumainfo (xsm_default_t def,struct domain *d) { -return xsm_ops.get_vnumainfo (d); +return alternative_call (xsm_ops.get_vnumainfo, d); }static inline int xsm_vm_event_control (xsm_default_t def,struct domain *d,int mode,int op) { -return xsm_ops.vm_event_control (d, mode, op); +return alternative_call (xsm_ops.vm_event_control, d, mode, op); }#ifdef CONFIG_MEM_ACCESS static inline int xsm_mem_access (xsm_default_t def,struct domain *d) { -return xsm_ops.mem_access (d); +return alternative_call (xsm_ops.mem_access, d); }#endif #ifdef CONFIG_MEM_PAGING static inline int xsm_mem_paging (xsm_default_t def,struct domain *d) { -return xsm_ops.mem_paging (d); +return alternative_call (xsm_ops.mem_paging, d); }#endif #ifdef CONFIG_MEM_SHARING static inline int xsm_mem_sharing (xsm_default_t def,struct domain *d) { -return xsm_ops.mem_sharing (d); +return alternative_call (xsm_ops.mem_sharing, d); }#endif static inline int xsm_platform_op (xsm_default_t def,uint32_t op) { -return xsm_ops.platform_op (op); +return alternative_call (xsm_ops.platform_op, op); }#ifdef CONFIG_X86 static inline int xsm_do_mca (xsm_default_t def) { -return xsm_ops.do_mca (); +return alternative_call (xsm_ops.do_mca); }static inline int xsm_shadow_control (xsm_default_t def,struct domain *d,uint32_t op) { -return xsm_ops.shadow_control (d, op); +return alternative_call (xsm_ops.shadow_control, d, op); }static inline int xsm_mem_sharing_op (xsm_default_t def,struct domain *d,struct domain *cd,int op) { -return xsm_ops.mem_sharing_op (d, cd, op); +return alternative_call (xsm_ops.mem_sharing_op, d, cd, op); }static inline int xsm_apic (xsm_default_t def,struct domain *d,int cmd) { -return xsm_ops.apic (d, cmd); +return alternative_call (xsm_ops.apic, d, cmd); }static inline int xsm_memtype (xsm_default_t def,uint32_t access) { -return xsm_ops.memtype (access); +return alternative_call (xsm_ops.memtype, access); }static inline int xsm_machine_memory_map (xsm_default_t def) { -return xsm_ops.machine_memory_map (); +return alternative_call (xsm_ops.machine_memory_map); }static inline int xsm_domain_memory_map (xsm_default_t def,struct domain *d) { -return xsm_ops.domain_memory_map (d); +return alternative_call (xsm_ops.domain_memory_map, d); }static inline int xsm_mmu_update (xsm_default_t def,struct domain *d,struct domain *t,struct domain *f,uint32_t flags) { -return xsm_ops.mmu_update (d, t, f, flags); +return alternative_call (xsm_ops.mmu_update, d, t, f, flags); }static inline int xsm_mmuext_op (xsm_default_t def,struct domain *d,struct domain *f) { -return xsm_ops.mmuext_op (d, f); +return alternative_call (xsm_ops.mmuext_op, d, f); } static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, struct domain *f,
@@ -666,61 +667,61 @@ static inline int xsm_update_va_mapping(xsm_default_t def, struct domain *d, strstatic inline int xsm_priv_mapping (xsm_default_t def,struct domain *d,struct domain *t) { -return xsm_ops.priv_mapping (d, t); +return alternative_call (xsm_ops.priv_mapping, d, t); }static inline int xsm_ioport_permission (xsm_default_t def,struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -return xsm_ops.ioport_permission (d, s, e, allow); +return alternative_call (xsm_ops.ioport_permission, d, s, e, allow); }static inline int xsm_ioport_mapping (xsm_default_t def,struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -return xsm_ops.ioport_mapping (d, s, e, allow); +return alternative_call (xsm_ops.ioport_mapping, d, s, e, allow); }static inline int xsm_pmu_op (xsm_default_t def,struct domain *d,unsigned int op) { -return xsm_ops.pmu_op (d, op); +return alternative_call (xsm_ops.pmu_op, d, op); }#endif /* CONFIG_X86 */ static inline int xsm_dm_op (xsm_default_t def,struct domain *d) { -return xsm_ops.dm_op (d); +return alternative_call (xsm_ops.dm_op, d); }static inline int xsm_xen_version (xsm_default_t def,uint32_t op) { -return xsm_ops.xen_version (op); +return alternative_call (xsm_ops.xen_version, op); }static inline int xsm_domain_resource_map (xsm_default_t def,struct domain *d) { -return xsm_ops.domain_resource_map (d); +return alternative_call (xsm_ops.domain_resource_map, d); }#ifdef CONFIG_ARGO static inline int xsm_argo_enable (const struct domain *d) { -return xsm_ops.argo_enable (d); +return alternative_call (xsm_ops.argo_enable, d); }static inline int xsm_argo_register_single_source (const struct domain *d,const struct domain *t) { -return xsm_ops.argo_register_single_source (d, t); +return alternative_call (xsm_ops.argo_register_single_source, d, t); }static inline int xsm_argo_register_any_source (const struct domain *d) { -return xsm_ops.argo_register_any_source (d); +return alternative_call (xsm_ops.argo_register_any_source, d); }static inline int xsm_argo_send (const struct domain *d,const struct domain *t) { -return xsm_ops.argo_send (d, t); +return alternative_call (xsm_ops.argo_send, d, t); }#endif /* CONFIG_ARGO */
Signature · 1 line
2.20.1
PATCH v3 5/7 xsm: decouple xsm header inclusion selection
In reply to Daniel P. SmithMultiple preprocessor defines were used as a mechanism to selective include parts of the xsm.h header file. This makes it difficult to know which portion is being included at any one time. This commit works to simplify this by separating the core structures and functions of XSM into xsm-core.h away from the wrapper functions which remain in xsm.h and dummy.h.
--- xen/include/xsm/dummy.h | 2 +- xen/include/xsm/xsm-core.h | 273 +++++++++++++++++++++++++++++++++++++ xen/include/xsm/xsm.h | 243 +-------------------------------- xen/xsm/dummy.c | 1 - xen/xsm/silo.c | 1 - 5 files changed, 275 insertions(+), 245 deletions(-) create mode 100644 xen/include/xsm/xsm-core.h
xen/include/xsm/dummy.h +1 -1
@@ -16,7 +16,7 @@*/ #include <xen/sched.h> -#include <xsm/xsm.h> +#include <xsm/xsm-core.h> #include <public/hvm/params.h> /* Cannot use BUILD_BUG_ON here because the expressions we check are not
xen/include/xsm/xsm-core.h new file +273 -0
273 lines not on this page · raw message
xen/include/xsm/xsm.h +1 -242
264 lines not on this page · raw message
xen/xsm/dummy.c +0 -1
@@ -10,7 +10,6 @@* as published by the Free Software Foundation. */ -#define XSM_NO_WRAPPERS #include <xsm/dummy.h> #define set_to_dummy_if_null (ops, function) \
xen/xsm/silo.c +0 -1
@@ -17,7 +17,6 @@* You should have received a copy of the GNU General Public License along with * this program; If not, see <http://www.gnu.org/licenses/>. */ -#define XSM_NO_WRAPPERS #include <xsm/dummy.h> /*
Signature · 1 line
2.20.1
PATCH v3 6/7 xsm: drop generic event channel labeling exclusion
In reply to Daniel P. SmithThe internal define flag is not used by any XSM module, removing the #ifdef leaving the generic event channel labeling as always present.
--- xen/include/xen/sched.h | 4 ---- 1 file changed, 4 deletions(-)
xen/include/xen/sched.h +0 -4
@@ -120,15 +120,12 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSMunion { -#ifdef XSM_NEED_GENERIC_EVTCHN_SSID/* * If an XSM module needs more space for its event channel context, * this pointer stores the necessary data for the security server. */ void *generic; -#endif#ifdef CONFIG_XSM_FLASK /* * Inlining the contents of the structure for FLASK avoids unneeded
@@ -138,7 +135,6 @@ struct evtchnuint32_t flask_sid;#endif } ssid; -#endif } __attribute__((aligned(64)));int evtchn_init (struct domain *d,unsigned int max_port);
Signature · 1 line
2.20.1
PATCH v3 7/7 xsm: removing facade that XSM can be enabled/disabled
In reply to Daniel P. SmithThe XSM facilities are always in use by Xen with the facade of being able to turn XSM on and off. This option is in fact about allowing the selection of which policies are available and which are used at runtime. To provide this facade a complicated serious of #ifdef's are used to selective include different headers or portions of headers. This series of #ifdef gyrations switches between two different versions of the XSM hook interfaces and their respective backing implementation. All of this is done to provide a minimal size/performance optimization for when alternative policies are disabled.
To unwind the #ifdef gyrations a series of changes were necessary,
* replace CONFIG_XSM with XSM_CONFIGURABLE to allow visibility of selecting alternate XSM policy modules to those that require it
* adjusted CONFIG_XSM_SILO, CONFIG_XSM_FLASK, and the default module selection to sensible defaults
* collapsed the "dummy/defualt" XSM interface and implementation with the "multiple policy" interface to provide a single inlined implementation that attempts to use a registered hook and falls back to the check from the dummy implementation
* the collapse to a single interface broke code relying on the alternate interface, specifically SILO, this was reworked to remove the indirection/abstraction making SILO explicit in its access control decisions
* with the change of the XSM hooks to fall back to enforcing the dummy policy, it is no longer necessary to fill NULL entries in the struct xsm_ops returned by an XSM module's init
--- xen/common/Kconfig | 47 +- xen/include/xsm/dummy.h | 709 +---------------------------- xen/include/xsm/xsm-core.h | 26 -- xen/include/xsm/xsm.h | 904 ++++++++++++++++++++++++++++--------- xen/xsm/Makefile | 3 +- xen/xsm/dummy.c | 157 ------- xen/xsm/silo.c | 15 +- xen/xsm/xsm_core.c | 18 +- 8 files changed, 726 insertions(+), 1153 deletions(-) delete mode 100644 xen/xsm/dummy.c
xen/common/Kconfig +20 -27
@@ -200,23 +200,15 @@ config XENOPROF If unsure, say Y. -config XSM - bool "Xen Security Modules support" - default ARM - ---help--- - Enables the security framework known as Xen Security Modules which - allows administrators fine-grained control over a Xen domain and - its capabilities by defining permissible interactions between domains, - the hypervisor itself, and related resources such as memory and - devices. - - If unsure, say N. +config XSM_CONFIGURABLE + bool "Enable Configuring Xen Security Modules" config XSM_FLASK - def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + default n + depends on XSM_CONFIGURABLE + select XSM_EVTCHN_LABELING + help Enables FLASK (FLux Advanced Security Kernel) as the access control mechanism used by the XSM framework. This provides a mandatory access control framework by which security enforcement, isolation, and
@@ -226,10 +218,10 @@ config XSM_FLASK If unsure, say Y. config XSM_FLASK_AVC_STATS - def_bool y - prompt "Maintain statistics on the FLASK access vector cache" if EXPERT + bool "Maintain statistics on the FLASK access vector cache" if EXPERT + default y depends on XSM_FLASK - ---help--- + help Maintain counters on the access vector cache that can be viewed using the FLASK_AVC_CACHESTATS sub-op of the xsm_op hypercall. Disabling this will save a tiny amount of memory and time to update the stats.
@@ -240,7 +232,7 @@ config XSM_FLASK_POLICY bool "Compile Xen with a built-in FLASK security policy" default y if "$(XEN_HAS_CHECKPOLICY)" = "y" depends on XSM_FLASK - ---help--- + help This includes a default XSM policy in the hypervisor so that the bootloader does not need to load a policy to get sane behavior from an XSM-enabled hypervisor. If this is disabled, a policy must be
@@ -253,10 +245,11 @@ config XSM_FLASK_POLICY If unsure, say Y. config XSM_SILO - def_bool y - prompt "SILO support" - depends on XSM - ---help--- + bool "SILO support" + default y if ARM + default n + depends on XSM_CONFIGURABLE + help Enables SILO as the access control mechanism used by the XSM framework. This is not the default module, add boot parameter xsm=silo to choose it. This will deny any unmediated communication channels (grant tables
@@ -265,14 +258,14 @@ config XSM_SILO If unsure, say Y. choice - prompt "Default XSM implementation" - depends on XSM + prompt "Default XSM module" default XSM_SILO_DEFAULT if XSM_SILO && ARM default XSM_FLASK_DEFAULT if XSM_FLASK default XSM_SILO_DEFAULT if XSM_SILO default XSM_DUMMY_DEFAULT + depends on XSM_CONFIGURABLE config XSM_DUMMY_DEFAULT - bool "Match non-XSM behavior" + bool "Classic Dom0 behavior" config XSM_FLASK_DEFAULT bool "FLux Advanced Security Kernel" if XSM_FLASK config XSM_SILO_DEFAULT
@@ -282,7 +275,7 @@ endchoice config LATE_HWDOM bool "Dedicated hardware domain" default n - depends on XSM && X86 + depends on XSM_FLASK && X86 ---help--- Allows the creation of a dedicated hardware domain distinct from domain 0 that manages devices without needing access to other
xen/include/xsm/dummy.h +1 -708
730 lines not on this page · raw message
xen/include/xsm/xsm-core.h +0 -26
@@ -199,8 +199,6 @@ struct xsm_ops {extern void xsm_fixup_ops (struct xsm_ops *ops); -#ifdef CONFIG_XSM -#ifdef CONFIG_MULTIBOOT extern int xsm_multiboot_init (unsigned long *module_map,const multiboot_info_t *mbi);
@@ -246,28 +244,4 @@ static const inline struct xsm_ops *silo_init(void) }#endif -#else /* CONFIG_XSM */ - -#ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init (unsigned long *module_map, -const multiboot_info_t *mbi) -{ -return 0 ; -} -#endif - -#ifdef CONFIG_HAS_DEVICE_TREE -static inline int xsm_dt_init (void ) -{ -return 0 ; -} - -static inline bool has_xsm_magic (paddr_t start) -{ -return false; -} -#endif /* CONFIG_HAS_DEVICE_TREE */ - -#endif /* CONFIG_XSM */ -#endif /* __XSM_CORE_H */
xen/include/xsm/xsm.h +691 -213
1,236 lines not on this page · raw message
xen/xsm/Makefile +1 -2
@@ -1,6 +1,5 @@ obj-y += xsm_core.o -obj-$(CONFIG_XSM) += xsm_policy.o -obj-$(CONFIG_XSM) += dummy.o +obj-y += xsm_policy.o obj-$(CONFIG_XSM_SILO) += silo.o obj-$(CONFIG_XSM_FLASK) += flask/
xen/xsm/dummy.c deleted +0 -157
157 lines not on this page · raw message
xen/xsm/silo.c +8 -7
@@ -17,6 +17,7 @@* You should have received a copy of the GNU General Public License along with * this program; If not, see <http://www.gnu.org/licenses/>. */ +#include <xsm/xsm-core.h> #include <xsm/dummy.h> /*
@@ -43,7 +44,7 @@ static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,else {if (silo_mode_dom_check (d1, d2) ) - rc =xsm_evtchn_unbound (d1, chn, id2); + rc =xsm_default_action (XSM_TARGET , current->domain, d1);rcu_unlock_domain (d2); }
@@ -54,7 +55,7 @@ static int silo_evtchn_interdomain(struct domain *d1, struct evtchn *chan1, struct domain *d2, struct evtchn *chan2) { if ( silo_mode_dom_check(d1, d2) ) - return xsm_evtchn_interdomain(d1, chan1, d2, chan2); + return xsm_default_action(XSM_HOOK, d1, d2);return -EPERM ; }
@@ -62,21 +63,21 @@ static int silo_grant_mapref(struct domain *d1, struct domain *d2, uint32_t flags) {if (silo_mode_dom_check (d1, d2) ) -return xsm_grant_mapref (d1, d2, flags); +return xsm_default_action (XSM_HOOK , d1, d2);return -EPERM ; }static int silo_grant_transfer (struct domain *d1,struct domain *d2) {if (silo_mode_dom_check (d1, d2) ) -return xsm_grant_transfer (d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2);return -EPERM ; }static int silo_grant_copy (struct domain *d1,struct domain *d2) {if (silo_mode_dom_check (d1, d2) ) -return xsm_grant_copy (d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2);return -EPERM ; }
@@ -86,14 +87,14 @@ static int silo_argo_register_single_source(const struct domain *d1, const struct domain *d2) {if (silo_mode_dom_check (d1, d2) ) -return xsm_argo_register_single_source (d1, d2); +return 0 ;return -EPERM ; }static int silo_argo_send (const struct domain *d1,const struct domain *d2) {if (silo_mode_dom_check (d1, d2) ) -return xsm_argo_send (d1, d2); +return 0 ;return -EPERM ; }
xen/xsm/xsm_core.c +5 -13
@@ -18,8 +18,6 @@#include <xen/hypercall.h> #include <xsm/xsm.h> -#ifdef CONFIG_XSM -#ifdef CONFIG_MULTIBOOT #include <asm/setup.h> #endif
@@ -124,16 +122,12 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)break ; } -/* -* This handles three cases, -* - dummy policy module was selected -* - a policy module does not provide all handlers -* - a policy module failed to init -*/ -xsm_fixup_ops (&xsm_ops); - -if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) +if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) { xsm_ops_registered =XSM_OPS_REG_FAILED ; +printk (XENLOG_ERR +"Could not init XSM, xsm_ops register failed\n" ); +return -EFAULT ; + }return 0 ; }
@@ -217,8 +211,6 @@ bool __init has_xsm_magic(paddr_t start) }#endif -#endif -long do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) {return xsm_do_xsm_op (op);
Signature · 1 line
2.20.1
Re: [PATCH v3 1/7] xen: Implement xen/alternative-call.h for use in common code
In reply to Daniel P. SmithQuoted 46 lines · Daniel P. Smith
xen/include/xen/alternative-call.h new file +43
-0@@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef XEN_ALTERNATIVE_CALL +#define XEN_ALTERNATIVE_CALL + +/* +* Some subsystems in Xen may have multiple implementions, which can be +* resolved to a single implementation at boot time. By default, this will +* result in the use of function pointers. +* +* Some architectures may have mechanisms for dynamically modifying .text. +* Using this mechnaism, function pointers can be converted to direct calls +* which are typically more efficient at runtime. +* +* For architectures to support: +* +* - Implement alternative_{,v}call() in asm/alternative.h. Code generation +* requirements are to emit a function pointer call at build time, and stash +* enough metadata to simplify the call at boot once the implementation has +* been resolved. +* - Select ALTERNATIVE_CALL in Kconfig. +* +* To use: +* +* Consider the following simplified example. +* +* 1) struct foo_ops __alt_call_maybe_initdata ops; +* +* 2) const struct foo_ops __initconst foo_a_ops = { ... }; +* const struct foo_ops __initconst foo_b_ops = { ... }; +* +* void foo_init(void) +* { +* ... +* if ( use_impl_a ) +* ops = *foo_a_ops; +* else if ( use_impl_b ) +* ops = *foo_b_ops; +* ... +* } +* +* 3) alternative_call(ops.bar, ...); +* +* There needs to a single ops object (1) which will eventually contain the
xen/include/xen/alternative-call.h line 53
Quoted 10 lines
xen/include/xen/alternative-call.h new file +10
-0+* function pointers. This should be populated in foo's init() function (2) +* by one of the available implementations. To call functions, use +* alternative_{,v}call() referencing the main ops object (3). +*/ + +#ifdef CONFIG_ALTERNATIVE_CALL + +#include <asm/alternative.h> + +#define __alt_call_maybe_initdata __initdata
I think it wants (needs) clarifying that this may only be used if the ops object is used exclusively in alternative_{,v}call() instances (besides the original assignments to it, of course).
xen/include/xen/alternative-call.h line 60
Quoted 6 lines
xen/include/xen/alternative-call.h new file +6
-0+#else + +#define alternative_call(func, args...) (func)(args) +#define alternative_vcall(func, args...) (func)(args) + +#define __alt_call_maybe_initdata
Wouldn't this want to resolve to __read_mostly?
Jan
Re: [PATCH v3 3/7] xsm: refactor xsm_ops handling
In reply to Daniel P. SmithQuoted 7 lines · Daniel P. Smith
xen/include/xsm/xsm.h +0
-3@@ -747,16 +747,16 @@ extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);extern bool has_xsm_magic (paddr_t );#endif -extern int register_xsm (struct xsm_operations *ops); - -extern struct xsm_operations dummy_xsm_ops;
xen/include/xsm/xsm.h extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); · line 756
Quoted 10 lines
xen/include/xsm/xsm.h +4
-3-extern void xsm_fixup_ops (struct xsm_operations *ops); +extern void xsm_fixup_ops (struct xsm_ops *ops);#ifdef CONFIG_XSM_FLASK -extern void flask_init (const void *policy_buffer,size_t policy_size); +extern const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size);#else -static inline void flask_init (const void *policy_buffer,size_t policy_size) +static inline struct xsm_ops *flask_init(const void *policy_buffer,
Please use const consistently between real function and stub.
xen/include/xsm/xsm.h extern const unsigned int xsm_flask_init_policy_size; · line 771
Quoted 9 lines
xen/include/xsm/xsm.h +2
-2@@ -766,9 +766,12 @@ extern const unsigned int xsm_flask_init_policy_size;#endif #ifdef CONFIG_XSM_SILO -extern void silo_init (void ); +extern const struct xsm_ops *silo_init (void );#else -static inline void silo_init (void ) {} +static inline struct xsm_ops *silo_init (void )
Same here.
xen/xsm/flask/hooks.c static int flask_argo_send(const struct domain *d, const struct domain *t) · line 1748
Quoted 8 lines
xen/xsm/flask/hooks.c +1
-1@@ -1745,7 +1745,7 @@ static int flask_argo_send(const struct domain *d, const struct domain *t)long do_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op);int compat_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op); -static struct xsm_operations flask_ops = { +static const struct xsm_ops __initconst flask_ops = {
__initconstrel please (I thought I had pointed out the difference already during earlier discussion). Same for SILO then of course.
xen/xsm/xsm_core.c line 33
Quoted 11 lines
xen/xsm/xsm_core.c +2
-2@@ -28,9 +28,17 @@#include <asm/setup.h> #endif -#define XSM_FRAMEWORK_VERSION "1.0.0" +#define XSM_FRAMEWORK_VERSION "1.0.1" -struct xsm_operations *xsm_ops; +struct xsm_ops xsm_ops;
__read_mostly?
Jan
Re: [PATCH v3 2/7] xsm: remove the ability to disable flask
In reply to Daniel P. SmithQuoted 11 lines · Daniel P. Smith
On Linux when SELinux is put into permissive mode the descretionary access controls are still in place. Whereas for Xen when the enforcing state of flask is set to permissive, all operations for all domains would succeed, i.e. it does not fall back to the default access controls. To provide a means to mimic a similar but not equivalent behavior, a flask op is present to allow a one-time switch back to the default access controls, aka the "dummy policy".
This patch removes this flask op to enforce a consistent XSM usage model that a reboot of Xen is required to change the XSM policy module in use.
Signed-off-by Daniel P. Smith <[email protected]>
The primary reason you remove this is - aiui - that with alternatives patching there's technically not really a way back (would need to re- patch every patched location, or every hook would need to check whether state changed to disabled and if so chain on to the dummy function). This became sufficiently clear to me only when looking at the next patch. It would be nice if description also said why the change is needed. As it stands to me the description reads at best like something that people could have different views on (and initially I didn't mean to reply here, for not being convinced of the removal of functionality in the common case).
Jan
Re: [PATCH v3 6/7] xsm: drop generic event channel labeling exclusion
In reply to Daniel P. SmithQuoted 2 lines · Daniel P. Smith
The internal define flag is not used by any XSM module, removing the #ifdef leaving the generic event channel labeling as always present.
With this description ...
Quoted 19 lines
xen/include/xen/sched.h +0
-3@@ -120,15 +120,12 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSMunion { -#ifdef XSM_NEED_GENERIC_EVTCHN_SSID/* * If an XSM module needs more space for its event channel context, * this pointer stores the necessary data for the security server. */ void *generic; -#endif#ifdef CONFIG_XSM_FLASK /* * Inlining the contents of the structure for FLASK avoids unneeded
xen/include/xen/sched.h struct evtchn · line 138
Quoted 5 lines
xen/include/xen/sched.h +0
-1@@ -138,7 +135,6 @@ struct evtchnuint32_t flask_sid;#endif } ssid; -#endif } __attribute__((aligned(64)));
... I can see the inner #ifdef go away, but not the outer one. While the (imo bogus) attribute means you don't alter the size of the struct, I'm afraid that's not obvious at all without counting bits and bytes, and hence this may also want saying explicitly in the description.
Jan
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
In reply to Daniel P. SmithQuoted 12 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +9
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +*
xen/include/xsm/xsm-core.h line 19
Quoted 10 lines
xen/include/xsm/xsm-core.h new file +10
-0+* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ + +#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h>
I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like multiboot.h isn't fit for this.
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);
Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
xen/include/xsm/xsm-core.h line 35
Quoted 12 lines
xen/include/xsm/xsm-core.h new file +12
-0+/* policy magic number (defined by XSM_MAGIC) */ +typedef uint32_t xsm_magic_t ; + +#ifdef CONFIG_XSM_FLASK +#define XSM_MAGIC 0xf97cff8c +#else +#define XSM_MAGIC 0x0 +#endif + +/* These annotations are used by callers and in dummy.h to document the +* default actions of XSM hooks. They should be compiled out otherwise. +*/
I realize you only move code, but like e.g. the u32 -> uint32_t change in context above I'd like to encourage you to also address other style issues in the newly introduced file. Here I'm talking about comment style, requiring /* to be on its own line.
xen/include/xsm/xsm-core.h line 47
Quoted 12 lines
xen/include/xsm/xsm-core.h new file +12
-0+enum xsm_default { +XSM_HOOK ,/* Guests can normally access the hypercall */ +XSM_DM_PRIV ,/* Device model can perform on its target domain */ +XSM_TARGET ,/* Can perform on self or your target domain */ +XSM_PRIV ,/* Privileged - normally restricted to dom0 */ +XSM_XS_PRIV ,/* Xenstore domain - can do some privileged operations */ +XSM_OTHER /* Something more complex */ +}; +typedef enum xsm_default xsm_default_t ; + +struct xsm_ops { + void (*security_domaininfo) (struct domain *d,
Similarly here (and below) - we don't normally put a blank between the closing and opening parentheses in function pointer declarations. The majority does so here, but ...
xen/include/xsm/xsm-core.h line 135
Quoted 3 lines
[...]
xen/include/xsm/xsm-core.h new file +2
-0+int (*page_offline)(uint32_t cmd); +int (*hypfs_op)(void );
... there are exceptions.
Quoted 18 lines
[...]
xen/include/xsm/xsm-core.h new file +17
-0+int (*platform_op) (uint32_t cmd); + +#ifdef CONFIG_X86 +int (*do_mca) (void ); +int (*shadow_control) (struct domain *d,uint32_t op); +int (*mem_sharing_op) (struct domain *d,struct domain *cd,int op); +int (*apic) (struct domain *d,int cmd); +int (*memtype) (uint32_t access); +int (*machine_memory_map) (void ); +int (*domain_memory_map) (struct domain *d); +#define XSM_MMU_UPDATE_READ 1 +#define XSM_MMU_UPDATE_WRITE 2 +#define XSM_MMU_NORMAL_UPDATE 4 +#define XSM_MMU_MACHPHYS_UPDATE 8 +int (*mmu_update) (struct domain *d,struct domain *t, +struct domain *f,uint32_t flags); +int (*mmuext_op) (struct domain *d,struct domain *f);
xen/include/xsm/xsm-core.h line 188
Quoted 10 lines
xen/include/xsm/xsm-core.h new file +10
-0+int (*update_va_mapping) (struct domain *d,struct domain *f, +l1_pgentry_t pte); +int (*priv_mapping) (struct domain *d,struct domain *t); +int (*ioport_permission) (struct domain *d,uint32_t s,uint32_t e, +uint8_t allow); +int (*ioport_mapping) (struct domain *d,uint32_t s,uint32_t e, +uint8_t allow); +int (*pmu_op) (struct domain *d,unsigned int op); +#endif +int (*dm_op) (struct domain *d);
To match grouping elsewhere, a blank line above here, ...
xen/include/xsm/xsm-core.h line 191
Quoted 3 lines
xen/include/xsm/xsm-core.h new file +3
-0+int (*xen_version) (uint32_t cmd); +int (*domain_resource_map) (struct domain *d); +#ifdef CONFIG_ARGO
... and here would be nice.
Quoted 37 lines
xen/include/xsm/xsm-core.h new file +37
-0+int (*argo_enable) (const struct domain *d); +int (*argo_register_single_source) (const struct domain *d, +const struct domain *t); +int (*argo_register_any_source) (const struct domain *d); +int (*argo_send) (const struct domain *d,const struct domain *t); +#endif +}; + +extern void xsm_fixup_ops (struct xsm_ops *ops); + +#ifdef CONFIG_XSM + +#ifdef CONFIG_MULTIBOOT +extern int xsm_multiboot_init (unsigned long *module_map, +const multiboot_info_t *mbi); +extern int xsm_multiboot_policy_init (unsigned long *module_map, +const multiboot_info_t *mbi, +void **policy_buffer, +size_t *policy_size); +#endif + +#ifdef CONFIG_HAS_DEVICE_TREE +/* +* Initialize XSM +* +* On success, return 1 if using SILO mode else 0. +*/ +extern int xsm_dt_init (void ); +extern int xsm_dt_policy_init (void **policy_buffer,size_t *policy_size); +extern bool has_xsm_magic (paddr_t ); +#endif + +#ifdef CONFIG_XSM_FLASK +extern const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size); +#else +static inline const struct xsm_ops *flask_init(const void *policy_buffer,
xen/include/xsm/xsm-core.h line 238
Quoted 10 lines
xen/include/xsm/xsm-core.h new file +10
-0+ size_t policy_size) +{ +return NULL ; +} +#endif + +#ifdef CONFIG_XSM_FLASK_POLICY +extern const unsigned char xsm_flask_init_policy[]; +extern const unsigned int xsm_flask_init_policy_size; +#endif
To be honest, I don't think this belongs in any header. This interfaces with a generated assembly file. In such a case I would always suggest to limit visibility of the symbols as much as possible, i.e. put the declarations in the sole file referencing them.
xen/include/xsm/xsm-core.h line 252
Quoted 13 lines
xen/include/xsm/xsm-core.h new file +13
-0+#ifdef CONFIG_XSM_SILO +extern const struct xsm_ops *silo_init (void ); +#else +static const inline struct xsm_ops *silo_init (void ) +{ +return NULL ; +} +#endif + +#else /* CONFIG_XSM */ + +#ifdef CONFIG_MULTIBOOT +static inline int xsm_multiboot_init (unsigned long *module_map,
Nit: Stray blank ahead of the opening parenthesis.
Looking back there's also the question of "extern" on function declarations. In new code I don't think we put the redundant storage class specifier there; they're only needed on data declarations. I'm inclined to suggest to drop all of them while moving the code.
Preferably with these adjustments
Jan
Re: [PATCH v3 7/7] xsm: removing facade that XSM can be enabled/disabled
In reply to Daniel P. SmithQuoted 4 lines · Daniel P. Smith
The XSM facilities are always in use by Xen with the facade of being able to turn XSM on and off. This option is in fact about allowing the selection of which policies are available and which are used at runtime. To provide this facade a complicated serious of #ifdef's are used to selective include
Nit: It took me a moment to realize that the sentence reads oddly because you likely mean "series", not "serious".
Quoted 5 lines
different headers or portions of headers. This series of #ifdef gyrations switches between two different versions of the XSM hook interfaces and their respective backing implementation. All of this is done to provide a minimal size/performance optimization for when alternative policies are disabled.
Quoted 16 lines
To unwind the #ifdef gyrations a series of changes were necessary,
* replaceCONFIG_XSMwithXSM_CONFIGURABLEto allow visibility of selecting alternate XSM policy modules to those that require it
* adjustedCONFIG_XSM_SILO,CONFIG_XSM_FLASK, and the default module selection to sensible defaults
* collapsed the "dummy/defualt" XSM interface and implementation with the "multiple policy" interface to provide a single inlined implementation that attempts to use a registered hook and falls back to the check from the dummy implementation
* the collapse to a single interface broke code relying on the alternate interface, specifically SILO, this was reworked to remove the indirection/abstraction making SILO explicit in its access control decisions
* with the change of the XSM hooks to fall back to enforcing the dummy policy, it is no longer necessary to fill NULL entries in the structxsm_opsreturned by an XSM module's init
It would be nice if some of this could be split. Is this really close to impossible?
Quoted 9 lines
xen/common/Kconfig +0
-3@@ -200,23 +200,15 @@ config XENOPROF If unsure, say Y. -config XSM - bool "Xen Security Modules support" - default ARM
xen/common/Kconfig config XENOPROF · line 204
Quoted 10 lines
xen/common/Kconfig +2
-8- ---help--- - Enables the security framework known as Xen Security Modules which - allows administrators fine-grained control over a Xen domain and - its capabilities by defining permissible interactions between domains, - the hypervisor itself, and related resources such as memory and - devices. - - If unsure, say N. +config XSM_CONFIGURABLE + bool "Enable Configuring Xen Security Modules"
Is there a reason to change not only the prompt, but also the name of the Kconfig setting? This alone is the reason for some otherwise unnecessary code churn.
Also please correct indentation here.
xen/common/Kconfig config XENOPROF · line 208
Quoted 7 lines
xen/common/Kconfig +2
-4config XSM_FLASK - def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + default n
I don't understand this change in default (and as an aside, a default of "n" doesn't need spelling out): In the description you say "adjusted CONFIG_XSM_SILO, CONFIG_XSM_FLASK, and the default module selection to sensible defaults". If that's to describe this change, then I'm afraid I don't see why defaulting to "n" is more sensible once the person configuring Xen has chosen the configure XSM's (or XSM_CONFIGURABLE's) sub-options. If that's unrelated to the change here, then I'm afraid I'm missing justification altogether. (Same for SILO then.)
xen/common/Kconfig config XENOPROF · line 210
Quoted 2 lines
xen/common/Kconfig +2
-0+ depends on XSM_CONFIGURABLE + select XSM_EVTCHN_LABELING
Neither this nor any prior patch introduces an option of this name, and there's also none in the present tree. All afaics; I may have overlooked something or typo-ed a "grep" command.
xen/common/Kconfig config XSM_SILO · line 266
Quoted 12 lines
xen/common/Kconfig +2
-2@@ -265,14 +258,14 @@ config XSM_SILO If unsure, say Y. choice - prompt "Default XSM implementation" - depends on XSM + prompt "Default XSM module" default XSM_SILO_DEFAULT if XSM_SILO && ARM default XSM_FLASK_DEFAULT if XSM_FLASK default XSM_SILO_DEFAULT if XSM_SILO default XSM_DUMMY_DEFAULT + depends on XSM_CONFIGURABLE
With the larger set of "default" lines I'd like to suggest to keep "depends on" ahead of them.
xen/common/Kconfig endchoice · line 278
Quoted 6 lines
xen/common/Kconfig +1
-1@@ -282,7 +275,7 @@ endchoice config LATE_HWDOM bool "Dedicated hardware domain" default n - depends on XSM && X86 + depends on XSM_FLASK && X86
This change is not mentioned or justified in the description. In fact I think it is unrelated to the change here and hence would want breaking out.
xen/common/Kconfig endchoice · line 279
Quoted 1 line
xen/common/Kconfig +0
-0---help---
As you're changing these elsewhere, any chance of you also changing this one to just "help"?
Quoted 12 lines
xen/include/xsm/xsm.h +2
-2@@ -19,545 +19,1023 @@#include <xen/sched.h> #include <xen/multiboot.h> #include <xsm/xsm-core.h> - -#ifdef CONFIG_XSM +#include <xsm/dummy.h> +#include <public/version.h> extern struct xsm_ops xsm_ops;
xen/include/xsm/xsm.h line 32
Quoted 10 lines
xen/include/xsm/xsm.h +5
-3-static inline void xsm_security_domaininfo (struct domain *d, -struct xen_domctl_getdomaininfo *info) +static inline void xsm_security_domaininfo ( +struct domain *d, +struct xen_domctl_getdomaininfo *info) { -alternative_vcall (xsm_ops.security_domaininfo, d, info); +if ( xsm_ops.security_domaininfo ) +alternative_vcall (xsm_ops.security_domaininfo, d, info);
Here and everywhere else, when !XSM_CONFIGURABLE you now needlessly force NULL checks to occur which are never going to be true. There's then also the dead indirect call and the associated patching data. I think this wants hiding in another pair of wrappers, which simply expand to nothing when !XSM_CONFIGURABLE - perhaps xsm_vcall() and xsm_call().
xen/include/xsm/xsm.h line 36
Quoted 5 lines
xen/include/xsm/xsm.h +2
-1} -static inline int xsm_domain_create (xsm_default_t def,struct domain *d,u32 ssidref) +static inline int xsm_domain_create (xsm_default_t action,struct domain *d, +u32 ssidref)
It would be nice if you kept on converting u32 -> uint32_t as you did in earlier patches.
xen/include/xsm/xsm.h line 41
Quoted 6 lines
xen/include/xsm/xsm.h +4
-1{ -return alternative_call (xsm_ops.domain_create, d, ssidref); +if ( xsm_ops.domain_create ) +return alternative_call (xsm_ops.domain_create, d, ssidref); + +XSM_ASSERT_ACTION (XSM_HOOK );
Any reason not to put these assertions first in the functions?
xen/include/xsm/xsm.h line 43
Quoted 2 lines
xen/include/xsm/xsm.h +1
-0+return xsm_default_action (action, current->domain, d); }
Since
static inline int xsm_domain_create(xsm_default_t action, struct domain *d,
uint32_t ssidref)
{
XSM_ASSERT_ACTION(XSM_HOOK);
return xsm_call(xsm_ops.domain_create, d, ssidref);
return xsm_default_action(action, current->domain, d);
}won't work, and since integrating "return" into xsm_call() also would't yield a sufficiently clear result:
static inline int xsm_domain_create(xsm_default_t action, struct domain *d,
uint32_t ssidref)
{
XSM_ASSERT_ACTION(XSM_HOOK);
xsm_call(xsm_ops.domain_create, d, ssidref);
return xsm_default_action(action, current->domain, d);
}(as control flow would be unobvious), the xsm_default_action() invocation likely would also need integrating into xsm_call() then.
Unless there's some obstacle, this would eliminate a whole lot of code redundancy.
xen/include/xsm/xsm.h line 81
Quoted 11 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) +static inline int xsm_set_target (xsm_default_t action,struct domain *d, +struct domain *e) { -return alternative_call (xsm_ops.set_target, d, e); +if ( xsm_ops.set_target ) +return alternative_call (xsm_ops.set_target, d, e); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, current->domain,NULL ); }
While benign because xsm_default_action() does nothing for XSM_HOOK, I think there's an inconsistency here which rather wants correcting (in a prereq patch): The default hook should have been passed consistent arguments, no matter whether used because of !XSM or because of the module in use left the hook unset.
Of course such anomalies are much easier to notice (outside of review of patches introducing such) with you now placing both invocations next to each other.
Quoted 6 lines
xen/include/xsm/xsm.h +4
-2-static inline int xsm_evtchn_interdomain (xsm_default_t def,struct domain *d1, -struct evtchn *chan1,struct domain *d2,struct evtchn *chan2) +static inline int xsm_evtchn_interdomain(xsm_default_t action, + struct domain *d1, + struct evtchn *chan1, + struct domain *d2,
xen/include/xsm/xsm.h line 143
Quoted 10 lines
xen/include/xsm/xsm.h +7
-1+ struct evtchn *chan2) { -return alternative_call (xsm_ops.evtchn_interdomain, d1, chan1, d2, chan2); +if ( xsm_ops.evtchn_interdomain ) +return alternative_call (xsm_ops.evtchn_interdomain, d1, chan1, d2, + chan2); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2); }
There's another anomaly here: The first argument to xsm_default_action() typically is current->domain in similar functions. Here d1 gets passed in despite always being current->domain. I think the unnecessary parameter wants dropping (again in a prereq patch)) from the wrapper and hook, to avoid giving the wrong impression of both domains potentially being remote ones.
xen/include/xsm/xsm.h line 158
Quoted 10 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_evtchn_send (xsm_default_t def,struct domain *d,struct evtchn *chn) +static inline int xsm_evtchn_send (xsm_default_t action,struct domain *d, +struct evtchn *chn) { -return alternative_call (xsm_ops.evtchn_send, d, chn); +if ( xsm_ops.evtchn_send ) +return alternative_call (xsm_ops.evtchn_send, d, chn); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d,NULL );
This again looks wrong (and again is benign only because XSM_HOOK means xsm_default_action() ignores the other function parameters), wanting to follow the usual
return xsm_default_action(action, current->domain, d);
pattern instead.
xen/include/xsm/xsm.h line 178
Quoted 10 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_evtchn_reset (xsm_default_t def,struct domain *d1,struct domain *d2) +static inline int xsm_evtchn_reset (xsm_default_t action,struct domain *d1, +struct domain *d2) { -return alternative_call (xsm_ops.evtchn_reset, d1, d2); +if ( xsm_ops.evtchn_reset ) +return alternative_call (xsm_ops.evtchn_reset, d1, d2); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2);
See xsm_evtchn_interdomain() above.
xen/include/xsm/xsm.h line 188
Quoted 11 lines
xen/include/xsm/xsm.h +7
-3-static inline int xsm_grant_mapref (xsm_default_t def,struct domain *d1,struct domain *d2, -uint32_t flags) +static inline int xsm_grant_mapref (xsm_default_t action,struct domain *d1, +struct domain *d2,uint32_t flags) { -return alternative_call (xsm_ops.grant_mapref, d1, d2, flags); +if ( xsm_ops.grant_mapref ) +return alternative_call (xsm_ops.grant_mapref, d1, d2, flags); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2);
Again (more similar grant ones follow).
xen/include/xsm/xsm.h line 324
Quoted 12 lines
xen/include/xsm/xsm.h +8
-3-static inline int xsm_memory_adjust_reservation (xsm_default_t def,struct domain *d1,struct -domain *d2) +static inline int xsm_memory_adjust_reservation (xsm_default_t action, +struct domain *d1, +struct domain *d2) { -return alternative_call (xsm_ops.memory_adjust_reservation, d1, d2); +if ( xsm_ops.memory_adjust_reservation ) +return alternative_call (xsm_ops.memory_adjust_reservation, d1, d2); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2);
Again (more similar memory ones follow).
xen/include/xsm/xsm.h line 345
Quoted 11 lines
xen/include/xsm/xsm.h +7
-3-static inline int xsm_memory_pin_page (xsm_default_t def,struct domain *d1,struct domain *d2, -struct page_info *page) +static inline int xsm_memory_pin_page (xsm_default_t action,struct domain *d1, +struct domain *d2,struct page_info *page) { -return alternative_call (xsm_ops.memory_pin_page, d1, d2, page); +if ( xsm_ops.memory_pin_page ) +return alternative_call (xsm_ops.memory_pin_page, d1, d2, page); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2);
This one has the same issue, but is more interesting: There's no similar hook/check for unpinning a page (nor does the same check get re-used there). Plus it's x86 (more precisely PV) specific.
xen/include/xsm/xsm.h line 375
Quoted 10 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_map_gmfn_foreign (xsm_default_t def,struct domain *d,struct domain *t) +static inline int xsm_map_gmfn_foreign (xsm_default_t action,struct domain *d, +struct domain *t) { -return alternative_call (xsm_ops.map_gmfn_foreign, d, t); +if ( xsm_ops.map_gmfn_foreign ) +return alternative_call (xsm_ops.map_gmfn_foreign, d, t); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d, t);
This one is also interesting: There's no check at all here that current->domain has any permissions towards d or t. Interestingly even flask_map_gmfn_foreign() doesn't check this.
Quoted 5 lines
xen/include/xsm/xsm.h +2
-2-static inline int xsm_console_io (xsm_default_t def,struct domain *d,int cmd) +static inline int xsm_console_io (xsm_default_t action,struct domain *d,int cmd) { -return alternative_call (xsm_ops.console_io, d, cmd); +if ( xsm_ops.console_io )
xen/include/xsm/xsm.h line 399
Quoted 10 lines
xen/include/xsm/xsm.h +10
-0+return alternative_call (xsm_ops.console_io, d, cmd); + +XSM_ASSERT_ACTION (XSM_OTHER ); +if ( d->is_console ) +return xsm_default_action (XSM_HOOK , d,NULL ); +#ifdef CONFIG_VERBOSE_DEBUG +if ( cmd == CONSOLEIO_write ) +return xsm_default_action (XSM_HOOK , d,NULL ); +#endif +return xsm_default_action (XSM_PRIV , d,NULL );
Same implication of d == current->domain here again. I guess I'll stop enumerating further ones.
xen/include/xsm/xsm.h line 534
Quoted 11 lines
xen/include/xsm/xsm.h +8
-2-static inline int xsm_pci_config_permission (xsm_default_t def,struct domain *d,uint32_t machine_bdf,uint16_t start,uint16_t end,uint8_t access) +static inline int xsm_pci_config_permission (xsm_default_t action, +struct domain *d, +uint32_t machine_bdf, +uint16_t start, +uint16_t end, +uint8_t access) { -return alternative_call (xsm_ops.pci_config_permission, d, machine_bdf, start, end, access); +if ( xsm_ops.pci_config_permission ) +return alternative_call (xsm_ops.pci_config_permission, d, machine_bdf, start, end, access);
Nit: Line length.
Quoted 8 lines
xen/include/xsm/xsm.h +5
-2-static inline int xsm_pmu_op (xsm_default_t def,struct domain *d,unsigned int op) +static inline int xsm_pmu_op (xsm_default_t action,struct domain *d, +unsigned int op) { -return alternative_call (xsm_ops.pmu_op, d, op); +if ( xsm_ops.pmu_op ) +return alternative_call (xsm_ops.pmu_op, d, op); +
xen/include/xsm/xsm.h line 954
Quoted 10 lines
xen/include/xsm/xsm.h +10
-0+XSM_ASSERT_ACTION (XSM_OTHER ); +switch ( op ) + { +case XENPMU_init: +case XENPMU_finish: +case XENPMU_lvtpc_set: +case XENPMU_flush: +return xsm_default_action (XSM_HOOK , d, current->domain); +default : +return xsm_default_action (XSM_PRIV , d, current->domain);
Urgh - isn't this the wrong way round? (Luckily vPMU isn't security supported, so no XSA would be needed.)
xen/xsm/Makefile line 2
Quoted 7 lines
xen/xsm/Makefile +1
-2@@ -1,6 +1,5 @@ obj-y += xsm_core.o -obj-$(CONFIG_XSM) += xsm_policy.o -obj-$(CONFIG_XSM) += dummy.o +obj-y += xsm_policy.o
Why would this now need compiling in all cases?
xen/xsm/silo.c line 21
Quoted 8 lines
xen/xsm/silo.c +1
-0@@ -17,6 +17,7 @@* You should have received a copy of the GNU General Public License along with * this program; If not, see <http://www.gnu.org/licenses/>. */ +#include <xsm/xsm-core.h> #include <xsm/dummy.h>
As already mentioned elsewhere - where possible please arrange #include-s alphabetically.
Quoted 4 lines
xen/xsm/silo.c +0
-0@@ -124,16 +122,12 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)break ; }
xen/xsm/silo.c static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 125
Quoted 10 lines
xen/xsm/silo.c +1
-9-/* -* This handles three cases, -* - dummy policy module was selected -* - a policy module does not provide all handlers -* - a policy module failed to init -*/ -xsm_fixup_ops (&xsm_ops); - -if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) +if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) {
Nit (style): Brace goes on its own line.
Jan
Re: [PATCH v3 2/7] xsm: remove the ability to disable flask
In reply to Jan BeulichQuoted 24 lines · Jan Beulich
Quoted 11 lines · Daniel P. Smith
On Linux when SELinux is put into permissive mode the descretionary access controls are still in place. Whereas for Xen when the enforcing state of flask is set to permissive, all operations for all domains would succeed, i.e. it does not fall back to the default access controls. To provide a means to mimic a similar but not equivalent behavior, a flask op is present to allow a one-time switch back to the default access controls, aka the "dummy policy".
This patch removes this flask op to enforce a consistent XSM usage model that a reboot of Xen is required to change the XSM policy module in use.
Signed-off-by Daniel P. Smith <[email protected]>The primary reason you remove this is - aiui - that with alternatives patching there's technically not really a way back (would need to re- patch every patched location, or every hook would need to check whether state changed to disabled and if so chain on to the dummy function). This became sufficiently clear to me only when looking at the next patch. It would be nice if description also said why the change is needed. As it stands to me the description reads at best like something that people could have different views on (and initially I didn't mean to reply here, for not being convinced of the removal of functionality in the common case).
Quoted 2 lines
Jan
Ack, I can expand further.
v/r,
dps
Re: [PATCH v3 3/7] xsm: refactor xsm_ops handling
In reply to Jan BeulichQuoted 11 lines · Jan Beulich
Quoted 10 lines · Daniel P. Smith
xen/include/xsm/xsm.h +1
-4@@ -747,16 +747,16 @@ extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size);extern bool has_xsm_magic (paddr_t );#endif -extern int register_xsm (struct xsm_operations *ops); - -extern struct xsm_operations dummy_xsm_ops; -extern void xsm_fixup_ops (struct xsm_operations *ops); +extern void xsm_fixup_ops (struct xsm_ops *ops);
Quoted 9 lines
xen/include/xsm/xsm.h extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); · line 756
Quoted 7 lines
xen/include/xsm/xsm.h +3
-2#ifdef CONFIG_XSM_FLASK -extern void flask_init (const void *policy_buffer,size_t policy_size); +extern const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size);#else -static inline void flask_init (const void *policy_buffer,size_t policy_size) +static inline struct xsm_ops *flask_init(const void *policy_buffer,Please use const consistently between real function and stub.
Ack.
Quoted 11 lines
xen/include/xsm/xsm.h extern const unsigned int xsm_flask_init_policy_size; · line 771
Quoted 9 lines
xen/include/xsm/xsm.h +2
-2@@ -766,9 +766,12 @@ extern const unsigned int xsm_flask_init_policy_size;#endif #ifdef CONFIG_XSM_SILO -extern void silo_init (void ); +extern const struct xsm_ops *silo_init (void );#else -static inline void silo_init (void ) {} +static inline struct xsm_ops *silo_init (void )Same here.
Ack.
Quoted 11 lines
xen/xsm/flask/hooks.c static int flask_argo_send(const struct domain *d, const struct domain *t) · line 1748
Quoted 8 lines
xen/xsm/flask/hooks.c +1
-1@@ -1745,7 +1745,7 @@ static int flask_argo_send(const struct domain *d, const struct domain *t)long do_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op);int compat_flask_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) u_flask_op); -static struct xsm_operations flask_ops = { +static const struct xsm_ops __initconst flask_ops = {
__initconstrelplease (I thought I had pointed out the difference already during earlier discussion). Same for SILO then of course.
Apologies, yes you did and that is my fault as I had only recorded the __initconst suggestion in my checklist and did not update with your __initconstrel suggestion.
Quoted 6 lines
Quoted 6 lines
xen/xsm/xsm_core.c +0
-0@@ -28,9 +28,17 @@#include <asm/setup.h> #endif
Quoted 7 lines
xen/xsm/xsm_core.c line 33
Quoted 5 lines
xen/xsm/xsm_core.c +2
-2-#define XSM_FRAMEWORK_VERSION "1.0.0" +#define XSM_FRAMEWORK_VERSION "1.0.1" -struct xsm_operations *xsm_ops; +struct xsm_ops xsm_ops;
__read_mostly?
Ack.
v/r,
dps
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
In reply to Jan BeulichQuoted 18 lines · Jan Beulich
Quoted 17 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +14
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ +
Quoted 8 lines
xen/include/xsm/xsm-core.h line 19
Quoted 5 lines
xen/include/xsm/xsm-core.h new file +5
-0+#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h> I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like
multiboot.hisn't fit for this.
So my understanding is to leave this as is.
Quoted 5 lines
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
Unless I am misunderstanding what you are calling for, I am afraid this will trickle further that what intended to be addressed in this patch set. If disagree and would like to provide me a suggest that stays bounded, I would gladly incorporate.
Quoted 9 lines
Quoted 9 lines
xen/include/xsm/xsm-core.h new file +9
-0+/* policy magic number (defined by XSM_MAGIC) */ +typedef uint32_t xsm_magic_t ; + +#ifdef CONFIG_XSM_FLASK +#define XSM_MAGIC 0xf97cff8c +#else +#define XSM_MAGIC 0x0 +#endif +
Quoted 8 lines
xen/include/xsm/xsm-core.h line 35
Quoted 3 lines
xen/include/xsm/xsm-core.h new file +3
-0+/* These annotations are used by callers and in dummy.h to document the +* default actions of XSM hooks. They should be compiled out otherwise. +*/ I realize you only move code, but like e.g. the u32 ->
uint32_tchange in context above I'd like to encourage you to also address other style issues in the newly introduced file. Here I'm talking about comment style, requiring /* to be on its own line.
Ack.
Quoted 8 lines
Quoted 8 lines
xen/include/xsm/xsm-core.h new file +8
-0+enum xsm_default { +XSM_HOOK ,/* Guests can normally access the hypercall */ +XSM_DM_PRIV ,/* Device model can perform on its target domain */ +XSM_TARGET ,/* Can perform on self or your target domain */ +XSM_PRIV ,/* Privileged - normally restricted to dom0 */ +XSM_XS_PRIV ,/* Xenstore domain - can do some privileged operations */ +XSM_OTHER /* Something more complex */ +};
Quoted 8 lines
xen/include/xsm/xsm-core.h line 47
Quoted 4 lines
xen/include/xsm/xsm-core.h new file +4
-0+typedef enum xsm_default xsm_default_t ; + +struct xsm_ops { + void (*security_domaininfo) (struct domain *d,Similarly here (and below) - we don't normally put a blank between the closing and opening parentheses in function pointer declarations. The majority does so here, but ...
Ack.
Quoted 28 lines
xen/include/xsm/xsm-core.h line 135
Quoted 3 lines
[...]
xen/include/xsm/xsm-core.h new file +2
-0+int (*page_offline)(uint32_t cmd); +int (*hypfs_op)(void );... there are exceptions.
Quoted 22 lines
[...]
xen/include/xsm/xsm-core.h new file +21
-0+int (*platform_op) (uint32_t cmd); + +#ifdef CONFIG_X86 +int (*do_mca) (void ); +int (*shadow_control) (struct domain *d,uint32_t op); +int (*mem_sharing_op) (struct domain *d,struct domain *cd,int op); +int (*apic) (struct domain *d,int cmd); +int (*memtype) (uint32_t access); +int (*machine_memory_map) (void ); +int (*domain_memory_map) (struct domain *d); +#define XSM_MMU_UPDATE_READ 1 +#define XSM_MMU_UPDATE_WRITE 2 +#define XSM_MMU_NORMAL_UPDATE 4 +#define XSM_MMU_MACHPHYS_UPDATE 8 +int (*mmu_update) (struct domain *d,struct domain *t, +struct domain *f,uint32_t flags); +int (*mmuext_op) (struct domain *d,struct domain *f); +int (*update_va_mapping) (struct domain *d,struct domain *f, +l1_pgentry_t pte); +int (*priv_mapping) (struct domain *d,struct domain *t); + int (*ioport_permission) (struct domain *d, uint32_t s, uint32_t e,
Quoted 8 lines
xen/include/xsm/xsm-core.h line 188
Quoted 6 lines
xen/include/xsm/xsm-core.h new file +6
-0+ uint8_t allow); +int (*ioport_mapping) (struct domain *d,uint32_t s,uint32_t e, +uint8_t allow); +int (*pmu_op) (struct domain *d,unsigned int op); +#endif +int (*dm_op) (struct domain *d);To match grouping elsewhere, a blank line above here, ...
Ack.
Quoted 5 lines
xen/include/xsm/xsm-core.h line 191
Quoted 3 lines
xen/include/xsm/xsm-core.h new file +3
-0+int (*xen_version) (uint32_t cmd); +int (*domain_resource_map) (struct domain *d); +#ifdef CONFIG_ARGO ... and here would be nice.
Ack.
Quoted 44 lines
Quoted 44 lines
xen/include/xsm/xsm-core.h new file +44
-0+int (*argo_enable) (const struct domain *d); +int (*argo_register_single_source) (const struct domain *d, +const struct domain *t); +int (*argo_register_any_source) (const struct domain *d); +int (*argo_send) (const struct domain *d,const struct domain *t); +#endif +}; + +extern void xsm_fixup_ops (struct xsm_ops *ops); + +#ifdef CONFIG_XSM + +#ifdef CONFIG_MULTIBOOT +extern int xsm_multiboot_init (unsigned long *module_map, +const multiboot_info_t *mbi); +extern int xsm_multiboot_policy_init (unsigned long *module_map, +const multiboot_info_t *mbi, +void **policy_buffer, +size_t *policy_size); +#endif + +#ifdef CONFIG_HAS_DEVICE_TREE +/* +* Initialize XSM +* +* On success, return 1 if using SILO mode else 0. +*/ +extern int xsm_dt_init (void ); +extern int xsm_dt_policy_init (void **policy_buffer,size_t *policy_size); +extern bool has_xsm_magic (paddr_t ); +#endif + +#ifdef CONFIG_XSM_FLASK +extern const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size); +#else +static inline const struct xsm_ops *flask_init (const void *policy_buffer, +size_t policy_size) +{ +return NULL ; +} +#endif + +#ifdef CONFIG_XSM_FLASK_POLICY
Quoted 8 lines
xen/include/xsm/xsm-core.h line 238
Quoted 3 lines
xen/include/xsm/xsm-core.h new file +3
-0+extern const unsigned char xsm_flask_init_policy[]; +extern const unsigned int xsm_flask_init_policy_size; +#endif To be honest, I don't think this belongs in any header. This interfaces with a generated assembly file. In such a case I would always suggest to limit visibility of the symbols as much as possible, i.e. put the declarations in the sole file referencing them.
Confirmed only used in xsm_core.c, so will move there.
Quoted 7 lines
Quoted 7 lines
xen/include/xsm/xsm-core.h new file +7
-0+#ifdef CONFIG_XSM_SILO +extern const struct xsm_ops *silo_init (void ); +#else +static const inline struct xsm_ops *silo_init (void ) +{ +return NULL ; +}
Quoted 8 lines
xen/include/xsm/xsm-core.h line 252
Quoted 6 lines
xen/include/xsm/xsm-core.h new file +6
-0+#endif + +#else /* CONFIG_XSM */ + +#ifdef CONFIG_MULTIBOOT +static inline int xsm_multiboot_init (unsigned long *module_map,Nit: Stray blank ahead of the opening parenthesis.
Ack.
Quoted 8 lines
Looking back there's also the question of "extern" on function declarations. In new code I don't think we put the redundant storage class specifier there; they're only needed on data declarations. I'm inclined to suggest to drop all of them while moving the code.
Preferably with these adjustments
Acked-by Jan Beulich <[email protected]>
I believe I have pretty much incorporated all your adjustments. Will include your Acked-by unless you feel I have not.
v/r,
dps
Re: [PATCH v3 6/7] xsm: drop generic event channel labeling exclusion
In reply to Jan BeulichQuoted 28 lines · Jan Beulich
Quoted 2 lines · Daniel P. Smith
The internal define flag is not used by any XSM module, removing the #ifdef leaving the generic event channel labeling as always present.
With this description ...
Quoted 22 lines
xen/include/xen/sched.h +0
-3@@ -120,15 +120,12 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSMunion { -#ifdef XSM_NEED_GENERIC_EVTCHN_SSID/* * If an XSM module needs more space for its event channel context, * this pointer stores the necessary data for the security server. */ void *generic; -#endif#ifdef CONFIG_XSM_FLASK /* * Inlining the contents of the structure for FLASK avoids unneeded @@ -138,7 +135,6 @@ struct evtchnuint32_t flask_sid;#endif } ssid;
Quoted 8 lines
xen/include/xen/sched.h struct evtchn · line 138
Quoted 2 lines
xen/include/xen/sched.h +0
-1-#endif } __attribute__((aligned(64)));... I can see the inner #ifdef go away, but not the outer one. While the (imo bogus) attribute means you don't alter the size of the struct, I'm afraid that's not obvious at all without counting bits and bytes, and hence this may also want saying explicitly in the description.
I can put the #ifdef CONFIG_XSM back and in the subsequent patch change it to CONFIG_XSM_CONFIGURABLE, making this the only difference between being able to select the XSM policy in effect or not.
v/r,
dps
Re: [PATCH v3 7/7] xsm: removing facade that XSM can be enabled/disabled
In reply to Jan BeulichQuoted 31 lines · Jan Beulich
Quoted 4 lines · Daniel P. Smith
The XSM facilities are always in use by Xen with the facade of being able to turn XSM on and off. This option is in fact about allowing the selection of which policies are available and which are used at runtime. To provide this facade a complicated serious of #ifdef's are used to selective include
Nit: It took me a moment to realize that the sentence reads oddly because you likely mean "series", not "serious".
Quoted 5 lines
different headers or portions of headers. This series of #ifdef gyrations switches between two different versions of the XSM hook interfaces and their respective backing implementation. All of this is done to provide a minimal size/performance optimization for when alternative policies are disabled.
Quoted 16 lines
To unwind the #ifdef gyrations a series of changes were necessary,
* replaceCONFIG_XSMwithXSM_CONFIGURABLEto allow visibility of selecting alternate XSM policy modules to those that require it
* adjustedCONFIG_XSM_SILO,CONFIG_XSM_FLASK, and the default module selection to sensible defaults
* collapsed the "dummy/defualt" XSM interface and implementation with the "multiple policy" interface to provide a single inlined implementation that attempts to use a registered hook and falls back to the check from the dummy implementation
* the collapse to a single interface broke code relying on the alternate interface, specifically SILO, this was reworked to remove the indirection/abstraction making SILO explicit in its access control decisions
* with the change of the XSM hooks to fall back to enforcing the dummy policy, it is no longer necessary to fill NULL entries in the structxsm_opsreturned by an XSM module's init
Quoted 2 lines
It would be nice if some of this could be split. Is this really close to impossible?
I am looking into that now, especially after my points below.
Quoted 15 lines
Quoted 15 lines
xen/common/Kconfig +0
-9@@ -200,23 +200,15 @@ config XENOPROF If unsure, say Y. -config XSM - bool "Xen Security Modules support" - default ARM - ---help--- - Enables the security framework known as Xen Security Modules which - allows administrators fine-grained control over a Xen domain and - its capabilities by defining permissible interactions between domains, - the hypervisor itself, and related resources such as memory and - devices.
Quoted 8 lines
xen/common/Kconfig config XENOPROF · line 204
Quoted 4 lines
xen/common/Kconfig +2
-2- - If unsure, say N. +config XSM_CONFIGURABLE + bool "Enable Configuring Xen Security Modules"Is there a reason to change not only the prompt, but also the name of the
Kconfigsetting? This alone is the reason for some otherwise unnecessary code churn.
Yes, because this idea of "turning off" XSM needs to end externally and internally. The XSM framework is always being used, it's just that it is possible to build a configuration with support only for the default/dummy policy, regardless of how the functions implementing the default/dummy policy are being invoked.
Quoted 1 line
Also please correct indentation here.
Ack.
Quoted 8 lines
xen/common/Kconfig config XENOPROF · line 208
Quoted 7 lines
xen/common/Kconfig +2
-4config XSM_FLASK - def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + default n
Quoted 8 lines
I don't understand this change in default (and as an aside, a default of "n" doesn't need spelling out): In the description you say "adjusted
CONFIG_XSM_SILO,CONFIG_XSM_FLASK, and the default module selection to sensible defaults". If that's to describe this change, then I'm afraid I don't see why defaulting to "n" is more sensible once the person configuring Xen has chosen the configure XSM's (or XSM_CONFIGURABLE's) sub-options. If that's unrelated to the change here, then I'm afraid I'm missing justification altogether. (Same for SILO then.)
When an individual selects to be able to be to configure/select alternative policy modules, they should be the ones to decide which one(s) should be enabled and not have presumptuous selections provided to them. IOW, the sensible default is to have no modules selected and allow the user to enable the one(s) they want.
Quoted 6 lines
xen/common/Kconfig config XENOPROF · line 210
Quoted 2 lines
xen/common/Kconfig +2
-0+ depends on XSM_CONFIGURABLE + select XSM_EVTCHN_LABELINGNeither this nor any prior patch introduces an option of this name, and there's also none in the present tree. All afaics; I may have overlooked something or typo-ed a "grep" command.
Ack, missed this in the previous patch. will clean it up there.
Quoted 14 lines
xen/common/Kconfig config XSM_SILO · line 266
Quoted 12 lines
xen/common/Kconfig +2
-2@@ -265,14 +258,14 @@ config XSM_SILO If unsure, say Y. choice - prompt "Default XSM implementation" - depends on XSM + prompt "Default XSM module" default XSM_SILO_DEFAULT if XSM_SILO && ARM default XSM_FLASK_DEFAULT if XSM_FLASK default XSM_SILO_DEFAULT if XSM_SILO default XSM_DUMMY_DEFAULT + depends on XSM_CONFIGURABLEWith the larger set of "default" lines I'd like to suggest to keep
Ack.
Quoted 10 lines
xen/common/Kconfig endchoice · line 278
Quoted 6 lines
xen/common/Kconfig +1
-1@@ -282,7 +275,7 @@ endchoice config LATE_HWDOM bool "Dedicated hardware domain" default n - depends on XSM && X86 + depends on XSM_FLASK && X86This change is not mentioned or justified in the description. In fact I think it is unrelated to the change here and hence would want breaking out.
Actually, if you read the help just below it specifically says to use this feature requires having an XSM policy (legacy wording for XSM Flask policy) to be able to do the proper fine grained delegation of the permissions/accesses necessary for a hardware domain to work. This should have been made XSM_FLASK when that KConfig option was added. Dropping the XSM KConfig option just exposed this oversight. Ack that I should have mentioned this in the commit message.
Quoted 4 lines
xen/common/Kconfig endchoice · line 279
Quoted 1 line
xen/common/Kconfig +0
-0---help---As you're changing these elsewhere, any chance of you also changing this one to just "help"?
Ack.
Quoted 13 lines
Quoted 13 lines
xen/include/xsm/xsm.h +2
-2@@ -19,545 +19,1023 @@#include <xen/sched.h> #include <xen/multiboot.h> #include <xsm/xsm-core.h> - -#ifdef CONFIG_XSM +#include <xsm/dummy.h> +#include <public/version.h> extern struct xsm_ops xsm_ops;
Quoted 16 lines
xen/include/xsm/xsm.h line 32
Quoted 9 lines
xen/include/xsm/xsm.h +5
-3-static inline void xsm_security_domaininfo (struct domain *d, -struct xen_domctl_getdomaininfo *info) +static inline void xsm_security_domaininfo ( +struct domain *d, +struct xen_domctl_getdomaininfo *info) { -alternative_vcall (xsm_ops.security_domaininfo, d, info); +if ( xsm_ops.security_domaininfo ) +alternative_vcall (xsm_ops.security_domaininfo, d, info);Here and everywhere else, when !XSM_CONFIGURABLE you now needlessly force NULL checks to occur which are never going to be true. There's then also the dead indirect call and the associated patching data. I think this wants hiding in another pair of wrappers, which simply expand to nothing when !XSM_CONFIGURABLE - perhaps
xsm_vcall()andxsm_call().
This has now come back full circle to the attempts made in v1 at addressing the RFC comments collected at the developer's summit. The calls xsm_vcall and xsm_call will not be simple since the different xsm hooks take a different number of arguments. Therefore these calls will have to become a series of macros to handle the varying number of arguments, similar to alternative_call and elsewhere but instead of being general purpose for use throughout the hypervisor they will create a complication in the code that is dedicated to a single file under XSM. Outside of a demonstrable significant performance impact that can be measured, the goal for security relevant code should be simplicity and ability to reason about correctness. Therefore without a demonstration that there is an actual performance impact simplicity should be the goal here, especially considering this effort has unmasked potential bugs noted below that were masked by this kind of complication.
With that I would like to withdraw this patch and spin a v4 of this patch set with that revives the dropping of the inlines done similar to v1/v2. As requested above, I will look to see if any of the changes that still applies could be split into dedicated commits.
<snip>
Quoted 18 lines
xen/include/xsm/xsm.h line 81
Quoted 11 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) +static inline int xsm_set_target (xsm_default_t action,struct domain *d, +struct domain *e) { -return alternative_call (xsm_ops.set_target, d, e); +if ( xsm_ops.set_target ) +return alternative_call (xsm_ops.set_target, d, e); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, current->domain,NULL ); }While benign because
xsm_default_action()does nothing forXSM_HOOK, I think there's an inconsistency here which rather wants correcting (in a prereq patch): The default hook should have been passed consistent arguments, no matter whether used because of !XSM or because of the module in use left the hook unset.
Quoted 3 lines
Of course such anomalies are much easier to notice (outside of review of patches introducing such) with you now placing both invocations next to each other.
This series assumes the logic is correct and is only focused on trying to make XSM more maintainable. I would be glad to consider looking at what the right security decisions should be in a subsequent patch set but will be consider out of scope for this patch set.
Quoted 15 lines
Quoted 15 lines
xen/include/xsm/xsm.h +11
-3-static inline int xsm_evtchn_interdomain (xsm_default_t def,struct domain *d1, -struct evtchn *chan1,struct domain *d2,struct evtchn *chan2) +static inline int xsm_evtchn_interdomain (xsm_default_t action, +struct domain *d1, +struct evtchn *chan1, +struct domain *d2, +struct evtchn *chan2) { -return alternative_call (xsm_ops.evtchn_interdomain, d1, chan1, d2, chan2); +if ( xsm_ops.evtchn_interdomain ) +return alternative_call (xsm_ops.evtchn_interdomain, d1, chan1, d2, + chan2); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2);
Quoted 8 lines
xen/include/xsm/xsm.h line 54
Quoted 1 line
xen/include/xsm/xsm.h +0
-0}There's another anomaly here: The first argument to
xsm_default_action()typically iscurrent->domainin similar functions. Here d1 gets passed in despite always beingcurrent->domain. I think the unnecessary parameter wants dropping (again in a prereq patch)) from the wrapper and hook, to avoid giving the wrong impression of both domains potentially being remote ones.
out of scope
Quoted 15 lines
xen/include/xsm/xsm.h line 158
Quoted 10 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_evtchn_send (xsm_default_t def,struct domain *d,struct evtchn *chn) +static inline int xsm_evtchn_send (xsm_default_t action,struct domain *d, +struct evtchn *chn) { -return alternative_call (xsm_ops.evtchn_send, d, chn); +if ( xsm_ops.evtchn_send ) +return alternative_call (xsm_ops.evtchn_send, d, chn); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d,NULL );This again looks wrong (and again is benign only because
XSM_HOOKmeansxsm_default_action()ignores the other function parameters), wanting to follow the usual
Quoted 3 lines
return xsm_default_action(action, current->domain, d);pattern instead.
out of scope
Quoted 4 lines
Quoted 4 lines
xen/include/xsm/xsm.h +2
-1-static inline int xsm_evtchn_reset (xsm_default_t def,struct domain *d1,struct domain *d2) +static inline int xsm_evtchn_reset (xsm_default_t action,struct domain *d1, +struct domain *d2) {
Quoted 8 lines
xen/include/xsm/xsm.h line 178
Quoted 6 lines
xen/include/xsm/xsm.h +5
-1-return alternative_call (xsm_ops.evtchn_reset, d1, d2); +if ( xsm_ops.evtchn_reset ) +return alternative_call (xsm_ops.evtchn_reset, d1, d2); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2);See
xsm_evtchn_interdomain()above.
out of scope
Quoted 5 lines
Quoted 5 lines
xen/include/xsm/xsm.h +2
-2-static inline int xsm_grant_mapref (xsm_default_t def,struct domain *d1,struct domain *d2, -uint32_t flags) +static inline int xsm_grant_mapref (xsm_default_t action,struct domain *d1, +struct domain *d2,uint32_t flags) {
Quoted 8 lines
xen/include/xsm/xsm.h line 188
Quoted 6 lines
xen/include/xsm/xsm.h +5
-1-return alternative_call (xsm_ops.grant_mapref, d1, d2, flags); +if ( xsm_ops.grant_mapref ) +return alternative_call (xsm_ops.grant_mapref, d1, d2, flags); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2);Again (more similar grant ones follow).
out of scope
Quoted 6 lines
Quoted 6 lines
xen/include/xsm/xsm.h +3
-2-static inline int xsm_memory_adjust_reservation (xsm_default_t def,struct domain *d1,struct -domain *d2) +static inline int xsm_memory_adjust_reservation (xsm_default_t action, +struct domain *d1, +struct domain *d2) {
Quoted 8 lines
xen/include/xsm/xsm.h line 324
Quoted 6 lines
xen/include/xsm/xsm.h +5
-1-return alternative_call (xsm_ops.memory_adjust_reservation, d1, d2); +if ( xsm_ops.memory_adjust_reservation ) +return alternative_call (xsm_ops.memory_adjust_reservation, d1, d2); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d1, d2);Again (more similar memory ones follow).
out of scope
Quoted 7 lines
Quoted 7 lines
xen/include/xsm/xsm.h +3
-3-static inline int xsm_memory_pin_page (xsm_default_t def,struct domain *d1,struct domain *d2, -struct page_info *page) +static inline int xsm_memory_pin_page (xsm_default_t action,struct domain *d1, +struct domain *d2,struct page_info *page) { -return alternative_call (xsm_ops.memory_pin_page, d1, d2, page); +if ( xsm_ops.memory_pin_page )
Quoted 8 lines
xen/include/xsm/xsm.h line 345
Quoted 4 lines
xen/include/xsm/xsm.h +4
-0+return alternative_call (xsm_ops.memory_pin_page, d1, d2, page); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, d1, d2);This one has the same issue, but is more interesting: There's no similar hook/check for unpinning a page (nor does the same check get re-used there). Plus it's x86 (more precisely PV) specific.
out of scope
Quoted 6 lines
Quoted 6 lines
xen/include/xsm/xsm.h +3
-2-static inline int xsm_map_gmfn_foreign (xsm_default_t def,struct domain *d,struct domain *t) +static inline int xsm_map_gmfn_foreign (xsm_default_t action,struct domain *d, +struct domain *t) { -return alternative_call (xsm_ops.map_gmfn_foreign, d, t); +if ( xsm_ops.map_gmfn_foreign )
Quoted 8 lines
xen/include/xsm/xsm.h line 375
Quoted 4 lines
xen/include/xsm/xsm.h +4
-0+return alternative_call (xsm_ops.map_gmfn_foreign, d, t); + +XSM_ASSERT_ACTION (XSM_TARGET ); +return xsm_default_action (action, d, t);This one is also interesting: There's no check at all here that
current->domainhas any permissions towards d or t. Interestingly evenflask_map_gmfn_foreign()doesn't check this.
out of scope
Quoted 10 lines
Quoted 10 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_console_io (xsm_default_t def,struct domain *d,int cmd) +static inline int xsm_console_io (xsm_default_t action,struct domain *d,int cmd) { -return alternative_call (xsm_ops.console_io, d, cmd); +if ( xsm_ops.console_io ) +return alternative_call (xsm_ops.console_io, d, cmd); + +XSM_ASSERT_ACTION (XSM_OTHER ); +if ( d->is_console ) +return xsm_default_action (XSM_HOOK , d,NULL );
Quoted 8 lines
xen/include/xsm/xsm.h line 399
Quoted 5 lines
xen/include/xsm/xsm.h +5
-0+#ifdef CONFIG_VERBOSE_DEBUG +if ( cmd == CONSOLEIO_write ) +return xsm_default_action (XSM_HOOK , d,NULL ); +#endif +return xsm_default_action (XSM_PRIV , d,NULL );Same implication of d ==
current->domainhere again. I guess I'll stop enumerating further ones.
out of scope
<snip>
Quoted 13 lines
Quoted 13 lines
xen/include/xsm/xsm.h +10
-2-static inline int xsm_pmu_op (xsm_default_t def,struct domain *d,unsigned int op) +static inline int xsm_pmu_op (xsm_default_t action,struct domain *d, +unsigned int op) { -return alternative_call (xsm_ops.pmu_op, d, op); +if ( xsm_ops.pmu_op ) +return alternative_call (xsm_ops.pmu_op, d, op); + +XSM_ASSERT_ACTION (XSM_OTHER ); +switch ( op ) + { +case XENPMU_init: +case XENPMU_finish:
Quoted 8 lines
xen/include/xsm/xsm.h line 954
Quoted 5 lines
xen/include/xsm/xsm.h +5
-0+case XENPMU_lvtpc_set: +case XENPMU_flush: +return xsm_default_action (XSM_HOOK , d, current->domain); +default : +return xsm_default_action (XSM_PRIV , d, current->domain);Urgh - isn't this the wrong way round? (Luckily vPMU isn't security supported, so no XSA would be needed.)
out of scope
<snip>
Quoted 11 lines
xen/xsm/silo.c line 21
Quoted 8 lines
xen/xsm/silo.c +1
-0@@ -17,6 +17,7 @@* You should have received a copy of the GNU General Public License along with * this program; If not, see <http://www.gnu.org/licenses/>. */ +#include <xsm/xsm-core.h> #include <xsm/dummy.h> As already mentioned elsewhere - where possible please arrange #include-s alphabetically.
Ack.
Quoted 4 lines
Quoted 4 lines
xen/xsm/silo.c +0
-0@@ -124,16 +122,12 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)break ; }
Quoted 12 lines
xen/xsm/silo.c static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 125
Quoted 10 lines
xen/xsm/silo.c +1
-9-/* -* This handles three cases, -* - dummy policy module was selected -* - a policy module does not provide all handlers -* - a policy module failed to init -*/ -xsm_fixup_ops (&xsm_ops); - -if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) +if ( xsm_ops_registered !=XSM_OPS_REGISTERED ) {Nit (style): Brace goes on its own line.
Ack
v/r,
dps
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
In reply to Daniel P. SmithQuoted 28 lines · Daniel P. Smith
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +14
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ +Quoted 8 lines
xen/include/xsm/xsm-core.h line 19
Quoted 5 lines
xen/include/xsm/xsm-core.h new file +5
-0+#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h> I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like
multiboot.hisn't fit for this.
Quoted 1 line
So my understanding is to leave this as is.
Yes, unfortunately.
Quoted 10 lines
Quoted 5 lines
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
Unless I am misunderstanding what you are calling for, I am afraid this will trickle further that what intended to be addressed in this patch set. If disagree and would like to provide me a suggest that stays bounded, I would gladly incorporate.
All I'm asking is to remove this pointless typedef and handle definition, seeing that you're doing a major rework anyway. I'm afraid I don't see how this would collide with the purpose of the overall series (albeit I may also have misunderstood your reply, as the 2nd half of the first sentence makes me struggle some with trying to parse it).
Jan
Re: [PATCH v3 6/7] xsm: drop generic event channel labeling exclusion
In reply to Daniel P. SmithQuoted 38 lines · Daniel P. Smith
Quoted 28 lines · Jan Beulich
Quoted 2 lines · Daniel P. Smith
The internal define flag is not used by any XSM module, removing the #ifdef leaving the generic event channel labeling as always present.
With this description ...
Quoted 22 lines
xen/include/xen/sched.h +0
-3@@ -120,15 +120,12 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSMunion { -#ifdef XSM_NEED_GENERIC_EVTCHN_SSID/* * If an XSM module needs more space for its event channel context, * this pointer stores the necessary data for the security server. */ void *generic; -#endif#ifdef CONFIG_XSM_FLASK /* * Inlining the contents of the structure for FLASK avoids unneeded @@ -138,7 +135,6 @@ struct evtchnuint32_t flask_sid;#endif } ssid;Quoted 8 lines
xen/include/xen/sched.h struct evtchn · line 138
Quoted 2 lines
xen/include/xen/sched.h +0
-1-#endif } __attribute__((aligned(64)));... I can see the inner #ifdef go away, but not the outer one. While the (imo bogus) attribute means you don't alter the size of the struct, I'm afraid that's not obvious at all without counting bits and bytes, and hence this may also want saying explicitly in the description.
Quoted 3 lines
I can put the #ifdef
CONFIG_XSMback and in the subsequent patch change it toCONFIG_XSM_CONFIGURABLE, making this the only difference between being able to select the XSM policy in effect or not.
Well, yes, that's one way of addressing my comment. Another would be to actually justify the removal. (Personally I'm in favor of the former.)
Jan
Re: [PATCH v3 7/7] xsm: removing facade that XSM can be enabled/disabled
In reply to Daniel P. SmithQuoted 19 lines · Daniel P. Smith
Quoted 17 lines · Jan Beulich
xen/common/Kconfig config XENOPROF · line 208
Quoted 7 lines · Daniel P. Smith
config
XSM_FLASKxen/common/Kconfig +2
-4- def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + default nI don't understand this change in default (and as an aside, a default of "n" doesn't need spelling out): In the description you say "adjusted
CONFIG_XSM_SILO,CONFIG_XSM_FLASK, and the default module selection to sensible defaults". If that's to describe this change, then I'm afraid I don't see why defaulting to "n" is more sensible once the person configuring Xen has chosen the configure XSM's (or XSM_CONFIGURABLE's) sub-options. If that's unrelated to the change here, then I'm afraid I'm missing justification altogether. (Same for SILO then.)
Quoted 5 lines
When an individual selects to be able to be to configure/select alternative policy modules, they should be the ones to decide which one(s) should be enabled and not have presumptuous selections provided to them. IOW, the sensible default is to have no modules selected and allow the user to enable the one(s) they want.
Just FTR - I disagree. Defaults should be such that a majority would not need to alter the respective settings.
Quoted 11 lines
Quoted 10 lines
xen/common/Kconfig endchoice · line 278
Quoted 6 lines
xen/common/Kconfig +1
-1@@ -282,7 +275,7 @@ endchoice config LATE_HWDOM bool "Dedicated hardware domain" default n - depends on XSM && X86 + depends on XSM_FLASK && X86This change is not mentioned or justified in the description. In fact I think it is unrelated to the change here and hence would want breaking out.
Quoted 7 lines
Actually, if you read the help just below it specifically says to use this feature requires having an XSM policy (legacy wording for XSM Flask policy) to be able to do the proper fine grained delegation of the permissions/accesses necessary for a hardware domain to work. This should have been made
XSM_FLASKwhen that KConfig option was added. Dropping the XSM KConfig option just exposed this oversight. Ack that I should have mentioned this in the commit message.
I'm getting the impression that you mistook "breaking out" for "dropping". I can see the point of the change; it merely shouldn't be hidden in this otherwise unrelated much larger change.
Quoted 18 lines
Quoted 18 lines
xen/include/xsm/xsm.h line 81
Quoted 11 lines
xen/include/xsm/xsm.h +7
-2-static inline int xsm_set_target (xsm_default_t def,struct domain *d,struct domain *e) +static inline int xsm_set_target (xsm_default_t action,struct domain *d, +struct domain *e) { -return alternative_call (xsm_ops.set_target, d, e); +if ( xsm_ops.set_target ) +return alternative_call (xsm_ops.set_target, d, e); + +XSM_ASSERT_ACTION (XSM_HOOK ); +return xsm_default_action (action, current->domain,NULL ); }While benign because
xsm_default_action()does nothing forXSM_HOOK, I think there's an inconsistency here which rather wants correcting (in a prereq patch): The default hook should have been passed consistent arguments, no matter whether used because of !XSM or because of the module in use left the hook unset.
Quoted 8 lines
Quoted 3 lines
Of course such anomalies are much easier to notice (outside of review of patches introducing such) with you now placing both invocations next to each other.
This series assumes the logic is correct and is only focused on trying to make XSM more maintainable. I would be glad to consider looking at what the right security decisions should be in a subsequent patch set but will be consider out of scope for this patch set.
Well, I came to make these comments because these anomalies look to stand in the way of producing a sufficiently small set of wrapper / helper macros. But since you want to go back to an older version's approach, the need to correct these as a (series of) prereq(s) may indeed vanish.
Jan
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
In reply to Jan BeulichQuoted 44 lines · Jan Beulich
Quoted 28 lines · Daniel P. Smith
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +14
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ +Quoted 8 lines
xen/include/xsm/xsm-core.h line 19
Quoted 5 lines
xen/include/xsm/xsm-core.h new file +5
-0+#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h> I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like
multiboot.hisn't fit for this.Quoted 1 line
So my understanding is to leave this as is.
Yes, unfortunately.
Quoted 10 lines
Quoted 5 lines
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
Unless I am misunderstanding what you are calling for, I am afraid this will trickle further that what intended to be addressed in this patch set. If disagree and would like to provide me a suggest that stays bounded, I would gladly incorporate.
Quoted 8 lines
All I'm asking is to remove this pointless typedef and handle definition, seeing that you're doing a major rework anyway. I'm afraid I don't see how this would collide with the purpose of the overall series (albeit I may also have misunderstood your reply, as the 2nd half of the first sentence makes me struggle some with trying to parse it).
Jan
If I drop the typedef and start changing everywhere xsm_op_t is referenced to void, this now adds hypercall.h to the files I am now touching.
In the end it is not about whether the change is big or small, but that more and more unrelated small changes/clean ups keep getting requested. There has to be a cut-off point to limit the scope of changes down to the purpose of the patch set, which is to unravel and simplify the XSM hooks. And this is being done so, so that the the XSM-Roles work can be introduced to bring a more solid definition to the the default access control system, which itself is needed to bring in hyperlaunch.
v/r,
dps
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
Quoted 55 lines · Daniel P. Smith
Quoted 44 lines · Jan Beulich
Quoted 28 lines · Daniel P. Smith
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +14
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ +Quoted 8 lines
xen/include/xsm/xsm-core.h line 19
Quoted 5 lines
xen/include/xsm/xsm-core.h new file +5
-0+#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h> I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like
multiboot.hisn't fit for this.Quoted 1 line
So my understanding is to leave this as is.
Yes, unfortunately.
Quoted 10 lines
Quoted 5 lines
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
Unless I am misunderstanding what you are calling for, I am afraid this will trickle further that what intended to be addressed in this patch set. If disagree and would like to provide me a suggest that stays bounded, I would gladly incorporate.
Quoted 5 lines
All I'm asking is to remove this pointless typedef and handle definition, seeing that you're doing a major rework anyway. I'm afraid I don't see how this would collide with the purpose of the overall series (albeit I may also have misunderstood your reply, as the 2nd half of the first sentence makes me struggle some with trying to parse it).
If I drop the typedef and start changing everywhere
xsm_op_tis referenced to void, this now addshypercall.hto the files I am now touching.
Quoted 7 lines
In the end it is not about whether the change is big or small, but that more and more unrelated small changes/clean ups keep getting requested. There has to be a cut-off point to limit the scope of changes down to the purpose of the patch set, which is to unravel and simplify the XSM hooks. And this is being done so, so that the the XSM-Roles work can be introduced to bring a more solid definition to the the default access control system, which itself is needed to bring in hyperlaunch.
Well, yes, you effectively suffer from XSM not having been actively maintained for a number of years. As said in the original reply, I'd prefer my ack to cover all the suggested changes, but I didn't mean to insist. If this particular one goes too far for your taste, so be it.
Jan
Re: [PATCH v3 5/7] xsm: decouple xsm header inclusion selection
Quoted 64 lines · Jan Beulich
Quoted 55 lines · Daniel P. Smith
Quoted 44 lines · Jan Beulich
Quoted 28 lines · Daniel P. Smith
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Daniel P. Smith
xen/include/xsm/xsm-core.h new file +14
-0@@ -0,0 +1,273 @@ +/* +* This file contains the XSM hook definitions for Xen. +* +* This work is based on the LSM implementation in Linux 2.6.13.4. +* +* Author: George Coker, <[email protected]> +* +* Contributors: Michael LeMay, <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2, +* as published by the Free Software Foundation. +*/ +Quoted 8 lines
xen/include/xsm/xsm-core.h line 19
Quoted 5 lines
xen/include/xsm/xsm-core.h new file +5
-0+#ifndef __XSM_CORE_H__ +#define __XSM_CORE_H__ + +#include <xen/sched.h> +#include <xen/multiboot.h> I was going to ask to invert the order (as we try to arrange #include-s alphabetically), but it looks like
multiboot.hisn't fit for this.Quoted 1 line
So my understanding is to leave this as is.
Yes, unfortunately.
Quoted 10 lines
Quoted 5 lines
xen/include/xsm/xsm-core.h line 22
Quoted 2 lines
xen/include/xsm/xsm-core.h new file +2
-0+typedef void xsm_op_t ; +DEFINE_XEN_GUEST_HANDLE (xsm_op_t);Just FTR - I consider this dubious. If void is meant, I don't see why a void handle can't be used.
Unless I am misunderstanding what you are calling for, I am afraid this will trickle further that what intended to be addressed in this patch set. If disagree and would like to provide me a suggest that stays bounded, I would gladly incorporate.
Quoted 5 lines
All I'm asking is to remove this pointless typedef and handle definition, seeing that you're doing a major rework anyway. I'm afraid I don't see how this would collide with the purpose of the overall series (albeit I may also have misunderstood your reply, as the 2nd half of the first sentence makes me struggle some with trying to parse it).
If I drop the typedef and start changing everywhere
xsm_op_tis referenced to void, this now addshypercall.hto the files I am now touching.Quoted 7 lines
In the end it is not about whether the change is big or small, but that more and more unrelated small changes/clean ups keep getting requested. There has to be a cut-off point to limit the scope of changes down to the purpose of the patch set, which is to unravel and simplify the XSM hooks. And this is being done so, so that the the XSM-Roles work can be introduced to bring a more solid definition to the the default access control system, which itself is needed to bring in hyperlaunch.
Quoted 8 lines
Well, yes, you effectively suffer from XSM not having been actively maintained for a number of years. As said in the original reply, I'd prefer my ack to cover all the suggested changes, but I didn't mean to insist. If this particular one goes too far for your taste, so be it.
Jan
I think we can agree that XSM has not been receiving appropriate care and maintenance. It can't all be fixed in one go and I am trying to step up to get it back into shape. Since this is really undoing a masking of void, I can add this and the risk is very low of breaking something else. Which this is my biggest concern as I see new files getting brought in with each cleanup requested.
v/r,
dps