lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H7ULiOUP-7RfLvQb2mOKt7NtqKUxipkfXdbkPGgzEptrQ@mail.gmail.com>
Date:   Thu, 16 Jun 2022 20:52:48 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc:     WANG Xuerui <kernel@...0n.name>,
        Xuefeng Li <lixuefeng@...ngson.cn>,
        Jianmin Lv <lvjianmin@...ngson.cn>, Jun Yi <yijun@...ngson.cn>,
        Rui Wang <wangrui@...ngson.cn>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH v3 3/3] LoongArch: No need to call RESTORE_ALL_AND_RET
 for all syscalls

Hi, Tiezhu,

On Wed, Jun 15, 2022 at 6:29 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> In handle_syscall, it is unnecessary to call RESTORE_ALL_AND_RET
> for all syscalls.
>
> (1) clone and clone3 call RESTORE_STATIC_SOME_SP_AND_RET.
> (2) rt_sigreturn and rt_sigsuspend call RESTORE_TEMP_SOME_SP_AND_RET.
I doubt that you have not tested, it is obvious that rt_sigreturn need
RESTORE_ALL.

Huacai

> (3) The other syscalls call RESTORE_SOME_SP_AND_RET.
>
> With this patch, it can reduce many load instructions.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> ---
>  arch/loongarch/include/asm/stackframe.h | 17 +++++++++++++++++
>  arch/loongarch/kernel/entry.S           | 25 ++++++++++++++++++++++++-
>  2 files changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
> index 4ca9530..52649a5f 100644
> --- a/arch/loongarch/include/asm/stackframe.h
> +++ b/arch/loongarch/include/asm/stackframe.h
> @@ -216,4 +216,21 @@
>         RESTORE_SP_AND_RET \docfi
>         .endm
>
> +       .macro  RESTORE_SOME_SP_AND_RET docfi=0
> +       RESTORE_SOME \docfi
> +       RESTORE_SP_AND_RET \docfi
> +       .endm
> +
> +       .macro  RESTORE_STATIC_SOME_SP_AND_RET docfi=0
> +       RESTORE_STATIC \docfi
> +       RESTORE_SOME \docfi
> +       RESTORE_SP_AND_RET \docfi
> +       .endm
> +
> +       .macro  RESTORE_TEMP_SOME_SP_AND_RET docfi=0
> +       RESTORE_TEMP \docfi
> +       RESTORE_SOME \docfi
> +       RESTORE_SP_AND_RET \docfi
> +       .endm
> +
>  #endif /* _ASM_STACKFRAME_H */
> diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S
> index a0f7fcc..e27e38b 100644
> --- a/arch/loongarch/kernel/entry.S
> +++ b/arch/loongarch/kernel/entry.S
> @@ -72,10 +72,33 @@ SYM_FUNC_START(handle_syscall)
>         li.d    tp, ~_THREAD_MASK
>         and     tp, tp, sp
>
> +       /* Syscall number held in a7, we can store it in TI_SYSCALL. */
> +        LONG_S  a7, tp, TI_SYSCALL
> +
>         move    a0, sp
>         bl      do_syscall
>
> -       RESTORE_ALL_AND_RET
> +       /*
> +        * Syscall number held in a7 which is stored in TI_SYSCALL.
> +        * clone and clone3 call RESTORE_STATIC_SOME_SP_AND_RET.
> +        * rt_sigreturn and rt_sigsuspend call RESTORE_TEMP_SOME_SP_AND_RET.
> +        * The other syscalls call RESTORE_SOME_SP_AND_RET.
> +        */
> +       LONG_L  t3, tp, TI_SYSCALL
> +       li.w    t4, __NR_clone
> +       beq     t3, t4, 3f
> +       li.w    t4, __NR_clone3
> +       beq     t3, t4, 3f
> +       li.w    t4, __NR_rt_sigreturn
> +       beq     t3, t4, 4f
> +       li.w    t4, __NR_rt_sigsuspend
> +       beq     t3, t4, 4f
> +
> +       RESTORE_SOME_SP_AND_RET
> +3:
> +       RESTORE_STATIC_SOME_SP_AND_RET
> +4:
> +       RESTORE_TEMP_SOME_SP_AND_RET
>  SYM_FUNC_END(handle_syscall)
>
>  SYM_CODE_START(ret_from_fork)
> --
> 2.1.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