[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190621121259.GU3463@hirez.programming.kicks-ass.net>
Date: Fri, 21 Jun 2019 14:12:59 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Vineet Gupta <Vineet.Gupta1@...opsys.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@...opsys.com>,
"linux-snps-arc@...ts.infradead.org"
<linux-snps-arc@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Alexey Brodkin <Alexey.Brodkin@...opsys.com>,
Jason Baron <jbaron@...mai.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
namit@...are.com
Subject: Re: [PATCH] ARC: ARCv2: jump label: implement jump label patching
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.
> + .byte 0x66, 0x90
> +.else
> + .byte STATIC_KEY_INIT_NOP
> +.endif
> + STATIC_BRANCH_ENTRY l_target=.Lstatic_branch_nop_\@, l_yes=\l_yes, key=\key, branch=\branch
> +.endm
> +
> +.macro STATIC_BRANCH_JMP l_yes:req key:req branch:req
> +.Lstatic_branch_jmp_\@:
> +.if \l_yes - . < 127
> + .byte 0xeb
> + .byte \l_yes - (. + 1)
> +.else
> + .byte 0xe9
> + .long \l_yes - (. + 4)
> +.endif
> + STATIC_BRANCH_ENTRY l_target=.Lstatic_branch_jmp_\@, l_yes=\l_yes, key=\key, branch=\branch
> +.endm
> +
> +#endif /* __ASSEMBLY__ */
> +#endif /* _ASM_X86_JUMP_LABEL_ASM_H */
Powered by blists - more mailing lists