On Tue, 23 Nov 2021 at 17:44, Richard Henderson <richard.hender...@linaro.org> wrote: > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > linux-user/host/mips/hostdep.h | 3 + > linux-user/host/mips/safe-syscall.inc.S | 123 ++++++++++++++++++++++++ > 2 files changed, 126 insertions(+) > create mode 100644 linux-user/host/mips/safe-syscall.inc.S
> +LEAF(safe_syscall_base) > + .cfi_startproc > +#if _MIPS_SIM == _ABIO32 > + /* > + * The syscall calling convention is nearly the same as C: > + * we enter with a0 == &signal_pending > + * a1 == syscall number > + * a2, a3, stack == syscall arguments > + * and return the result in a0 > + * and the syscall instruction needs > + * v0 == syscall number > + * a0 ... a3, stack == syscall arguments > + * and returns the result in v0 > + * Shuffle everything around appropriately. > + */ > + move t0, a0 /* signal_pending pointer */ > + move v0, a1 /* syscall number */ > + move a0, a2 /* syscall arguments */ > + move a1, a3 > + lw a2, 16(sp) > + lw a3, 20(sp) > + lw t4, 24(sp) > + lw t5, 28(sp) > + lw t6, 32(sp) > + lw t7, 40(sp) > + sw t4, 16(sp) > + sw t5, 20(sp) > + sw t6, 24(sp) > + sw t7, 28(sp) This is a varargs call, so (unless I'm confused, which is quite possible) the caller will only allocate enough stack space for the arguments we're actually passed, right? That means that unless the syscall actually has 3 or more arguments the memory at 16(sp) will be whatever the caller had on the stack above the argument-passing area, and we can't write to it. I think we need to actually move sp down here so we have some space we know we can scribble on. -- PMM