2022-05-09 10:19:41

by Gaosheng Cui

[permalink] [raw]
Subject: [PATCH -next] arm64: add missing header dependencies

We get one error when building module with processor.h:

./arch/arm64/include/asm/processor.h:263:36: error: implicit declaration of function ‘task_stack_page’;
((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
./arch/arm64/include/asm/processor.h:266:42: note: in expansion of macro ‘task_pt_regs’
#define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))

task_stack_page is declared in linux/sched/task_stack.h, so this patch
add the missing header dependencies.

Signed-off-by: Gaosheng Cui <[email protected]>
---
arch/arm64/include/asm/processor.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 73e38d9a540c..1c239841c4d6 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -28,6 +28,7 @@
#include <linux/build_bug.h>
#include <linux/cache.h>
#include <linux/init.h>
+#include <linux/sched/task_stack.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/thread_info.h>
--
2.25.1



2022-05-10 13:45:17

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH -next] arm64: add missing header dependencies

On Mon, May 09, 2022 at 02:17:51PM +0800, Gaosheng Cui wrote:
> We get one error when building module with processor.h:
>
> ./arch/arm64/include/asm/processor.h:263:36: error: implicit declaration of function ‘task_stack_page’;
> ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
> ./arch/arm64/include/asm/processor.h:266:42: note: in expansion of macro ‘task_pt_regs’
> #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))
>
> task_stack_page is declared in linux/sched/task_stack.h, so this patch
> add the missing header dependencies.
>
> Signed-off-by: Gaosheng Cui <[email protected]>
> ---
> arch/arm64/include/asm/processor.h | 1 +
> 1 file changed, 1 insertion(+)

Do you know which commit is causing this error? I haven't seen any other
reports, but it's hard to know which tree should take your patch as it
stands.

Thanks,

Will

> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 73e38d9a540c..1c239841c4d6 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -28,6 +28,7 @@
> #include <linux/build_bug.h>
> #include <linux/cache.h>
> #include <linux/init.h>
> +#include <linux/sched/task_stack.h>
> #include <linux/stddef.h>
> #include <linux/string.h>
> #include <linux/thread_info.h>
> --
> 2.25.1
>

2022-05-11 09:56:34

by Mark Rutland

[permalink] [raw]
Subject: Re: [PATCH -next] arm64: add missing header dependencies

On Wed, May 11, 2022 at 09:39:55AM +0800, cuigaosheng wrote:
> Do you know which commit is causing this error?
>
> 9cce7a435f89 arm64: CPU support I got the error when building a module with
> processor.h on arm64 and the module calls the KSTK_ESP macro,

I assume that's an out-of-tree module?

Looking at v5.18-rc5, the only users of KSTK_ESP() on arm64 are built in:

| [mark@lakrids:~/src/linux]% git grep KSTK_ESP
| arch/alpha/include/asm/processor.h:#define KSTK_ESP(tsk) \
| arch/arc/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
| arch/arm/include/asm/processor.h:#define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp
| arch/arm64/include/asm/processor.h:#define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))
| arch/csky/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp)
| arch/h8300/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
| arch/hexagon/include/asm/processor.h:#define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk)))
| arch/ia64/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk)->thread.ksp)
| arch/m68k/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
| arch/microblaze/include/asm/processor.h:# define KSTK_ESP(task) (task_sp(task))
| arch/mips/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
| arch/nios2/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk)->thread.kregs->sp)
| arch/openrisc/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
| arch/parisc/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
| arch/powerpc/include/asm/processor.h:#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
| arch/riscv/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
| arch/s390/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->gprs[15])
| arch/sh/include/asm/processor_32.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
| arch/sparc/include/asm/processor_32.h:#define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP])
| arch/sparc/include/asm/processor_64.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->u_regs[UREG_FP])
| arch/um/include/asm/stacktrace.h: return (unsigned long *)KSTK_ESP(task);
| arch/x86/include/asm/processor.h:#define KSTK_ESP(task) (task_pt_regs(task)->sp)
| arch/x86/include/asm/processor.h:extern unsigned long KSTK_ESP(struct task_struct *task);
| arch/x86/kernel/process_64.c:unsigned long KSTK_ESP(struct task_struct *task)
| arch/x86/um/asm/processor.h:#define KSTK_ESP(tsk) KSTK_REG(tsk, HOST_SP)
| arch/xtensa/include/asm/processor.h:#define KSTK_ESP(tsk) (task_pt_regs(tsk)->areg[1])
| fs/proc/array.c: esp = KSTK_ESP(task);
| mm/util.c: return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t));

... or is that module being added in another tree at the moment?

Thanks,
Mark.

