From 2282ad09eeb92f2dd89ab98e413b0b16aff8ff35 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 16 Oct 2024 09:12:52 -0700 Subject: [PATCH] ANDROID: GKI: Put vendor_data_pad behind CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE vendor_data_pad uses CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX, which is only defined when CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE is enabled, resulting in build failures when it is not: In file included from arch/arm/kernel/asm-offsets.c:12: In file included from include/linux/mm.h:1120: In file included from include/linux/huge_mm.h:8: In file included from include/linux/fs.h:33: In file included from include/linux/percpu-rwsem.h:7: In file included from include/linux/rcuwait.h:6: In file included from include/linux/sched/signal.h:9: include/linux/sched/task.h:59:28: error: use of undeclared identifier 'CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX' 59 | extern u64 vendor_data_pad[CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX / sizeof(u64)]; | ^ 1 error generated. Place all instances of vendor_data_pad behind CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE to address the build failures. Fixes: 1827ee5e5a2de3 ("ANDROID: GKI: Add padding after init_task structure") Fixes: 5e9a8cb7144f7d ("ANDROID: GKI: Add to task_struct size via cmdline") Change-Id: I7f5dcdd0aaffc5af3063a1b2ca4c1a3517043378 Signed-off-by: Nathan Chancellor --- include/linux/sched/task.h | 2 ++ init/init_task.c | 2 ++ kernel/sched/sched.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index b5ea64d15f43..8404847cf93e 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -56,7 +56,9 @@ extern spinlock_t mmlist_lock; extern union thread_union init_thread_union; extern struct task_struct init_task; +#ifdef CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE extern u64 vendor_data_pad[CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX / sizeof(u64)]; +#endif extern int lockdep_tasklist_lock_is_held(void); diff --git a/init/init_task.c b/init/init_task.c index 7fa55779b9cb..8827bd6f17b1 100644 --- a/init/init_task.c +++ b/init/init_task.c @@ -226,8 +226,10 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = { }; EXPORT_SYMBOL(init_task); +#ifdef CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE u64 vendor_data_pad[CONFIG_GKI_TASK_STRUCT_VENDOR_SIZE_MAX / sizeof(u64)]; EXPORT_SYMBOL_GPL(vendor_data_pad); +#endif /* * Initial thread structure. Alignment of this is handled by a special diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 32ece39e4d70..4f3420cd071a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3865,6 +3865,7 @@ void sched_enq_and_set_task(struct sched_enq_and_set_ctx *ctx); #include "ext.h" +#ifdef CONFIG_GKI_DYNAMIC_TASK_STRUCT_SIZE static inline void *android_task_vendor_data(struct task_struct *p) { if (p == &init_task) @@ -3872,5 +3873,6 @@ static inline void *android_task_vendor_data(struct task_struct *p) return p + 1; } +#endif #endif /* _KERNEL_SCHED_SCHED_H */