Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [daveh-devel:kss-2026-10-23 25/25] arch/x86/kernel/cet.c:330:6: error: redefinition of 'arch_kernel_stack_lock_current'
@ 2026-10-24  0:50 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-10-24  0:50 UTC (permalink / raw)
  To: Dave Hansen; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/daveh/devel.git kss-2026-10-23
head:   b6fa923e47fcecf329844fd91ed615de35478ea3
commit: b6fa923e47fcecf329844fd91ed615de35478ea3 [25/25] x86/boot: Add CPU shadow stack bootstrapping
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20261024/202610240248.jnn1TnCR-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261024/202610240248.jnn1TnCR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610240248.jnn1TnCR-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/x86/kernel/cet.c:277:17: warning: no previous prototype for function 'kshstk_build' [-Wmissing-prototypes]
     277 | asmlinkage void kshstk_build(unsigned long *root_sp)
         |                 ^
   arch/x86/kernel/cet.c:277:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
     277 | asmlinkage void kshstk_build(unsigned long *root_sp)
         |            ^
         |            static 
>> arch/x86/kernel/cet.c:330:6: error: redefinition of 'arch_kernel_stack_lock_current'
     330 | void arch_kernel_stack_lock_current(void)
         |      ^
   arch/x86/include/asm/shstk.h:49:20: note: previous definition is here
      49 | static inline void arch_kernel_stack_lock_current(void) {}
         |                    ^
>> arch/x86/kernel/cet.c:351:18: error: no member named 'kshstk_ssp' in 'struct thread_struct'
     351 |         current->thread.kshstk_ssp = kshstk_enable_current();
         |         ~~~~~~~~~~~~~~~ ^
>> arch/x86/kernel/cet.c:351:31: error: call to undeclared function 'kshstk_enable_current'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     351 |         current->thread.kshstk_ssp = kshstk_enable_current();
         |                                      ^
   1 warning and 3 errors generated.


