Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp751784imm; Wed, 20 Jun 2018 06:07:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzYqERS8yERtqixx2unqsR+9ryjVGAIF/ZorYcaSzHZIx9dYa/2N/ENsCPRQ/NuwHw7slH X-Received: by 2002:a63:2dc2:: with SMTP id t185-v6mr19125845pgt.204.1529500079797; Wed, 20 Jun 2018 06:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529500079; cv=none; d=google.com; s=arc-20160816; b=JUdqWdKFYSbyCcIHlynyf1McDArbRLlI0sskIL8Wdl5AiRm7ZIB1FfETkNsjute9lt G2BJHOny9fJoiNvrP8+M31LQbLaOr3iXve8G/KVCHV6vgqWFog4NO3VgH8KcxXgdyuYG j9O01i8fwY2XQBsC4mUFJUdfzAAcVrQiRjCP0Z7zbWlPegWvVIixvEgmlIe9ZwjH8HYt UNy3GrzvD8nbCWJu9oezwnTFmvVh4K9fGaMVDTRNqaAugVfJ9remaqzt64OUjSTk1OQs PLY5rFzR9/Iwotej89zIbn33i2OdTDEo+dK5jVXcKySBOLo9/98c0eMeAeSdyVxRtnav mtjQ== 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:arc-authentication-results; bh=TJEh0uTDOlXwZQeHzFDMF3QbEXH8AiztTc3Y8g2InN4=; b=Qdto7airYavyb4uXFgiXONjr4v0qxZhK+K44wHIcaJj80qb4QHjgnRhoM1CGrZrnTV c7wn7voRlcHiLMtEyy8LOgzmB6K8OFszXxQnD3+ZodzqnE1JQwnkHhS046KPygBUw2GP iLuAMVL1lcGH8mLv1XIIyPYuMM82luDvLc/73LuVGZd+2d/cISNTgiZotdqh9gjFFfN6 BIojt00+3TAST5USbW36Ts7a/pEGs9pzSJjFfeElPUAO+cs/jzW8g9eYUWCiNnNmb/KL HJiI6fqrLY+0Bx9nPv1Pj4apxQWrZpUlM6aryUxAeFePlfAWx1Re/Hw7nVInl/eDTVgz PwIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=b2WivrWZ; 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 k2-v6si1870989pgq.442.2018.06.20.06.07.32; Wed, 20 Jun 2018 06:07:59 -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=merlin.20170209 header.b=b2WivrWZ; 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 S1753885AbeFTNGk (ORCPT + 99 others); Wed, 20 Jun 2018 09:06:40 -0400 Received: from merlin.infradead.org ([205.233.59.134]:57376 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbeFTNGd (ORCPT ); Wed, 20 Jun 2018 09:06:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=TJEh0uTDOlXwZQeHzFDMF3QbEXH8AiztTc3Y8g2InN4=; b=b2WivrWZGkiR4DrV5qjWRQ0Cj h9JkVnRXnRtxPBHANu/gOoZ9yH9XU7AKeUcPhSCbmg5iPL+2UyToOC0y2DR1rcSAwazTApkFm/NTj 3YBU+2ga3Vw2m/rLtC/x5O2jqGYXRbD+o4jV1oampgOLAgMAfqlVmGB8IPJCkBjCTb//84VAbPbgu 24TDtFxWaIuCyLTB70Le++dIKtSATqk/zcqPi2futjXWfrRaJtSWwUKyaHlfnMD0vBV08hve54acl laiplkrcjPPnYNIvbwchM48SISug4zX0v/DYhKOxeudIvb4FYp7QnuJBOBP94u7mJ72ueKaOC0mfM IMx/nPE5A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVcod-00053l-CC; Wed, 20 Jun 2018 13:06:27 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id AFDDC2029FA0A; Wed, 20 Jun 2018 15:06:24 +0200 (CEST) Date: Wed, 20 Jun 2018 15:06:24 +0200 From: Peter Zijlstra To: Nadav Amit Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne Subject: Re: [PATCH v5 9/9] x86: jump-labels: use macros instead of inline assembly Message-ID: <20180620130624.GC2530@hirez.programming.kicks-ass.net> References: <20180619194854.69486-1-namit@vmware.com> <20180619194854.69486-10-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180619194854.69486-10-namit@vmware.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 12:48:54PM -0700, Nadav Amit wrote: > diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h > index 8c0de4282659..f321a50e6727 100644 > --- a/arch/x86/include/asm/jump_label.h > +++ b/arch/x86/include/asm/jump_label.h > @@ -108,6 +99,26 @@ struct jump_entry { > .popsection > .endm > > +.macro STATIC_BRANCH_NOP l_yes:req key:req branch:req > +1: > + .byte STATIC_KEY_INIT_NOP > + .pushsection __jump_table, "aw" > + _ASM_ALIGN > + _ASM_PTR 1b, \l_yes, \key + \branch > + .popsection > +.endm > + > +.macro STATIC_BRANCH_JMP l_yes:req key:req branch:req > +1: > + .byte 0xe9 > + .long \l_yes - 2f > +2: > + .pushsection __jump_table, "aw" > + _ASM_ALIGN > + _ASM_PTR 1b, \l_yes, \key + \branch > + .popsection > +.endm > + > #endif /* __ASSEMBLY__ */ > > #endif This also allows the below, the old macros were slightly easier to understand, but not in wide use, in fact, only a single user, so I see no point in preserving them. --- --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -67,38 +67,6 @@ struct jump_entry { #else /* __ASSEMBLY__ */ -.macro STATIC_JUMP_IF_TRUE target, key, def -.Lstatic_jump_\@: - .if \def - /* Equivalent to "jmp.d32 \target" */ - .byte 0xe9 - .long \target - .Lstatic_jump_after_\@ -.Lstatic_jump_after_\@: - .else - .byte STATIC_KEY_INIT_NOP - .endif - .pushsection __jump_table, "aw" - _ASM_ALIGN - _ASM_PTR .Lstatic_jump_\@, \target, \key - .popsection -.endm - -.macro STATIC_JUMP_IF_FALSE target, key, def -.Lstatic_jump_\@: - .if \def - .byte STATIC_KEY_INIT_NOP - .else - /* Equivalent to "jmp.d32 \target" */ - .byte 0xe9 - .long \target - .Lstatic_jump_after_\@ -.Lstatic_jump_after_\@: - .endif - .pushsection __jump_table, "aw" - _ASM_ALIGN - _ASM_PTR .Lstatic_jump_\@, \target, \key + 1 - .popsection -.endm - .macro STATIC_BRANCH_NOP l_yes:req key:req branch:req 1: .byte STATIC_KEY_INIT_NOP diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index 352e70cd33e8..7c0d2ace8839 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h @@ -338,7 +338,7 @@ For 32-bit we have the following conventions - kernel is built with .macro CALL_enter_from_user_mode #ifdef CONFIG_CONTEXT_TRACKING #ifdef HAVE_JUMP_LABEL - STATIC_JUMP_IF_FALSE .Lafter_call_\@, context_tracking_enabled, def=0 + STATIC_BRANCH_JMP .Lafter_call_\@, context_tracking_enabled, 1 #endif call enter_from_user_mode .Lafter_call_\@: