]> git.itanic.dy.fi Git - linux-stable/commit
x86: improve on the non-rep 'clear_user' function
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 16 Apr 2023 21:06:58 +0000 (14:06 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 19 Apr 2023 00:05:28 +0000 (17:05 -0700)
commit8c9b6a88b7e2f33c656cd667a081bfd4dc8f5005
tree4472b64ceefb67bc6d4115d1af4bc7ebb7201741
parent577e6a7fd50d519c201d20968b6a027a6563dc4c
x86: improve on the non-rep 'clear_user' function

The old version was oddly written to have the repeat count in multiple
registers.  So instead of taking advantage of %rax being zero, it had
some sub-counts in it.  All just for a "single word clearing" loop,
which isn't even efficient to begin with.

So get rid of those games, and just keep all the state in the same
registers we got it in (and that we should return things in).  That not
only makes this act much more like 'rep stos' (which this function is
replacing), but makes it much easier to actually do the obvious loop
unrolling.

Also rename the function from the now nonsensical 'clear_user_original'
to what it now clearly is: 'rep_stos_alternative'.

End result: if we don't have a fast 'rep stosb', at least we can have a
fast fallback for it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/include/asm/uaccess_64.h
arch/x86/lib/clear_page_64.S
tools/objtool/check.c