vim +/arch_kernel_stack_lock_current +330 arch/x86/kernel/cet.c

   266	
   267	/*
   268	 * Use the unwinder infrastructure to walk back up the regular stack
   269	 * and mirror all the return addresses over to the shadow stack.
   270	 *
   271	 * root_sp is captured in assembly before calling here to prevent the
   272	 * compiler from messing with it. There may be additional frames or
   273	 * other gunk on the stack below root_sp by the time the unwinder
   274	 * starts, but those will ignored. All that matters is that the stack
   275	 * is back to "root_sp" when shadow stacks are enabled.
   276	 */
 > 277	asmlinkage void kshstk_build(unsigned long *root_sp)
   278	{
   279		unsigned long ents[KSHSTK_MAX_ENTS];
   280		struct unwind_state state;
   281		unsigned long *ro_slot;
   282		unsigned long *rw_slot;
   283		int n = 0;
   284	
   285		/*
   286		 * Use the unwinder to find the return addresses of callers.
   287		 * Note that ents[0] is the most recent call. The is the
   288		 * opposite of stacks. ents[] is tempoarary "upside down"
   289		 * storage that will be reversed when copied to the shadow
   290		 * stack.
   291		 */
   292		for (unwind_start(&state, current, NULL, root_sp);
   293		     !unwind_done(&state) && n < KSHSTK_MAX_ENTS;
   294		     unwind_next_frame(&state))
   295			ents[n++] = unwind_get_return_address(&state);
   296	
   297		BUG_ON(n == KSHSTK_MAX_ENTS);
   298	
   299		/* Transfer the return addresses to the shadow stack: */
   300		ro_slot = task_shstk_slot(0);
   301		rw_slot = shstk_alias(ro_slot);
   302		for (int i = n - 1; i >= 0; i--) {
   303			*rw_slot = ents[i];
   304			rw_slot--;
   305			ro_slot--;
   306		}
   307		/* Put a restore token in the last slot: */
   308		shstk_create_restore_token(ro_slot);
   309	}
   310	
   311	static void kshstk_prepare_pages(void)
   312	{
   313		/*
   314		 * Necessary for the init_task shadow stack on the boot CPU,
   315		 * but not the secondary CPUs which have normal vmap'd stacks.
   316		 */
   317		set_memory_shstk_noalias((unsigned long)task_shadow_stack(current),
   318					 shadow_stack_size() / PAGE_SIZE);
   319	}
   320	
   321	/*
   322	 * This "locks" the stack in place and does not allow any control
   323	 * flow manipulation to occur because of changes to the stack.
   324	 *
   325	 * CPU enters with shadow stacks disabled and leaves with them
   326	 * enabled.
   327	 *
   328	 * Must be called before the CPU does its first context switch.
   329	 */
 > 330	void arch_kernel_stack_lock_current(void)
   331	{
   332		unsigned long flags;
   333	
   334		if (!cpu_feature_enabled(X86_FEATURE_KERN_SHSTK))
   335			return;
   336	
   337		kshstk_prepare_pages();
   338	
   339		/*
   340		 * Regular interrupts are delivered on stack level 0. There
   341		 * is a window within the enabling where CET_SHSTK_EN=1 but
   342		 * SSP is not yet set. If an interrupt is delivered in that
   343		 * window, it would try to push on to this stack. Disable
   344		 * regular interrupts over this window.
   345		 *
   346		 * Interrupts that use other stack levels (like NMI) are OK
   347		 * because FRED switches stacks for them and does not push
   348		 * on stack level 0.
   349		 */
   350		local_irq_save(flags);
 > 351		current->thread.kshstk_ssp = kshstk_enable_current();

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [daveh-devel:kss-2026-10-23 25/25] arch/x86/kernel/cet.c:330:6: error: redefinition of 'arch_kernel_stack_lock_current'
@ 2026-10-25  2:24 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-10-25  2:24 UTC (permalink / raw)
  To: Dave Hansen; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/daveh/devel.git kss-2026-10-23
head:   b6fa923e47fcecf329844fd91ed615de35478ea3
commit: b6fa923e47fcecf329844fd91ed615de35478ea3 [25/25] x86/boot: Add CPU shadow stack bootstrapping
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20261025/202610251021.TiL9FTBK-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261025/202610251021.TiL9FTBK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610251021.TiL9FTBK-lkp@intel.com/

All errors (new ones prefixed by >>):

   arch/x86/kernel/cet.c:277:17: warning: no previous prototype for function 'kshstk_build' [-Wmissing-prototypes]
     277 | asmlinkage void kshstk_build(unsigned long *root_sp)
         |                 ^
   arch/x86/kernel/cet.c:277:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
     277 | asmlinkage void kshstk_build(unsigned long *root_sp)
         |            ^
         |            static 
>> arch/x86/kernel/cet.c:330:6: error: redefinition of 'arch_kernel_stack_lock_current'
     330 | void arch_kernel_stack_lock_current(void)
         |      ^
   arch/x86/include/asm/shstk.h:49:20: note: previous definition is here
      49 | static inline void arch_kernel_stack_lock_current(void) {}
         |                    ^
>> arch/x86/kernel/cet.c:351:18: error: no member named 'kshstk_ssp' in 'struct thread_struct'
     351 |         current->thread.kshstk_ssp = kshstk_enable_current();
         |         ~~~~~~~~~~~~~~~ ^
>> arch/x86/kernel/cet.c:351:31: error: call to undeclared function 'kshstk_enable_current'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     351 |         current->thread.kshstk_ssp = kshstk_enable_current();
         |                                      ^
   1 warning and 3 errors generated.


vim +/arch_kernel_stack_lock_current +330 arch/x86/kernel/cet.c

   320	
   321	/*
   322	 * This "locks" the stack in place and does not allow any control
   323	 * flow manipulation to occur because of changes to the stack.
   324	 *
   325	 * CPU enters with shadow stacks disabled and leaves with them
   326	 * enabled.
   327	 *
   328	 * Must be called before the CPU does its first context switch.
   329	 */
 > 330	void arch_kernel_stack_lock_current(void)
   331	{
   332		unsigned long flags;
   333	
   334		if (!cpu_feature_enabled(X86_FEATURE_KERN_SHSTK))
   335			return;
   336	
   337		kshstk_prepare_pages();
   338	
   339		/*
   340		 * Regular interrupts are delivered on stack level 0. There
   341		 * is a window within the enabling where CET_SHSTK_EN=1 but
   342		 * SSP is not yet set. If an interrupt is delivered in that
   343		 * window, it would try to push on to this stack. Disable
   344		 * regular interrupts over this window.
   345		 *
   346		 * Interrupts that use other stack levels (like NMI) are OK
   347		 * because FRED switches stacks for them and does not push
   348		 * on stack level 0.
   349		 */
   350		local_irq_save(flags);
 > 351		current->thread.kshstk_ssp = kshstk_enable_current();

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-25  2:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-25  2:24 [daveh-devel:kss-2026-10-23 25/25] arch/x86/kernel/cet.c:330:6: error: redefinition of 'arch_kernel_stack_lock_current' kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2026-10-24  0:50 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox