On 5 August 2015 at 17:51, Christopher Covington <c...@codeaurora.org> wrote: > This is for full-system only; not implemented in user mode > > Written by Derek Hower.
> - cpu_memory_rw_debug(cs, env->regs[13]-64+32, (uint8_t *)&size, 4, 0); > - env->regs[0] = be32_to_cpu(size); > + if (env->aarch64) { > + cpu_memory_rw_debug(cs, env->pc-64+32, (uint8_t *)&size, 4, 0); > + env->xregs[0] = be32_to_cpu(size); > + } else { > + cpu_memory_rw_debug(cs, env->regs[13]-64+32, (uint8_t *)&size, 4, 0); > + env->regs[0] = be32_to_cpu(size); > + } > case TARGET_SYS_FLEN: > GET_ARG(0); > if (use_gdb_syscalls()) { > + if (env->aarch64) { > + gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x", > + arg0, env->pc-64); > + return env->xregs[0]; > + > + } else { > gdb_do_syscall(arm_semi_flen_cb, "fstat,%x,%x", > arg0, env->regs[13]-64); > return env->regs[0]; > + } These two bits are badly buggy if you ever try to use this semihosting call with gdb syscalls enabled on A64. r13 is SP, not PC, but your A64 code is telling gdb to write the struct stat buf to guest memory starting at pc-64, so it will corrupt the code we've just executed... (I'm working on an inspired-by-this but rewritten patchset for A64 semihosting, so this is just in case you were using these patches somewhere in the interim.) thanks -- PMM