HomeFreeBSD

arm64: Set the endian without a memory access

Description

arm64: Set the endian without a memory access

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.

Reviewed by: emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D51012

Details

Provenance
andrewAuthored on Sep 19 2025, 10:05 AM
Reviewer
emaste
Differential Revision
D51012: arm64: Set the endian without a memory access
Parents
rG5e690f1e12ce: arm64: Fix enabling CPU features
Branches
Unknown
Tags
Unknown