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]
Date:   Sat, 2 Sep 2023 08:22:37 +0200
From:   Willy Tarreau <w@....eu>
To:     Ammar Faizi <ammarfaizi2@...weeb.org>
Cc:     Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
        Thomas Weißschuh <linux@...ssschuh.net>,
        David Laight <David.Laight@...lab.com>,
        Nicholas Rosenberg <inori@...x.org>,
        Michael William Jonathan <moe@...weeb.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH v2 1/4] tools/nolibc: x86-64: Use `rep movsb` for
 `memcpy()` and `memmove()`

On Sat, Sep 02, 2023 at 01:11:06PM +0700, Ammar Faizi wrote:
> On Sat, Sep 02, 2023 at 01:07:50PM +0700, Alviro Iskandar Setiawan wrote:
> > Btw, sir, this can be simplified more by merging the forward copy
> > path, only using two "rep movsb" for both memmove() and memcpy()
> > should be enough?
> > ```
> > __asm__ (
> > ".section .text.nolibc_memmove_memcpy\n"
> > ".weak memmove\n"
> > ".weak memcpy\n"
> > "memmove:\n"
> >         "movq %rdx, %rcx\n"
> >         "movq %rdi, %rdx\n"
> >         "movq %rdi, %rax\n"
> >         "subq %rsi, %rdx\n"
> >         "cmpq %rcx, %rdx\n"
> >         "jnb __nolibc_forward_copy\n"
> >         "leaq -1(%rdi, %rcx, 1), %rdi\n"
> >         "leaq -1(%rsi, %rcx, 1), %rsi\n"
> >         "std\n"
> >         "rep movsb\n"
> >         "cld\n"
> >         "retq\n"
> > 
> > "memcpy:\n"
> >         "movq %rdi, %rax\n"
> >         "movq %rdx, %rcx\n"
> > "__nolibc_forward_copy:\n"
> >         "rep movsb\n"
> >         "retq\n"
> > );
> > ```
> 
> Looks good. I'll apply that change.

Note that in this case we simply don't need a special
version of memcpy(), memmove() is always OK for this,
so you can simplify this further by starting with:

  memcpy:
  memmove:
        ...

Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