@@ -559,14 +559,21 @@ int work_start_highpri(void)
559559 sinfo ("Starting high-priority kernel worker thread(s)\n" );
560560
561561#ifdef SCHED_HPWORKSTACKSECTION
562- static uint8_t hp_work_stack [CONFIG_SCHED_HPNTHREADS ]
563- [CONFIG_SCHED_HPWORKSTACKSIZE ]
562+ /* Ensure each stack is properly aligned by rounding up the stack size.
563+ * This is critical when CONFIG_SCHED_HPNTHREADS > 1 to ensure all
564+ * thread stacks start at properly aligned addresses.
565+ */
566+
567+ #define HP_WORK_STACK_SIZE STACK_ALIGN_UP(CONFIG_SCHED_HPWORKSTACKSIZE)
568+
569+ static aligned_data (STACK_ALIGNMENT ) uint8_t
570+ hp_work_stack [CONFIG_SCHED_HPNTHREADS ][HP_WORK_STACK_SIZE ]
564571 locate_data (CONFIG_SCHED_HPWORKSTACKSECTION );
565572
566573 return work_thread_create (HPWORKNAME ,
567574 CONFIG_SCHED_HPWORKPRIORITY ,
568575 hp_work_stack ,
569- CONFIG_SCHED_HPWORKSTACKSIZE ,
576+ HP_WORK_STACK_SIZE ,
570577 (FAR struct kwork_wqueue_s * )& g_hpwork );
571578#else
572579 return work_thread_create (HPWORKNAME , CONFIG_SCHED_HPWORKPRIORITY , NULL ,
@@ -599,14 +606,21 @@ int work_start_lowpri(void)
599606 sinfo ("Starting low-priority kernel worker thread(s)\n" );
600607
601608#ifdef SCHED_LPWORKSTACKSECTION
602- static uint8_t lp_work_stack [CONFIG_SCHED_LPNTHREADS ]
603- [CONFIG_SCHED_LPWORKSTACKSIZE ]
609+ /* Ensure each stack is properly aligned by rounding up the stack size.
610+ * This is critical when CONFIG_SCHED_LPNTHREADS > 1 to ensure all
611+ * thread stacks start at properly aligned addresses.
612+ */
613+
614+ #define LP_WORK_STACK_SIZE STACK_ALIGN_UP(CONFIG_SCHED_LPWORKSTACKSIZE)
615+
616+ static aligned_data (STACK_ALIGNMENT ) uint8_t
617+ lp_work_stack [CONFIG_SCHED_LPNTHREADS ][LP_WORK_STACK_SIZE ]
604618 locate_data (CONFIG_SCHED_LPWORKSTACKSECTION );
605619
606620 return work_thread_create (LPWORKNAME ,
607621 CONFIG_SCHED_LPWORKPRIORITY ,
608622 lp_work_stack ,
609- CONFIG_SCHED_LPWORKSTACKSIZE ,
623+ LP_WORK_STACK_SIZE ,
610624 (FAR struct kwork_wqueue_s * )& g_lpwork );
611625#else
612626 return work_thread_create (LPWORKNAME ,
0 commit comments