From 61a0b724ff85586c5c168af5bef4e6eb043cff0c Mon Sep 17 00:00:00 2001 From: SashegDev Date: Fri, 11 Sep 2026 06:24:09 +0000 Subject: [PATCH] sbl b13: NOP null-struct strb; vec trap banked regs+BKPT --- qemu/saimaa.c | 2 ++ tools/sbl_patch.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/qemu/saimaa.c b/qemu/saimaa.c index 7c63678..c5d2e68 100644 --- a/qemu/saimaa.c +++ b/qemu/saimaa.c @@ -442,6 +442,8 @@ static void saimaa_machine_init(MachineState *machine) cpu_physical_memory_write(0x085FFF5C, &v, 4); v = 0x8016183; /* S5 pop10 @ff50: 0x8013ae4 caller */ cpu_physical_memory_write(0x085FFF74, &v, 4); + v = 0x8013ba5; /* S6 ldmia.w @7afc: sp=0x85fff20, pc=[+36] */ + cpu_physical_memory_write(0x085FFF44, &v, 4); { /* words that popped regs must read as 0 (not stub-fill) */ uint32_t z = 0; cpu_physical_memory_write(0x085FFF58, &z, 4); /* r7 src */ diff --git a/tools/sbl_patch.py b/tools/sbl_patch.py index 233bbf6..7d1c1b6 100644 --- a/tools/sbl_patch.py +++ b/tools/sbl_patch.py @@ -133,6 +133,28 @@ def main(): assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8) d[o:o + 4] = bytes.fromhex('c046c046') save(d, 'img0_b12.elf') + # b13 = b12 + NOP strb.w fp,[r1,#-7]! at 0x8006684 (helper stores + # fp into struct r1, but r1 arrives NULL from 0x8007e82 chain; + # store to [0-7]=0xfffffff9 faults; struct unrecoverable here) + d = bytearray(base) + for va, (a, b) in BLX2BL.items(): + set4(d, va, b) + for va, exp, new in [ + (0x802F664, 'e4f77efc', 'c046c046'), + (0x802F672, 'e6f7bbfa', 'c046c046'), + (0x802F678, 'e9f7fef9', 'c046c046'), + (0x801B71E, '9847fee7', 'c046c046'), + (0x8008396, 'fef780f9', 'c046c046'), + (0x8016184, 'fdf790fc', 'c046c046'), + (0x801B76C, '280b0508', '00000708'), + (0x8006684, '01f807bd', '46c046c0'), + ]: + assert hx(d, va) == exp, (hex(va), hx(d, va)) + set4(d, va, new) + o = off(0x8013AA8) + assert d[o:o + 4].hex() == '07f026be', hx(d, 0x8013AA8) + d[o:o + 4] = bytes.fromhex('c046c046') + save(d, 'img0_b13.elf') if __name__ == '__main__':