Skip to content

arm64: ctxr-execmem: keep an M4-generation boot CPU at EL2 from its first entry - #1184

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
jgoyvaerts:pr/ctxr-boot-cpu-el2
Nov 10, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
jgoyvaerts:pr/ctxr-boot-cpu-el2

Conversation

@jgoyvaerts

Copy link
Copy Markdown
Contributor

On a J616s (MacBook Pro M4 Pro, T6040) booted from a kcbz 0 boot object (#985, U-Boot #32/#36, aura 1.0.0b7), the kernel died before earlycon=efifb printed anything. That happened through U-Boot booti and through GRUB alike. aura, U-Boot and GRUB all ran, and the image was in the window. The only code before earlycon that is new under a window is the boot CPU's trip through EL1, which 46c5ae7 kept because CTXR_D_CTL_EL1 reads 0 on the T8140's boot CPU. The T6040's boot CPU (cpu@10100) also reads 0, so that value doesn't show whether a core is confined.

This puts back the direct VHE entry for the boot CPU's first entry on Apple cores from part number 0x50 that implement VHE, as 73b99c1 and a572073 had it. It doesn't read ctxr_stay_el2, because the flag isn't set yet at that point. Secondaries and resume still read the flag. The documentation paragraph about the entry path is updated to match.

Trade-off

This re-opens the two points 46c5ae7 fixed, for the boot CPU of those chips only. A kernel with the option and no window now enters differently from one without it, and kvm-arm.mode=nvhe/protected and id_aa64mmfr1.vh=0 no longer move that boot CPU off VHE. At first entry the boot CPU can't tell whether it is in a window, because the window comes from the DT, and on the T6040 the register 46c5ae7 relied on doesn't tell either. If you'd rather key this on something else, I can test it on this machine.

Testing (J616s, our tree with #985 and #1079 at the same head.S)

  • Mach-O Stage 1 (kcbz 0) → U-Boot booti:
    • The window was at 0x10006c00000 (128 MiB) and 14 CPUs started at EL2.
    • execmem-confine boot verify passed: 968 executable mappings, 0 violations, with ctxr_exec_enforce=0.
    • CPU features: detected: TSO memory model (Apple), and PR_SET_MEM_MODEL reports TSO enabled.
    • In a KVM guest, ACTLR_EL1 bit 1 is writable on P and E cores.
  • Same kernel without this commit, same chain: dies before earlycon, twice: once through booti and once through GRUB.
  • Raw Stage 1 with this commit: 14 CPUs at EL2, no window, the same results as before.
  • Not tested: the T8140 and the M5. On their boot CPUs this goes back to what 73b99c1 did.
  • The head.S change is byte-identical to the one we booted. This branch is that commit on integration/aurora 57c6874a6ec9, plus the doc paragraph.

🤖 Generated with Claude Code

…irst entry

On a J616s (T6040) booted from a kcbz 0 boot object, Linux died before
earlycon=efifb printed a line, through U-Boot's booti and through GRUB
alike, with the image in the CTXR window. aura 1.0.0b7, U-Boot e1ef8b63
and GRUB all ran. The only kernel code before earlycon that is new under
a window is the boot CPU's trip through EL1, which 46c5ae7 judged
safe because CTXR_D_CTL_EL1 reads 0 on the T8140's boot CPU. The T6040's
boot CPU, cpu@10100, also reads 0 there, so that value does not tell a
confined core from a free one.

Take the direct VHE entry on the boot CPU's first entry again when it is
an Apple core with a part number from 0x50 that implements VHE, as
73b99c1 and a572073 did, without reading ctxr_stay_el2.
Secondaries and resume keep reading the flag. This skips the boot CPU's
EL1 phase on raw boots of those chips too, and with it the VHE overrides
(kvm-arm.mode=nvhe/protected, id_aa64mmfr1.vh=0), which 46c5ae7 kept:
this early the boot CPU can't tell whether it is in a window.

Tested on a J616s with aura 1.0.0b7's Mach-O Stage 1 and U-Boot booti:
the window at 0x10006c00000 (128 MiB), 14 CPUs started at EL2, boot
verify 968 executable mappings and 0 violations (ctxr_exec_enforce=0),
and the Apple TSO cpucap detected. The same kernel without this commit
died before earlycon on that chain. On the raw Stage 1 it also brings up
all 14 CPUs at EL2.

Fixes: 46c5ae7 ("arm64: ctxr-execmem: keep the boot CPU on the usual entry path")
Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
RyanTheTide pushed a commit to aurora-silicon/aura that referenced this pull request Nov 9, 2026
A J616s (M4 Pro) now runs Linux as a daily install from a padded
1.0.0b7 Mach-O Stage 1. Write down what that settles: iBoot starts the
T6040 on cpu@10100, all 14 CPUs come up at EL2 in an enforced 128 MiB
window, KVM runs guests, Apple TSO works and restart works. Also note
that the kernel needs aurora-silicon/linux#1184 on that chip.

Also document a trap found on the same Mac. Enrolling the Mach-O
object turned Kernel CTRR back on in the LocalPolicy, which had been set
up with it off. The raw Stage 1 enrolled after it then came up on one
CPU, because iBoot armed CTXR_D from the device tree to the load base.
bputil -nc before the raw enrolment brought all 14 back.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
RyanTheTide added a commit that referenced this pull request Nov 9, 2026
@RyanTheTide
RyanTheTide merged commit aba667e into aurora-silicon:integration/aurora Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants