Page MenuHomeFreeBSD

arm64: Set the endian without a memory access
ClosedPublic

Authored by andrew on Jun 24 2025, 2:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 5, 10:38 AM
Unknown Object (File)
Mon, Sep 22, 3:06 AM
Unknown Object (File)
Sun, Sep 21, 8:45 PM
Unknown Object (File)
Sun, Sep 21, 7:18 PM
Unknown Object (File)
Sun, Sep 21, 2:08 PM
Unknown Object (File)
Sep 17 2025, 4:20 AM
Unknown Object (File)
Sep 14 2025, 8:09 AM
Unknown Object (File)
Sep 14 2025, 2:24 AM
Subscribers

Details

Summary

Early in the kernel we set the endian through the sctlr_el1 and
sctlr_el2 registers. To get the value to put into these registers we
load them from memory. As this will depend on the endian to get the
fields in the correct order then it will fail if the endian is not
what the kernel expects.

Add a macro to load a 64-bit value into a register without a memory
access and use this to set the register. As instructions are not
affected by the endian set in sctlr this is safe.

It is unlikely this will be hit as UEFI requires the processor to be
in little endian mode, however when booting using the Linux ABI the
kernel may start in big-endian, and secondary CPUs could be big-endian.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/arm64/arm64/locore.S
381–386

Add a comment here that the system is in little endian mode and memory operations can be used from here on? Or extend the comment above with something like memory operations can be used after this operation?

This revision is now accepted and ready to land.Thu, Sep 18, 6:54 PM