Repository navigation
Conversation
|
Read at 05a27bd. Moving the key from the board to the part is the right direction, and the opcode/range/page/erase policy, readback and fault latch are untouched. Because this NOR holds the boot firmware, I don't think the DT partition can be the only bound on the window yet:
Checked and fine: the end <= size bound is exact; page programs can't cross a page; erases are aligned 4 KiB inside the window; the windows and parts of the boards in the old table are unchanged; the J613 probe gate still keeps the J615 off this path. Rows: besides the J813 row, the J700 (Neo), J616s (Macronix ID) and J713 at this head. On each: aurora-bless set, read back and clear, with a sha256 of the whole NOR outside the nvram window taken before and after, which shows nothing outside the window changed. Assisted-by: LLM (Claude:Opus 5.5) |
05a27bd to
a909103
Compare
|
Thanks for the thorough review. a909103 (amended) addresses it point by point:
Boards whose DT gives the driver a usable window at this head:
J813 row. One trial boot of
J700, J616s and J713 rows. I don't have those machines. The script I used is below, if your team can run it at this head. On non-J813 boards, change row.sh (J813)#!/bin/bash
# row.sh: linux#2817 J813 row, on the one-shot trial boot of 7.3.0-aurora-j813-q2817+
# (clean integration/aurora + #2817). Run as root. The DTB adds a read-only partition
# "nor-low" over [0, 0x700000) next to "nvram", for the hashes.
set -u
B=/usr/local/bin/aurora-bless
P=/sys/module/spi_apple_qspi/parameters/read_only
mtd() { grep "\"$1\"" /proc/mtd | cut -d: -f1; }
hash() { dd if=/dev/$(mtd $1)ro bs=64k 2>/dev/null | sha256sum | cut -d' ' -f1; }
low0=$(hash nor-low); nv0=$(hash nvram)
$B --next --set-boot "Macintosh HD" -y && $B --get-boot --next && $B --clear-next && $B --get-boot --next
low1=$(hash nor-low); nv1=$(hash nvram)
echo "nor-low $low0 -> $low1"; echo "nvram $nv0 -> $nv1"; cat $P
dmesg | grep -E "nvram window|NVRAM denied|write fault"Assisted-by: LLM (Claude:Opus 5.5) |
The J813 (MacBook Air 13-inch, M5) reads a Winbond W25Q64 (ef6517) with QE set and the SR3 drive strength at its default, and no block protection: flash_status: jedec=ef6517 sr1=00 sr2=02 sr3=60 Since aurora-silicon#2817 the J813 is a write candidate through its device tree's nvram partition (0x700000, 1 MiB, the ADT anvram) and its probed part, with no board entry. Check in KUnit that these status registers pass the write policy for a part that tolerates no block-protect bits. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
|
Re-read at a909103. Thanks, this covers most of the last round:
Rows still needed at this head: the J813 row, plus J700 (Neo, ideally both part variants), J616s (Macronix ID) and J713. On each Mac: the new Assisted-by: LLM (Claude:Opus 5.5) |
A controller became a write candidate only through a row of
apple_qspi_boards[]: controller and machine compatible, controller
base, the nvram window the device tree had to describe exactly, the
JEDEC IDs and the block-protect bits the firmware leaves set. Each new
Mac needed a row, and five of the ten rows were assumed rather than
checked against an ADT and a probe.
Take those facts from the machine instead, and check the device tree's
partition against the flash before anything is written to it:
- The window is the node's one "nvram" partition, if it is not marked
read-only, is a whole number of 64 KiB NVRAM banks from a 4 KiB
boundary and lies within three-byte addressing
(apple_qspi_window_valid()).
- The part is read back before every program or erase and must be in a
short part table (W25Q64, Macronix 2B27, W25Q16, GD25UF16E), which
gives its size and the block-protect bits its firmware leaves set.
The window must end within the part: a three-byte address past it
wraps around into the start of the flash.
- Before the first program or erase, and latched for the controller:
the part's SFDP density must be the size the table bounds the window
with, and every bank of the window must start with a v3 NVRAM store
header ("3VVN", version 1, a store size within the bank) or be blank
throughout, with at least one store. A partition over firmware, a
stale one, or one running into padding or an image partway through a
bank, admits nothing.
- Also at that point, the block-protect bits are decoded, and a bank
they reach even in part is dropped from the writable banks. A program
or erase there is refused before WREN, so a bank erase cannot stop
halfway with the bank's header already gone. On the J700, BP0 covers
the top 64 KiB, so the window's last bank [0x1e4000, 0x1f4000) is
never written. The bits are decoded against each request as well:
one in the protected range is refused before WREN instead of failing
its readback and latching read-only.
The read-only default and the root opt-in, the opcode, range, page and
erase checks, the readback verify and the fault latch are unchanged.
Refusals for the part, its size, SFDP, the window and protection are
logged, rate limited, with the reason.
The boards the table admitted keep their window and part. Any other
board whose device tree describes a usable nvram partition is admitted
by these checks alone.
The rules live in spi-apple-qspi-policy.h, where KUnit covers the window
rule, the bank header, the part table, the protected ranges, the banks
they leave writable and SFDP parsing. tools/asahi/qspi-nvram-tests.py
runs the driver's write path against a flash model with SFDP and NVRAM
banks, with changed-guard controls for each new check.
Closes: aurora-silicon#2815
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
a909103 to
44a1bae
Compare
The J813 (MacBook Air 13-inch, M5) reads a Winbond W25Q64 (ef6517) with QE set and the SR3 drive strength at its default, and no block protection: flash_status: jedec=ef6517 sr1=00 sr2=02 sr3=60 Since aurora-silicon#2817 the J813 is a write candidate through its device tree's nvram partition (0x700000, 1 MiB, the ADT anvram) and its probed part, with no board entry. Check in KUnit that these status registers pass the write policy for a part that tolerates no block-protect bits. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
|
Thanks. 44a1bae (amended) fixes both:
#2772 is rebased onto this head (87650bc: still only the J813 status-register KUnit case). The J813 row at this head comes next; the kernel is built. J700, J616s and J713 still need someone with those machines. Assisted-by: LLM (Claude:Opus 5.5) |
|
J813 row at 44a1bae: ALL PASS. One trial boot of
CI Assisted-by: LLM (Claude:Opus 5.5) |
|
Thanks, this replaces the board table we were about to add a J775D row to, so we're dropping that change in favour of this PR. One part is missing for the M5 Ultra: the J775D (Mac Studio) boot NOR reads JEDEC ID #define APPLE_QSPI_JEDEC_GD25UF64E { 0xc8, 0x83, 0x17 }
/* J775D (M5 Ultra): no block protection left set, SR1 0x00 */
{ APPLE_QSPI_JEDEC_GD25UF64E, 0x800000, 0 },with Those status values were validated on the J775D with the old board-table path: with Assisted-by: LLM (Claude:Opus 5.5) |
|
@funkzy thanks, and good to hear the J775D board row can go. I'd rather you send the GD25UF64E entry separately after this lands, for two reasons. Ryan's review and the rows here cover the current four parts. And #2625 adds the same part for the J773g, so the entry should go in once, in whichever of the two lands first, with the other rebasing onto it. For that commit, besides the
For the J775D row of this PR alone, expect Assisted-by: LLM (Claude:Opus 5.5) |
|
J775D (Mac Studio, M5 Ultra) row of this PR, extra evidence for the boards it lists. The J775D isn't admitted until the GD25UF64E entry lands. Read-only one-shot boots through the default 27.0 stub with the published Aura, default command line, in window upsm10@20261122-1511:
The entry commit adds the part to Assisted-by: LLM (Claude:Opus 5.5) |
|
44a1bae merges without conflicts on integration/aurora daa9e2d, and tools/asahi/qspi-nvram-tests.py passes on the merged tree (37 checks). The tip still admits writes through apple_qspi_boards[], so this is still needed. Before it leaves draft: a re-read of the two fixes in 44a1bae (blank banks must be 0xff throughout, banks under block protection are dropped), and write rows on boards that move from the table to the part path besides the J813. #2851 and #2625 each add to the table this removes, so they will need a rebase onto this if it lands first. |
|
Thanks. Both fixes in 44a1bae are ready for the re-read:
Write rows on the boards that move off the table. I have none of them (J613, J713/J715, J604, J623/J624, J773g, J616s, J700). The only one I can run is the J813, which is posted. The J700 would show the most, because iBoot leaves BP0 set there over the top 64 KiB: it exercises the protected-bank drop and the GD25UF16E alternative together. Could you run that one on your A18 Pro? The procedure from funkzy's J775D row works as is:
For the J700, the probe line should show the writes window ending below the protected top 64 KiB. Noted on #2851 and #2625. If this lands first, both need a rebase from the table onto the part path, and funkzy's GD25UF64E entry already has that form. Assisted-by: LLM (Claude:Opus 5.5) |
|
J700 (MacBook Neo, One-shot trial boot of clean
Also re-read both fixes in Assisted-by: LLM (Google:Gemini 4 Neon) |
|
@niteria thank you, that is the row this needed. The J700 is where both fixes show, and the probe line, the dropped bank and the hashes are what the code should give. @RyanTheTide with that, both conditions you set for leaving draft are met:
So I'm marking it ready. J616s and J713 rows would still be welcome. One change since your merge check: integration/aurora
The merge with Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR review at 44a1bae6dd09a6496924072626581d98d723f16a: APPROVE.
Driver Safety & Write-Protection Audit (§1–§3)
- §1 No model gating — PASS: Replaces the hardcoded per-board
apple_qspi_boards[]table with DT partition parsing plus runtime JEDEC/SFDP/NVRAM-bank/SR1 qualification. Merges cleanly ontointegration/aurora(where#2593already removed the T8122 probe gate). - §2 Production-ready, no hacks — PASS: Default kernel command line (
read_only=Ydefault with unchanged root runtime opt-in), zero sleeps/retries over races or lab-only code paths. - §3 Boot NOR safety invariants — PASS:
- Window validation (
apple_qspi_window_valid()/apple_qspi_nvram_window()): Requires exactly one available CS0nvrampartition withreg_cells == 2, not markedread-only, 4 KiB-aligned start, non-zero multiple of 64 KiB NVRAM banks, andstart + size <= 16 MiB. Correctly keepsread-onlypartitions (e.g. K114c, J615) and disabled/zero-size partitions out. - First-write latched qualification (
apple_qspi_qualify()): Serialized underapple_qspi_policy_lock. Confirms JEDEC SFDP basic parameter table density matchespart->size(apple_qspi_sfdp_basic_table()/apple_qspi_sfdp_size()), verifies every 64 KiB bank starts with a valid3VVNv1 header (24 <= size <= 0x10000) or is0xffacross all 64 KiB (memchr_invin 4 KiB chunks, withkfree(buf)on every exit), and requiresstores >= 1. Latches policy denials (sfdp/part-size/window/protected) without latching transient-EIO/-ENOMEM. - Block-protection decoding (
apple_qspi_protected_range()/apple_qspi_unprotected_banks()): Verified against the Winbond W25Q16JV/JW and GigaDevice GD25UF16ECMP=0protection tables (GDBP3/BP4andCMP/SUSstay refused byapple_qspi_gd_status_allows_write()). Dropping any partially overlapped 64 KiB bank whole cleanly closes the J700 BP0 overlap ([0x1e4000, 0x1f4000)excluded so a bank erase cannot stop halfway), while retaining the per-request[write_start, write_end)check, per-request manufacturer status check, per-request SR1 decode, and unchanged opcode/page/erase/readback/fault-latch invariants.
- Window validation (
Non-blocking Observations
- In
apple_qspi_nvram_modify(), runningapple_qspi_status()+apple_qspi_part_status_allows_write()beforeapple_qspi_qualify()would avoid emittingdev_info("nvram window ... writes in ...")whenCMP/WPS/BP3/BP4immediately denies the write withreason=status(no safety impact since the status check still rejects before WREN). - In
apple_qspi_window_valid(), writingstart <= (1ULL << 24) && size <= (1ULL << 24) - startwould guard direct 64-bit callers against unsigned wraparound (unreachable fromu32 reg[2]inapple_qspi_nvram_window()).
Attribution, Evidence, CI & Naming (§4–§6)
- §4 Clean-room & attribution — PASS: Single commit
44a1bae6dd09carries human author/committer (Thomas Glanzmann <thomas@glanzmann.de>) and humanSigned-off-by:only (zero AI trailers in commit); PR body ends withAssisted-by:. - §5 Evidence & CI — PASS:
- Live CI at exact head
44a1bae6dd09:host-testsSUCCESS (KUnitapple-qspi-nvram-policy17/17 andtools/asahi/qspi-nvram-tests.py37/37 with 30 changed-guard controls). - Exact-head live HW rows: J813 (
ef6517, 16 stores,aurora-blessround-trip, outside-window SHA-256 unchanged, 0 denials/faults/errors), J700 (ef6515, 29 stores, BP0 drops bank 28[0x1e4000, 0x1f4000),aurora-blessround-trip, bank 28 +syscfg+ outside-window SHA-256 unchanged, 0 denials/faults/errors), and J775D negative control (reason=partrefusal on unlistedc88317) + positive control with GD25UF64E entry. Follow-up J616s (c22b27SFDP), J713, and J575c rows remain welcome and fail safe if SFDP disagrees.
- Live CI at exact head
- §6 Naming — PASS.
Assisted-by: LLM (Gemini 4 Neon)
Closes #2815. Follow-up to #2772, as Ryan and Dj asked there: the write path no longer needs
apple_qspi_boards[]. Instead the facts come from the machine, and the device tree's partition is checked against the flash before anything is written.Change
nvrampartition (apple_qspi_window_valid()). It must not beread-only, must be a whole number of 64 KiB NVRAM banks from a 4 KiB boundary, and must lie within three-byte addressing.3VVN, version 1, store size within the bank) or be blank throughout (0xff over the whole 64 KiB), and at least one bank must be a store. A partition over firmware, a stale one, or one running into padding or into an image that starts partway through a bank, admits nothing.apple_qspi_unprotected_banks()). On the J700, BP0 covers [0x1f0000, 0x200000), so writes go to [0x24000, 0x1e4000) and the last bank [0x1e4000, 0x1f4000) is never written. A bank erase therefore can't stop halfway with its header already gone. Protection over the whole window admits nothing.nvram window [start, end): N stores, writes in [start, end), part ID. Refusals logNVRAM denied: reason=part|part-size|sfdp|window|protected|status, rate limited.Boards
All 138 Apple DTBs at this head, checked with the driver's partition rule (controller enabled, CS0
jedec,spi-nor, one usablenvrampartition, T8122 probe gate):read-only.7946d189a56f, 11-24): the merge is clean. Two changes from the tip since this head's base:ef6517, per arm64: dts: apple: t6041-j575c: describe the boot NOR and its NVRAM #2851), subject to the same SFDP and bank checks.nvramread-only, so it is still not admitted.Testing
apple-qspi-nvram-policy: 17/17 (UML). It covers the window rule, bank headers, the part table and size bound, protected ranges, the banks they leave writable, and SFDP parsing.tools/asahi/qspi-nvram-tests.py, alone and throughrun-host-tests.py --only qspi: all checks pass.part-id,protected,bank-invalid,bank-none,bank-latch,bank-blank,protected-bank,protected-qualify,sfdp-size,window-read-only,window-bank). All fail as they should.W=1build clean, checkpatch--strictclean.7.3.0-aurora-j813-q2817+). The DTB adds only a read-onlynor-lowpartition over [0, 0x700000), for hashing.nvram window [0x700000, 0x800000): 16 stores, writes in [0x700000, 0x800000), part ef6517.read_onlywas Y before and after each step.428be7f9…74bfbefore and after.nvram window [0x24000, 0x1f4000): 29 stores, writes in [0x24000, 0x1e4000), part ef6515: BP0 dropped the last bank, as intended.syscfgand the rest of the NOR hashed the same before and after.tools/asahi/qspi-nvram-tests.pyon the merge with integration/aurora7946d189a56f: 37/37.Still to run
Assisted-by: LLM (Claude:Opus 5.5)