Re: [PATCH 03/20] x86/uaccess: Move copy_user_handle_tail into asm

From: Josh Poimboeuf
Date: Fri Mar 08 2019 - 13:53:31 EST


On Thu, Mar 07, 2019 at 12:45:14PM +0100, Peter Zijlstra wrote:
> /*
> + * Try to copy last bytes and clear the rest if needed.
> + * Since protection fault in copy_from/to_user is not a normal situation,
> + * it is not necessary to optimize tail handling.
> + *
> + * Input:
> + * rdi destination
> + * rsi source
> + * rdx count
> + *
> + * Output:
> + * eax uncopied bytes or 0 if successful.
> + */
> +ALIGN;
> +copy_user_handle_tail:
> + movl %edx,%ecx
> +1: rep movsb
> +2: mov %ecx,%eax
> + ASM_CLAC
> + ret
> +
> + _ASM_EXTABLE_UA(1b, 2b)
> +ENDPROC(copy_user_handle_tail)

This is an unstructured piece of code rather than a callable function,
END would probably be more appropriate. Or maybe it should just be a
local label (.Lcopy_user_handle_tail) because I don't think the
alignment and ELF symbol size are even needed.

--
Josh