Subject: linux-next: build failure after merge of the akpm-current tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 31 Mar 2022 14:18:58 +1100

Hi all,

After merging the akpm-current tree, today's linux-next build (arm64
defconfig) failed like this:

In file included from include/asm-generic/percpu.h:7,
                 from arch/arm64/include/asm/percpu.h:248,
                 from include/linux/irqflags.h:17,
                 from include/linux/spinlock.h:58,
                 from include/linux/irq.h:14,
                 from arch/arm64/kernel/irq.c:13:
arch/arm64/kernel/irq.c: In function 'init_irq_scs':
arch/arm64/kernel/irq.c:44:25: error: 'irq_shadow_call_stack_ptr' undeclared (first use in this function)
   44 |                 per_cpu(irq_shadow_call_stack_ptr, cpu) =
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:219:54: note: in definition of macro '__verify_pcpu_ptr'
  219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
      |                                                      ^~~
include/linux/percpu-defs.h:269:35: note: in expansion of macro 'per_cpu_ptr'
  269 | #define per_cpu(var, cpu)       (*per_cpu_ptr(&(var), cpu))
      |                                   ^~~~~~~~~~~
arch/arm64/kernel/irq.c:44:17: note: in expansion of macro 'per_cpu'
   44 |                 per_cpu(irq_shadow_call_stack_ptr, cpu) =
      |                 ^~~~~~~
arch/arm64/kernel/irq.c:44:25: note: each undeclared identifier is reported only once for each function it appears in
   44 |                 per_cpu(irq_shadow_call_stack_ptr, cpu) =
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:219:54: note: in definition of macro '__verify_pcpu_ptr'
  219 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
      |                                                      ^~~
include/linux/percpu-defs.h:269:35: note: in expansion of macro 'per_cpu_ptr'
  269 | #define per_cpu(var, cpu)       (*per_cpu_ptr(&(var), cpu))
      |                                   ^~~~~~~~~~~
arch/arm64/kernel/irq.c:44:17: note: in expansion of macro 'per_cpu'
   44 |                 per_cpu(irq_shadow_call_stack_ptr, cpu) =
      |                 ^~~~~~~

Caused by commit

  aa0120feb340 ("arm64, scs: save scs_sp values per-cpu when switching stacks")

I have applied the following patch for today.

From: Stephen Rothwell <[email-masked]>
Date: Thu, 31 Mar 2022 13:33:55 +1100
Subject: [PATCH] fix up for "arm64, scs: save scs_sp values per-cpu when switching stacks"

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 arch/arm64/kernel/irq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 4199f900714a..5a15e6a42cbf 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -22,6 +22,7 @@
 #include <linux/vmalloc.h>
 #include <asm/daifflags.h>
 #include <asm/vmap_stack.h>
+#include <asm/scs.h>
 
 /* Only access this in an NMI enter/exit */
 DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
-- 
2.35.1

This then produced the following:

arch/arm64/kernel/stacktrace.c: In function 'arch_stack_walk_shadow':
arch/arm64/kernel/stacktrace.c:289:20: error: implicit declaration of function 'task_scs'; did you mean 'task_lock'? [-Werror=implicit-function-declaration]
  289 |         scs_base = task_scs(current);
      |                    ^~~~~~~~
      |                    task_lock
arch/arm64/kernel/stacktrace.c:289:18: warning: assignment to 'long unsigned int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  289 |         scs_base = task_scs(current);
      |                  ^

I assume this has never been compiled with CONFIG_SHADOW_CALL_STACK not
set :-(

I have reverted these commits for today:

5c6df774c321 kasan: use stack_trace_save_shadow
0f63d30c44d6 arm64: implement stack_trace_save_shadow
aa0120feb340 arm64, scs: save scs_sp values per-cpu when switching stacks
636fecb8f05e stacktrace: add interface based on shadow call stack

-- 
Cheers,
Stephen Rothwell