Function sched_adjust() is responsible for XEN_DOMCTL_scheduler_op domctl-op,
so it could be wrapped with CONFIG_MGMT_HYPERCALLS.
Tracing its calling chain, the following functions shall be wrapped with
CONFIG_MGMT_HYPERCALLS too:
- sched_adjust_dom()
- scheduler-specific .adjust() callback
- xsm_sysctl_scheduler_op()
Otherwise all these functions will become unreachable when MGMT_HYPERCALLS=n,
and hence violating Misra rule 2.1.
Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
v1 -> v2:
- adapt to changes of "unify DOMCTL to MGMT_HYPERCALLS"
- wrap XEN_DOMCTL_scheduler_op-case transiently
---
v2 -> v3
- add missing wrapping in xsm/dummy.h
- move and get away with just a single #ifdef
- address "violating Misra rule 2.1" in commit message
- remove transient wrapping around XEN_DOMCTL_scheduler_op-case
---
xen/common/sched/arinc653.c | 1 -
xen/common/sched/core.c | 2 --
xen/common/sched/credit.c | 4 +++-
xen/common/sched/credit2.c | 4 +++-
xen/common/sched/private.h | 8 ++++----
xen/common/sched/rt.c | 4 ++++
xen/include/xsm/dummy.h | 2 ++
xen/include/xsm/xsm.h | 4 ++--
xen/xsm/dummy.c | 2 +-
xen/xsm/flask/hooks.c | 4 ++--
10 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/xen/common/sched/arinc653.c b/xen/common/sched/arinc653.c
index 7d6c40d800..5a6f8c8642 100644
--- a/xen/common/sched/arinc653.c
+++ b/xen/common/sched/arinc653.c
@@ -735,7 +735,6 @@ static const struct scheduler sched_arinc653_def = {
.switch_sched = a653_switch_sched,
- .adjust = NULL,
#ifdef CONFIG_MGMT_HYPERCALLS
.adjust_global = a653sched_adjust_global,
#endif
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 180de784fa..6cee0858ec 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2072,7 +2072,6 @@ int scheduler_id(void)
{
return operations.sched_id;
}
-#endif
/* Adjust scheduling parameter for a given domain. */
long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)
@@ -2109,7 +2108,6 @@ long sched_adjust(struct domain *d, struct xen_domctl_scheduler_op *op)
return ret;
}
-#ifdef CONFIG_MGMT_HYPERCALLS
long sched_adjust_global(struct xen_sysctl_scheduler_op *op)
{
struct cpupool *pool;
diff --git a/xen/common/sched/credit.c b/xen/common/sched/credit.c
index 0cbec2a9c0..ed3241bec8 100644
--- a/xen/common/sched/credit.c
+++ b/xen/common/sched/credit.c
@@ -1183,6 +1183,7 @@ csched_unit_yield(const struct scheduler *ops, struct sched_unit *unit)
set_bit(CSCHED_FLAG_UNIT_YIELD, &svc->flags);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static int cf_check
csched_dom_cntl(
const struct scheduler *ops,
@@ -1227,6 +1228,7 @@ csched_dom_cntl(
return rc;
}
+#endif /* CONFIG_MGMT_HYPERCALLS */
static void cf_check
csched_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,
@@ -2288,9 +2290,9 @@ static const struct scheduler sched_credit_def = {
.wake = csched_unit_wake,
.yield = csched_unit_yield,
- .adjust = csched_dom_cntl,
.adjust_affinity= csched_aff_cntl,
#ifdef CONFIG_MGMT_HYPERCALLS
+ .adjust = csched_dom_cntl,
.adjust_global = csched_sys_cntl,
#endif
diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c
index 307e63ebd8..b73dd3c548 100644
--- a/xen/common/sched/credit2.c
+++ b/xen/common/sched/credit2.c
@@ -2909,6 +2909,7 @@ static void cf_check csched2_unit_migrate(
sched_set_res(unit, get_sched_res(new_cpu));
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static int cf_check
csched2_dom_cntl(
const struct scheduler *ops,
@@ -3114,6 +3115,7 @@ csched2_dom_cntl(
return rc;
}
+#endif /* CONFIG_MGMT_HYPERCALLS */
static void cf_check
csched2_aff_cntl(const struct scheduler *ops, struct sched_unit *unit,
@@ -4246,9 +4248,9 @@ static const struct scheduler sched_credit2_def = {
.wake = csched2_unit_wake,
.yield = csched2_unit_yield,
- .adjust = csched2_dom_cntl,
.adjust_affinity= csched2_aff_cntl,
#ifdef CONFIG_MGMT_HYPERCALLS
+ .adjust = csched2_dom_cntl,
.adjust_global = csched2_sys_cntl,
#endif
diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h
index b7ff67200b..3b35002c5d 100644
--- a/xen/common/sched/private.h
+++ b/xen/common/sched/private.h
@@ -349,14 +349,14 @@ struct scheduler {
void (*migrate) (const struct scheduler *ops,
struct sched_unit *unit,
unsigned int new_cpu);
- int (*adjust) (const struct scheduler *ops,
- struct domain *d,
- struct xen_domctl_scheduler_op *op);
void (*adjust_affinity)(const struct scheduler *ops,
struct sched_unit *unit,
const struct cpumask *hard,
const struct cpumask *soft);
#ifdef CONFIG_MGMT_HYPERCALLS
+ int (*adjust) (const struct scheduler *ops,
+ struct domain *d,
+ struct xen_domctl_scheduler_op *op);
int (*adjust_global) (const struct scheduler *ops,
struct xen_sysctl_scheduler_op *sc);
#endif
@@ -506,13 +506,13 @@ static inline void sched_adjust_affinity(const struct scheduler *s,
s->adjust_affinity(s, unit, hard, soft);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static inline int sched_adjust_dom(const struct scheduler *s, struct domain *d,
struct xen_domctl_scheduler_op *op)
{
return s->adjust ? s->adjust(s, d, op) : 0;
}
-#ifdef CONFIG_MGMT_HYPERCALLS
static inline int sched_adjust_cpupool(const struct scheduler *s,
struct xen_sysctl_scheduler_op *op)
{
diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c
index 7b1f64a779..a42040b259 100644
--- a/xen/common/sched/rt.c
+++ b/xen/common/sched/rt.c
@@ -1362,6 +1362,7 @@ out:
unit_schedule_unlock_irq(lock, unit);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
/*
* set/get each unit info of each domain
*/
@@ -1471,6 +1472,7 @@ rt_dom_cntl(
return rc;
}
+#endif /* CONFIG_MGMT_HYPERCALLS */
/*
* The replenishment timer handler picks units
@@ -1572,7 +1574,9 @@ static const struct scheduler sched_rtds_def = {
.insert_unit = rt_unit_insert,
.remove_unit = rt_unit_remove,
+#ifdef CONFIG_MGMT_HYPERCALLS
.adjust = rt_dom_cntl,
+#endif
.pick_resource = rt_res_pick,
.do_schedule = rt_schedule,
diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index 9b1d31b6ec..5810a18087 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -141,12 +141,14 @@ static XSM_INLINE int cf_check xsm_getdomaininfo(
return xsm_default_action(action, current->domain, d);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static XSM_INLINE int cf_check xsm_domctl_scheduler_op(
XSM_DEFAULT_ARG struct domain *d, int cmd)
{
XSM_ASSERT_ACTION(XSM_HOOK);
return xsm_default_action(action, current->domain, d);
}
+#endif /* CONFIG_MGMT_HYPERCALLS */
#ifdef CONFIG_MGMT_HYPERCALLS
static XSM_INLINE int cf_check xsm_sysctl_scheduler_op(XSM_DEFAULT_ARG int cmd)
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 4c6e0dc0f9..9dd485646a 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -56,8 +56,8 @@ struct xsm_ops {
struct xen_domctl_getdomaininfo *info);
int (*domain_create)(struct domain *d, uint32_t ssidref);
int (*getdomaininfo)(struct domain *d);
- int (*domctl_scheduler_op)(struct domain *d, int op);
#ifdef CONFIG_MGMT_HYPERCALLS
+ int (*domctl_scheduler_op)(struct domain *d, int op);
int (*sysctl_scheduler_op)(int op);
#endif
int (*set_target)(struct domain *d, struct domain *e);
@@ -240,13 +240,13 @@ static inline int xsm_get_domain_state(xsm_default_t def, struct domain *d)
return alternative_call(xsm_ops.get_domain_state, d);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static inline int xsm_domctl_scheduler_op(
xsm_default_t def, struct domain *d, int cmd)
{
return alternative_call(xsm_ops.domctl_scheduler_op, d, cmd);
}
-#ifdef CONFIG_MGMT_HYPERCALLS
static inline int xsm_sysctl_scheduler_op(xsm_default_t def, int cmd)
{
return alternative_call(xsm_ops.sysctl_scheduler_op, cmd);
diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c
index dbe363f0de..724b2a2653 100644
--- a/xen/xsm/dummy.c
+++ b/xen/xsm/dummy.c
@@ -18,8 +18,8 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
.security_domaininfo = xsm_security_domaininfo,
.domain_create = xsm_domain_create,
.getdomaininfo = xsm_getdomaininfo,
- .domctl_scheduler_op = xsm_domctl_scheduler_op,
#ifdef CONFIG_MGMT_HYPERCALLS
+ .domctl_scheduler_op = xsm_domctl_scheduler_op,
.sysctl_scheduler_op = xsm_sysctl_scheduler_op,
#endif
.set_target = xsm_set_target,
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index d0fd057db5..839a4cf9e6 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -609,6 +609,7 @@ static int cf_check flask_getdomaininfo(struct domain *d)
return current_has_perm(d, SECCLASS_DOMAIN, DOMAIN__GETDOMAININFO);
}
+#ifdef CONFIG_MGMT_HYPERCALLS
static int cf_check flask_domctl_scheduler_op(struct domain *d, int op)
{
switch ( op )
@@ -626,7 +627,6 @@ static int cf_check flask_domctl_scheduler_op(struct domain *d, int op)
}
}
-#ifdef CONFIG_MGMT_HYPERCALLS
static int cf_check flask_sysctl_scheduler_op(int op)
{
switch ( op )
@@ -1883,8 +1883,8 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
.security_domaininfo = flask_security_domaininfo,
.domain_create = flask_domain_create,
.getdomaininfo = flask_getdomaininfo,
- .domctl_scheduler_op = flask_domctl_scheduler_op,
#ifdef CONFIG_MGMT_HYPERCALLS
+ .domctl_scheduler_op = flask_domctl_scheduler_op,
.sysctl_scheduler_op = flask_sysctl_scheduler_op,
#endif
.set_target = flask_set_target,
--
2.34.1