Re: [PATCH] ARC: ARCv2: jump label: implement jump label patching

From: Nadav Amit
Date: Fri Jun 21 2019 - 14:37:57 EST


> On Jun 21, 2019, at 5:12 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Jun 21, 2019 at 02:09:23PM +0200, Peter Zijlstra wrote:
>
>> --- /dev/null
>> +++ b/arch/x86/include/asm/jump_label_asm.h
>> @@ -0,0 +1,44 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +#ifndef _ASM_X86_JUMP_LABEL_ASM_H
>> +#define _ASM_X86_JUMP_LABEL_ASM_H
>> +
>> +#include <asm/asm.h>
>> +#include <asm/nops.h>
>> +
>> +#ifdef __ASSEMBLY__
>> +
>> +.macro STATIC_BRANCH_ENTRY l_target:req l_yes:req key:req branch:req
>> + .pushsection __jump_table, "aw"
>> + .long \l_target - ., \l_yes - .
>> +#ifdef __X86_64__
>> + .quad (\key - .) + \branch
>> +#else
>> + .long (\key - .) + \branch
>> +#endif
>> + .popsection
>> +.endm
>> +
>> +.macro STATIC_BRANCH_NOP l_yes:req key:req branch:req
>> +.Lstatic_branch_nop_\@:
>> +.iflt 127 - .
>
> That should've been:
>
> .if \l_yes - . < 127
>
> too, I had been playing with various forms to see when it compiles.
> But as soon as a label (either \l_yes or '.' gets used) it barfs.

I think the error makes sense as it creates a âcircular dependencyâ:
assembly of the code might affect the label address, and this address affect
the assembly.