Skip to content

PSX3DS v0.2.3 — Real New 3DS ARM11 L1 I-Cache Fix & Dedicated SD Scan Folders

Choose a tag to compare

@codescv codescv released this 11 Nov 02:04
· 12 commits to main since this release

PSX3DS v0.2.3 — Real New 3DS ARM11 L1 I-Cache Invalidation, VIPT & 32B JIT Alignment, SP Guard, and Dedicated SD Scan Folders

v0.2.3 fixes a real-hardware New 3DS XL (Luma3DS) prefetch abort (Permission - Section) crash during JIT execution (PC = 0x08067E70, LR = 0x001378D8) and restricts SD card ROM/BIOS scanning to dedicated PS1 folders instead of scanning the SD root.


English Release Notes

Root Cause Fixed from Real-Hardware v0.2.2 Crash Dump (PC = 0x08067E70, SP = 0x0803DEA0)

  • On real ARM11 MPCore hardware, svcFlushProcessDataCache only cleans the L1 D-Cache out to FCRAM without invalidating the separate 32 KiB 4-way (8 KiB/way) VIPT L1 Instruction Cache or branch target buffer.
  • Inside a newly compiled JIT block, emit_call executed push {r12, lr} (SP: 0x0803DE80 -> 0x0803DE78) and then crossed a 32-byte ARM11 L1 I-Cache line boundary into a cache line that still held stale 0x00000000 (andeq r0, r0, r0 = NOP) words cached by earlier instruction prefetching across 4-byte-packed blocks.
  • Executing blx r12 and pop {r12, lr} as NOPs left LR = 0x001378D8 (psx_run_frame + 0x778) untouched and SP shifted by -8 bytes at jit_exit, causing pop {r4-r12, pc} to pop saved_r11 = 0x08067E70 (sys + 0xb000, non-executable heap data) into PC while leaving [0x0803DEA0] = 0x08931D30 (saved_r12) and [0x0803DEA4] = 0x001378D8 (saved_lr) at [SP].

What's New in v0.2.3

  1. ARM11 L1 I-Cache & Branch Predictor Invalidation on Every JIT Commit (jit_mem_commit):
    • Flushes 32-byte aligned D-Cache lines for both the m->rw view and m->rx mirror, invalidates the ARM11 L1 I-Cache + BTB via Luma3DS svc 0x94 (svcInvalidateEntireInstructionCache, with r0-r3, r12 clobbers; or the 128 KiB NOP eviction sled on non-Luma hardware), and executes EL0-safe DSB (c7, c10, 4) + ISB (c7, c5, 4).
  2. 16 KiB VIPT Cache-Color Alignment & 32-Byte JIT Block Alignment:
    • jit_mem_alloc() now allocates m->rw via memalign(0x4000, size) (16 KiB >= 8 KiB/way) to match the 1 MiB-aligned m->rx mirror across all ARM11 VIPT cache colors (VA bits [13:12]).
    • arm_jit now aligns and zero-pads every emitted native block to a 32-byte ARM11 cache-line boundary (((uintptr_t)entry & 31) == 0).
  3. Hardware SP Guard Across jit_enter / jit_exit* (jit_thunks.S):
    • jit_enter saves the exact host stack pointer at cpu->jit_saved_sp ([r11, #0x270]), and all 4 exit paths (jit_exit, jit_exit_step_one, jit_exit_with_reason, jit_raise_exception_exit) restore ldr sp, [r11, #0x270] immediately before pop {r4-r12, pc}.
  4. Dedicated SD Card ROM & BIOS Scan Folders (No Full SD Root Scan):
    • 1:ROMS now scans only sdmc:/psx3ds/roms, sdmc:/roms/psx, and sdmc:/psx (sdmc:/ root is never scanned).
    • External BIOS auto-detection scans only sdmc:/psx3ds/bios, sdmc:/bios, and those three PS1 ROM folders.

中文更新说明 (v0.2.3)

  1. 修复 New 3DS 实机 ARM11 L1 指令缓存(I-Cache)未失效导致的 PC = 0x08067E70 崩溃:
    • 每次编译提交 JIT 代码块(jit_mem_commit)时,同步刷写 m->rw 与 m->rx 的数据缓存(D-Cache),并通过 Luma3DS svc 0x94 使 ARM11 L1 指令缓存与分支预测器(BTB)失效,随后执行 DSB + ISB 内存与指令屏障。
    • JIT 读写缓冲区升级为 16 KiB 对齐(memalign(0x4000, size)),消除 ARM11 32 KiB 4-way(8 KiB/way)VIPT 缓存颜色别名;所有 JIT 代码块统一按 32 字节缓存行边界对齐与填充。
    • jit_enter / jit_exit* 新增硬件栈指针保护([r11, #0x270] 保存与恢复 SP),确保 pop {r4-r12, pc} 永不错位。
  2. 精简 SD 卡扫描目录(不再扫描 SD 卡根目录):
    • 1:ROMS 游戏列表现仅扫描 sdmc:/psx3ds/roms、sdmc:/roms/psx 与 sdmc:/psx(外置 BIOS 仅扫描 sdmc:/psx3ds/bios、sdmc:/bios 及上述游戏目录),大幅加快大肚量 SD 卡启动与刷新速度。