Guest User

Untitled

a guest
Jul 10th, 2026
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. The Linux comment: head.S supports being entered with the MMU either on or off, and the two branches around that comment handle mirror-image hazards:
  2.  
  3. - Entered MMU off: it just wrote init_idmap_pg_dir with non-cacheable stores, but clean lines may have been speculatively allocated over those addresses — so it invalidates the
  4. tables to PoC before the caches come on.
  5. - Entered MMU on (your quote): the image was written into RAM by the EFI stub through Inner-Shareable Write-Back mappings, and those writes may still be dirty above the PoC.
  6. init_kernel_el is about to turn the MMU off, and MMU-off reads of that code are mismatched-attribute observers: literal-pool data reads are Device-nGnRnE (straight to DRAM), and
  7. instruction fetches are OSH-WT vs the ISH-WB writes. Per B2.11, such reads "might not return the value most recently written" — i.e., stale bytes from DRAM. The only point every
  8. observer is guaranteed to see is the PoC, hence dcache_clean_poc(__idmap_text_start, __idmap_text_end). PoU (dc cvau/ic ivau) is only sufficient when both writer and fetcher are
  9. Normal-cacheable — which is why it's the right point for our kernel-image maintenance, since Ultra kernels start with MMU+caches on.
  10.  
  11. And yes — you caught a real gap
  12.  
  13. So the direct answer to your previous question splits in two:
  14.  
  15. - Data: no flush needed — the trampoline makes zero data accesses in the MMU-off window (everything preloaded into registers), and afterwards WB→WB attributes match, so dirty lines
  16. remain valid cached data. That part of my earlier answer stands.
  17. - The trampoline's own instruction fetches: my "it's WT-cacheable and unmodified, so coherent" claim was wrong in exactly the way Linux's comment addresses. The trampoline's bytes
  18. were written by EDK2's PE loader via ISH-WB mappings and cleaned only to the PoU — the MMU-off fetch is a mismatched observer with no architectural guarantee of seeing them. Same
  19. bug class, ~15 instructions wide, invisible on QEMU.
  20.  
  21. Fixed: handover_prepare_for() now also cleans [kernel_handover_aarch64, kernel_handover_aarch64_end) to the PoC (dc cvac + dsb sy), with an end label exported from the asm and the
  22. three maintenance loops deduplicated into a CACHE_OP_RANGE macro. Disassembly verified (dc cvau → dsb ish → ic ivau → dc cvac → dsb sy; isb), all 14 aarch64 tests pass, and the
  23. change is folded into the rework commit (now bab4df0, message updated to document both the no-data-access invariant and the PoC clean; the other four commits cherry-picked back on
  24. top unchanged, tree clean).
Advertisement
Add Comment
Please, Sign In to add comment