Skip to content

arm: apple: map every DRAM bank on every SoC - #54

Draft
RyanTheTide wants to merge 2 commits into
aurora-wipfrom
sweep/apple-map-every-dram-bank
Draft

RyanTheTide wants to merge 2 commits into
aurora-wipfrom
sweep/apple-map-every-dram-bank

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

dram_init_banksize() gives LMB and EFI every /memory range the boot loader passes, so the MMU has to map every one of them. Only the T8140, T8132 and T6040 maps did this. Every other SoC (T8103, T8112, T6000/1/2, T6020/1/2, T8122, T6030/1/4, T8142, T8152) mapped bank 0 only, so anything LMB or EFI placed in a later bank sat outside the page tables.

The reason for mapping every bank has nothing to do with which SoC it is, so this applies it everywhere:

  • The per-SoC tables now hold only the I/O regions, and they are const. The fixed-size RAM entries, the framebuffer slots and the terminators are gone.
  • build_mem_map() builds one map for every SoC: the SoC's I/O regions, then each populated bi_dram bank, then /chosen/framebuffer if there is one, then the terminator. Banks and framebuffer are page-aligned as before.
  • A BUILD_BUG_ON keeps every table within the map's 24 I/O slots (the largest, T6022, has 24).
  • The t8140/t8132/t6040 special case and its hard-coded RAM slot indices are gone.

The SoC-to-I/O-table selection itself stays, because the I/O address layout really does differ per SoC.

Credit: the per-bank loop is the one from 097a434 ("arm: apple: Map all inherited memory banks on T8140"), extended to T8132 in e7f9187 and to T6040 in c21ef1a.

Why it matters on the older SoCs

The OS trees on our M2 (J413) and M1 Pro (J316s) carry 9 memory ranges, not one: a large main range plus 8 small ranges near the top of RAM (read-only /proc/device-tree/memory@*/reg, 2026-11-19). Before this change, U-Boot mapped only the first one.

Tests

  • apple_m1_defconfig, GCC 16.1 aarch64: builds with no warnings. board.o also builds clean with -Werror -Wextra.
  • test/py/tests/test_apple_*.py with --noconftest: 35 passed, 2 skipped. test_apple_mem_map.py now checks all 14 SoCs (1, 2 and 16 banks, with and without a framebuffer, plus the T8132 ANS/PCIe I/O coverage), not only T8132 and T8140.
  • Host harness: it pulls the I/O tables and build_mem_map() out of board.c and runs them for all 14 SoC compatibles, with 1, 6, 11 and 16 banks, with and without a framebuffer, under ASan and UBSan. In all 112 cases every bank is mapped, in order, after the I/O regions, page-aligned, followed by the framebuffer and the terminator.

Hardware rows owed (draft until done)

One-shot U-Boot boots, each to the U-Boot prompt and then into Linux through EFI:

  • M1 Pro (T6000, J316s) and M2 (T8112, J413): the behaviour changes here (more than one bank is now mapped).
  • Neo (T8140, J700) and J616s (T6040): no change intended. Check that they still boot.

RyanTheTide and others added 2 commits November 19, 2026 22:19
dram_init_banksize() hands every /memory range from the boot loader to
LMB and EFI, so the MMU has to map every one of them. Only the T8140,
T8132 and T6040 maps did; every other SoC mapped bank 0 and left the
rest to fault when LMB or EFI handed them out.

Keep only the I/O regions in the per-SoC tables and build one map at
cache enable time on every SoC: the I/O regions, then each populated
bank, then the framebuffer, then the terminator. The tables become
const, and a build-time check keeps them within the map's I/O slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The map now has the same shape on every SoC: its I/O regions, every
DRAM bank, then the framebuffer. Check that for all 14 SoC compatibles,
not only T8132 and T8140, and drop the fixed framebuffer slot that a
tree without a framebuffer no longer has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

The change is right and has no SoC gate. dram_init_banksize() gives LMB and EFI every bank, so the MMU has to map every bank on every SoC. What I checked:

  • build_mem_map() (arch/arm/mach-apple/board.c:1084-1156) copies the SoC's I/O regions, then the populated banks, then the framebuffer, into one zeroed apple_mem_map. That array has room for the largest I/O table (BUILD_BUG_ON, :1067), CONFIG_NR_DRAM_BANKS banks, the framebuffer and the terminator.
  • The framebuffer still comes after the banks, so it keeps winning as non-cacheable where it overlaps one.
  • The ordering and bounds hold in the host test for all 14 SoCs.
  1. Commits 4beeff2 and 21451d5 have no Signed-off-by and carry Co-Authored-By: Claude Opus 5.5. Each needs the author's Signed-off-by and no agent trailer.

Coordination: #58 (caches before relocation) pulls the old per-SoC tables, RAM entries included, out through apple_soc_mem_map(). This PR removes those entries and makes the tables const, and #56 edits the T8152 selection line. Whichever lands second needs a rebase, and #58's early map has to take its I/O regions from the new *_io_map tables.

Watch in the rows: page tables are still a fixed 256 KiB (:1166-1168), split between the normal and the emergency copy. The J316s and J413 trees add 8 small ranges near the top of RAM, each of which can need its own level-3 tables. The T6022 table (24 I/O regions) has the least room. A table overflow panics after relocation.

HW row: one-shot U-Boot boots on this head, to the U-Boot prompt and then into Linux through EFI:

  • M1 Pro J316s and M2 J413 (behaviour changes): bdinfo lists all 9 banks, no page-table panic.
  • Neo J700 and J616s: unchanged, still boot.

All with 0 AVC, 0 failed units and no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

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.

1 participant