On 12 October 2016 at 12:48, Aleksandar Markovic
<aleksandar.marko...@rt-rk.com> wrote:
> From: Aleksandar Markovic <aleksandar.marko...@imgtec.com>
>
> By looking at the file arch/mips/kernel/sys.S in Linux kernel,
> it can be deduced that, for Mips32 platform, syscall
> corresponding to number _NR_fadvise64 translates to kernel
> function sys_fadvise64_64, and that argument layout is as
> follows:
>           0             32 0             32
>          +----------------+----------------+
>   (arg1) |       fd       |     __pad      | (arg2)
>          +----------------+----------------+
>   (arg3) |             buffer              | (arg4)
>          +----------------+----------------+
>   (arg5) |               len               | (arg6)
>          +----------------+----------------+
>   (arg7) |     advise     |    not used    | (arg8)
>          +----------------+----------------+
>
> This can be deduced from glibc code as well, and relevant commits
> in linux kernel and glibc.
>
> Mips32 uniqness is that it does not define _NR_fadvise64_64,
> however its fadvise64 implemantation is identical to
> fadvise64_64 implementation on most other platforms.
>
> The fix is to change TARGET_NR_fadvise64 to TARGET_NR_fadvise64_64
> in Mips32 syscall numbers table. Array mips_syscall_args[] in
> linux-user/main.c also already have "fadvise64_64" (and not
> "fadvise64") in corresponding place for the syscall number in
> question, so no change for linux-user/main.c.
>
> This patch also fixes the failure LTP test posix_fadvise03, if
> executed on Qemu-emulated Mips32 platform (user mode).
>
> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>

Eh? No I didn't...

> Signed-off-by: Aleksandar Rikalo <aleksandar.rik...@imgtec.com>
> Signed-off-by: Miroslav Tisma <miroslav.ti...@imgtec.com>
> Signed-off-by: Aleksandar Markovic <aleksandar.marko...@imgtec.com>
> ---
>  linux-user/mips/syscall_nr.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/mips/syscall_nr.h b/linux-user/mips/syscall_nr.h
> index 8681558..299b6dd 100644
> --- a/linux-user/mips/syscall_nr.h
> +++ b/linux-user/mips/syscall_nr.h
> @@ -256,7 +256,7 @@
>  #define TARGET_NR_remap_file_pages     (TARGET_NR_Linux + 251)
>  #define TARGET_NR_set_tid_address      (TARGET_NR_Linux + 252)
>  #define TARGET_NR_restart_syscall      (TARGET_NR_Linux + 253)
> -#define TARGET_NR_fadvise64            (TARGET_NR_Linux + 254)
> +#define TARGET_NR_fadvise64_64          (TARGET_NR_Linux + 254)

A comment mentioning that the kernel calls this fadvise64 but
the semantics are those of fadvise64_64 seems worthwhile to
avoid it being "corrected" back in future.

>  #define TARGET_NR_statfs64             (TARGET_NR_Linux + 255)
>  #define TARGET_NR_fstatfs64            (TARGET_NR_Linux + 256)
>  #define TARGET_NR_timer_create         (TARGET_NR_Linux + 257)
> --
> 2.9.3

thanks
-- PMM

Reply via email to