Re: [RFC][PATCH 21/22] x86,word-at-a-time: Remove .fixup usage

Josh Poimboeuf
2021-11-04T23:33:19Z

On Thu, Nov 04, 2021 at 05:47:50PM +0100, Peter Zijlstra wrote:
> XXX: I'm not really happy with this patch
>
> static inline unsigned long load_unaligned_zeropad(const void *addr)
> {
> - unsigned long ret, dummy;
> + unsigned long ret;
> +
> + asm("1:\tmov (%0),%0\n"
> + "2:\n"
> + _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_LOAD_UNALIGNED, %0)
> + : "=&r" (ret)
> + : "0" ((unsigned long)addr));
>
> - asm(
> - "1:\tmov %2,%0\n"
> - "2:\n"
> - ".section .fixup,\"ax\"\n"
> - "3:\t"
> - "lea %2,%1\n\t"
> - "and %3,%1\n\t"
> - "mov (%1),%0\n\t"
> - "leal %2,%%ecx\n\t"
> - "andl %4,%%ecx\n\t"
> - "shll $3,%%ecx\n\t"
> - "shr %%cl,%0\n\t"
> - "jmp 2b\n"
> - ".previous\n"
> - _ASM_EXTABLE(1b, 3b)
> - :"=&r" (ret),"=&c" (dummy)
> - :"m" (*(unsigned long *)addr),
> - "i" (-sizeof(unsigned long)),
> - "i" (sizeof(unsigned long)-1));
> return ret;
> }

Yeah, it hurts code generation and I guess it's a hot path.

Maybe put the fixup code in the function. In case of
CONFIG_CC_HAS_ASM_GOTO_OUTPUT, it could be at a label at the end of the
function. Otherwise it'd have to be inline.

--
Josh