From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A634C43613 for ; Fri, 21 Jun 2019 12:13:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38B772084E for ; Fri, 21 Jun 2019 12:13:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AOAPr7/x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbfFUMNH (ORCPT ); Fri, 21 Jun 2019 08:13:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58854 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfFUMNH (ORCPT ); Fri, 21 Jun 2019 08:13:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MSebylk6wL/Ah+aEpsz4r0kz2woEUYnwoq1toi6sVBU=; b=AOAPr7/xrNCZSo94DKYDdYG0H 62l4KH80zr+LodtUNiEfMLC2/dpJdiHnAcN2WWKWFwp0I9m09YU2LjM1dUHhX4xIsoQasVaTriUzf sJI0MpC2gaohwvUm+FRhrP9KNofEDwXGPS7quz+2XxLRrhXMVrvovxTz2aBqoWdjZvOG+9PKRT3N1 Tnvw+Y4gN4vcpX6o5IWNY3gwBF2rkCreDfK5yrfkKHhTQMdV2a9FCra3/ID/04oHGA/90QdoLaLLs kEi8Cc/TS6KVoEaTSXwNccW+jALV83Xf04SfgtLSWGHLHPCw/yO4jGEGZdR4sIhKu4vYbkgWaATC4 BUeaAbuEw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1heIPd-0005so-88; Fri, 21 Jun 2019 12:13:01 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id ACD962021E58E; Fri, 21 Jun 2019 14:12:59 +0200 (CEST) Date: Fri, 21 Jun 2019 14:12:59 +0200 From: Peter Zijlstra To: Vineet Gupta Cc: Eugeniy Paltsev , "linux-snps-arc@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Alexey Brodkin , Jason Baron , Paolo Bonzini , Ard Biesheuvel , "linux-arch@vger.kernel.org" , namit@vmware.com Subject: Re: [PATCH] ARC: ARCv2: jump label: implement jump label patching Message-ID: <20190621121259.GU3463@hirez.programming.kicks-ass.net> References: <20190614164049.31626-1-Eugeniy.Paltsev@synopsys.com> <20190619081227.GL3419@hirez.programming.kicks-ass.net> <20190620070120.GU3402@hirez.programming.kicks-ass.net> <20190620212256.GC3436@hirez.programming.kicks-ass.net> <20190621120923.GT3463@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190621120923.GT3463@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > +#include > + > +#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 */