Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp605552ybi; Fri, 21 Jun 2019 05:13:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM/Pofx7/bG2oy2bbng/xH+aHoDX9YaI5PWFheTlITIISyXzQKyG/U7lgK+YRGrAmXooMV X-Received: by 2002:a63:4c0b:: with SMTP id z11mr1530898pga.440.1561119208149; Fri, 21 Jun 2019 05:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561119208; cv=none; d=google.com; s=arc-20160816; b=nl7IcSFjXzi7L6ydO7yV0mkIUkarrs5bbl/viRbgW1V3ddkbBiQh67xrRyhw4Jj+8N tTZTUPO2YIZ7+jCu497vAO5CLgUl0qd5LflPSXKJ+REVDfMYeNid1+RSzaWLQkzVr/VB D0pLfhvhQ7Kt19E+Ia7mtaNjXVEHmGNWI0LHE38RJSkfr9MGSFUw8Sp8spTy/nqvrfEE 2VUHYKCdyJN3PSNDTN0xtI+sLNYwooSpP6R6opPzk7z0buMNuazTNmWKNpNwMvNkiAio wKG6I705060uXA/Ye7QMvyw9aRCITVXs6oXX4x1tSoxGz5XHZ4uvASvgZumFXfrCyhwB I1Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MSebylk6wL/Ah+aEpsz4r0kz2woEUYnwoq1toi6sVBU=; b=udvs2dWu+lJLVmxqMFNnRnMnjlgcBcRwNpcZC3K8/wlNsCo9jGGF9PPk04XQbfE3Gh TfO1KttxI5Ank/diIk2Fxcsli3+yeasQKCsWKbmM2ImgLJbR3xryKwgnSxNiVgGFGkAj 3Vp22w+qj1rhEl2eFs2gODDpsYfSy+f0Oxe/bmZsY5wekAlaX5TuIyIVvWRPZRmHNsXV LS/LgOl9wzVsIRPevqMDBmUMjJ19aD6Vf7mq4bW81WMNGjfOYS2KhcnjdttXQMEQKeTh wdrbPqEXDVXUim1OA1FkZiWfMFAyrb3U0hHE+qBFOxCK8rw8mPCGCu40eqNjEa/T//f5 dHgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="AOAPr7/x"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si2870655pjo.26.2019.06.21.05.13.11; Fri, 21 Jun 2019 05:13:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="AOAPr7/x"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfFUMNH (ORCPT + 99 others); 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 */