From 987f065f1bb78b091205fff080dd4f48732b7216 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 27 Oct 2023 15:10:53 +0200 Subject: [PATCH] m1n1.adt: fix padding in DAPFT8110B definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When I tried to use the proxyclient shell, I got: "Exception parsing /device-tree/arm-io/dart-dcp.dapf-instance-0 value […]" I laid out the hex dump in a text editor, and added line breaks every 56 bytes (the former size of DAPFT8110B): 0000703b020000000080713b0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000 40723b020000000080723b020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000 003b020000007f73073b02000000200000000000000000000000000000000000000000000000000000000000000000030100000000000028 3d020000000040283d020000002000000000000000000000000000000000000000000000000000000000000000000301000000000080003d 020000000380003d020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000e03f02 000000ffffef3f0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000c0403e0200 0000ffff403e020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000433e020000 00ff3f433e020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000783d02000000 03417a3d0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000003c3b0200000000 003e3b020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000403c02000000ffff 473c020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000103c020000004f0c10 3c020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000703d020000000341723d 02000000200000000000000000000000000000000000000000000000000000000000000000030100000000 Looking at the patterns shared by all struct instances (r0h = 3, r0l = 1, for example), each row appeared to be shifted one byte to the left compared to its predecessor. This suggests that DAPFT8110B has only three extra bytes of padding compared to DAPFT8110. Removing the one byte of unknown data in the DAPFT8110B fixed the problem, allowing me to start the shell. Signed-off-by: Alyssa Ross --- proxyclient/m1n1/adt.py | 1 - src/adt.c | 2 +- src/hv_vm.c | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/proxyclient/m1n1/adt.py b/proxyclient/m1n1/adt.py index ae04371a3..075db75fa 100644 --- a/proxyclient/m1n1/adt.py +++ b/proxyclient/m1n1/adt.py @@ -228,7 +228,6 @@ "unk3" / Hex(Int8ul), "r0h" / Hex(Int8ul), "r0l" / Hex(Int8ul), - "unk4" / Hex(Int8ul), "pad" / Hex(Int32ul), ) diff --git a/src/adt.c b/src/adt.c index cddbd88f2..96afe7127 100644 --- a/src/adt.c +++ b/src/adt.c @@ -320,7 +320,7 @@ int adt_get_reg(const void *adt, int *path, const char *prop, int idx, u64 *padd u32 pa_cells = 2; ADT_GETPROP(adt, parent, "#address-cells", &pa_cells); - dprintf(" translate range to address-cells=%d size-cells=%d\n", pa_cells, ps_cells); + dprintf(" translate range to address-cells=%d\n", pa_cells); if (pa_cells < 1 || pa_cells > 2 || s_cells > 2) return ADT_ERR_BADNCELLS; diff --git a/src/hv_vm.c b/src/hv_vm.c index 58a9a86f0..5dedcc9ae 100644 --- a/src/hv_vm.c +++ b/src/hv_vm.c @@ -445,7 +445,7 @@ u64 hv_pt_walk(u64 addr) u64 l1d = hv_Ltop[idx]; - dprintf(" l1d = 0x%lx\n", l2d); + dprintf(" l1d = 0x%lx\n", l1d); if (!L1_IS_TABLE(l1d)) { dprintf(" result: 0x%lx\n", l1d); @@ -871,7 +871,7 @@ bool hv_pa_write(struct exc_info *ctx, u64 addr, u64 *val, int width) write64(addr + 8 * i, val[i]); break; default: - dprintf("HV: unsupported write width %ld\n", width); + dprintf("HV: unsupported write width %d\n", width); exc_guard = GUARD_OFF; return false; } @@ -918,7 +918,7 @@ bool hv_pa_read(struct exc_info *ctx, u64 addr, u64 *val, int width) val[3] = read64(addr + 24); break; default: - dprintf("HV: unsupported read width %ld\n", width); + dprintf("HV: unsupported read width %d\n", width); exc_guard = GUARD_OFF; return false; } @@ -982,8 +982,8 @@ static bool hv_emulate_rw_aligned(struct exc_info *ctx, u64 pte, u64 vaddr, u64 hv_hook_t *hook = (hv_hook_t *)target; if (!hook(ctx, ipa, val, true, width)) return false; - dprintf("HV: SPTE_HOOK[W] @0x%lx 0x%lx -> 0x%lx (w=%d) @%p: 0x%lx\n", elr, far, ipa, - 1 << width, hook, wval); + dprintf("HV: SPTE_HOOK[W] @0x%lx 0x%lx -> 0x%lx (w=%d) @%p: 0x%lx\n", elr, ipa, paddr, + 1 << width, hook, val); break; } case SPTE_PROXY_HOOK_RW: @@ -1021,7 +1021,7 @@ static bool hv_emulate_rw_aligned(struct exc_info *ctx, u64 pte, u64 vaddr, u64 hv_hook_t *hook = (hv_hook_t *)target; if (!hook(ctx, ipa, val, false, width)) return false; - dprintf("HV: SPTE_HOOK[R] @0x%lx 0x%lx -> 0x%lx (w=%d) @%p: 0x%lx\n", elr, far, ipa, + dprintf("HV: SPTE_HOOK[R] @0x%lx 0x%lx -> 0x%lx (w=%d) @%p: 0x%lx\n", elr, ipa, paddr, 1 << width, hook, val); break; }