Repository navigation
kboot: T6050: hand the PMP's sleep SRAM range over from the ADT - #582
Conversation
Before a deep sleep Linux stops the PMP and keeps part of its SRAM for the restart: the range in apple,sram-keep, the firmware's __DATA segment. Without it the T6050 PMP keeps nothing, and its restart after the wake has no data segment. The segment moves between firmware versions, so a board DT cannot carry it for every Mac. When kboot_pmp.c pairs a T6050 PMP with its ADT node, take the segment that the node's segment-names calls __DATA from its segment-ranges, and set apple,sram-keep to its offset into the PMP's SRAM window and its length. segment-names must give one non-empty name per segment and exactly one __DATA; the segment must be whole 32-bit words, which is how Linux keeps it, and lie inside both the ADT register window the pairing matched and the DT's pmp window. Otherwise the DT's apple,sram-keep, if any, stays; a full DT restores every byte, as for the other values. Signed-off-by: Erik Bourget <erik@ebourget.net>
Reflow two comments and two call lines to the column limit so format-check passes. No code change. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: HOLD at 944ed93c
Blockers:
- Queued hosted CI at
944ed93c:build,gcc,selftest,clang-macos,Pytest,fedora/alarm/nix,pr-text, andreadinessare still running/queued. Wait for all hosted checks to finish green. - Additional T6050 board confirmation (optional/noted under
Not yet:): Sinceapple,sram-keepreplaces the compiled-in DT value onJ714sandK116swhen valid, confirm whetherJ716c(<0x56000 0x9b000>, matchingK116s's DT value) is the intended final row until deep sleep is unblocked onJ716cand other T6050 boards can test.
Checked:
- Audited full diff (
+216/-13acrosssrc/kboot_pmp.candtests/pmp_boot_data.c):adt_pmp_sram_keep()strictly validatessegment-names(non-empty;-separated names, at most one NUL atnames_len - 1, no inner NULs, exactly one__DATA, entry count matchingsegment-ranges), bounds-checksdata.size > 0,data.phys >= base,data.phys - base <= min(window, dt_window),data.size <= size - (data.phys - base), 32-bit offset fit, and 4-byte word alignment on both offset and size.- Confirmed missing/malformed
__DATApreserves the DT's existingapple,sram-keepwhile still copying other PMP properties, and anyfdt_setprop()failure restores the entire DT atomically fromsaved. - Confirmed
tests/pmp_boot_data.cexercises 13 malformed/out-of-window negative controls, DT-replacement, FDT-full rollback, and unterminatedsegment-names, passing under ASan/UBSan. - Confirmed live
J716cone-shot Stage 2 boot delivered/proc/device-tree/soc@200000000/pmp@284e00000/apple,sram-keep = <0x56000 0x9b000>withPMP startedandapple-pmp-reportrunning.
Evidence
- Head commit:
944ed93c2734a69a38a0ce529debd3507c02b0c5(MERGEABLEintomain). - CI snapshot:
policy,ESP stage 2 vital size,format-check, andPytest (ubuntu-24.04-arm)passed; remaining jobs queued/in-progress.
There was a problem hiding this comment.
Verdict: MERGE at 944ed93c
Blockers: None.
Checked:
- Hosted CI at
944ed93cis now completely green (19P/0F/0Q: all builds,selftest,Pytestmatrices,ESP stage 2 vital size,format-check,policy,pr-text,readiness, and distro builds passed). - Full audit of
src/kboot_pmp.candtests/pmp_boot_data.c(+216/-13) confirmed strict validation of ADTsegment-names/segment-ranges__DATA, word-alignment and window-bounds checks, fallback preservation of compiled-inapple,sram-keep, atomic DT rollback onfdt_setpropfailure, 13 negative-control + FDT-full ASan/UBSan tests, and liveJ716c(T6050, 27.2) Stage 2 boot delivering<0x56000 0x9b000>(matchingK116s's DT value) withPMP startedandapple-pmp-reportrunning.
Evidence
- Head commit:
944ed93c2734a69a38a0ce529debd3507c02b0c5(MERGEABLEintomain). - CI snapshot:
19P/0F/0Q(0non-passing checks).
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approved. adt_pmp_sram_keep() accepts only one __DATA entry among well-formed segment-names, word-aligned and inside both the matched ADT window and the DT's pmp window, and the offset arithmetic can't underflow. Without a usable range the DT's own value stays, and a failed write restores the whole DT. Rows: J716c on the same patch (this head adds only clang-format), and a J714s (M5 Pro) Stage 2 boot at this head: the loader kept 0x9b000 bytes at 0x58000 from ADT pmp0's __DATA (J716c's ADT gives 0x56000, so the per-machine value is doing its job), the PMP ran with status 0x1 and restarted after each wake, with no PMP errors.
What: Before a deep sleep Linux stops the PMP and keeps part of its SRAM for the restart: the range in
apple,sram-keep, the firmware's__DATAsegment. On T6050,kboot_pmp.c(#506) already copies the per-unit PMP settings from the ADT, but not this range, so a DT without a compiled-in range keeps nothing, and the segment moves between firmware versions, so a compiled-in range is only right for one. The loader now setsapple,sram-keepfrom the ADT PMP node's__DATAsegment (bysegment-names, fromsegment-ranges), as an offset into the PMP's SRAM window and a length. Needed by aurora-silicon/linux#3651 (J716c PMP) for deep sleep.Tested: host test
tests/run-pmp-boot-data.shat78343765: PASS, with new cases for the range, a firmware layout replacing a DT's value, thirteen missing, malformed, misaligned or out-of-window segment tables that leave the DT's value, and a DT with room for every value but this one, which comes back byte for byte. J716c (16-inch M5 Max, 27.2) with this commit on the J716c daily loader:apple,sram-keepreaches Linux as<0x56000 0x9b000>, the PMP starts, the PMP report runs and the PMC's static agents are0xb.Risk: two-way door · T6050 Macs whose DT enables the PMP without the pmp alias: J716c (#3651), J714c, J714s and K116s. On J714s and K116s the ADT's range, when it validates, replaces the DT's compiled-in one.
Not yet:
Details
segment-namesmust give one non-empty name persegment-rangesentry (;-separated, with at most one NUL, as its last byte) and exactly one__DATA. That entry must be non-empty, whole 32-bit words at both ends (Linux keeps it a word at a time) and inside both the ADT register window the pairing matched and the DT'spmpwindow; the offset is relative to that window, as the kernel's PMP driver expects.apple,sram-keep(if any) stays and the other values are still copied. A failed write restores the whole DT, as for the other values.__DATAis0x9b000bytes at offset0x56000, the same as the value the K116s DT carries for 27.2.Evidence
sh tests/run-pmp-boot-data.sh(ASan and UBSan) at78343765.aura-try, under a watchdog dead-man) built from the J716c daily loader00976384plus this commit (3804504a, the same patch),make USE_CLANG=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1, with the default Stage 2's boot variables; kernel7.3.0-ewb391+= aurora-silicon/linux mainde965eb5b26b+ #3650 + #3651, DTB withoutt6050-media.dtsi(J716c (M5 Max) hangs at boot since #2278: ave0 encoder with pmgr4 enabled linux#3618)./proc/device-tree/soc@200000000/pmp@284e00000/apple,sram-keep=00056000 0009b000;PMP started;apple-pmp-report ...: PMP running (status 0x1), requests 0x1000047000.rtcwake -d rtc1 -m mem -s 30) on that boot, and on the same kernel and loader with main's J716c DT (PMP off): both reset the Mac a few seconds into the sleep and came back on the default kernel. The default J716c daily kernel resets the same way.