Skip to content

Commit

Permalink
arm64: fix tpidr maybe null
Browse files Browse the repository at this point in the history
Before the MPU initialization, the up_update_task(this_cpu()) function is called at a time when hardware cache coherency is not yet enabled.
In certain critical scenarios, Core 1 reads a zero value for tcb from the global variable g_assignedtask and stores this zero value into the tpidr
register. This results in subsequent interrupt handlers reading a zero tcb, causing an exception.

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Dec 25, 2024
1 parent 286de7d commit c4586e3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions arch/arm64/src/common/arm64_cpustart.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ int up_cpu_start(int cpu)

void arm64_boot_secondary_c_routine(void)
{
struct tcb_s *tcb = current_task(this_cpu());

/* Init idle task to percpu reg */

up_update_task(tcb);

#ifdef CONFIG_ARCH_HAVE_MPU
arm64_mpu_init(false);
#endif
Expand All @@ -231,6 +225,15 @@ void arm64_boot_secondary_c_routine(void)
arm64_mmu_init(false);
#endif

/* We need to confirm that current_task has been initialized. */

while (!current_task(this_cpu()));

/* Init idle task to percpu reg */

up_update_task(current_task(this_cpu()));


Check failure on line 236 in arch/arm64/src/common/arm64_cpustart.c

View workflow job for this annotation

GitHub Actions / check

Too many blank lines
arm64_gic_secondary_init();

arm64_smp_init_top();
Expand Down

0 comments on commit c4586e3

Please sign in to comment.