xsm: refactoring xsm hooks
v2 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 remove the psuedo is/is not enable 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
Andrew Cooper (1):
xen: Implement xen/alternative-call.h for use in common code
Daniel P. Smith (9):
xsm: refactor xsm_ops handling
xsm: remove the ability to disable flask
xsm: convert xsm_ops hook calls to alternative call
xsm: decouple xsm header inclusion selection
xsm: enable xsm to always be included
xsm: drop generic event channel labeling
xsm: remove xsm_default_t from hook definitions
xsm: expand the function related macros in dummy.h
xsm: removing the XSM_ASSERT_ACTION macro
xen/arch/arm/dm.c | 2 +- xen/arch/arm/domctl.c | 6 +- xen/arch/arm/hvm.c | 2 +- xen/arch/arm/mm.c | 2 +- xen/arch/arm/platform_hypercall.c | 2 +- xen/arch/x86/Kconfig | 1 + xen/arch/x86/cpu/mcheck/mce.c | 2 +- xen/arch/x86/cpu/vpmu.c | 2 +- xen/arch/x86/domctl.c | 8 +- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/hvm.c | 12 +- xen/arch/x86/irq.c | 5 +- xen/arch/x86/mm.c | 20 +- xen/arch/x86/mm/mem_paging.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 9 +- xen/arch/x86/mm/p2m.c | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/set.c | 2 +- xen/arch/x86/msi.c | 3 +- xen/arch/x86/pci.c | 2 +- xen/arch/x86/physdev.c | 17 +- xen/arch/x86/platform_hypercall.c | 10 +- xen/arch/x86/pv/emul-priv-op.c | 2 +- xen/arch/x86/sysctl.c | 4 +- xen/common/Kconfig | 48 +- xen/common/domain.c | 4 +- xen/common/domctl.c | 12 +- xen/common/event_channel.c | 12 +- xen/common/grant_table.c | 16 +- xen/common/hypfs.c | 2 +- xen/common/kernel.c | 2 +- xen/common/kexec.c | 2 +- xen/common/mem_access.c | 2 +- xen/common/memory.c | 16 +- xen/common/monitor.c | 2 +- xen/common/sched/core.c | 6 +- xen/common/sysctl.c | 8 +- xen/common/vm_event.c | 2 +- xen/common/xenoprof.c | 2 +- xen/drivers/char/console.c | 2 +- xen/drivers/passthrough/device_tree.c | 4 +- xen/drivers/passthrough/pci.c | 12 +- xen/include/xen/alternative-call.h | 65 +++ xen/include/xen/sched.h | 9 - xen/include/xsm/dummy.h | 774 -------------------------- xen/include/xsm/xsm-core.h | 237 ++++++++ xen/include/xsm/xsm.h | 623 +++++++-------------- xen/xsm/Makefile | 4 +- xen/xsm/dummy.c | 7 +- xen/xsm/dummy.h | 696 +++++++++++++++++++++++ xen/xsm/flask/flask_op.c | 30 - xen/xsm/flask/hooks.c | 11 +- xen/xsm/silo.c | 23 +- xen/xsm/xsm_core.c | 76 +-- 54 files changed, 1381 insertions(+), 1451 deletions(-) create mode 100644 xen/include/xen/alternative-call.h delete mode 100644 xen/include/xsm/dummy.h create mode 100644 xen/include/xsm/xsm-core.h create mode 100644 xen/xsm/dummy.h
Signature · 1 line
2.20.1
PATCH v2 1/10 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.
--- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 ++ xen/include/xen/alternative-call.h | 65 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 xen/include/xen/alternative-call.h
xen/arch/x86/Kconfig +1 -0
@@ -9,6 +9,7 @@ config X86 select ARCH_SUPPORTS_INT128 select CORE_PARKING select HAS_ALTERNATIVE + select ALTERNATIVE_CALL select HAS_COMPAT select HAS_CPUFREQ select HAS_EHCI
xen/common/Kconfig +3 -0
@@ -25,6 +25,9 @@ config GRANT_TABLE config HAS_ALTERNATIVE bool +config ALTERNATIVE_CALL + bool + config HAS_COMPAT bool
xen/include/xen/alternative-call.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
Quoted 25 lines · Daniel P. Smith
xen/include/xen/alternative-call.h new file +19
-0@@ -0,0 +1,65 @@ +/* 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.
xen/include/xen/alternative-call.h line 29
Quoted 10 lines
xen/include/xen/alternative-call.h new file +10
-0+* - Select ALTERNATIVE_CALL in Kconfig. +* +* To use: +* +* Consider the following simplified example. +* +* 1) struct foo_ops __alt_call_maybe_initdata ops; +* +* 2) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... }; +* struct foo_ops __alt_call_maybe_initconst foo_b_ops = { ... };
It occurs to me after reviewing patch 2 that these want to be const struct foo_ops __initconst ..., and there is no need for __alt_call_maybe_initconst at all.
The only thing wanting a conditional annotation like this is the single ops object, and it needs to be initdata (or hopefully ro_after_init in the future).
~Andrew
Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
Quoted 31 lines · Andrew Cooper
Quoted 30 lines · Daniel P. Smith
xen/include/xen/alternative-call.h new file +24
-0@@ -0,0 +1,65 @@ +/* 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.
Quoted 8 lines
xen/include/xen/alternative-call.h line 29
Quoted 5 lines
xen/include/xen/alternative-call.h new file +5
-0+* +* 1) struct foo_ops __alt_call_maybe_initdata ops; +* +* 2) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... }; +* struct foo_ops __alt_call_maybe_initconst foo_b_ops = { ... }; It occurs to me after reviewing patch 2 that these want to be const struct
foo_ops__initconst...,
__initconstrel then, I suppose.
Quoted 6 lines
and there is no need for
__alt_call_maybe_initconstat all.The only thing wanting a conditional annotation like this is the single ops object, and it needs to be initdata (or hopefully
ro_after_initin the future).
ro_after_init and initdata can't be alternatives of one another; ops (until be gain ro_after_init) need to remain in .bss (or .data).
Jan
Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
Quoted 41 lines · Jan Beulich
Quoted 30 lines · Andrew Cooper
Quoted 29 lines · Daniel P. Smith
xen/include/xen/alternative-call.h new file +23
-0@@ -0,0 +1,65 @@ +/* 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: +* Quoted 8 lines
xen/include/xen/alternative-call.h line 29
Quoted 6 lines
xen/include/xen/alternative-call.h new file +6
-0+* Consider the following simplified example. +* +* 1) struct foo_ops __alt_call_maybe_initdata ops; +* +* 2) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... }; +* struct foo_ops __alt_call_maybe_initconst foo_b_ops = { ... }; It occurs to me after reviewing patch 2 that these want to be const struct
foo_ops__initconst...,
__initconstrelthen, I suppose.
Quoted 8 lines
Quoted 6 lines
and there is no need for
__alt_call_maybe_initconstat all.The only thing wanting a conditional annotation like this is the single ops object, and it needs to be initdata (or hopefully
ro_after_initin the future).
ro_after_initand initdata can't be alternatives of one another; ops (until be gainro_after_init) need to remain in .bss (or .data).
Once alternatives have run, the ops structure is no longer referenced by anything at runtime, and can be reclaimed.
All the x86 examples are weird because we've either got extra data fields which are referenced at runtime, or we've not accelerated all function pointers.
In neither case does modifying an accelerated function pointer after the fact do what the programmer expected, and conditionally initdata makes this far more obvious.
~Andrew
Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
Quoted 45 lines · Andrew Cooper
Quoted 44 lines · Jan Beulich
Quoted 30 lines · Andrew Cooper
Quoted 29 lines · Daniel P. Smith
xen/include/xen/alternative-call.h new file +23
-0@@ -0,0 +1,65 @@ +/* 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: +* Quoted 8 lines
xen/include/xen/alternative-call.h line 29
Quoted 6 lines
xen/include/xen/alternative-call.h new file +6
-0+* Consider the following simplified example. +* +* 1) struct foo_ops __alt_call_maybe_initdata ops; +* +* 2) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... }; +* struct foo_ops __alt_call_maybe_initconst foo_b_ops = { ... }; It occurs to me after reviewing patch 2 that these want to be const struct
foo_ops__initconst...,
__initconstrelthen, I suppose.Quoted 3 lines
and there is no need for
__alt_call_maybe_initconstat all.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The only thing wanting a conditional annotation like this is the single ops object, and it needs to be initdata (or hopefully
ro_after_initin the future).
ro_after_initand initdata can't be alternatives of one another; ops (until be gainro_after_init) need to remain in .bss (or .data).Once alternatives have run, the ops structure is no longer referenced by anything at runtime, and can be reclaimed.
Oh, right - if all pointers have been consumed for patching, initdata is of course fine.
Jan
Quoted 10 lines
All the x86 examples are weird because we've either got extra data fields which are referenced at runtime, or we've not accelerated all function pointers.
In neither case does modifying an accelerated function pointer after the fact do what the programmer expected, and conditionally initdata makes this far more obvious.
~Andrew
Re: [PATCH v2 01/10] xen: Implement xen/alternative-call.h for use in common code
In reply to Daniel P. Smithxen/arch/x86/Kconfig config X86 · line 15
Quoted 10 lines · Daniel P. Smith
xen/arch/x86/Kconfig +1
-0@@ -9,6 +9,7 @@ config X86 select ARCH_SUPPORTS_INT128 select CORE_PARKING select HAS_ALTERNATIVE + select ALTERNATIVE_CALL select HAS_COMPAT select HAS_CPUFREQ select HAS_EHCI
Please respect the (at least largely) alphabetical ordering here and ...
xen/common/Kconfig config GRANT_TABLE · line 32
Quoted 11 lines
xen/common/Kconfig +3
-0@@ -25,6 +25,9 @@ config GRANT_TABLE config HAS_ALTERNATIVE bool +config ALTERNATIVE_CALL + bool + config HAS_COMPAT bool
... maybe also here.
Quoted 40 lines
xen/include/xen/alternative-call.h new file +37
-0@@ -0,0 +1,65 @@ +/* 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) struct foo_ops __alt_call_maybe_initconst foo_a_ops = { ... }; +* struct foo_ops __alt_call_maybe_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;
xen/include/xen/alternative-call.h line 47
Quoted 10 lines
xen/include/xen/alternative-call.h new file +10
-0+* ... +* } +* +* 3) alternative_call(ops.bar, ...); +* +* There needs to a single ops object (1) which will eventually contain the +* 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). +*/
May be worth adding a sentence about the section annotations, the more that (as you did point out in an earlier reply) there are pre-existing cases differing from the general goal here?
xen/include/xen/alternative-call.h line 54
Quoted 6 lines
xen/include/xen/alternative-call.h new file +6
-0+#ifdef CONFIG_ALTERNATIVE_CALL + +#include <asm/alternative.h> + +#define __alt_call_maybe_initdata __initdata +#define __alt_call_maybe_initconst __initconst
As indicated elsewhere, I think this wants to be __initconstrel, as the function pointers to place in the structures will definitely involve relocations. Otoh, given your initial reply, __alt_call_maybe_initdata may be all that's actually needed.
xen/include/xen/alternative-call.h line 65
Quoted 10 lines
xen/include/xen/alternative-call.h new file +10
-0+#else + +#define alternative_call(func, args...) (func)(args) +#define alternative_vcall(func, args...) (func)(args) + +#define __alt_call_maybe_initdata +#define __alt_call_maybe_initconst + +#endif /* !CONFIG_ALTERNATIVE_CALL */ +#endif /* XEN_ALTERNATIVE_CALL */
I'm surprised you have no "Local variables:" footer comment here. Not that I need it for anything, but I thought you and others are quite interested in it to be there.
Jan
PATCH v2 2/10 xsm: refactor xsm_ops handling
In reply to Daniel P. SmithThis converts the global xsm_ops from being a pointer to a struct xsm_ops to being an explicit instance. It then reworks the XSM modules init function to return their xsm_ops struct which is copied in to the global xsm_ops.
--- xen/include/xsm/xsm.h | 215 ++++++++++++++++++++------------------- xen/xsm/dummy.c | 2 - xen/xsm/flask/flask_op.c | 4 +- xen/xsm/flask/hooks.c | 11 +- xen/xsm/silo.c | 5 +- xen/xsm/xsm_core.c | 72 +++++++------ 6 files changed, 158 insertions(+), 151 deletions(-)
xen/include/xsm/xsm.h +108 -107
@@ -191,295 +191,295 @@ struct xsm_operations {#ifdef CONFIG_XSM -extern struct xsm_operations *xsm_ops; +extern struct xsm_operations 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,14 @@ 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);#ifdef CONFIG_XSM_FLASK -extern void flask_init (const void *policy_buffer,size_t policy_size); +extern struct xsm_operations *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_operations *flask_init (const void *policy_buffer,size_t policy_size) { +return NULL ; }#endif
@@ -766,9 +764,12 @@ extern const unsigned int xsm_flask_init_policy_size;#endif #ifdef CONFIG_XSM_SILO -extern void silo_init (void ); +extern struct xsm_operations *silo_init (void );#else -static inline void silo_init (void ) {} +static inline struct xsm_operations *silo_init (void ) +{ +return NULL ; +}#endif #else /* CONFIG_XSM */
xen/xsm/dummy.c +0 -2
@@ -13,8 +13,6 @@#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 ) \
xen/xsm/flask/flask_op.c +3 -1
@@ -226,6 +226,7 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)static int flask_disable (void ) {static int flask_disabled =0 ; +struct xsm_operations default_ops;if ( ss_initialized ) {
@@ -244,7 +245,8 @@ static int flask_disable(void) flask_disabled =1 ;/* Reset xsm_ops to the original module. */ - xsm_ops = &dummy_xsm_ops; +xsm_fixup_ops (&default_ops); + xsm_ops = default_ops;return 0 ; }
xen/xsm/flask/hooks.c +6 -5
@@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {#endif }; -void __init flask_init (const void *policy_buffer,size_t policy_size) +struct xsm_operations __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,9 @@ 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 +2 -3
@@ -112,12 +112,11 @@ static struct xsm_operations silo_xsm_ops = {#endif }; -void __init silo_init (void ) +struct xsm_operations __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
Re: [PATCH v2 02/10] xsm: refactor xsm_ops handling
Quoted 13 lines · Daniel P. Smith
xen/include/xsm/xsm.h +0
-3@@ -747,16 +747,14 @@ 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);
xen/include/xsm/xsm.h extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); · line 759
Quoted 10 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 struct xsm_operations *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_operations *flask_init (const void *policy_buffer,size_t policy_size) { +return NULL ; }#endif
As you touch almost every current user of xsm_operations and introduce quite a few more, can I recommend taking the opportunity to shorten the name to struct xsm_ops.
Quoted 13 lines
xen/xsm/flask/flask_op.c +1
-0@@ -226,6 +226,7 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)static int flask_disable (void ) {static int flask_disabled =0 ; +struct xsm_operations default_ops;if ( ss_initialized ) {
xen/xsm/flask/flask_op.c static int flask_disable(void) · line 252
Quoted 9 lines
xen/xsm/flask/flask_op.c +2
-1@@ -244,7 +245,8 @@ static int flask_disable(void) flask_disabled =1 ;/* Reset xsm_ops to the original module. */ - xsm_ops = &dummy_xsm_ops; +xsm_fixup_ops (&default_ops); + xsm_ops = default_ops;return 0 ; }
These two hunks will disappear when patch 3 is reordered with respect to this one.
... which is good because you've just pointed xsm_ops at a soon-to-be-out-of-scope local variable on the stack.
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1884
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-0@@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {#endif };
flask and silo ops should become:
static const struct xsm_ops __initconst {flask,silo}_ops = {
as they're neither modified, nor needed after init, following this change.
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1887
Quoted 4 lines
xen/xsm/flask/hooks.c +2
-1-void __init flask_init (const void *policy_buffer,size_t policy_size) +struct xsm_operations __init *flask_init (const void *policy_buffer, +size_t policy_size)
struct xsm_ops *__init flask_init(...)
Otherwise you've got the __init in the middle of the return type, and some compilers are more picky than others.
xen/xsm/flask/hooks.c void __init flask_init(const void *policy_buffer, size_t policy_size) · line 1926
Quoted 7 lines
xen/xsm/flask/hooks.c +3
-0@@ -1923,6 +1921,9 @@ 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; +
Stray newline.
xen/xsm/silo.c static struct xsm_operations silo_xsm_ops = { · line 115
Quoted 13 lines
xen/xsm/flask/hooks.c +0
-0}/* xen/xsm/silo.c +1
-1@@ -112,12 +112,11 @@ static struct xsm_operations silo_xsm_ops = {#endif }; -void __init silo_init (void ) +struct xsm_operations __init *silo_init (void )
Same here as with flask.
Quoted 11 lines
xen/xsm/xsm_core.c +0
-3@@ -68,17 +76,10 @@ static int __init parse_xsm_param(const char *s) }custom_param ("xsm" , parse_xsm_param); -static inline int verify (struct xsm_operations *ops) -{ -/* verify the security_operations structure exists */
xen/xsm/xsm_core.c static int __init parse_xsm_param(const char *s) · line 82
Quoted 10 lines
xen/xsm/xsm_core.c +2
-6-if ( !ops ) -return -EINVAL ; -xsm_fixup_ops (ops); -return 0 ; -} -static int __init xsm_core_init (const void *policy_buffer,size_t policy_size) { +struct xsm_operations *mod_ops; +
Hard tabs, and later in this function. Also, how about just 'ops' for the local variable name?
xen/xsm/xsm_core.c static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 130
Quoted 8 lines
xen/xsm/xsm_core.c +4
-0@@ -113,6 +124,17 @@ 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
Stray double space.
~Andrew
Re: [PATCH v2 02/10] xsm: refactor xsm_ops handling
Quoted 14 lines · Andrew Cooper
Quoted 13 lines · Daniel P. Smith
xen/include/xsm/xsm.h +0
-3@@ -747,16 +747,14 @@ 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);
Quoted 14 lines
xen/include/xsm/xsm.h extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); · line 759
Quoted 10 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 struct xsm_operations *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_operations *flask_init (const void *policy_buffer,size_t policy_size) { +return NULL ; }#endif As you touch almost every current user of
xsm_operationsand introduce quite a few more, can I recommend taking the opportunity to shorten the name to structxsm_ops.
+1
Quoted 18 lines
Quoted 18 lines
xen/xsm/flask/flask_op.c +3
-1@@ -226,6 +226,7 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)static int flask_disable (void ) {static int flask_disabled =0 ; +struct xsm_operations default_ops;if ( ss_initialized ) {@@ -244,7 +245,8 @@ static int flask_disable(void) flask_disabled =1 ;/* Reset xsm_ops to the original module. */ - xsm_ops = &dummy_xsm_ops; +xsm_fixup_ops (&default_ops); + xsm_ops = default_ops;
Quoted 8 lines
xen/xsm/flask/flask_op.c static int flask_disable(void) · line 252
Quoted 2 lines
xen/xsm/flask/flask_op.c +0
-0return 0 ; }These two hunks will disappear when patch 3 is reordered with respect to this one.
... which is good because you've just pointed
xsm_opsat a soon-to-be-out-of-scope local variable on the stack.
Not really, it's a structure copy now. What I'm concerned about is the size of that on-stack variable and its lack of an initializer, undermining the many set_to_dummy_if_null() that xsm_fixup_ops() uses. Can't xsm_fixup_ops() act on xsm_ops directly, perhaps after memset()-ing it here first (if nothing else then just to be on the safe side)?
Quoted 15 lines
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1884
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-0@@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {#endif };flask and silo ops should become:
static const struct
xsm_ops__initconst{flask,silo}_ops = {as they're neither modified, nor needed after init, following this change.
Quoted 1 line
Quoted 8 lines
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1887
Quoted 3 lines
xen/xsm/flask/hooks.c +2
-1-void __init flask_init (const void *policy_buffer,size_t policy_size) +struct xsm_operations __init *flask_init (const void *policy_buffer, +size_t policy_size)struct
xsm_ops*__initflask_init(...)Otherwise you've got the
__initin the middle of the return type, and some compilers are more picky than others.
Also, even if {flask,silo}_ops couldn't be const for some reason, these init functions now want to return a pointer-to-const, as the caller isn't supposed to modify the struct-s any further.
Jan
Re: [PATCH v2 02/10] xsm: refactor xsm_ops handling
In reply to Andrew CooperQuoted 14 lines · Andrew Cooper
Quoted 13 lines · Daniel P. Smith
xen/include/xsm/xsm.h +0
-3@@ -747,16 +747,14 @@ 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);
Quoted 14 lines
xen/include/xsm/xsm.h extern int xsm_dt_policy_init(void **policy_buffer, size_t *policy_size); · line 759
Quoted 10 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 struct xsm_operations *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_operations *flask_init (const void *policy_buffer,size_t policy_size) { +return NULL ; }#endif As you touch almost every current user of
xsm_operationsand introduce quite a few more, can I recommend taking the opportunity to shorten the name to structxsm_ops.
Looks like Jan also agreed, so I will add this to the mix.
Quoted 20 lines
Quoted 20 lines
xen/xsm/flask/flask_op.c +3
-1@@ -226,6 +226,7 @@ static int flask_security_sid(struct xen_flask_sid_context *arg)static int flask_disable (void ) {static int flask_disabled =0 ; +struct xsm_operations default_ops;if ( ss_initialized ) {@@ -244,7 +245,8 @@ static int flask_disable(void) flask_disabled =1 ;/* Reset xsm_ops to the original module. */ - xsm_ops = &dummy_xsm_ops; +xsm_fixup_ops (&default_ops); + xsm_ops = default_ops;
Quoted 9 lines
xen/xsm/flask/flask_op.c static int flask_disable(void) · line 252
Quoted 2 lines
xen/xsm/flask/flask_op.c +0
-0return 0 ; }These two hunks will disappear when patch 3 is reordered with respect to this one.
... which is good because you've just pointed
xsm_opsat a soon-to-be-out-of-scope local variable on the stack.
As Jan has pointed out it is not a ref issue, but it was very bad of me to leave the stack var uninitialized. Regardless as you pointed out, this will be irrelevant with moving patch 3 ahead of this.
Quoted 10 lines
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1884
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-0@@ -1883,7 +1883,8 @@ static struct xsm_operations flask_ops = {#endif };flask and silo ops should become:
Quoted 4 lines
static const struct
xsm_ops__initconst{flask,silo}_ops = {as they're neither modified, nor needed after init, following this change.
After this and seeing Jan's comments, I am going to walk through this again and see if there is more adjustments/cleanups I can do/
Quoted 9 lines
xen/xsm/flask/hooks.c static struct xsm_operations flask_ops = { · line 1887
Quoted 4 lines
xen/xsm/flask/hooks.c +2
-1-void __init flask_init (const void *policy_buffer,size_t policy_size) +struct xsm_operations __init *flask_init (const void *policy_buffer, +size_t policy_size)struct
xsm_ops*__initflask_init(...)Otherwise you've got the
__initin the middle of the return type, and some compilers are more picky than others.
Ack
Quoted 9 lines
xen/xsm/flask/hooks.c void __init flask_init(const void *policy_buffer, size_t policy_size) · line 1926
Quoted 7 lines
xen/xsm/flask/hooks.c +3
-0@@ -1923,6 +1921,9 @@ 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; +Stray newline.
Ack
Quoted 11 lines
Quoted 11 lines
xen/xsm/flask/hooks.c +0
-0}/* xen/xsm/silo.c +0
-0@@ -112,12 +112,11 @@ static struct xsm_operations silo_xsm_ops = {#endif };
Quoted 4 lines
xen/xsm/silo.c static struct xsm_operations silo_xsm_ops = { · line 115
Quoted 2 lines
xen/xsm/silo.c +1
-1-void __init silo_init (void ) +struct xsm_operations __init *silo_init (void )Same here as with flask.
Ack
Quoted 8 lines
Quoted 8 lines
xen/xsm/xsm_core.c +0
-0@@ -68,17 +76,10 @@ static int __init parse_xsm_param(const char *s) }custom_param ("xsm" , parse_xsm_param);
Quoted 16 lines
xen/xsm/xsm_core.c static int __init parse_xsm_param(const char *s) · line 82
Quoted 13 lines
xen/xsm/xsm_core.c +2
-9-static inline int verify (struct xsm_operations *ops) -{ -/* verify the security_operations structure exists */ -if ( !ops ) -return -EINVAL ; -xsm_fixup_ops (ops); -return 0 ; -} -static int __init xsm_core_init (const void *policy_buffer,size_t policy_size) { +struct xsm_operations *mod_ops; +Hard tabs, and later in this function. Also, how about just 'ops' for the local variable name?
Ack
Quoted 10 lines
xen/xsm/xsm_core.c static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 130
Quoted 8 lines
xen/xsm/xsm_core.c +4
-0@@ -113,6 +124,17 @@ 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 Stray double space.
Ack
Quoted 2 lines
~Andrew
v/r,
dps
PATCH v2 3/10 xsm: remove the ability to disable flask
In reply to Daniel P. SmithThe flask XSM module provided the ability to switch from flask back to the dummy XSM module during runtime. With this removal the only way to switch between XSM modules is at boot time.
--- xen/xsm/flask/flask_op.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
xen/xsm/flask/flask_op.c +0 -32
@@ -223,34 +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 ; -struct xsm_operations default_ops; - -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_fixup_ops (&default_ops); - xsm_ops = default_ops; - -return 0 ; -} -static int flask_security_setavc_threshold (struct xen_flask_setavc_threshold *arg) {int rv =0 ;
@@ -700,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
Re: [PATCH v2 03/10] xsm: remove the ability to disable flask
Quoted 5 lines · Daniel P. Smith
The flask XSM module provided the ability to switch from flask back to the dummy XSM module during runtime. With this removal the only way to switch between XSM modules is at boot time.
Signed-off-by Daniel P. Smith <[email protected]>
This patch wants reordering ahead of "xsm: refactor xsm_ops handling" which will reduce the churn in that patch.
In addition, you want:
(quoted diff) +0 -0
b/xen/include/public/xsm/flask_op.h
index 16af7bc22f75..b41dd6dac894 100644
xen/include/public/xsm/flask_op.h +0 -0
@@ -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
to match the removal of FLASK_USER in c/s 559f439bfa3bf
~Andrew
Re: [PATCH v2 03/10] xsm: remove the ability to disable flask
Quoted 9 lines · Andrew Cooper
Quoted 5 lines · Daniel P. Smith
The flask XSM module provided the ability to switch from flask back to the dummy XSM module during runtime. With this removal the only way to switch between XSM modules is at boot time.
Signed-off-by Daniel P. Smith <[email protected]>This patch wants reordering ahead of "xsm: refactor
xsm_opshandling" which will reduce the churn in that patch.
Ack
Quoted 17 lines
In addition, you want:
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
Quoted 1 line
to match the removal of
FLASK_USERin c/s559f439bfa3bf
Ack
Re: [PATCH v2 03/10] xsm: remove the ability to disable flask
In reply to Daniel P. SmithQuoted 5 lines · Daniel P. Smith
The flask XSM module provided the ability to switch from flask back to the dummy XSM module during runtime. With this removal the only way to switch between XSM modules is at boot time.
Signed-off-by Daniel P. Smith <[email protected]>
Can you please add a statement as to why you/we want this, perhaps helping clarify why apparently you think no-one is making use of this?
Jan
Re: [PATCH v2 03/10] xsm: remove the ability to disable flask
Quoted 10 lines · Jan Beulich
Quoted 5 lines · Daniel P. Smith
The flask XSM module provided the ability to switch from flask back to the dummy XSM module during runtime. With this removal the only way to switch between XSM modules is at boot time.
Signed-off-by Daniel P. Smith <[email protected]>Can you please add a statement as to why you/we want this, perhaps helping clarify why apparently you think no-one is making use of this?
Yes, I can expand more on the why.
v/r
dps
PATCH v2 4/10 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 | 195 +++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 96 deletions(-)
xen/include/xsm/xsm.h +99 -96
@@ -15,6 +15,9 @@#ifndef __XSM_H__#define __XSM_H__ +#ifdef CONFIG_XSM +#include <xen/alternative-call.h> +#endif #include <xen/sched.h> #include <xen/multiboot.h>
@@ -198,288 +201,288 @@ extern struct xsm_operations 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 +490,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 +560,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 +669,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
Re: [PATCH v2 04/10] xsm: convert xsm_ops hook calls to alternative call
Quoted 13 lines · Daniel P. Smith
To reduce retpolines convert all the pointer function calls of the
xsm_opshooks over to thealternative_callinfrastructure.Signed-off-by Daniel P. Smith <[email protected]>--- xen/include/xsm/xsm.h | 195 +++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 96 deletions(-)xen/include/xsm/xsm.h +0
-0
xen/include/xsm/xsm.h line 20
Quoted 6 lines
xen/include/xsm/xsm.h +3
-0@@ -15,6 +15,9 @@#ifndef __XSM_H__#define __XSM_H__ +#ifdef CONFIG_XSM +#include <xen/alternative-call.h> +#endif
This guard needs dropping to fix the build on ARM.
Otherwise, Acked-by: Andrew Cooper <[email protected]>
Re: [PATCH v2 04/10] xsm: convert xsm_ops hook calls to alternative call
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Daniel P. Smith
To reduce retpolines convert all the pointer function calls of the
xsm_opshooks over to thealternative_callinfrastructure.Signed-off-by Daniel P. Smith <[email protected]>--- xen/include/xsm/xsm.h | 195 +++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 96 deletions(-)xen/include/xsm/xsm.h +0
-0@@ -15,6 +15,9 @@#ifndef __XSM_H__#define __XSM_H__
Quoted 5 lines
xen/include/xsm/xsm.h line 20
Quoted 3 lines
xen/include/xsm/xsm.h +3
-0+#ifdef CONFIG_XSM +#include <xen/alternative-call.h> +#endif This guard needs dropping to fix the build on ARM.
Ack
Quoted 2 lines
Otherwise, Acked-by: Andrew Cooper <[email protected]>
v/r,
dps
PATCH v2 5/10 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 anyone time. This commit works to simplify this by separating the core structure 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 | 263 +++++++++++++++++++++++++++++++++++++ xen/include/xsm/xsm.h | 241 +-------------------------------- xen/xsm/dummy.c | 1 - xen/xsm/silo.c | 1 - 5 files changed, 265 insertions(+), 243 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 +263 -0
263 lines not on this page · raw message
xen/include/xsm/xsm.h +1 -240
262 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 v2 6/10 xsm: enable xsm to always be included
In reply to Daniel P. SmithThe only difference between !CONFIG_XSM and CONFIG_XSM when SILO and FLASK are not enabled is whether the XSM hooks in dummy.h are called as static inline functions or as function pointers to static functions. As such this commit,
* eliminates CONFIG_XSM
* introduces CONFIG_XSM_EVTCHN_LABELING as replacement for enabling event channel labels
* makes CONFIG_XSM_SILO AND CONFIG_XSM_FLASK default to no
---
xen/common/Kconfig | 51 ++++----
xen/include/xen/sched.h | 2 +-
xen/include/xsm/xsm-core.h | 26 ----
xen/include/xsm/xsm.h | 8 --
xen/xsm/Makefile | 4 +-
xen/xsm/dummy.c | 4 +-
xen/{include => }/xsm/dummy.h | 220 ++++++++++++++++------------------
xen/xsm/silo.c | 17 +--
xen/xsm/xsm_core.c | 4 -
9 files changed, 141 insertions(+), 195 deletions(-)
rename xen/{include => }/xsm/dummy.h (63%)xen/common/Kconfig +25 -26
@@ -200,23 +200,20 @@ 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. +menu "Xen Security Modules" - If unsure, say N. +config XSM_EVTCHN_LABELING + bool "Enables security labeling of event channels" + default n + help + This enables an XSM module to label and enforce access control over + event channels. config XSM_FLASK - def_bool y - prompt "FLux Advanced Security Kernel support" - depends on XSM - ---help--- + bool "FLux Advanced Security Kernel support" + default n + 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 +223,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 +237,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 +250,10 @@ 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 + 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,24 +262,26 @@ 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 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 bool "SILO" if XSM_SILO + endchoice +endmenu + 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/xen/sched.h +1 -1
@@ -120,7 +120,7 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSM +#ifdef CONFIG_XSM_EVTCHN_LABELING union { #ifdef XSM_NEED_GENERIC_EVTCHN_SSID /*
xen/include/xsm/xsm-core.h +0 -26
@@ -191,8 +191,6 @@ struct xsm_operations {extern void xsm_fixup_ops (struct xsm_operations *ops); -#ifdef CONFIG_XSM -#ifdef CONFIG_MULTIBOOT extern int xsm_multiboot_init (unsigned long *module_map,const multiboot_info_t *mbi);
@@ -236,28 +234,4 @@ static inline struct xsm_operations *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 +0 -8
@@ -22,8 +22,6 @@#include <xen/multiboot.h> #include <xsm/xsm-core.h> -#ifdef CONFIG_XSM -extern struct xsm_operations xsm_ops; static inline void xsm_security_domaininfo (struct domain *d,
@@ -556,10 +554,4 @@ static inline int xsm_argo_send(const struct domain *d, const struct domain *t)#endif /* CONFIG_ARGO */ -#else /* CONFIG_XSM */ - -#include <xsm/dummy.h> - -#endif /* CONFIG_XSM */ -#endif /* __XSM_H */
xen/xsm/Makefile +2 -2
@@ -1,6 +1,6 @@ obj-y += xsm_core.o -obj-$(CONFIG_XSM) += xsm_policy.o -obj-$(CONFIG_XSM) += dummy.o +obj-y += xsm_policy.o +obj-y += dummy.o obj-$(CONFIG_XSM_SILO) += silo.o obj-$(CONFIG_XSM_FLASK) += flask/
xen/xsm/dummy.c +2 -2
@@ -10,12 +10,12 @@* as published by the Free Software Foundation. */ -#include <xsm/dummy.h> +#include "dummy.h" #define set_to_dummy_if_null (ops, function) \ do { \ if ( !ops->function ) \ - ops->function = xsm_##function; \ + ops->function = dummy_##function; \ } while (0)void __init xsm_fixup_ops (struct xsm_operations *ops)
xen/xsm/dummy.h renamed from xen/include/xsm/dummy.h +102 -118
742 lines not on this page · raw message
xen/xsm/silo.c +9 -8
@@ -17,7 +17,8 @@* 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/dummy.h> +#include <xsm/xsm-core.h> +#include "dummy.h" /* * Check if inter-domain communication is allowed.
@@ -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 =dummy_evtchn_unbound (d1, chn, id2);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 dummy_evtchn_interdomain(d1, chan1, d2, chan2);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 dummy_grant_mapref (d1, d2, flags);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 dummy_grant_transfer (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 dummy_grant_copy (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 dummy_argo_register_single_source (d1, d2);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 dummy_argo_send (d1, d2);return -EPERM ; }
xen/xsm/xsm_core.c +0 -4
@@ -18,8 +18,6 @@#include <xen/hypercall.h> #include <xsm/xsm.h> -#ifdef CONFIG_XSM -#ifdef CONFIG_MULTIBOOT #include <asm/setup.h> #endif
@@ -217,8 +215,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 v2 06/10] xsm: enable xsm to always be included
Quoted 6 lines · Daniel P. Smith
xen/common/Kconfig +0
-0@@ -200,23 +200,20 @@ config XENOPROF If unsure, say Y.
xen/common/Kconfig config XENOPROF · line 203
Quoted 10 lines
xen/common/Kconfig +1
-9-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. +menu "Xen Security Modules"
I remain unconvinced of the removal of this top level option. I don't view my concern on code size / performance as "unreasonable" (as Andrew did call it) when comparing with the current !XSM configuration, and I also remain to be convinced of people who had to simply answer 'n' to the XSM kconfig prompt being happy to make an informed decision for all the (previously sub-)options that they will now be prompted for. As said before - it is one thing to re-work what exactly !XSM means internally (and the conversion away from inline functions may very well be a win; we simply don't know without you showing e.g. bloat-o-meter like data). It is another to require in-depth knowledge to configure Xen that previously wasn't required.
Keeping the top-level option would then also make it unnecessary to alter some of the (prior sub-)options' defaults.
As to Andrew previously having said
"There is no such thing as !XSM even in staging right now.
All over Xen, we have calls to xsm_*() functions which, even in the !XSM case, contain a non-trivial security policy."
Yes, this is one possible viewpoint, which I simply do not share. I view the xsm_*() calls in the !XSM case as simple surrogates, not anything that deserves the name "module". This is actually supported by the help text of the XSM Kconfig option saying "which allows administrators fine-grained control": There's nothing fine-grained with what currently is !XSM.
xen/common/Kconfig config XENOPROF · line 206
Quoted 3 lines
xen/common/Kconfig +2
-1- If unsure, say N. +config XSM_EVTCHN_LABELING + bool "Enables security labeling of event channels"
Does this really need to have a prompt, instead of simply being selected by the module(s) needing it? IOW what do users gain when they answer y here but n for XSM_FLASK?
Furthermore, if the prompt is to remain, then I'll have to again raise the question of ordering of options: This way, via e.g. the "syncconfig" or "oldconfig" targets, I'd be asked for the setting here when, if I'd then also set XSM_FLASK=y, the question was in vein - the option will be set to y anyway.
xen/common/Kconfig config XENOPROF · line 206
Quoted 1 line
xen/common/Kconfig +1
-0+ default n
May I ask to omit "default n" lines. I'm unaware of anything good they do.
Quoted 10 lines
xen/common/Kconfig +1
-2@@ -265,24 +262,26 @@ 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
xen/common/Kconfig config XSM_SILO · line 277
Quoted 10 lines
xen/common/Kconfig +2
-1default XSM_DUMMY_DEFAULT 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 bool "SILO" if XSM_SILO + endchoice
Nit: I see only two consistent formatting options here: Either there is a blank line ahead of "endchoice" and after "choice", or there are none in both places. I don't mind which one it is, but I do mind inconsistencies getting introduced.
Jan
Re: [PATCH v2 06/10] xsm: enable xsm to always be included
Quoted 21 lines · Jan Beulich
Quoted 6 lines · Daniel P. Smith
xen/common/Kconfig +0
-0@@ -200,23 +200,20 @@ config XENOPROF If unsure, say Y.xen/common/Kconfig config XENOPROF · line 203
Quoted 10 lines
xen/common/Kconfig +1
-9-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. +menu "Xen Security Modules"I remain unconvinced of the removal of this top level option. I don't view my concern on code size / performance as "unreasonable" (as Andrew did call it) when comparing with the current !XSM configuration, and I
Quoted 8 lines
also remain to be convinced of people who had to simply answer 'n' to the XSM kconfig prompt being happy to make an informed decision for all the (previously sub-)options that they will now be prompted for. As said before - it is one thing to re-work what exactly !XSM means internally (and the conversion away from inline functions may very well be a win; we simply don't know without you showing e.g. bloat-o-meter like data). It is another to require in-depth knowledge to configure Xen that previously wasn't required.
For me personally a concern about code size / performance itself is not "unreasonable" but I would say it is a bit disingenuous to use it to defend a position that the security framework should be special conditioned and kept convoluted considering, 1) other subsystems, e.g. iommu, do not appear to me to have the same subjugation requiring a special case of one hook set over another, 2) the architecture (Arm) which IMHO has the greatest concern over code size / performance is also the architecture with the only security supported configuration that requires an XSM enabled configuration, 3) this approach effectively requires the maintaining of two sets of hook handlers which increases work and risk for vulnerability introduction, and 4) based on the discussions at the Developers Summit, no one seemed to be aware that the only logical difference between !XSM and XSM was the invocation mechanism, inline vs call-site, let alone that XSM_HOOK represented no control check.
To bring context to the discussion, after applying the clean up patches (everything up to the patch dropping !XSM) of the patch set, the bloat-o-meter shows a 0.18% increase going from !XSM to XSM (without SILO and Flask). IMHO this increase does not justify keeping the convoluted gyrations being done to swap in an optimized security hook when no other security module is enabled. In fact we should be working to make the security framework clear and concise. I am all for maximizing performance while doing so but the end goal is for it to be clear and concise so that it can be reasoned about by everybody.
As to your position that this increases configuration complexity, I would have to strongly disagree. I have worked to ensure no new configuration steps are necessary. The default config will only have XSM and the default/dummy policy enabled unless on Arm which will enable SILO and make it the default policy. Prior to this if XSM was enabled, the default policy was forced to Flask. While I am an advocate for Flask, I do not agree this is a reasonable configuration. It now works such that,
- if you enable only SILO, it is set as the default
- if you enable only Flask, it is set as the default
- if you enable both SILO & Flask, it uses SILO as the default
Which basically works such that if one selects a policy, then it assumes that policy is desired to be used, and when more than one is selected it will default to the one that functions most like classic Dom0 model. IMHO this is much more intuitive. Now one alternative I am thinking about that might be a bit of a compromise is to move the default policy selection up to the same level as XSM menu. That would make it so one could immediately see what the default policy is but must go into the XSM menu if they want to alter what policy modules are available.
Quoted 2 lines
Keeping the top-level option would then also make it unnecessary to alter some of the (prior sub-)options' defaults.
I would beg to differ, it now makes the builder have to explicitly enter that sub-option if they desire to enable an alternate security model, e.g. have explicit intent instead of having the potential for accidental selection.
Quoted 4 lines
As to Andrew previously having said
"There is no such thing as !XSM even in staging right now.
Quoted 8 lines
All over Xen, we have calls to xsm_*() functions which, even in the !XSM case, contain a non-trivial security policy."
Yes, this is one possible viewpoint, which I simply do not share. I view the xsm_*() calls in the !XSM case as simple surrogates, not anything that deserves the name "module". This is actually supported by the help text of the XSM
Kconfigoption saying "which allows administrators fine-grained control": There's nothing fine-grained with what currently is !XSM.
IMHO that is a very unfortunate viewpoint. An xsm_*() call is an access control check point where a decision needs to be made on whether an access to a resource should be allowed. In a kernel with a monolithic access control there would still be an implicit or an explicit access check necessary at this location. What XSM does is makes all the access check locations to be explicit checks where the decision can be handled by different access control frameworks to be plugged in to implement the security architecture that the implementer requires.
Quoted 14 lines
xen/common/Kconfig config XENOPROF · line 206
Quoted 3 lines
xen/common/Kconfig +2
-1- If unsure, say N. +config XSM_EVTCHN_LABELING + bool "Enables security labeling of event channels"Does this really need to have a prompt, instead of simply being selected by the module(s) needing it? IOW what do users gain when they answer y here but n for
XSM_FLASK?Furthermore, if the prompt is to remain, then I'll have to again raise the question of ordering of options: This way, via e.g. the "syncconfig" or "oldconfig" targets, I'd be asked for the setting here when, if I'd then also set XSM_FLASK=y, the question was in vein - the option will be set to y anyway.
Quoted 4 lines
xen/common/Kconfig config XENOPROF · line 206
Quoted 1 line
xen/common/Kconfig +1
-0+ default nMay I ask to omit "default n" lines. I'm unaware of anything good they do.
It has been dropped
Quoted 17 lines
Quoted 17 lines
xen/common/Kconfig +2
-3@@ -265,24 +262,26 @@ 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 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
Quoted 8 lines
xen/common/Kconfig config XSM_SILO · line 277
Quoted 3 lines
xen/common/Kconfig +1
-0bool "SILO" if XSM_SILO + endchoiceNit: I see only two consistent formatting options here: Either there is a blank line ahead of "endchoice" and after "choice", or there are none in both places. I don't mind which one it is, but I do mind inconsistencies getting introduced.
ack
v/r,
dps
Re: [PATCH v2 06/10] xsm: enable xsm to always be included
Quoted 47 lines · Daniel P. Smith
Quoted 21 lines · Jan Beulich
Quoted 6 lines · Daniel P. Smith
xen/common/Kconfig +0
-0@@ -200,23 +200,20 @@ config XENOPROF If unsure, say Y.xen/common/Kconfig config XENOPROF · line 203
Quoted 10 lines
xen/common/Kconfig +1
-9-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. +menu "Xen Security Modules"I remain unconvinced of the removal of this top level option. I don't view my concern on code size / performance as "unreasonable" (as Andrew did call it) when comparing with the current !XSM configuration, and I
Quoted 8 lines
also remain to be convinced of people who had to simply answer 'n' to the XSM kconfig prompt being happy to make an informed decision for all the (previously sub-)options that they will now be prompted for. As said before - it is one thing to re-work what exactly !XSM means internally (and the conversion away from inline functions may very well be a win; we simply don't know without you showing e.g. bloat-o-meter like data). It is another to require in-depth knowledge to configure Xen that previously wasn't required.
For me personally a concern about code size / performance itself is not "unreasonable" but I would say it is a bit disingenuous to use it to defend a position that the security framework should be special conditioned and kept convoluted considering, 1) other subsystems, e.g. iommu, do not appear to me to have the same subjugation requiring a special case of one hook set over another, 2) the architecture (Arm) which IMHO has the greatest concern over code size / performance is also the architecture with the only security supported configuration that requires an XSM enabled configuration, 3) this approach effectively requires the maintaining of two sets of hook handlers which increases work and risk for vulnerability introduction, and 4) based on the discussions at the Developers Summit, no one seemed to be aware that the only logical difference between !XSM and XSM was the invocation mechanism, inline vs call-site, let alone that
XSM_HOOKrepresented no control check.
Quoted 9 lines
To bring context to the discussion, after applying the clean up patches (everything up to the patch dropping !XSM) of the patch set, the bloat-o-meter shows a 0.18% increase going from !XSM to XSM (without SILO and Flask). IMHO this increase does not justify keeping the convoluted gyrations being done to swap in an optimized security hook when no other security module is enabled. In fact we should be working to make the security framework clear and concise. I am all for maximizing performance while doing so but the end goal is for it to be clear and concise so that it can be reasoned about by everybody.
Well, I guess if the majority is with you then that's what is going to happen.
Quoted 3 lines
As to your position that this increases configuration complexity, I would have to strongly disagree. I have worked to ensure no new configuration steps are necessary.
I'm having a hard time seeing how this could be the case, especially since ...
Quoted 4 lines
The default config will only have XSM
and the default/dummy policy enabled unless on Arm which will enable SILO and make it the default policy. Prior to this if XSM was enabled, the default policy was forced to Flask. While I am an advocate for
Quoted 8 lines
Flask, I do not agree this is a reasonable configuration. It now works such that,
- if you enable only SILO, it is set as the default
- if you enable only Flask, it is set as the default
- if you enable both SILO & Flask, it uses SILO as the default
Which basically works such that if one selects a policy, then it assumes that policy is desired to be used, and when more than one is selected it will default to the one that functions most like classic Dom0 model.
... I don't see how putting in place suitable defaults would suppress any respective prompts during e.g. "make syncconfig". (I can see that what you say may apply to e.g. "make menuconfig", which I think I've indicated before I don't use myself and hence I don't care all that much about.)
Quoted 5 lines
IMHO this is much more intuitive. Now one alternative I am thinking about that might be a bit of a compromise is to move the default policy selection up to the same level as XSM menu. That would make it so one could immediately see what the default policy is but must go into the XSM menu if they want to alter what policy modules are available.
All of this appears to support my assumption that you're looking at things from a "make menuconfig"-centric viewpoint.
Jan
PATCH v2 7/10 xsm: drop generic event channel labeling
In reply to Daniel P. SmithThe generic event channel labeling has not been used by any XSM module since its introduction. This commit removes the capability leaving FLASK labeling field always present. In the future if a new XSM module needs to have its own channel label, this or a new form can be introduced.
--- xen/common/Kconfig | 8 -------- xen/include/xen/sched.h | 9 --------- 2 files changed, 17 deletions(-)
xen/common/Kconfig +0 -8
@@ -202,17 +202,9 @@ config XENOPROF menu "Xen Security Modules" -config XSM_EVTCHN_LABELING - bool "Enables security labeling of event channels" - default n - help - This enables an XSM module to label and enforce access control over - event channels. - config XSM_FLASK bool "FLux Advanced Security Kernel support" default n - 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
xen/include/xen/sched.h +0 -9
@@ -120,15 +120,7 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSM_EVTCHN_LABELINGunion { -#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 +130,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
Re: [PATCH v2 07/10] xsm: drop generic event channel labeling
Quoted 4 lines · Daniel P. Smith
The generic event channel labeling has not been used by any XSM module since its introduction. This commit removes the capability leaving FLASK labeling field always present. In the future if a new XSM module needs to have its own channel label, this or a new form can be introduced.
You're missing a SoB line.
Also, this too would benefit from being reordered higher than patch 6, to reduce the churn there.
Re: [PATCH v2 07/10] xsm: drop generic event channel labeling
Quoted 7 lines · Andrew Cooper
Quoted 4 lines · Daniel P. Smith
The generic event channel labeling has not been used by any XSM module since its introduction. This commit removes the capability leaving FLASK labeling field always present. In the future if a new XSM module needs to have its own channel label, this or a new form can be introduced.
You're missing a SoB line.
Apologies, i was originally going to squash this but then decided it probably served to be kept as a standalone commit. Will get the SoB added.
Quoted 2 lines
Also, this too would benefit from being reordered higher than patch 6, to reduce the churn there.
Ack
v/r,
dps
Re: [PATCH v2 07/10] xsm: drop generic event channel labeling
In reply to Daniel P. SmithQuoted 4 lines · Daniel P. Smith
The generic event channel labeling has not been used by any XSM module since its introduction. This commit removes the capability leaving FLASK labeling field always present. In the future if a new XSM module needs to have its own channel label, this or a new form can be introduced.
I'm not fully convinced of this removal: Does it get in the way of anything?
Quoted 8 lines
xen/include/xen/sched.h +0
-1@@ -120,15 +120,7 @@ struct evtchnunsigned short notify_vcpu_id;/* VCPU for local delivery notification */ uint32_t fifo_lastq;/* Data for identifying last queue. */ -#ifdef CONFIG_XSM_EVTCHN_LABELINGunion {
xen/include/xen/sched.h struct evtchn · line 126
Quoted 10 lines
xen/include/xen/sched.h +0
-7-#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
This comment's "with only FLASK" now becomes stale, and hence would imo better be updated.
Jan
PATCH v2 8/10 xsm: remove xsm_default_t from hook definitions
In reply to Daniel P. SmithThe passing of an xsm_default_t at each of the xsm hook call sites served different functions depending on whether XSM was enabled or not. When XSM was not enabled it attempted to function as a link-time check that declared default action at the call site matched the default declared action for that hook in the dummy policy. When XSM was enabled, it would just drop the parameter.
The removal of these values is two fold. They are a redundancy that provides little context, especially when the value is XSM_OTHER. A more appropriate approach is that the hook functions in the dummy policy should provide reasoning of the default value when it is not clear. Next is that with the change to make XSM always enabled is the case where the parameter is completely ignored. Thus it is logical to remove them from the hook call sites.
--- xen/arch/arm/dm.c | 2 +- xen/arch/arm/domctl.c | 6 +- xen/arch/arm/hvm.c | 2 +- xen/arch/arm/mm.c | 2 +- xen/arch/arm/platform_hypercall.c | 2 +- xen/arch/x86/cpu/mcheck/mce.c | 2 +- xen/arch/x86/cpu/vpmu.c | 2 +- xen/arch/x86/domctl.c | 8 +- xen/arch/x86/hvm/dm.c | 2 +- xen/arch/x86/hvm/hvm.c | 12 +- xen/arch/x86/irq.c | 5 +- xen/arch/x86/mm.c | 20 +-- xen/arch/x86/mm/mem_paging.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 9 +- xen/arch/x86/mm/p2m.c | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/set.c | 2 +- xen/arch/x86/msi.c | 3 +- xen/arch/x86/pci.c | 2 +- xen/arch/x86/physdev.c | 17 ++- xen/arch/x86/platform_hypercall.c | 10 +- xen/arch/x86/pv/emul-priv-op.c | 2 +- xen/arch/x86/sysctl.c | 4 +- xen/common/domain.c | 4 +- xen/common/domctl.c | 12 +- xen/common/event_channel.c | 12 +- xen/common/grant_table.c | 16 +-- xen/common/hypfs.c | 2 +- xen/common/kernel.c | 2 +- xen/common/kexec.c | 2 +- xen/common/mem_access.c | 2 +- xen/common/memory.c | 16 +-- xen/common/monitor.c | 2 +- xen/common/sched/core.c | 6 +- xen/common/sysctl.c | 8 +- xen/common/vm_event.c | 2 +- xen/common/xenoprof.c | 2 +- xen/drivers/char/console.c | 2 +- xen/drivers/passthrough/device_tree.c | 4 +- xen/drivers/passthrough/pci.c | 12 +- xen/include/xsm/xsm.h | 172 +++++++++++++------------- 41 files changed, 197 insertions(+), 203 deletions(-)
xen/arch/arm/dm.c +1 -1
@@ -45,7 +45,7 @@ int dm_op(const struct dmop_args *op_args)if ( rc )return rc; - rc =xsm_dm_op (XSM_DM_PRIV , d); + rc =xsm_dm_op (d);if ( rc ) goto out;
xen/arch/arm/domctl.c +3 -3
@@ -95,11 +95,11 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,* done by the 2 hypercalls for consistency with other * architectures. */ - rc =xsm_map_domain_irq (XSM_HOOK , d, irq,NULL ); + rc =xsm_map_domain_irq (d, irq,NULL );if ( rc )return rc; - rc =xsm_bind_pt_irq (XSM_HOOK , d, bind); + rc =xsm_bind_pt_irq (d, bind);if ( rc )return rc;
@@ -130,7 +130,7 @@ long arch_do_domctl(struct xen_domctl *domctl, struct domain *d,if ( irq != virq )return -EINVAL ; - rc =xsm_unbind_pt_irq (XSM_HOOK , d, bind); + rc =xsm_unbind_pt_irq (d, bind);if ( rc )return rc;
xen/arch/arm/hvm.c +1 -1
@@ -101,7 +101,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -ESRCH ; - rc =xsm_hvm_param (XSM_TARGET , d, op); + rc =xsm_hvm_param (d, op);if ( rc ) goto param_fail;
xen/arch/arm/mm.c +1 -1
@@ -1446,7 +1446,7 @@ int xenmem_add_to_physmap_one(return -EINVAL ; } - rc =xsm_map_gmfn_foreign (XSM_TARGET , d, od); + rc =xsm_map_gmfn_foreign (d, od);if ( rc ) {put_pg_owner (od);
xen/arch/arm/platform_hypercall.c +1 -1
@@ -33,7 +33,7 @@ long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)if ( d ==NULL )return -ESRCH ; - ret =xsm_platform_op (XSM_PRIV , op->cmd); + ret =xsm_platform_op (op->cmd);if ( ret )return ret;
xen/arch/x86/cpu/mcheck/mce.c +1 -1
@@ -1376,7 +1376,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)struct xen_mc_msrinject *mc_msrinject;struct xen_mc_mceinject *mc_mceinject; - ret =xsm_do_mca (XSM_PRIV ); + ret =xsm_do_mca ();if ( ret )return x86_mcerr ("" , ret);
xen/arch/x86/cpu/vpmu.c +1 -1
@@ -706,7 +706,7 @@ long do_xenpmu_op(unsigned int op, XEN_GUEST_HANDLE_PARAM(xen_pmu_params_t) arg)if ( !opt_vpmu_enabled ||has_vlapic (current->domain) )return -EOPNOTSUPP ; - ret =xsm_pmu_op (XSM_OTHER , current->domain, op); + ret =xsm_pmu_op (current->domain, op);if ( ret )return ret;
xen/arch/x86/domctl.c +4 -4
@@ -234,7 +234,7 @@ long arch_do_domctl(if ( (fp + np) <= fp || (fp + np) >MAX_IOPORTS ) ret = -EINVAL ;else if ( !ioports_access_permitted (currd, fp, fp + np -1 ) || -xsm_ioport_permission (XSM_HOOK , d, fp, fp + np -1 , allow) ) +xsm_ioport_permission (d, fp, fp + np -1 , allow) ) ret = -EPERM ;else if ( allow ) ret =ioports_permit_access (d, fp, fp + np -1 );
@@ -534,7 +534,7 @@ long arch_do_domctl(if ( !is_hvm_domain (d) )break ; - ret =xsm_bind_pt_irq (XSM_HOOK , d, bind); + ret =xsm_bind_pt_irq (d, bind);if ( ret )break ;
@@ -569,7 +569,7 @@ long arch_do_domctl(if ( irq <=0 || !irq_access_permitted (currd, irq) )break ; - ret =xsm_unbind_pt_irq (XSM_HOOK , d, bind); + ret =xsm_unbind_pt_irq (d, bind);if ( ret )break ;
@@ -616,7 +616,7 @@ long arch_do_domctl(if ( !ioports_access_permitted (currd, fmp, fmp + np -1 ) )break ; - ret =xsm_ioport_mapping (XSM_HOOK , d, fmp, fmp + np -1 , add); + ret =xsm_ioport_mapping (d, fmp, fmp + np -1 , add);if ( ret )break ;
xen/arch/x86/hvm/dm.c +1 -1
@@ -370,7 +370,7 @@ int dm_op(const struct dmop_args *op_args)if ( !is_hvm_domain (d) ) goto out; - rc =xsm_dm_op (XSM_DM_PRIV , d); + rc =xsm_dm_op (d);if ( rc ) goto out;
xen/arch/x86/hvm/hvm.c +6 -6
@@ -4080,7 +4080,7 @@ static int hvm_allow_set_param(struct domain *d,uint64_t value;int rc; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_set_param); + rc =xsm_hvm_param (d, HVMOP_set_param);if ( rc )return rc;
@@ -4227,7 +4227,7 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value) rc =pmtimer_change_ioport (d, value);break ;case HVM_PARAM_ALTP2M : - rc =xsm_hvm_param_altp2mhvm (XSM_PRIV , d); + rc =xsm_hvm_param_altp2mhvm (d);if ( rc )break ; if ( (value > XEN_ALTP2M_limited) ||
@@ -4356,7 +4356,7 @@ static int hvm_allow_get_param(struct domain *d, {int rc; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_get_param); + rc =xsm_hvm_param (d, HVMOP_get_param);if ( rc )return rc;
@@ -4566,7 +4566,7 @@ static int do_altp2m_op( goto out; } -if ( (rc =xsm_hvm_altp2mhvm_op (XSM_OTHER , d, mode, a.cmd)) ) +if ( (rc =xsm_hvm_altp2mhvm_op (d, mode, a.cmd)) ) goto out; switch ( a.cmd )
@@ -4947,7 +4947,7 @@ static int hvmop_get_mem_type(if ( d ==NULL )return -ESRCH ; - rc =xsm_hvm_param (XSM_TARGET , d, HVMOP_get_mem_type); + rc =xsm_hvm_param (d, HVMOP_get_mem_type);if ( rc ) goto out;
@@ -5040,7 +5040,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)if (unlikely (d != current->domain) ) rc = -EOPNOTSUPP ;else if (is_hvm_domain (d) &&paging_mode_shadow (d) ) - rc =xsm_hvm_param (XSM_TARGET , d, op); + rc =xsm_hvm_param (d, op);if ( !rc )pagetable_dying (a.gpa);
xen/arch/x86/irq.c +2 -3
@@ -2122,7 +2122,7 @@ int map_domain_pirq(return 0 ; } - ret =xsm_map_domain_irq (XSM_HOOK , d, irq, data); + ret =xsm_map_domain_irq (d, irq, data);if ( ret ) { dprintk(XENLOG_G_ERR, "dom%d: could not permit access to irq %d mapping to pirq %d\n",
@@ -2342,8 +2342,7 @@ int unmap_domain_pirq(struct domain *d, int pirq) nr = msi_desc->msi.nvec; } - ret =xsm_unmap_domain_irq (XSM_HOOK , d, irq, - msi_desc ? msi_desc->dev :NULL ); + ret =xsm_unmap_domain_irq (d, irq, msi_desc ? msi_desc->dev :NULL );if ( ret ) goto done;
xen/arch/x86/mm.c +10 -10
@@ -977,7 +977,7 @@ get_page_from_l1e(* minor hack can go away. */ if ( (real_pg_owner ==NULL ) || (pg_owner == l1e_owner) || -xsm_priv_mapping (XSM_TARGET , pg_owner, real_pg_owner) ) +xsm_priv_mapping (pg_owner, real_pg_owner) ) { gdprintk(XENLOG_WARNING, "pg_owner d%d l1e_owner d%d, but real_pg_owner d%d\n",
@@ -3407,7 +3407,7 @@ long do_mmuext_op(return -EINVAL ; } - rc =xsm_mmuext_op (XSM_TARGET , currd, pg_owner); + rc =xsm_mmuext_op (currd, pg_owner);if ( rc ) {put_pg_owner (pg_owner);
@@ -3497,7 +3497,7 @@ long do_mmuext_op(break ; } - rc =xsm_memory_pin_page (XSM_HOOK , currd, pg_owner, page); + rc =xsm_memory_pin_page (currd, pg_owner, page);if ( !rc &&unlikely (test_and_set_bit (_PGT_pinned, &page->u.inuse.type_info)) ) {
@@ -4006,7 +4006,7 @@ long do_mmu_update( }if ( xsm_needed != xsm_checked ) { - rc =xsm_mmu_update (XSM_TARGET , d, pt_owner, pg_owner, xsm_needed); + rc =xsm_mmu_update (d, pt_owner, pg_owner, xsm_needed);if ( rc )break ; xsm_checked = xsm_needed;
@@ -4142,7 +4142,7 @@ long do_mmu_update( xsm_needed |=XSM_MMU_MACHPHYS_UPDATE ;if ( xsm_needed != xsm_checked ) { - rc =xsm_mmu_update (XSM_TARGET , d,NULL , pg_owner, xsm_needed); + rc =xsm_mmu_update (d,NULL , pg_owner, xsm_needed);if ( rc )break ; xsm_checked = xsm_needed;
@@ -4391,7 +4391,7 @@ static int __do_update_va_mapping(perfc_incr (calls_to_update_va); - rc =xsm_update_va_mapping (XSM_TARGET , d, pg_owner, val); + rc =xsm_update_va_mapping (d, pg_owner, val);if ( rc )return rc;
@@ -4630,7 +4630,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -ESRCH ; - rc =xsm_domain_memory_map (XSM_TARGET , d); + rc =xsm_domain_memory_map (d);if ( rc ) {rcu_unlock_domain (d);
@@ -4697,7 +4697,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)unsigned int i;bool store; - rc =xsm_machine_memory_map (XSM_PRIV ); + rc =xsm_machine_memory_map ();if ( rc )return rc;
@@ -4787,9 +4787,9 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)return -ESRCH ;if ( cmd == XENMEM_set_pod_target ) - rc =xsm_set_pod_target (XSM_PRIV , d); + rc =xsm_set_pod_target (d);else - rc =xsm_get_pod_target (XSM_PRIV , d); + rc =xsm_get_pod_target (d);if ( rc !=0 ) goto pod_target_out_unlock;
xen/arch/x86/mm/mem_paging.c +1 -1
@@ -452,7 +452,7 @@ int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg)if ( rc )return rc; - rc =xsm_mem_paging (XSM_DM_PRIV , d); + rc =xsm_mem_paging (d);if ( rc ) goto out;
xen/arch/x86/mm/mem_sharing.c +4 -5
@@ -1883,7 +1883,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg)if ( rc )return rc; - rc =xsm_mem_sharing (XSM_DM_PRIV , d); + rc =xsm_mem_sharing (d);if ( rc ) goto out;
@@ -1928,7 +1928,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg)if ( rc ) goto out; - rc =xsm_mem_sharing_op (XSM_DM_PRIV , d, cd, mso.op); + rc =xsm_mem_sharing_op (d, cd, mso.op);if ( rc ) {rcu_unlock_domain (cd);
@@ -1994,7 +1994,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg)if ( rc ) goto out; - rc =xsm_mem_sharing_op (XSM_DM_PRIV , d, cd, mso.op); + rc =xsm_mem_sharing_op (d, cd, mso.op);if ( rc ) {rcu_unlock_domain (cd);
@@ -2056,8 +2056,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg)* We reuse XENMEM_sharing_op_share XSM check here as this is * essentially the same concept repeated over multiple pages. */ - rc =xsm_mem_sharing_op (XSM_DM_PRIV , d, cd, - XENMEM_sharing_op_share); + rc =xsm_mem_sharing_op (d, cd, XENMEM_sharing_op_share);if ( rc ) {rcu_unlock_domain (cd);
xen/arch/x86/mm/p2m.c +1 -1
@@ -2637,7 +2637,7 @@ static int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, goto out; } - rc =xsm_map_gmfn_foreign (XSM_TARGET , tdom, fdom); + rc =xsm_map_gmfn_foreign (tdom, fdom);if ( rc ) goto out;
xen/arch/x86/mm/paging.c +2 -2
@@ -714,7 +714,7 @@ int paging_domctl(struct domain *d, struct xen_domctl_shadow_op *sc,return -EBUSY ; } - rc =xsm_shadow_control (XSM_HOOK , d, sc->op); + rc =xsm_shadow_control (d, sc->op);if ( rc )return rc;
@@ -771,7 +771,7 @@ long paging_domctl_continuation(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)if ( d ==NULL )return -ESRCH ; - ret =xsm_domctl (XSM_OTHER , d, op.cmd); + ret =xsm_domctl (d, op.cmd);if ( !ret ) {if (domctl_lock_acquire () )
xen/arch/x86/mm/shadow/set.c +1 -1
@@ -117,7 +117,7 @@ shadow_get_page_from_l1e(shadow_l1e_t sl1e, struct domain *d, p2m_type_t type)* not own, we let it succeed anyway. */ if ( owner && (d != owner) && - !(res =xsm_priv_mapping (XSM_TARGET , d, owner)) ) + !(res =xsm_priv_mapping (d, owner)) ) { res =get_page_from_l1e (sl1e, d, owner); SHADOW_PRINTK("privileged %pd installs map of %pd's mfn %"PRI_mfn": %s\n",
xen/arch/x86/msi.c +1 -2
@@ -1310,8 +1310,7 @@ int pci_restore_msi_state(struct pci_dev *pdev)if ( !use_msi )return -EOPNOTSUPP ; - ret =xsm_resource_setup_pci (XSM_PRIV , - (pdev->seg <<16 ) | (pdev->bus <<8 ) | + ret =xsm_resource_setup_pci ((pdev->seg <<16 ) | (pdev->bus <<8 ) | pdev->devfn);if ( ret )return ret;
xen/arch/x86/pci.c +1 -1
@@ -74,7 +74,7 @@ int pci_conf_write_intercept(unsigned int seg, unsigned int bdf, uint32_t *data) {struct pci_dev *pdev; -int rc =xsm_pci_config_permission (XSM_HOOK , current->domain, bdf, +int rc =xsm_pci_config_permission (current->domain, bdf, reg, reg + size -1 ,1 );if ( rc <0 )
xen/arch/x86/physdev.c +8 -9
@@ -110,7 +110,7 @@ int physdev_map_pirq(domid_t domid, int type, int *index, int *pirq_p,if ( d ==NULL )return -ESRCH ; - ret =xsm_map_domain_pirq (XSM_DM_PRIV , d); + ret =xsm_map_domain_pirq (d);if ( ret ) goto free_domain;
@@ -148,7 +148,7 @@ int physdev_unmap_pirq(domid_t domid, int pirq)return -ESRCH ;if ( domid !=DOMID_SELF || !is_hvm_domain (d) || !has_pirq (d) ) - ret =xsm_unmap_domain_pirq (XSM_DM_PRIV , d); + ret =xsm_unmap_domain_pirq (d);if ( ret ) goto free_domain;
@@ -355,7 +355,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = -EFAULT ;if (copy_from_guest (&apic, arg,1 ) !=0 )break ; - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (currd, cmd);if ( ret )break ; ret =ioapic_guest_read (apic.apic_physbase, apic.reg, &apic.value);
@@ -369,7 +369,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) ret = -EFAULT ;if (copy_from_guest (&apic, arg,1 ) !=0 )break ; - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (currd, cmd);if ( ret )break ; ret =ioapic_guest_write (apic.apic_physbase, apic.reg, apic.value);
@@ -385,7 +385,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)/* Use the APIC check since this dummy hypercall should still only * be called by the domain with access to program the ioapic */ - ret =xsm_apic (XSM_PRIV , currd, cmd); + ret =xsm_apic (currd, cmd);if ( ret )break ;
@@ -535,8 +535,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if (copy_from_guest (&dev, arg,1 ) ) ret = -EFAULT ;else - ret =xsm_resource_setup_pci (XSM_PRIV , - (dev.seg <<16 ) | (dev.bus <<8 ) | + ret =xsm_resource_setup_pci ((dev.seg <<16 ) | (dev.bus <<8 ) | dev.devfn) ?:pci_prepare_msix (dev.seg, dev.bus, dev.devfn, cmd != PHYSDEVOP_prepare_msix);
@@ -546,7 +545,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)case PHYSDEVOP_pci_mmcfg_reserved: {struct physdev_pci_mmcfg_reserved info; - ret =xsm_resource_setup_misc (XSM_PRIV ); + ret =xsm_resource_setup_misc ();if ( ret )break ;
@@ -611,7 +610,7 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( setup_gsi.gsi <0 || setup_gsi.gsi >= nr_irqs_gsi )break ; - ret =xsm_resource_setup_gsi (XSM_PRIV , setup_gsi.gsi); + ret =xsm_resource_setup_gsi (setup_gsi.gsi);if ( ret )break ;
xen/arch/x86/platform_hypercall.c +5 -5
@@ -221,7 +221,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)if ( op->interface_version !=XENPF_INTERFACE_VERSION )return -EACCES ; - ret =xsm_platform_op (XSM_PRIV , op->cmd); + ret =xsm_platform_op (op->cmd);if ( ret )return ret;
@@ -639,7 +639,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) {int cpu = op->u.cpu_ol.cpuid; - ret =xsm_resource_plug_core (XSM_HOOK ); + ret =xsm_resource_plug_core ();if ( ret )break ;
@@ -665,7 +665,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) {int cpu = op->u.cpu_ol.cpuid; - ret =xsm_resource_unplug_core (XSM_HOOK ); + ret =xsm_resource_unplug_core ();if ( ret )break ;
@@ -694,7 +694,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)break ;case XENPF_cpu_hotadd: - ret =xsm_resource_plug_core (XSM_HOOK ); + ret =xsm_resource_plug_core ();if ( ret )break ;
@@ -704,7 +704,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)break ;case XENPF_mem_hotadd: - ret =xsm_resource_plug_core (XSM_HOOK ); + ret =xsm_resource_plug_core ();if ( ret )break ;
xen/arch/x86/pv/emul-priv-op.c +1 -1
@@ -252,7 +252,7 @@ static bool pci_cfg_ok(struct domain *currd, unsigned int start, }return !write ? -xsm_pci_config_permission (XSM_HOOK , currd, machine_bdf, +xsm_pci_config_permission (currd, machine_bdf, start, start + size -1 ,0 ) ==0 :pci_conf_write_intercept (0 , machine_bdf, start, size, write) >=0 ; }
xen/arch/x86/sysctl.c +2 -2
@@ -190,8 +190,8 @@ long arch_do_sysctl( }if ( !ret ) - ret = plug ?xsm_resource_plug_core (XSM_HOOK ) - :xsm_resource_unplug_core (XSM_HOOK ); + ret = plug ?xsm_resource_plug_core () + :xsm_resource_unplug_core ();if ( !ret ) ret =continue_hypercall_on_cpu (0 , fn, hcpu);
xen/common/domain.c +2 -2
@@ -311,7 +311,7 @@ static int late_hwdom_init(struct domain *d)if ( d != hardware_domain || d->domain_id ==0 )return 0 ; - rv =xsm_init_hardware_domain (XSM_HOOK , d); + rv =xsm_init_hardware_domain (d);if ( rv )return rv;
@@ -649,7 +649,7 @@ struct domain *domain_create(domid_t domid,if ( !d->iomem_caps || !d->irq_caps ) goto fail; -if ( (err =xsm_domain_create (XSM_HOOK , d, config->ssidref)) !=0 ) +if ( (err =xsm_domain_create (d, config->ssidref)) !=0 ) goto fail; d->controller_pause_count =1 ;
xen/common/domctl.c +6 -6
@@ -314,7 +314,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)return -ESRCH ; } - ret =xsm_domctl (XSM_OTHER , d, op->cmd); + ret =xsm_domctl (d, op->cmd);if ( ret ) goto domctl_out_unlock_domonly;
@@ -553,7 +553,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)if ( d ==NULL ) goto getdomaininfo_out; - ret =xsm_getdomaininfo (XSM_HOOK , d); + ret =xsm_getdomaininfo (d);if ( ret ) goto getdomaininfo_out;
@@ -688,7 +688,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)break ; } irq =pirq_access_permitted (current->domain, pirq); -if ( !irq ||xsm_irq_permission (XSM_HOOK , d, irq, allow) ) +if ( !irq ||xsm_irq_permission (d, irq, allow) ) ret = -EPERM ;else if ( allow ) ret =irq_permit_access (d, irq);
@@ -709,7 +709,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)if ( !iomem_access_permitted (current->domain, mfn, mfn + nr_mfns -1 ) || -xsm_iomem_permission (XSM_HOOK , d, mfn, mfn + nr_mfns -1 , allow) ) +xsm_iomem_permission (d, mfn, mfn + nr_mfns -1 , allow) ) ret = -EPERM ;else if ( allow ) ret =iomem_permit_access (d, mfn, mfn + nr_mfns -1 );
@@ -746,7 +746,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) !iomem_access_permitted(d, mfn, mfn_end) )break ; - ret =xsm_iomem_mapping (XSM_HOOK , d, mfn, mfn_end, add); + ret =xsm_iomem_mapping (d, mfn, mfn_end, add);if ( ret )break ;
@@ -804,7 +804,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) ret = -EOPNOTSUPP ;if (is_hvm_domain (e) ) - ret =xsm_set_target (XSM_HOOK , d, e); + ret =xsm_set_target (d, e);if ( ret ) {put_domain (e);
xen/common/event_channel.c +6 -6
@@ -301,7 +301,7 @@ static int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)ERROR_EXIT_DOM (port, d); chn =evtchn_from_port (d, port); - rc =xsm_evtchn_unbound (XSM_TARGET , d, chn, alloc->remote_dom); + rc =xsm_evtchn_unbound (d, chn, alloc->remote_dom);if ( rc ) goto out;
@@ -376,7 +376,7 @@ static int evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) (rchn->u.unbound.remote_domid != ld->domain_id) )ERROR_EXIT_DOM (-EINVAL , rd); - rc =xsm_evtchn_interdomain (XSM_HOOK , ld, lchn, rd, rchn); + rc =xsm_evtchn_interdomain (ld, lchn, rd, rchn);if ( rc ) goto out;
@@ -754,7 +754,7 @@ int evtchn_send(struct domain *ld, unsigned int lport) goto out; } - ret =xsm_evtchn_send (XSM_HOOK , ld, lchn); + ret =xsm_evtchn_send (ld, lchn);if ( ret ) goto out;
@@ -979,7 +979,7 @@ int evtchn_status(evtchn_status_t *status) goto out; } - rc =xsm_evtchn_status (XSM_TARGET , d, chn); + rc =xsm_evtchn_status (d, chn);if ( rc ) goto out;
@@ -1295,7 +1295,7 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -ESRCH ; - rc =xsm_evtchn_reset (XSM_TARGET , current->domain, d); + rc =xsm_evtchn_reset (current->domain, d);if ( !rc ) rc =evtchn_reset (d, cmd == EVTCHNOP_reset_cont);
@@ -1356,7 +1356,7 @@ int alloc_unbound_xen_event_channel( goto out; chn =evtchn_from_port (ld, port); - rc =xsm_evtchn_unbound (XSM_TARGET , ld, chn, remote_domid); + rc =xsm_evtchn_unbound (ld, chn, remote_domid);if ( rc ) goto out;
xen/common/grant_table.c +8 -8
@@ -1051,7 +1051,7 @@ map_grant_ref(return ; } - rc =xsm_grant_mapref (XSM_HOOK , ld, rd, op->flags); + rc =xsm_grant_mapref (ld, rd, op->flags);if ( rc ) {rcu_unlock_domain (rd);
@@ -1391,7 +1391,7 @@ unmap_common(return ; } - rc =xsm_grant_unmapref (XSM_HOOK , ld, rd); + rc =xsm_grant_unmapref (ld, rd);if ( rc ) {rcu_unlock_domain (rd);
@@ -2009,7 +2009,7 @@ gnttab_setup_table( goto out; } -if (xsm_grant_setup (XSM_TARGET , curr->domain, d) ) +if (xsm_grant_setup (curr->domain, d) ) { op.status = GNTST_permission_denied; goto out;
@@ -2091,7 +2091,7 @@ gnttab_query_size( goto out; } -if (xsm_grant_query_size (XSM_TARGET , current->domain, d) ) +if (xsm_grant_query_size (current->domain, d) ) { op.status = GNTST_permission_denied; goto out;
@@ -2262,7 +2262,7 @@ gnttab_transfer( goto put_gfn_and_copyback; } -if (xsm_grant_transfer (XSM_HOOK , d, e) ) +if (xsm_grant_transfer (d, e) ) { gop.status = GNTST_permission_denied; unlock_and_copyback:
@@ -2800,7 +2800,7 @@ static int gnttab_copy_lock_domains(const struct gnttab_copy *op,if ( rc <0 ) goto error; - rc =xsm_grant_copy (XSM_HOOK , src->domain, dest->domain); + rc =xsm_grant_copy (src->domain, dest->domain);if ( rc <0 ) { rc = GNTST_permission_denied;
@@ -3219,7 +3219,7 @@ gnttab_get_status_frames(XEN_GUEST_HANDLE_PARAM(gnttab_get_status_frames_t) uop, op.status = GNTST_bad_domain; goto out1; } - rc =xsm_grant_setup (XSM_TARGET , current->domain, d); + rc =xsm_grant_setup (current->domain, d);if ( rc ) { op.status = GNTST_permission_denied;
@@ -3283,7 +3283,7 @@ gnttab_get_version(XEN_GUEST_HANDLE_PARAM(gnttab_get_version_t) uop)if ( d ==NULL )return -ESRCH ; - rc =xsm_grant_query_size (XSM_TARGET , current->domain, d); + rc =xsm_grant_query_size (current->domain, d);if ( rc ) {rcu_unlock_domain (d);
xen/common/hypfs.c +1 -1
@@ -679,7 +679,7 @@ long do_hypfs_op(unsigned int cmd,struct hypfs_entry *entry;static char path[XEN_HYPFS_MAX_PATHLEN ]; -if (xsm_hypfs_op (XSM_PRIV ) ) +if (xsm_hypfs_op () )return -EPERM ;if ( cmd == XEN_HYPFS_OP_get_version )
xen/common/kernel.c +1 -1
@@ -459,7 +459,7 @@ __initcall(param_init);DO (xen_version)(int cmd,XEN_GUEST_HANDLE_PARAM (void ) arg) { -bool_t deny = !!xsm_xen_version (XSM_OTHER , cmd); +bool_t deny = !!xsm_xen_version (cmd);switch ( cmd ) {
xen/common/kexec.c +1 -1
@@ -1219,7 +1219,7 @@ static int do_kexec_op_internal(unsigned long op, {int ret = -EINVAL ; - ret =xsm_kexec (XSM_PRIV ); + ret =xsm_kexec ();if ( ret )return ret;
xen/common/mem_access.c +1 -1
@@ -47,7 +47,7 @@ int mem_access_memop(unsigned long cmd,if ( !p2m_mem_access_sanity_check (d) ) goto out; - rc =xsm_mem_access (XSM_DM_PRIV , d); + rc =xsm_mem_access (d);if ( rc ) goto out;
xen/common/memory.c +8 -8
@@ -609,7 +609,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) goto fail_early; } - rc =xsm_memory_exchange (XSM_TARGET , d); + rc =xsm_memory_exchange (d);if ( rc ) {rcu_unlock_domain (d);
@@ -1072,7 +1072,7 @@ static long xatp_permission_check(struct domain *d, unsigned int space) (!is_hardware_domain(d) || (d != current->domain)) ) return -EACCES; -return xsm_add_to_physmap (XSM_TARGET , current->domain, d); +return xsm_add_to_physmap (current->domain, d); }unsigned int ioreq_server_max_frames (const struct domain *d)
@@ -1232,7 +1232,7 @@ static int acquire_resource(if ( rc )return rc; - rc =xsm_domain_resource_map (XSM_DM_PRIV , d); + rc =xsm_domain_resource_map (d);if ( rc ) goto out;
@@ -1388,7 +1388,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) && (reservation.mem_flags & XENMEMF_populate_on_demand) ) args.memflags |= MEMF_populate_on_demand; -if (xsm_memory_adjust_reservation (XSM_TARGET , curr_d, d) ) +if (xsm_memory_adjust_reservation (curr_d, d) ) {rcu_unlock_domain (d);return start_extent;
@@ -1462,7 +1462,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -ESRCH ; - rc =xsm_memory_stat_reservation (XSM_TARGET , curr_d, d); + rc =xsm_memory_stat_reservation (curr_d, d);if ( rc ) {rcu_unlock_domain (d);
@@ -1584,7 +1584,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)return -ESRCH ; rc =paging_mode_translate (d) - ?xsm_remove_from_physmap (XSM_TARGET , curr_d, d) + ?xsm_remove_from_physmap (curr_d, d) : -EACCES ;if ( rc ) {
@@ -1631,7 +1631,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )return -EINVAL ; - rc =xsm_claim_pages (XSM_PRIV , d); + rc =xsm_claim_pages (d);if ( !rc ) rc =domain_set_outstanding_pages (d, reservation.nr_extents);
@@ -1662,7 +1662,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( (d =rcu_lock_domain_by_any_id (topology.domid)) ==NULL )return -ESRCH ; - rc =xsm_get_vnumainfo (XSM_TARGET , d); + rc =xsm_get_vnumainfo (d);if ( rc ) {rcu_unlock_domain (d);
xen/common/monitor.c +1 -1
@@ -36,7 +36,7 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)if (unlikely (current->domain == d) )/* no domain_pause() */ return -EPERM ; - rc =xsm_vm_event_control (XSM_PRIV , d, mop->op, mop->event); + rc =xsm_vm_event_control (d, mop->op, mop->event);if (unlikely (rc) )return rc;
xen/common/sched/core.c +3 -3
@@ -1944,7 +1944,7 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)if ( d ==NULL )break ; - ret =xsm_schedop_shutdown (XSM_DM_PRIV , current->domain, d); + ret =xsm_schedop_shutdown (current->domain, d);if (likely (!ret) )domain_shutdown (d, sched_remote_shutdown.reason);
@@ -2046,7 +2046,7 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op) {long ret; - ret =xsm_domctl_scheduler_op (XSM_HOOK , d, op->cmd); + ret =xsm_domctl_scheduler_op (d, op->cmd);if ( ret )return ret;
@@ -2081,7 +2081,7 @@ long sched_adjust_global(struct xen_sysctl_scheduler_op *op)struct cpupool *pool;int rc; - rc =xsm_sysctl_scheduler_op (XSM_HOOK , op->cmd); + rc =xsm_sysctl_scheduler_op (op->cmd);if ( rc )return rc;
xen/common/sysctl.c +4 -4
@@ -41,7 +41,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)if ( op->interface_version !=XEN_SYSCTL_INTERFACE_VERSION )return -EACCES ; - ret =xsm_sysctl (XSM_PRIV , op->cmd); + ret =xsm_sysctl (op->cmd);if ( ret )return ret;
@@ -58,7 +58,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)switch ( op->cmd ) {case XEN_SYSCTL_readconsole: - ret =xsm_readconsole (XSM_HOOK , op->u.readconsole.clear); + ret =xsm_readconsole (op->u.readconsole.clear);if ( ret )break ;
@@ -88,7 +88,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)if ( num_domains == op->u.getdomaininfolist.max_domains )break ; - ret =xsm_getdomaininfo (XSM_HOOK , d); + ret =xsm_getdomaininfo (d);if ( ret )continue ;
@@ -191,7 +191,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)if ( op->u.page_offline.end < op->u.page_offline.start )break ; - ret =xsm_page_offline (XSM_HOOK , op->u.page_offline.cmd); + ret =xsm_page_offline (op->u.page_offline.cmd);if ( ret )break ;
xen/common/vm_event.c +1 -1
@@ -584,7 +584,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)return 0 ; } - rc =xsm_vm_event_control (XSM_PRIV , d, vec->mode, vec->op); + rc =xsm_vm_event_control (d, vec->mode, vec->op);if ( rc )return rc;
xen/common/xenoprof.c +1 -1
@@ -737,7 +737,7 @@ ret_t do_xenoprof_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)return -EPERM ; } - ret =xsm_profile (XSM_HOOK , current->domain, op); + ret =xsm_profile (current->domain, op);if ( ret )return ret;
xen/drivers/char/console.c +1 -1
@@ -681,7 +681,7 @@ long do_console_io(unsigned int cmd, unsigned int count,long rc;unsigned int idx, len; - rc =xsm_console_io (XSM_OTHER , current->domain, cmd); + rc =xsm_console_io (current->domain, cmd);if ( rc )return rc;
xen/drivers/passthrough/device_tree.c +2 -2
@@ -230,7 +230,7 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,if ( ret )break ; - ret =xsm_assign_dtdevice (XSM_HOOK , d,dt_node_full_name (dev)); + ret =xsm_assign_dtdevice (d,dt_node_full_name (dev));if ( ret )break ;
@@ -284,7 +284,7 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,if ( ret )break ; - ret =xsm_deassign_dtdevice (XSM_HOOK , d,dt_node_full_name (dev)); + ret =xsm_deassign_dtdevice (d,dt_node_full_name (dev));if ( d == dom_io )return -EINVAL ;
xen/drivers/passthrough/pci.c +6 -6
@@ -704,7 +704,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,else pdev_type ="device" ; - ret =xsm_resource_plug_pci (XSM_PRIV , (seg <<16 ) | (bus <<8 ) | devfn); + ret =xsm_resource_plug_pci ((seg <<16 ) | (bus <<8 ) | devfn);if ( ret )return ret;
@@ -814,7 +814,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)struct pci_dev *pdev;int ret; - ret =xsm_resource_unplug_pci (XSM_PRIV , (seg <<16 ) | (bus <<8 ) | devfn); + ret =xsm_resource_unplug_pci ((seg <<16 ) | (bus <<8 ) | devfn);if ( ret )return ret;
@@ -1477,7 +1477,7 @@ static int iommu_get_device_group( ((pdev->bus == bus) && (pdev->devfn == devfn)) )continue ; -if (xsm_get_device_group (XSM_HOOK , (seg <<16 ) | (pdev->bus <<8 ) | pdev->devfn) ) +if (xsm_get_device_group ((seg <<16 ) | (pdev->bus <<8 ) | pdev->devfn) )continue ; sdev_id = ops->get_device_group_id (seg, pdev->bus, pdev->devfn);
@@ -1545,7 +1545,7 @@ int iommu_do_pci_domctl(u32 max_sdevs;XEN_GUEST_HANDLE_64 (uint32) sdevs; - ret =xsm_get_device_group (XSM_HOOK , domctl->u.get_device_group.machine_sbdf); + ret =xsm_get_device_group (domctl->u.get_device_group.machine_sbdf);if ( ret )break ;
@@ -1596,7 +1596,7 @@ int iommu_do_pci_domctl( machine_sbdf = domctl->u.assign_device.u.pci.machine_sbdf; - ret =xsm_assign_device (XSM_HOOK , d, machine_sbdf); + ret =xsm_assign_device (d, machine_sbdf);if ( ret )break ;
@@ -1641,7 +1641,7 @@ int iommu_do_pci_domctl( machine_sbdf = domctl->u.assign_device.u.pci.machine_sbdf; - ret =xsm_deassign_device (XSM_HOOK , d, machine_sbdf); + ret =xsm_deassign_device (d, machine_sbdf);if ( ret )break ;
xen/include/xsm/xsm.h +85 -87
545 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
Quoted 9 lines · Daniel P. Smith
The passing of an
xsm_default_tat each of the xsm hook call sites served different functions depending on whether XSM was enabled or not. When XSM was not enabled it attempted to function as a link-time check that declared default action at the call site matched the default declared action for that hook in the dummy policy. When XSM was enabled, it would just drop the parameter.The removal of these values is two fold. They are a redundancy that provides little context, especially when the value is
XSM_OTHER.
For XSM_OTHER I may agree, but in general I find the call-site uses helpful to know at least the rough level of intended restriction. E.g. ...
xen/arch/x86/cpu/mcheck/mce.c long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) · line 1379
Quoted 8 lines
xen/arch/x86/cpu/mcheck/mce.c +1
-1@@ -1376,7 +1376,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)struct xen_mc_msrinject *mc_msrinject;struct xen_mc_mceinject *mc_mceinject; - ret =xsm_do_mca (XSM_PRIV ); + ret =xsm_do_mca ();
... to now understand what this enforces (or not) I have to go to the actual implementation, even if I only want to know the trivial dummy incarnation of it. This effectively extends the "provides little context" from XSM_OTHER to all hooks.
Jan
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
Quoted 20 lines · Jan Beulich
Quoted 9 lines · Daniel P. Smith
The passing of an
xsm_default_tat each of the xsm hook call sites served different functions depending on whether XSM was enabled or not. When XSM was not enabled it attempted to function as a link-time check that declared default action at the call site matched the default declared action for that hook in the dummy policy. When XSM was enabled, it would just drop the parameter.The removal of these values is two fold. They are a redundancy that provides little context, especially when the value is
XSM_OTHER.For
XSM_OTHERI may agree, but in general I find the call-site uses helpful to know at least the rough level of intended restriction. E.g. ...Quoted 6 lines
xen/arch/x86/cpu/mcheck/mce.c +0
-0@@ -1376,7 +1376,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)struct xen_mc_msrinject *mc_msrinject;struct xen_mc_mceinject *mc_mceinject;
Quoted 6 lines
xen/arch/x86/cpu/mcheck/mce.c long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) · line 1379
Quoted 2 lines
xen/arch/x86/cpu/mcheck/mce.c +1
-1- ret =xsm_do_mca (XSM_PRIV ); + ret =xsm_do_mca ();... to now understand what this enforces (or not) I have to go to the actual implementation, even if I only want to know the trivial dummy incarnation of it. This effectively extends the "provides little context" from
XSM_OTHERto all hooks.
The old scheme was even worse because it was only a plausible approximation for the !XSM case while being actively wrong for SILO and FLASK.
Furthermore, someone reading the code could be forgiven for thinking that XSM_HOOK was something other than dead code.
~Andrew
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
Quoted 28 lines · Andrew Cooper
Quoted 20 lines · Jan Beulich
Quoted 9 lines · Daniel P. Smith
The passing of an
xsm_default_tat each of the xsm hook call sites served different functions depending on whether XSM was enabled or not. When XSM was not enabled it attempted to function as a link-time check that declared default action at the call site matched the default declared action for that hook in the dummy policy. When XSM was enabled, it would just drop the parameter.The removal of these values is two fold. They are a redundancy that provides little context, especially when the value is
XSM_OTHER.For
XSM_OTHERI may agree, but in general I find the call-site uses helpful to know at least the rough level of intended restriction. E.g. ...Quoted 6 lines
xen/arch/x86/cpu/mcheck/mce.c +0
-0@@ -1376,7 +1376,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)struct xen_mc_msrinject *mc_msrinject;struct xen_mc_mceinject *mc_mceinject;Quoted 6 lines
xen/arch/x86/cpu/mcheck/mce.c long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) · line 1379
Quoted 2 lines
xen/arch/x86/cpu/mcheck/mce.c +1
-1- ret =xsm_do_mca (XSM_PRIV ); + ret =xsm_do_mca ();... to now understand what this enforces (or not) I have to go to the actual implementation, even if I only want to know the trivial dummy incarnation of it. This effectively extends the "provides little context" from
XSM_OTHERto all hooks.
Quoted 3 lines
The old scheme was even worse because it was only a plausible approximation for the !XSM case while being actively wrong for SILO and FLASK.
"Actively wrong" is perhaps going a little far? I don't think SILO relaxes things anywhere over the !XSM case, and I also wouldn't expect a Flask policy to commonly relax things. Of course these simplistic categories can't reflect the full possible range with an actual policy, but seeing XSM_PRIV in a call used to be a fair hint that subsequent code isn't expected to be reachable for unprivileged entities. No such hints would exist anymore following this change, and its description didn't sound to me like this aspect was taken into consideration. Yet it is a difference to me whether such removal of information (no matter how precise it is) is deliberate or an unintended / unnoticed / unexpected side effect.
Quoted 2 lines
Furthermore, someone reading the code could be forgiven for thinking that
XSM_HOOKwas something other than dead code.
I certainly agree with this part.
Jan
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
In reply to Daniel P. Smithxen/include/xsm/xsm.h static inline void xsm_security_domaininfo (struct domain *d, · line 33
Quoted 8 lines · Daniel P. Smith
xen/include/xsm/xsm.h +1
-1@@ -30,53 +30,53 @@ static inline void xsm_security_domaininfo (struct domain *d,alternative_vcall (xsm_ops.security_domaininfo, d, info); } -static inline int xsm_domain_create (xsm_default_t def,struct domain *d,u32 ssidref) +static inline int xsm_domain_create (struct domain *d,u32 ssidref)
When you have to touch such lines anyway, may I suggest that you also take the opportunity and drop the stray blanks immediately ahead of the opening parenthesis, to bring this file better in line with ./CODING_STYLE? And as just said for a later patch, converting u<N> to uint<N>_t at this occasion would also be nice, for the same reason.
Jan
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
In reply to Daniel P. SmithI have read the thread here and it seems that there are some disagreements which may be blocking progress.
The mailing list thread is a rather tangled way of dealing with this. I did read it but I feel I am lacking some of the context and/or having trouble synthesising it.
Daniel, if you agree with me that this seems to be getting hung up on disagreements, do you think you would be able to summarise the disagreement(s) including the context and the arguments you can see on the various sides ? I'm not expecting such a summary to be neutral but I think you are in a good position to motivate your changes.
Thanks,
Ian.
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
Quoted 7 lines · Ian Jackson
I have read the thread here and it seems that there are some disagreements which may be blocking progress.
The mailing list thread is a rather tangled way of dealing with this. I did read it but I feel I am lacking some of the context and/or having trouble synthesising it.
Quoted 9 lines
Daniel, if you agree with me that this seems to be getting hung up on disagreements, do you think you would be able to summarise the disagreement(s) including the context and the arguments you can see on the various sides ? I'm not expecting such a summary to be neutral but I think you are in a good position to motivate your changes.
Thanks,
Ian.
Hey Ian,
Thank you so much for reaching out. While there is definitely a disagreement, as you will likely have seen, I put out a v3 of the patch set where there is an attempt to strike a compromise between the two positions. To provide some context, below is a list of points of contention, my concerns regarding the points of contention, and a list of what was addressed in v3 of the series.
Points of contention:
A1. Agreement on what is and constitutes XSM.
A2. Based on (A1), what does it really mean to turn XSM on or off. A3. Providing the facade that a capability is turned off to hide config options
a user may not understand
A4. There are two versions of the XSM hook interfaces and corresponding
XSM hook implementations
A5. Whether the XSM hook's call sites should include the access level
My concerns/issues:
B1. The irony that XSM is unsupported but XSM + SILO is supported (for
Arm)
B2. The counter-positive to the position of (A3) is that every KConfig
option must be understandable by all users
B3. The complexity of the preprocessor code to enable (A3) results in
challenging code to reason about
B4. The increased overhead in having to maintaining the two sets of
hooks caused by (A3)
B5. The (A3) optimization is being done to common code but only applies
to x86 security supported configurations
B6. That (A3) is justified to maintain a legacy mental model that Dom0
is all powerful at the expense of unnecessarily complicating Xen's core access control code.
B7. That (A5) is only completely correct when default/dummy policy is in
effect B8. (A5) was justified as it gives the developer a notion of what will be checked, which is bad for a number of reasons, but the primary is that it will either directly or indirectly influence a developer to write code with false sense of what access level a domain may have
What v3 addresses:
C1. Instead of doing a submenu for XSM v3 replaces XSM on/off with a
"select to configure XSM", addressing (A2, A3, B2)
C2. Instead of dropping one of the interfaces/implementations, merged
them to provide a single interface with similar inlining properties, addressing (A4, B3, B4, B5)
C3. The passing of a default at the call site was left intact addressing
(A5)
Deferrals and concessions in v3:
D1. Answering (A1) can be addressed later by reviewing, refreshing, and
expanding XSM documentation
D2. Will work with community to get XSM in a supported status to resolve
(B1)
D3. The issue of (B6) is partially resolved in v3, v1 and v2 provided a
better separation but all three are logically equivalent
D4. I conceded on (B7) and (B8) which are related to (B6) with respect
that the all powerful dom0 continues to be hard coded throughout the hypervisor instead of trying to abstracting it out.
While not all of the points of contentions nor all of my concerns are all addressed, I would like to hope that v3 is seen as an attempt compromise, those compromises are acceptable, and that I can begin to bring the next patch set forward. Thank you and looking forward to responses.
V/r,
Daniel P. Smith
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
Quoted 3 lines · Daniel P. Smith
My concerns/issues:
B1. The irony that XSM is unsupported but XSM + SILO is supported (for
Arm)
Just one remark here: Prior to SILO introduction (and to some perhaps ever afterwards), just like !XSM stood for "XSM dummy module", XSM stood for "XSM/Flask". There's pretty little core XSM code, and the reason for it to be considered unsupported was mainly the bad quality of Flask code (which no-one, not even the maintainer, ever cared to address, except maybe tiny aspects thereof). Which luckily ...
Quoted 5 lines
Deferrals and concessions in v3:
D1. Answering (A1) can be addressed later by reviewing, refreshing, and
expanding XSM documentation
D2. Will work with community to get XSM in a supported status to resolve
(B1)
... you aim to address. Until such point I think though that people better wouldn't be forced or talked into including unsupported code in their builds. (I say this without having looked at v3 yet; you may very well have taken care of this already.)
Jan
Re: [PATCH v2 08/10] xsm: remove xsm_default_t from hook definitions
In reply to Daniel P. SmithQuoted 5 lines · Daniel P. Smith
While not all of the points of contentions nor all of my concerns are all addressed, I would like to hope that v3 is seen as an attempt compromise, those compromises are acceptable, and that I can begin to bring the next patch set forward. Thank you and looking forward to responses.
Having gone through the series I've been happy to see the adjustments that have been made. There are still further requests I have spelled out, but I think (hope) those aren't as controversial anymore.
Jan
PATCH v2 9/10 xsm: expand the function related macros in dummy.h
In reply to Daniel P. SmithWith the elimination of switching how dummy.h gets included, the function declaration macros are no longer necessary. This commit expands them out to the only value for which they will ever be set. This results in function declaration lengths changing and since some definitions did not even follow the 80 column wrapping style, all function definitions were aligned with the predominate style found in core hypervisor code.
--- xen/xsm/dummy.h | 275 +++++++++++++++++++++++++++--------------------- 1 file changed, 153 insertions(+), 122 deletions(-)
xen/xsm/dummy.h +153 -122
@@ -9,7 +9,7 @@* * * Each XSM hook implementing an access check should have its first parameter -* preceded by XSM_DEFAULT_ARG (or use XSM_DEFAULT_VOID if it has no +* preceded by (or use XSM_DEFAULT_VOID if it has no * arguments). The first non-declaration statement shold be XSM_ASSERT_ACTION * with the expected type of the hook, which will either define or check the * value of action.
@@ -47,14 +47,11 @@ void __xsm_action_mismatch_detected(void);* xsm_default_t argument available, so the value from the assertion is used to * initialize the variable. */ -#define XSM_INLINE __maybe_unused - -#define XSM_DEFAULT_ARG /* */ -#define XSM_DEFAULT_VOID void#define XSM_ASSERT_ACTION (def) xsm_default_t action = def; (void)action -static always_inline int xsm_default_action( -xsm_default_t action,struct domain *src,struct domain *target) +static always_inline int xsm_default_action(xsm_default_t action, +struct domain *src, +struct domain *target) {switch ( action ) {case XSM_HOOK :
@@ -82,43 +79,43 @@ static always_inline int xsm_default_action( } } -static XSM_INLINE void dummy_security_domaininfo(struct domain *d, +static inline void dummy_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info) {return ; } -static XSM_INLINE int dummy_domain_create(XSM_DEFAULT_ARG struct domain *d, u32 ssidref) +static inline int dummy_domain_create (struct domain *d,u32 ssidref) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_getdomaininfo(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_getdomaininfo (struct domain *d) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_domctl_scheduler_op(XSM_DEFAULT_ARG struct domain *d, int cmd) +static inline int dummy_domctl_scheduler_op (struct domain *d,int cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_sysctl_scheduler_op(XSM_DEFAULT_ARG int cmd) +static inline int dummy_sysctl_scheduler_op (int cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_set_target(XSM_DEFAULT_ARG struct domain *d, struct domain *e) +static inline int dummy_set_target (struct domain *d,struct domain *e) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_domctl(XSM_DEFAULT_ARG struct domain *d, int cmd) +static inline int dummy_domctl (struct domain *d,int cmd) {XSM_ASSERT_ACTION (XSM_OTHER ); switch ( cmd )
@@ -135,85 +132,91 @@ static XSM_INLINE int dummy_domctl(XSM_DEFAULT_ARG struct domain *d, int cmd) } } -static XSM_INLINE int dummy_sysctl(XSM_DEFAULT_ARG int cmd) +static inline int dummy_sysctl (int cmd) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_readconsole(XSM_DEFAULT_ARG uint32_t clear) +static inline int dummy_readconsole (uint32_t clear) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_alloc_security_domain(struct domain *d) +static inline int dummy_alloc_security_domain (struct domain *d) {return 0 ; } -static XSM_INLINE void dummy_free_security_domain(struct domain *d) +static inline void dummy_free_security_domain (struct domain *d) {return ; } -static XSM_INLINE int dummy_grant_mapref(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2, -uint32_t flags) +static inline int dummy_grant_mapref (struct domain *d1, +struct domain *d2, +uint32_t flags) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_grant_unmapref(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_grant_unmapref (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_grant_setup(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_grant_setup (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_grant_transfer(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_grant_transfer (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_grant_copy(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_grant_copy (struct domain *d1,struct domain *d2) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_grant_query_size(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_grant_query_size (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_memory_exchange(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_memory_exchange (struct domain *d) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_memory_adjust_reservation(XSM_DEFAULT_ARG struct domain *d1, -struct domain *d2) +static inline int dummy_memory_adjust_reservation (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_memory_stat_reservation(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_memory_stat_reservation (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_console_io(XSM_DEFAULT_ARG struct domain *d, int cmd) +static inline int dummy_console_io (struct domain *d,int cmd) {XSM_ASSERT_ACTION (XSM_OTHER );if ( d->is_console )
@@ -225,129 +228,140 @@ static XSM_INLINE int dummy_console_io(XSM_DEFAULT_ARG struct domain *d, int cmdreturn xsm_default_action (XSM_PRIV , d,NULL ); } -static XSM_INLINE int dummy_profile(XSM_DEFAULT_ARG struct domain *d, int op) +static inline int dummy_profile (struct domain *d,int op) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d,NULL ); } -static XSM_INLINE int dummy_kexec(XSM_DEFAULT_VOID) +static inline int dummy_kexec (void ) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_schedop_shutdown(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_schedop_shutdown (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_memory_pin_page(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2, -struct page_info *page) +static inline int dummy_memory_pin_page (struct domain *d1, +struct domain *d2, +struct page_info *page) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_claim_pages(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_claim_pages (struct domain *d) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_evtchn_unbound(XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn, -domid_t id2) +static inline int dummy_evtchn_unbound (struct domain *d, +struct evtchn *chn, +domid_t id2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_evtchn_interdomain(XSM_DEFAULT_ARG struct domain *d1, struct evtchn - *chan1,struct domain *d2,struct evtchn *chan2) +static inline int dummy_evtchn_interdomain (struct domain *d1, +struct evtchn *chan1, +struct domain *d2, +struct evtchn *chan2) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d1, d2); } -static XSM_INLINE void dummy_evtchn_close_post(struct evtchn *chn) +static inline void dummy_evtchn_close_post (struct evtchn *chn) {return ; } -static XSM_INLINE int dummy_evtchn_send(XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn) +static inline int dummy_evtchn_send (struct domain *d, +struct evtchn *chn) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, d,NULL ); } -static XSM_INLINE int dummy_evtchn_status(XSM_DEFAULT_ARG struct domain *d, struct evtchn *chn) +static inline int dummy_evtchn_status (struct domain *d, +struct evtchn *chn) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_evtchn_reset(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_evtchn_reset (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_alloc_security_evtchns( -struct evtchn chn[],unsigned int nr) +static inline int dummy_alloc_security_evtchns (struct evtchn chn[], +unsigned int nr) {return 0 ; } -static XSM_INLINE void dummy_free_security_evtchns( -struct evtchn chn[],unsigned int nr) +static inline void dummy_free_security_evtchns (struct evtchn chn[], +unsigned int nr) {return ; } -static XSM_INLINE char *dummy_show_security_evtchn(struct domain *d, const struct evtchn *chn) +static inline char *dummy_show_security_evtchn (struct domain *d, +const struct evtchn *chn) {return NULL ; } -static XSM_INLINE int dummy_init_hardware_domain(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_init_hardware_domain (struct domain *d) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_get_pod_target(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_get_pod_target (struct domain *d) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_set_pod_target(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_set_pod_target (struct domain *d) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_get_vnumainfo(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_get_vnumainfo (struct domain *d) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); }#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI ) -static XSM_INLINE int dummy_get_device_group(XSM_DEFAULT_ARG uint32_t machine_bdf) +static inline int dummy_get_device_group (uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_assign_device(XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf) +static inline int dummy_assign_device (struct domain *d, +uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_deassign_device(XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf) +static inline int dummy_deassign_device (struct domain *d, +uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d);
@@ -356,15 +370,15 @@ static XSM_INLINE int dummy_deassign_device(XSM_DEFAULT_ARG struct domain *d, ui#endif /* HAS_PASSTHROUGH && HAS_PCI */ #if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) -static XSM_INLINE int dummy_assign_dtdevice(XSM_DEFAULT_ARG struct domain *d, -const char *dtpath) +static inline int dummy_assign_dtdevice (struct domain *d, +const char *dtpath) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_deassign_dtdevice(XSM_DEFAULT_ARG struct domain *d, -const char *dtpath) +static inline int dummy_deassign_dtdevice (struct domain *d, +const char *dtpath) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d);
@@ -372,178 +386,190 @@ static XSM_INLINE int dummy_deassign_dtdevice(XSM_DEFAULT_ARG struct domain *d,#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ -static XSM_INLINE int dummy_resource_plug_core(XSM_DEFAULT_VOID) +static inline int dummy_resource_plug_core (void ) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_unplug_core(XSM_DEFAULT_VOID) +static inline int dummy_resource_unplug_core (void ) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_plug_pci(XSM_DEFAULT_ARG uint32_t machine_bdf) +static inline int dummy_resource_plug_pci (uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_unplug_pci(XSM_DEFAULT_ARG uint32_t machine_bdf) +static inline int dummy_resource_unplug_pci (uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_setup_pci(XSM_DEFAULT_ARG uint32_t machine_bdf) +static inline int dummy_resource_setup_pci (uint32_t machine_bdf) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_setup_gsi(XSM_DEFAULT_ARG int gsi) +static inline int dummy_resource_setup_gsi (int gsi) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_resource_setup_misc(XSM_DEFAULT_VOID) +static inline int dummy_resource_setup_misc (void ) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_page_offline(XSM_DEFAULT_ARG uint32_t cmd) +static inline int dummy_page_offline (uint32_t cmd) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_hypfs_op(XSM_DEFAULT_VOID) +static inline int dummy_hypfs_op (void ) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE long dummy_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) +static inline long dummy_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) {return -ENOSYS ; }#ifdef CONFIG_COMPAT -static XSM_INLINE int dummy_do_compat_op(XEN_GUEST_HANDLE_PARAM(xsm_op_t) op) +static inline int dummy_do_compat_op ( +XEN_GUEST_HANDLE_PARAM (xsm_op_t) op) {return -ENOSYS ; }#endif -static XSM_INLINE char *dummy_show_irq_sid(int irq) +static inline char *dummy_show_irq_sid (int irq) {return NULL ; } -static XSM_INLINE int dummy_map_domain_pirq(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_map_domain_pirq (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_map_domain_irq(XSM_DEFAULT_ARG struct domain *d, -int irq,const void *data) +static inline int dummy_map_domain_irq (struct domain *d,int irq, +const void *data) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_unmap_domain_pirq(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_unmap_domain_pirq (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_bind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) +static inline int dummy_bind_pt_irq (struct domain *d, +struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_unbind_pt_irq(XSM_DEFAULT_ARG struct domain *d, struct xen_domctl_bind_pt_irq *bind) +static inline int dummy_unbind_pt_irq (struct domain *d, +struct xen_domctl_bind_pt_irq *bind) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_unmap_domain_irq(XSM_DEFAULT_ARG struct domain *d, -int irq,const void *data) +static inline int dummy_unmap_domain_irq (struct domain *d,int irq, +const void *data) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_irq_permission(XSM_DEFAULT_ARG struct domain *d, int pirq, uint8_t allow) +static inline int dummy_irq_permission (struct domain *d,int pirq, +uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_iomem_permission(XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allow) +static inline int dummy_iomem_permission (struct domain *d,uint64_t s, +uint64_t e,uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_iomem_mapping(XSM_DEFAULT_ARG struct domain *d, uint64_t s, uint64_t e, uint8_t allow) +static inline int dummy_iomem_mapping (struct domain *d,uint64_t s, +uint64_t e,uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_pci_config_permission(XSM_DEFAULT_ARG struct domain *d, uint32_t machine_bdf, -uint16_t start,uint16_t end, -uint8_t access) +static inline int dummy_pci_config_permission (struct domain *d, +uint32_t machine_bdf, +uint16_t start, +uint16_t end, +uint8_t access) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_add_to_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_add_to_physmap (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1, struct domain *d2) +static inline int dummy_remove_from_physmap (struct domain *d1, +struct domain *d2) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d1, d2); } -static XSM_INLINE int dummy_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain *d, struct domain *t) +static inline int dummy_map_gmfn_foreign (struct domain *d, +struct domain *t) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d, t); } -static XSM_INLINE int dummy_hvm_param(XSM_DEFAULT_ARG struct domain *d, unsigned long op) +static inline int dummy_hvm_param (struct domain *d,unsigned long op) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_hvm_control(XSM_DEFAULT_ARG struct domain *d, unsigned long op) +static inline int dummy_hvm_control (struct domain *d,unsigned long op) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_hvm_param_altp2mhvm (struct domain *d) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *d, uint64_t mode, uint32_t op) +static inline int dummy_hvm_altp2mhvm_op (struct domain *d, +uint64_t mode,uint32_t op) {XSM_ASSERT_ACTION (XSM_OTHER );
@@ -562,14 +588,15 @@ static XSM_INLINE int dummy_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *d, u } } -static XSM_INLINE int dummy_vm_event_control(XSM_DEFAULT_ARG struct domain *d, int mode, int op) +static inline int dummy_vm_event_control (struct domain *d,int mode, +int op) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain, d); }#ifdef CONFIG_MEM_ACCESS -static XSM_INLINE int dummy_mem_access(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_mem_access (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d);
@@ -577,7 +604,7 @@ static XSM_INLINE int dummy_mem_access(XSM_DEFAULT_ARG struct domain *d)#endif #ifdef CONFIG_MEM_PAGING -static XSM_INLINE int dummy_mem_paging(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_mem_paging (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d);
@@ -585,58 +612,59 @@ static XSM_INLINE int dummy_mem_paging(XSM_DEFAULT_ARG struct domain *d)#endif #ifdef CONFIG_MEM_SHARING -static XSM_INLINE int dummy_mem_sharing(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_mem_sharing (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d); }#endif -static XSM_INLINE int dummy_platform_op(XSM_DEFAULT_ARG uint32_t op) +static inline int dummy_platform_op (uint32_t op) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); }#ifdef CONFIG_X86 -static XSM_INLINE int dummy_do_mca(XSM_DEFAULT_VOID) +static inline int dummy_do_mca (void ) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) +static inline int dummy_shadow_control (struct domain *d,uint32_t op) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_mem_sharing_op(XSM_DEFAULT_ARG struct domain *d, struct domain *cd, int op) +static inline int dummy_mem_sharing_op (struct domain *d, +struct domain *cd,int op) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, cd); } -static XSM_INLINE int dummy_apic(XSM_DEFAULT_ARG struct domain *d, int cmd) +static inline int dummy_apic (struct domain *d,int cmd) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, d,NULL ); } -static XSM_INLINE int dummy_machine_memory_map(XSM_DEFAULT_VOID) +static inline int dummy_machine_memory_map (void ) {XSM_ASSERT_ACTION (XSM_PRIV );return xsm_default_action (action, current->domain,NULL ); } -static XSM_INLINE int dummy_domain_memory_map(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_domain_memory_map (struct domain *d) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_mmu_update(XSM_DEFAULT_ARG struct domain *d, struct domain *t, -struct domain *f,uint32_t flags) +static inline int dummy_mmu_update (struct domain *d,struct domain *t, +struct domain *f,uint32_t flags) {int rc =0 ;XSM_ASSERT_ACTION (XSM_TARGET );
@@ -647,38 +675,41 @@ static XSM_INLINE int dummy_mmu_update(XSM_DEFAULT_ARG struct domain *d, structreturn rc; } -static XSM_INLINE int dummy_mmuext_op(XSM_DEFAULT_ARG struct domain *d, struct domain *f) +static inline int dummy_mmuext_op (struct domain *d,struct domain *f) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d, f); } -static XSM_INLINE int dummy_update_va_mapping(XSM_DEFAULT_ARG struct domain *d, struct domain *f, -l1_pgentry_t pte) +static inline int dummy_update_va_mapping (struct domain *d, +struct domain *f, +l1_pgentry_t pte) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d, f); } -static XSM_INLINE int dummy_priv_mapping(XSM_DEFAULT_ARG struct domain *d, struct domain *t) +static inline int dummy_priv_mapping (struct domain *d,struct domain *t) {XSM_ASSERT_ACTION (XSM_TARGET );return xsm_default_action (action, d, t); } -static XSM_INLINE int dummy_ioport_permission(XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, uint8_t allow) +static inline int dummy_ioport_permission (struct domain *d,uint32_t s, +uint32_t e,uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_ioport_mapping(XSM_DEFAULT_ARG struct domain *d, uint32_t s, uint32_t e, uint8_t allow) +static inline int dummy_ioport_mapping (struct domain *d,uint32_t s, +uint32_t e,uint8_t allow) {XSM_ASSERT_ACTION (XSM_HOOK );return xsm_default_action (action, current->domain, d); } -static XSM_INLINE int dummy_pmu_op (XSM_DEFAULT_ARG struct domain *d, unsigned int op) +static inline int dummy_pmu_op (struct domain *d,unsigned int op) {XSM_ASSERT_ACTION (XSM_OTHER ); switch ( op )
@@ -695,31 +726,31 @@ static XSM_INLINE int dummy_pmu_op (XSM_DEFAULT_ARG struct domain *d, unsigned i#endif /* CONFIG_X86 */ -static XSM_INLINE int dummy_dm_op(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_dm_op (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d); }#ifdef CONFIG_ARGO -static XSM_INLINE int dummy_argo_enable(const struct domain *d) +static inline int dummy_argo_enable (const struct domain *d) {return 0 ; } -static XSM_INLINE int dummy_argo_register_single_source(const struct domain *d, -const struct domain *t) +static inline int dummy_argo_register_single_source (const struct domain *d, +const struct domain *t) {return 0 ; } -static XSM_INLINE int dummy_argo_register_any_source(const struct domain *d) +static inline int dummy_argo_register_any_source (const struct domain *d) {return 0 ; } -static XSM_INLINE int dummy_argo_send(const struct domain *d, -const struct domain *t) +static inline int dummy_argo_send (const struct domain *d, +const struct domain *t) {return 0 ; }
@@ -727,7 +758,7 @@ static XSM_INLINE int dummy_argo_send(const struct domain *d,#endif /* CONFIG_ARGO */ #include <public/version.h> -static XSM_INLINE int dummy_xen_version (XSM_DEFAULT_ARG uint32_t op) +static inline int dummy_xen_version (uint32_t op) {XSM_ASSERT_ACTION (XSM_OTHER ); switch ( op )
@@ -751,7 +782,7 @@ static XSM_INLINE int dummy_xen_version (XSM_DEFAULT_ARG uint32_t op) } } -static XSM_INLINE int dummy_domain_resource_map(XSM_DEFAULT_ARG struct domain *d) +static inline int dummy_domain_resource_map (struct domain *d) {XSM_ASSERT_ACTION (XSM_DM_PRIV );return xsm_default_action (action, current->domain, d);
Signature · 1 line
2.20.1
Re: [PATCH v2 09/10] xsm: expand the function related macros in dummy.h
Quoted 6 lines · Daniel P. Smith
With the elimination of switching how
dummy.hgets included, the function declaration macros are no longer necessary. This commit expands them out to the only value for which they will ever be set. This results in function declaration lengths changing and since some definitions did not even follow the 80 column wrapping style, all function definitions were aligned with the predominate style found in core hypervisor code.
I'm afraid this last half sentence is quite far from true:
xen/xsm/dummy.h static always_inline int xsm_default_action( · line 83
Quoted 7 lines
xen/xsm/dummy.h +1
-1@@ -82,43 +79,43 @@ static always_inline int xsm_default_action( } } -static XSM_INLINE void dummy_security_domaininfo(struct domain *d, +static inline void dummy_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info)
Padding wasn't good here before, but you clearly do not change it to either of the forms we agreed on as being the goal for consistency:
static inline void dummy_security_domaininfo(struct domain *d,
struct xen_domctl_getdomaininfo *info)
or
static inline void dummy_security_domaininfo(
struct domain *d,
struct xen_domctl_getdomaininfo *info)
. Further down there are enough other examples.
xen/xsm/dummy.h static always_inline int xsm_default_action( · line 88
Quoted 2 lines
xen/xsm/dummy.h +1
-1-static XSM_INLINE int dummy_domain_create(XSM_DEFAULT_ARG struct domain *d, u32 ssidref) +static inline int dummy_domain_create (struct domain *d,u32 ssidref)
When you have to touch lines anyway, may I suggest that you also take the opportunity and convert u<N> to uint<N>_t, to bring this file better in line with ./CODING_STYLE?
Jan
Re: [PATCH v2 09/10] xsm: expand the function related macros in dummy.h
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Daniel P. Smith
With the elimination of switching how
dummy.hgets included, the function declaration macros are no longer necessary. This commit expands them out to the only value for which they will ever be set. This results in function declaration lengths changing and since some definitions did not even follow the 80 column wrapping style, all function definitions were aligned with the predominate style found in core hypervisor code.I'm afraid this last half sentence is quite far from true:
I would disagree since I know I went through the frustration of trying to find a discernible consistency in the files in common/ in the end I settled on following common/memory.c since it seemed to have the most uniform, it had only a couple of anomalies, as opposed to other files where indentation was varied throughout.
Quoted 10 lines
xen/xsm/dummy.h static always_inline int xsm_default_action( · line 83
Quoted 7 lines
xen/xsm/dummy.h +1
-1@@ -82,43 +79,43 @@ static always_inline int xsm_default_action( } } -static XSM_INLINE void dummy_security_domaininfo(struct domain *d, +static inline void dummy_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info)Padding wasn't good here before, but you clearly do not change it to either of the forms we agreed on as being the goal for consistency:
Then that agreement should be document as CODING_STYLE only states:
Line Length
-----------
Lines should be less than 80 characters in length. Long lines should be split at sensible places and the trailing portions indented.
I found that in common/memory.c the predominate style was to align parameters with the first parameter when wrapping, which is what I followed. In this specific case when I wrapped the second parameter to make the line less than 80 chars (an explicit rule in CODING_STYLE) and attempted to align with the first paramter resulted in the line exceeding 80 chars. Since the only hard rule is lines must be less than 80, I decreased the indent by enough characters for the line to be less than 80 to be in line with CODING_STYLE since it only calls for sensible splits that are indented.
Quoted 9 lines
static inline void dummy_security_domaininfo(struct domain *d,
structxen_domctl_getdomaininfo*info)or
static inline void dummy_security_domaininfo(
struct domain *d,
structxen_domctl_getdomaininfo*info)
I will align to the second, even though I find it annoying to switch alignment styles, since the first would be in violation of CODING_STYLE sine the second line would exceed 80 chars
Quoted 6 lines
xen/xsm/dummy.h static always_inline int xsm_default_action( · line 88
Quoted 2 lines
xen/xsm/dummy.h +1
-1-static XSM_INLINE int dummy_domain_create(XSM_DEFAULT_ARG struct domain *d, u32 ssidref) +static inline int dummy_domain_create (struct domain *d,u32 ssidref)When you have to touch lines anyway, may I suggest that you also take the opportunity and convert u<N> to uint<N>_t, to bring this file better in line with ./CODING_STYLE?
Sure.
v/r,
dps
Re: [PATCH v2 09/10] xsm: expand the function related macros in dummy.h
Quoted 9 lines · Daniel P. Smith
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Daniel P. Smith
With the elimination of switching how
dummy.hgets included, the function declaration macros are no longer necessary. This commit expands them out to the only value for which they will ever be set. This results in function declaration lengths changing and since some definitions did not even follow the 80 column wrapping style, all function definitions were aligned with the predominate style found in core hypervisor code.
Quoted 8 lines
Quoted 1 line
I'm afraid this last half sentence is quite far from true:
I would disagree since I know I went through the frustration of trying to find a discernible consistency in the files in common/ in the end I settled on following
common/memory.csince it seemed to have the most uniform, it had only a couple of anomalies, as opposed to other files where indentation was varied throughout.
Going back into the patch I found what happened. I am not sure how, but every parameter line I wrapped had 7 additional spaces. This has been corrected.
v/r
dps
Re: [PATCH v2 09/10] xsm: expand the function related macros in dummy.h
In reply to Daniel P. SmithQuoted 53 lines · Daniel P. Smith
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Daniel P. Smith
With the elimination of switching how
dummy.hgets included, the function declaration macros are no longer necessary. This commit expands them out to the only value for which they will ever be set. This results in function declaration lengths changing and since some definitions did not even follow the 80 column wrapping style, all function definitions were aligned with the predominate style found in core hypervisor code.I'm afraid this last half sentence is quite far from true:
I would disagree since I know I went through the frustration of trying to find a discernible consistency in the files in common/ in the end I settled on following
common/memory.csince it seemed to have the most uniform, it had only a couple of anomalies, as opposed to other files where indentation was varied throughout.Quoted 10 lines
xen/xsm/dummy.h static always_inline int xsm_default_action( · line 83
Quoted 7 lines
xen/xsm/dummy.h +1
-1@@ -82,43 +79,43 @@ static always_inline int xsm_default_action( } } -static XSM_INLINE void dummy_security_domaininfo(struct domain *d, +static inline void dummy_security_domaininfo (struct domain *d,struct xen_domctl_getdomaininfo *info)Padding wasn't good here before, but you clearly do not change it to either of the forms we agreed on as being the goal for consistency:
Then that agreement should be document as
CODING_STYLEonly states:Line Length
-----------Lines should be less than 80 characters in length. Long lines should be split at sensible places and the trailing portions indented.
I found that in
common/memory.cthe predominate style was to align parameters with the first parameter when wrapping, which is what I followed. In this specific case when I wrapped the second parameter to make the line less than 80 chars (an explicit rule inCODING_STYLE) and attempted to align with the first paramter resulted in the line exceeding 80 chars. Since the only hard rule is lines must be less than 80, I decreased the indent by enough characters for the line to be less than 80 to be in line withCODING_STYLEsince it only calls for sensible splits that are indented.Quoted 5 lines
static inline void dummy_security_domaininfo(struct domain *d,
structxen_domctl_getdomaininfo*info)or
Quoted 8 lines
Quoted 4 lines
static inline void dummy_security_domaininfo(
struct domain *d,
structxen_domctl_getdomaininfo*info)I will align to the second, even though I find it annoying to switch alignment styles, since the first would be in violation of
CODING_STYLEsine the second line would exceed 80 chars
I guess you nevertheless realize that this 2nd form is precisely to overcome the problem with otherwise exceeding the 80 chars limit, while at the same time making sure the indentation doesn't end up entirely random then?
As to extending ./CODING_STYLE - I've had rather bad experience with attempts to do so, with my two most recent patches to that effect just having had their 2nd anniversary without getting any feedback moving things forward (despite, unlike in some earlier instances, the proposed changes not looking overly controversial to me).
Coincidence or not, just a few days after my submission Volodymyr submitted a patch making an attempt to document function parameter indentation [1]. While the patch as is had some comments, it didn't seem like it was controversial either. Yet nothing has since made it in.
Jan
[1] https://lists.xen.org/archives/html/xen-devel/2019-07/msg02440.html
PATCH v2 10/10 xsm: removing the XSM_ASSERT_ACTION macro
In reply to Daniel P. SmithWith the eliminations of default priv from all the XSM hook call sites, this renders the XSM_ASSERT_ACTION macro unneeded. This commit cleans up all the dummy hooks, removing the macro.
--- xen/xsm/dummy.h | 253 +++++++++++++++--------------------------------- 1 file changed, 80 insertions(+), 173 deletions(-)
xen/xsm/dummy.h +80 -173
@@ -6,13 +6,6 @@* 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. -* -* -* Each XSM hook implementing an access check should have its first parameter -* preceded by (or use XSM_DEFAULT_VOID if it has no -* arguments). The first non-declaration statement shold be XSM_ASSERT_ACTION -* with the expected type of the hook, which will either define or check the -* value of action. */ #include <xen/sched.h>
@@ -47,7 +40,6 @@ void __xsm_action_mismatch_detected(void);* xsm_default_t argument available, so the value from the assertion is used to * initialize the variable. */ -#define XSM_ASSERT_ACTION (def) xsm_default_t action = def; (void)action static always_inline int xsm_default_action(xsm_default_t action, struct domain *src,
@@ -87,37 +79,31 @@ static inline void dummy_security_domaininfo(struct domain *d,static inline int dummy_domain_create (struct domain *d,u32 ssidref) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_getdomaininfo (struct domain *d) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_domctl_scheduler_op (struct domain *d,int cmd) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_sysctl_scheduler_op (int cmd) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_set_target (struct domain *d,struct domain *e) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_domctl (struct domain *d,int cmd) { -XSM_ASSERT_ACTION (XSM_OTHER );switch ( cmd ) {case XEN_DOMCTL_ioport_mapping:
@@ -134,14 +120,12 @@ static inline int dummy_domctl(struct domain *d, int cmd)static inline int dummy_sysctl (int cmd) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_readconsole (uint32_t clear) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_alloc_security_domain (struct domain *d)
@@ -158,67 +142,57 @@ static inline int dummy_grant_mapref(struct domain *d1,struct domain *d2, uint32_t flags) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); + return xsm_default_action(XSM_HOOK, d1, d2); }static inline int dummy_grant_unmapref (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2); }static inline int dummy_grant_setup (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_grant_transfer (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2); }static inline int dummy_grant_copy (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2); }static inline int dummy_grant_query_size (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_memory_exchange (struct domain *d) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); }static inline int dummy_memory_adjust_reservation (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_memory_stat_reservation (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_console_io (struct domain *d,int cmd) { -XSM_ASSERT_ACTION (XSM_OTHER );if ( d->is_console )return xsm_default_action (XSM_HOOK , d,NULL );#ifdef CONFIG_VERBOSE_DEBUG
@@ -230,43 +204,37 @@ static inline int dummy_console_io(struct domain *d, int cmd)static inline int dummy_profile (struct domain *d,int op) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d,NULL ); +return xsm_default_action (XSM_HOOK , d,NULL ); }static inline int dummy_kexec (void ) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_schedop_shutdown (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_PRIV , d1, d2); }static inline int dummy_memory_pin_page (struct domain *d1,struct domain *d2,struct page_info *page) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_HOOK , d1, d2); }static inline int dummy_claim_pages (struct domain *d) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_PRIV , current->domain, d); }static inline int dummy_evtchn_unbound (struct domain *d,struct evtchn *chn,domid_t id2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); } static inline int dummy_evtchn_interdomain(struct domain *d1,
@@ -274,8 +242,7 @@ static inline int dummy_evtchn_interdomain(struct domain *d1,struct domain *d2, struct evtchn *chan2) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d1, d2); + return xsm_default_action(XSM_HOOK, d1, d2); }static inline void dummy_evtchn_close_post (struct evtchn *chn)
@@ -286,22 +253,19 @@ static inline void dummy_evtchn_close_post(struct evtchn *chn)static inline int dummy_evtchn_send (struct domain *d,struct evtchn *chn) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, d,NULL ); +return xsm_default_action (XSM_HOOK , d,NULL ); }static inline int dummy_evtchn_status (struct domain *d,struct evtchn *chn) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); }static inline int dummy_evtchn_reset (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); } static inline int dummy_alloc_security_evtchns(struct evtchn chn[],
@@ -324,47 +288,40 @@ static inline char *dummy_show_security_evtchn(struct domain *d,static inline int dummy_init_hardware_domain (struct domain *d) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_get_pod_target (struct domain *d) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_PRIV , current->domain, d); }static inline int dummy_set_pod_target (struct domain *d) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_PRIV , current->domain, d); }static inline int dummy_get_vnumainfo (struct domain *d) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); }#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_PCI )static inline int dummy_get_device_group (uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_assign_device (struct domain *d,uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_deassign_device (struct domain *d,uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }#endif /* HAS_PASSTHROUGH && HAS_PCI */
@@ -373,71 +330,60 @@ static inline int dummy_deassign_device(struct domain *d,static inline int dummy_assign_dtdevice (struct domain *d,const char *dtpath) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_deassign_dtdevice (struct domain *d,const char *dtpath) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ static inline int dummy_resource_plug_core (void ) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_resource_unplug_core (void ) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_resource_plug_pci (uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_resource_unplug_pci (uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_resource_setup_pci (uint32_t machine_bdf) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_resource_setup_gsi (int gsi) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_resource_setup_misc (void ) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_page_offline (uint32_t cmd) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_HOOK , current->domain,NULL ); }static inline int dummy_hypfs_op (void ) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline long dummy_do_xsm_op (XEN_GUEST_HANDLE_PARAM (xsm_op_t) op)
@@ -460,63 +406,54 @@ static inline char *dummy_show_irq_sid(int irq)static inline int dummy_map_domain_pirq (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }static inline int dummy_map_domain_irq (struct domain *d,int irq,const void *data) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_unmap_domain_pirq (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }static inline int dummy_bind_pt_irq (struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_unbind_pt_irq (struct domain *d,struct xen_domctl_bind_pt_irq *bind) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_unmap_domain_irq (struct domain *d,int irq,const void *data) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_irq_permission (struct domain *d,int pirq,uint8_t allow) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_iomem_permission (struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_iomem_mapping (struct domain *d,uint64_t s,uint64_t e,uint8_t allow) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); } static inline int dummy_pci_config_permission(struct domain *d,
@@ -525,54 +462,45 @@ static inline int dummy_pci_config_permission(struct domain *d, uint16_t end, uint8_t access) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_add_to_physmap (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_remove_from_physmap (struct domain *d1,struct domain *d2) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d1, d2); +return xsm_default_action (XSM_TARGET , d1, d2); }static inline int dummy_map_gmfn_foreign (struct domain *d,struct domain *t) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d, t); +return xsm_default_action (XSM_TARGET , d, t); }static inline int dummy_hvm_param (struct domain *d,unsigned long op) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); }static inline int dummy_hvm_control (struct domain *d,unsigned long op) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }static inline int dummy_hvm_param_altp2mhvm (struct domain *d) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_PRIV , current->domain, d); }static inline int dummy_hvm_altp2mhvm_op (struct domain *d,uint64_t mode,uint32_t op) { -XSM_ASSERT_ACTION (XSM_OTHER ); -switch ( mode ) {case XEN_ALTP2M_mixed:
@@ -591,127 +519,109 @@ static inline int dummy_hvm_altp2mhvm_op(struct domain *d,static inline int dummy_vm_event_control (struct domain *d,int mode,int op) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_PRIV , current->domain, d); }#ifdef CONFIG_MEM_ACCESS static inline int dummy_mem_access (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }#endif #ifdef CONFIG_MEM_PAGING static inline int dummy_mem_paging (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }#endif #ifdef CONFIG_MEM_SHARING static inline int dummy_mem_sharing (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }#endif static inline int dummy_platform_op (uint32_t op) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }#ifdef CONFIG_X86 static inline int dummy_do_mca (void ) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_shadow_control (struct domain *d,uint32_t op) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_mem_sharing_op (struct domain *d,struct domain *cd,int op) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, cd); +return xsm_default_action (XSM_DM_PRIV , current->domain, cd); }static inline int dummy_apic (struct domain *d,int cmd) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, d,NULL ); +return xsm_default_action (XSM_PRIV , d,NULL ); }static inline int dummy_machine_memory_map (void ) { -XSM_ASSERT_ACTION (XSM_PRIV ); -return xsm_default_action (action, current->domain,NULL ); +return xsm_default_action (XSM_PRIV , current->domain,NULL ); }static inline int dummy_domain_memory_map (struct domain *d) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_TARGET , current->domain, d); }static inline int dummy_mmu_update (struct domain *d,struct domain *t,struct domain *f,uint32_t flags) {int rc =0 ; -XSM_ASSERT_ACTION (XSM_TARGET );if ( f != dom_io ) - rc =xsm_default_action (action, d, f); + rc =xsm_default_action (XSM_TARGET , d, f);if (evaluate_nospec (t) && !rc ) - rc =xsm_default_action (action, d, t); + rc =xsm_default_action (XSM_TARGET , d, t);return rc; }static inline int dummy_mmuext_op (struct domain *d,struct domain *f) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d, f); +return xsm_default_action (XSM_TARGET , d, f); }static inline int dummy_update_va_mapping (struct domain *d,struct domain *f,l1_pgentry_t pte) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d, f); +return xsm_default_action (XSM_TARGET , d, f); }static inline int dummy_priv_mapping (struct domain *d,struct domain *t) { -XSM_ASSERT_ACTION (XSM_TARGET ); -return xsm_default_action (action, d, t); +return xsm_default_action (XSM_TARGET , d, t); }static inline int dummy_ioport_permission (struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_ioport_mapping (struct domain *d,uint32_t s,uint32_t e,uint8_t allow) { -XSM_ASSERT_ACTION (XSM_HOOK ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_HOOK , current->domain, d); }static inline int dummy_pmu_op (struct domain *d,unsigned int op) { -XSM_ASSERT_ACTION (XSM_OTHER );switch ( op ) {case XENPMU_init:
@@ -728,8 +638,7 @@ static inline int dummy_pmu_op (struct domain *d, unsigned int op)static inline int dummy_dm_op (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }#ifdef CONFIG_ARGO
@@ -760,7 +669,6 @@ static inline int dummy_argo_send(const struct domain *d,#include <public/version.h> static inline int dummy_xen_version (uint32_t op) { -XSM_ASSERT_ACTION (XSM_OTHER );switch ( op ) {case XENVER_version:
@@ -784,6 +692,5 @@ static inline int dummy_xen_version(uint32_t op)static inline int dummy_domain_resource_map (struct domain *d) { -XSM_ASSERT_ACTION (XSM_DM_PRIV ); -return xsm_default_action (action, current->domain, d); +return xsm_default_action (XSM_DM_PRIV , current->domain, d); }
Signature · 1 line
2.20.1
Quoted 10 lines · Daniel P. Smith
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_opswrapper hooks to use thealternative_callinfrastructure. Then proceeds to move and realign the headers to remove the psuedo is/is not enable implementation. The remainder of the changes are clean up and removing no longer necessary abstractions.
Quoted 8 lines
v2:
- restructured the patches, breaking them up as needed
- incorporate Andrew Cooper's alternative call common code
- change XSM module registration, removingregister_xsm
- incoporate KConfig recommendations
- reworded commit messages
- incorporate macro expansion recommendations
- misc clean-up fallout from recommendations
CI is heavily broken atm, but there is one issue I've spotted which is introduced by this series.
https://gitlab.com/xen-project/patchew/xen/-/jobs/1418359368
In file included from xsm_policy.c:21:
/builds/xen-project/patchew/xen/xen/include/xsm/xsm.h: In function 'xsm_security_domaininfo':
/builds/xen-project/patchew/xen/xen/include/xsm/xsm.h:30:5: error:
implicit declaration of function 'alternative_vcall' [-Werror=implicit-function-declaration]
30 | alternative_vcall(xsm_ops.security_domaininfo, d, info); | ^~~~~~~~~~~~~~~~~
You need to drop the XSM guard around including xen/alternative-call.h in patch 4, especially seeing as as you don't delete it in patch 6 where CONFIG_XSM formally disappears. The x86 build only works by chance, with asm/alternative.h being included implicitly.
~Andrew