From: Guan Jing guanjing6@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8ZJI8 CVE: NA
-------------------------------
We reserve some fields beforehand for sched structures prone to change, therefore, we can hot add/change features of sched with this enhancement. After reserving, normally cache does not matter as the reserved fields are not accessed at all.
Signed-off-by: Guan Jing guanjing6@huawei.com --- include/linux/fwnode.h | 1 + include/linux/sched.h | 38 ++++++++++++++++++++++++++++++++++++ include/linux/sched/signal.h | 5 +++++ kernel/sched/sched.h | 35 ++++++++++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 5700451b300f..72cfbe7d6f13 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -13,6 +13,7 @@ #include <linux/list.h> #include <linux/bits.h> #include <linux/err.h> +#include <linux/kabi.h>
struct fwnode_operations; struct device; diff --git a/include/linux/sched.h b/include/linux/sched.h index 4f18d4505618..1295dc3fe051 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -39,6 +39,7 @@ #include <linux/livepatch_sched.h> #include <asm/kmap_size.h> #include <linux/thread_bits.h> +#include <linux/kabi.h>
/* task_struct member predeclarations (sorted alphabetically): */ struct audit_context; @@ -389,6 +390,8 @@ struct sched_info { /* When were we last queued to run? */ unsigned long long last_queued;
+ KABI_RESERVE(1) + KABI_RESERVE(2) #endif /* CONFIG_SCHED_INFO */ };
@@ -553,6 +556,14 @@ struct sched_statistics { u64 nr_qos_smt_send_ipi; u64 nr_qos_smt_expelled; #endif + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) #endif /* CONFIG_SCHEDSTATS */ } ____cacheline_aligned;
@@ -595,6 +606,10 @@ struct sched_entity { */ struct sched_avg avg; #endif + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) };
struct sched_rt_entity { @@ -613,6 +628,8 @@ struct sched_rt_entity { /* rq "owned" by this entity/group: */ struct rt_rq *my_q; #endif + KABI_RESERVE(1) + KABI_RESERVE(2) } __randomize_layout;
struct sched_dl_entity { @@ -751,6 +768,9 @@ struct kmap_ctrl { #endif };
+struct task_struct_resvd { +}; + struct task_struct { #ifdef CONFIG_THREAD_INFO_IN_TASK /* @@ -1570,6 +1590,24 @@ struct task_struct { */ randomized_struct_fields_end
+ KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) + KABI_RESERVE(9) + KABI_RESERVE(10) + KABI_RESERVE(11) + KABI_RESERVE(12) + KABI_RESERVE(13) + KABI_RESERVE(14) + KABI_RESERVE(15) + KABI_RESERVE(16) + KABI_AUX_PTR(task_struct) + /* CPU-specific state of this task: */ struct thread_struct thread;
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 0014d3adaf84..75e71a0ce2d1 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -12,6 +12,7 @@ #include <linux/posix-timers.h> #include <linux/mm_types.h> #include <asm/ptrace.h> +#include <linux/kabi.h>
/* * Types defining task->signal and task->sighand and APIs using them: @@ -245,6 +246,10 @@ struct signal_struct { * and may have inconsistent * permissions. */ + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) } __randomize_layout;
/* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index bd5d45ba0de8..e1e28eba1b39 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -286,6 +286,8 @@ struct rt_bandwidth { u64 rt_runtime; struct hrtimer rt_period_timer; unsigned int rt_period_active; + KABI_RESERVE(1) + KABI_RESERVE(2) };
void __dl_clear_params(struct task_struct *p); @@ -360,6 +362,14 @@ struct cfs_bandwidth { int nr_burst; u64 throttled_time; u64 burst_time; + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) #endif };
@@ -731,7 +741,14 @@ struct cfs_rq { unsigned long qos_idle_h_nr_running_padding; }; #endif - + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) };
static inline int rt_bandwidth_enabled(void) @@ -778,6 +795,8 @@ struct rt_rq { struct rq *rq; struct task_group *tg; #endif + KABI_RESERVE(1) + KABI_RESERVE(2) };
static inline bool rt_rq_is_runnable(struct rt_rq *rt_rq) @@ -972,6 +991,8 @@ struct root_domain { * CPUs of the rd. Protected by RCU. */ struct perf_domain __rcu *pd; + KABI_RESERVE(1) + KABI_RESERVE(2) };
extern void init_defrootdomain(void); @@ -1266,6 +1287,14 @@ struct rq { call_single_data_t cfsb_csd; struct list_head cfsb_csd_list; #endif + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) };
#ifdef CONFIG_FAIR_GROUP_SCHED @@ -2031,6 +2060,8 @@ struct sched_group { struct sched_group_capacity *sgc; int asym_prefer_cpu; /* CPU of highest priority in group */ int flags; + KABI_RESERVE(1) + KABI_RESERVE(2)
/* * The CPUs this group covers. @@ -2414,6 +2445,8 @@ struct sched_class { #ifdef CONFIG_SCHED_CORE int (*task_is_throttled)(struct task_struct *p, int cpu); #endif + KABI_RESERVE(1) + KABI_RESERVE(2) };
static inline void put_prev_task(struct rq *rq, struct task_struct *prev)