Skip to content

broken atomic lock when starting multiple cores #463

Open

Description

@bruelc

Hello,

Synchronization between cores in SMP mode relies on STLR/LDAR instructions to implement release/acquire semantics on the print_lock flag. These instructions depend on proper cache coherency and on memory being mapped as Normal, Inner Shareable.

Therefore, all cores must have the MMU (and caches) enabled with consistent attributes in order to use locks across cores0

In loader.c:main(), the MMU on logical core 0 is enabled after the secondary cores have already been started.
As a result, core 0 does not participate in the coherency domain when the other cores begin execution. Consequently, updates to the print_lock flag performed by secondary cores are not observed by core 0, leading to an infinite loop.

Workarounds are: Disabling the data cache via SCTLR.C, or using Normal_NC in MAIR for the translation tables

The MMU on core 0 should be enabled before releasing secondary cores.

Originally posted by @bruelc in #446 (comment)

Activity

  1. bruelc commented on Mar 31, 2026

    @bruelc
    ContributorAuthor

    Only reproducible on STMP32MP2 port, but probably latent on other aarch64 platforms

  2. Indanz commented on Apr 11, 2026

    @Indanz

    The lock should never be used with MMU disabled, just like any other shared data may not be used by MMU disabled code.

  3. self-assigned this
    on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions