[lkml]   [2021]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH] tools/nolibc: x86: Remove `r8`, `r9` and `r10` from the clobber list
From: Willy Tarreau
> Sent: 12 October 2021 10:07
> On Tue, Oct 12, 2021 at 03:36:44PM +0700, Ammar Faizi wrote:
> > I have tried to search for the documentation about this one, but I
> > couldn't find any. Checking at `Documentation/x86/entry_64.rst`, but
> > it doesn't tell anything relevant.
> (...)
> OK thanks for the detailed story, thus I didn't miss any obvious
> reference.
> > My stance comes from SO, Telegram group discussion, and reading source
> > code. Therefore, I don't think I can attach the link to it as
> > "authoritative information". Or can I?
> You're right, that's not exactly what we can call authoritative :-)

Given the cost of a system call the code benefit from telling
gcc that r8 to r10 are preserved is likely to be noise.
Especially since most syscalls are made from C library stubs
so the application calling code will assume they are trashed.

There may even be a bigger gain from the syscall exit code just
setting the registers to zero (instead of restoring them).

There are probably even bigger gains from zeroing the AVX
registers (which, IIRC, are all caller-saved) somewhere
between syscall entry and the process sleeping.
(This can't be done for non-syscall kernel entry.)


Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

 \ /
  Last update: 2021-10-12 23:21    [W:0.098 / U:3.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site