Skip to content

Unable to run in release mode for aarch64 #225

@li041

Description

@li041

Description

On AArch64, the CPU ID retrieved during early boot is corrupted in non-debug (optimized) builds. The corruption occurs before SMP bring-up, indicating that the issue originates in the early boot path rather than later runtime logic.

Root Cause

At address 0x40400050, x17 is used as a loop variable after compiler optimization. In earlier (non-optimized or debug) builds, this register was not used for this purpose.

However:

  • x17 is a caller-saved register per the AArch64 ABI
  • Its value is assumed to remain intact across calls during early boot
  • This assumption is invalid under optimization

As a result, x17—which temporarily holds the CPU ID—is overwritten during boot_pt_init, leading to corrupted CPU identification.

Resolution

The issue is resolved by:

  • Replacing the use of x17 with x19, which is callee-saved according to the AArch64 calling convention

Metadata

Metadata

Assignees

No one assigned

    Labels

    aarch64bugSomething isn't workingciGithub CI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions