[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 04/16] linux-user/host/mips: Add safe-syscall.inc.S
From: |
Peter Maydell |
Subject: |
Re: [PATCH v6 04/16] linux-user/host/mips: Add safe-syscall.inc.S |
Date: |
Mon, 29 Nov 2021 16:40:03 +0000 |
On Tue, 23 Nov 2021 at 17:44, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Signed-off-by: Richard Henderson <richard.henderson@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
- [PATCH for-7.0 v6 00/16] linux-user: simplify safe signal handling, Richard Henderson, 2021/11/23
- [PATCH v6 02/16] linux-user/host/ppc64: Use r11 for signal_pending address, Richard Henderson, 2021/11/23
- [PATCH v6 01/16] linux-user: Untabify all safe-syscall.inc.S, Richard Henderson, 2021/11/23
- [PATCH v6 03/16] linux-user: Move syscall error detection into safe_syscall_base, Richard Henderson, 2021/11/23
- [PATCH v6 04/16] linux-user/host/mips: Add safe-syscall.inc.S, Richard Henderson, 2021/11/23
- [PATCH v6 05/16] linux-user/host/sparc64: Add safe-syscall.inc.S, Richard Henderson, 2021/11/23
- [PATCH v6 06/16] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h, Richard Henderson, 2021/11/23
- [PATCH v6 07/16] linux-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS, Richard Henderson, 2021/11/23
- [PATCH v6 08/16] bsd-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS, Richard Henderson, 2021/11/23
- [PATCH v6 09/16] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN, Richard Henderson, 2021/11/23
- [PATCH v6 10/16] linux-user: Create special-errno.h, Richard Henderson, 2021/11/23
- [PATCH v6 11/16] bsd-user: Create special-errno.h, Richard Henderson, 2021/11/23
- [PATCH v6 12/16] common-user: Move safe-syscall.* from linux-user, Richard Henderson, 2021/11/23
- [PATCH v6 14/16] linux-user: Move thunk.c from top-level, Richard Henderson, 2021/11/23