> we can also add
> additional header file dependencies(linux/sched/task_stack.h) in the module to
> avoid this error. Maybe perfecting header file dependencies of processor.h is a
> better option? Thanks,
>
> 在 2022/5/10 18:40, Will Deacon 写道:
>
> On Mon, May 09, 2022 at 02:17:51PM +0800, Gaosheng Cui wrote:
>
> We get one error when building module with processor.h:
>
> ./arch/arm64/include/asm/processor.h:263:36: error: implicit declaration of function ‘task_stack_page’;
> ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
> ./arch/arm64/include/asm/processor.h:266:42: note: in expansion of macro ‘task_pt_regs’
> #define KSTK_ESP(tsk) user_stack_pointer(task_pt_regs(tsk))
>
> task_stack_page is declared in linux/sched/task_stack.h, so this patch
> add the missing header dependencies.
>
> Signed-off-by: Gaosheng Cui <[email protected]>
> ---
> arch/arm64/include/asm/processor.h | 1 +
> 1 file changed, 1 insertion(+)
>
> Do you know which commit is causing this error? I haven't seen any other
> reports, but it's hard to know which tree should take your patch as it
> stands.
>
> Thanks,
>
> Will
>
>
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 73e38d9a540c..1c239841c4d6 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -28,6 +28,7 @@
> #include <linux/build_bug.h>
> #include <linux/cache.h>
> #include <linux/init.h>
> +#include <linux/sched/task_stack.h>
> #include <linux/stddef.h>
> #include <linux/string.h>
> #include <linux/thread_info.h>
> --
> 2.25.1
>
>
> .
>

2022-05-14 02:38:22

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH -next] arm64: add missing header dependencies

Hi Gaosheng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220506]

url: https://github.com/intel-lab-lkp/linux/commits/Gaosheng-Cui/arm64-add-missing-header-dependencies/20220509-142946
base: 38a288f5941ef03752887ad86f2d85442358c99a
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220513/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/05d29bfe89ad4e7205d77fcdd8199dd6544ff784
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Gaosheng-Cui/arm64-add-missing-header-dependencies/20220509-142946
git checkout 05d29bfe89ad4e7205d77fcdd8199dd6544ff784
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=arm64 prepare

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All error/warnings (new ones prefixed by >>):

scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
In file included from include/linux/ipc.h:7,
from include/uapi/linux/sem.h:5,
from include/linux/sem.h:5,
from include/linux/sched.h:15,
from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
>> include/linux/rhashtable-types.h:88:41: error: field 'mutex' has incomplete type
88 | struct mutex mutex;
| ^~~~~
In file included from include/linux/hrtimer.h:20,
from include/linux/sched.h:19,
from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
include/linux/seqlock.h: In function '__seqprop_mutex_sequence':
>> include/linux/seqlock.h:277:86: error: implicit declaration of function 'mutex_lock' [-Werror=implicit-function-declaration]
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~~~~~~
include/linux/seqlock.h:151:33: note: in definition of macro '__SEQ_LOCK'
151 | #define __SEQ_LOCK(expr) expr
| ^~~~
include/linux/seqlock.h:277:1: note: in expansion of macro 'SEQCOUNT_LOCKNAME'
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~~~~~~~~~~~~~
>> include/linux/seqlock.h:277:76: error: implicit declaration of function 'mutex_unlock'; did you mean 'write_unlock'? [-Werror=implicit-function-declaration]
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~
include/linux/seqlock.h:151:33: note: in definition of macro '__SEQ_LOCK'
151 | #define __SEQ_LOCK(expr) expr
| ^~~~
include/linux/seqlock.h:277:1: note: in expansion of macro 'SEQCOUNT_LOCKNAME'
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~~~~~~~~~~~~~
include/linux/seqlock.h: In function '__seqprop_mutex_assert':
>> include/linux/lockdep.h:282:61: error: invalid use of undefined type 'struct mutex'
282 | #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map)
| ^~
include/linux/seqlock.h:151:33: note: in definition of macro '__SEQ_LOCK'
151 | #define __SEQ_LOCK(expr) expr
| ^~~~
include/linux/lockdep.h:306:14: note: in expansion of macro 'WARN_ON'
306 | do { WARN_ON(debug_locks && !(cond)); } while (0)
| ^~~~~~~
include/linux/lockdep.h:312:9: note: in expansion of macro 'lockdep_assert'
312 | lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
| ^~~~~~~~~~~~~~
include/linux/lockdep.h:312:24: note: in expansion of macro 'lockdep_is_held'
312 | lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
| ^~~~~~~~~~~~~~~
include/linux/seqlock.h:245:20: note: in expansion of macro 'lockdep_assert_held'
245 | __SEQ_LOCK(lockdep_assert_held(lockmember)); \
| ^~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:277:1: note: in expansion of macro 'SEQCOUNT_LOCKNAME'
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~~~~~~~~~~~~~
include/linux/seqlock.h: In function 'read_seqbegin':
>> include/linux/seqlock.h:330:17: error: implicit declaration of function 'cpu_relax' [-Werror=implicit-function-declaration]
330 | cpu_relax(); \
| ^~~~~~~~~
include/linux/seqlock.h:344:25: note: in expansion of macro '__read_seqcount_begin'
344 | unsigned _seq = __read_seqcount_begin(s); \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:359:9: note: in expansion of macro 'raw_read_seqcount_begin'
359 | raw_read_seqcount_begin(s); \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:836:24: note: in expansion of macro 'read_seqcount_begin'
836 | unsigned ret = read_seqcount_begin(&sl->seqcount);
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
include/linux/sched.h: At top level:
>> include/linux/sched.h:1227:41: error: field 'futex_exit_mutex' has incomplete type
1227 | struct mutex futex_exit_mutex;
| ^~~~~~~~~~~~~~~~
>> include/linux/sched.h:1232:41: error: field 'perf_event_mutex' has incomplete type
1232 | struct mutex perf_event_mutex;
| ^~~~~~~~~~~~~~~~
>> include/linux/sched.h:1512:41: error: field 'thread' has incomplete type
1512 | struct thread_struct thread;
| ^~~~~~
In file included from include/vdso/processor.h:10,
from arch/arm64/include/asm/processor.h:36,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
>> arch/arm64/include/asm/vdso/processor.h:10:20: warning: conflicting types for 'cpu_relax'; have 'void(void)'
10 | static inline void cpu_relax(void)
| ^~~~~~~~~
>> arch/arm64/include/asm/vdso/processor.h:10:20: error: static declaration of 'cpu_relax' follows non-static declaration
In file included from include/linux/hrtimer.h:20,
from include/linux/sched.h:19,
from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
include/linux/seqlock.h:330:17: note: previous implicit declaration of 'cpu_relax' with type 'void(void)'
330 | cpu_relax(); \
| ^~~~~~~~~
include/linux/seqlock.h:344:25: note: in expansion of macro '__read_seqcount_begin'
344 | unsigned _seq = __read_seqcount_begin(s); \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:359:9: note: in expansion of macro 'raw_read_seqcount_begin'
359 | raw_read_seqcount_begin(s); \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/seqlock.h:836:24: note: in expansion of macro 'read_seqcount_begin'
836 | unsigned ret = read_seqcount_begin(&sl->seqcount);
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
>> arch/arm64/include/asm/processor.h:70: warning: "TASK_SIZE_OF" redefined
70 | #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
|
In file included from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
include/linux/sched.h:2248: note: this is the location of the previous definition
2248 | #define TASK_SIZE_OF(tsk) TASK_SIZE
|
In file included from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
>> include/linux/mutex.h:218:13: warning: conflicting types for 'mutex_unlock'; have 'void(struct mutex *)'
218 | extern void mutex_unlock(struct mutex *lock);
| ^~~~~~~~~~~~
In file included from include/linux/hrtimer.h:20,
from include/linux/sched.h:19,
from include/linux/sched/task_stack.h:9,
from arch/arm64/include/asm/processor.h:31,
from include/linux/mutex.h:19,
from include/linux/kernfs.h:11,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/irqdomain.h:35,
from include/linux/acpi.h:13,
from include/acpi/apei.h:9,
from include/acpi/ghes.h:5,
from include/linux/arm_sdei.h:8,
from arch/arm64/kernel/asm-offsets.c:10:
include/linux/seqlock.h:277:76: note: previous implicit declaration of 'mutex_unlock' with type 'void(struct mutex *)'
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~
include/linux/seqlock.h:151:33: note: in definition of macro '__SEQ_LOCK'
151 | #define __SEQ_LOCK(expr) expr
| ^~~~
include/linux/seqlock.h:277:1: note: in expansion of macro 'SEQCOUNT_LOCKNAME'
277 | SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:122: arch/arm64/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1284: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:226: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.


vim +/cpu_relax +10 arch/arm64/include/asm/vdso/processor.h

f511e079177a9b Vincenzo Frascino 2020-03-20 9
f511e079177a9b Vincenzo Frascino 2020-03-20 @10 static inline void cpu_relax(void)
f511e079177a9b Vincenzo Frascino 2020-03-20 11 {
f511e079177a9b Vincenzo Frascino 2020-03-20 12 asm volatile("yield" ::: "memory");
f511e079177a9b Vincenzo Frascino 2020-03-20 13 }
f511e079177a9b Vincenzo Frascino 2020-03-20 14

--
0-DAY CI Kernel Test Service
https://01.org/lkp