mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Nadav Amit <namit@vmware.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Philippe Ombredanne <pombredanne@nexb.com>
Subject: Re: [PATCH v5 9/9] x86: jump-labels: use macros instead of inline assembly
Date: Wed, 20 Jun 2018 15:06:24 +0200	[thread overview]
Message-ID: <20180620130624.GC2530@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180619194854.69486-10-namit@vmware.com>

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_\@:

  reply	other threads:[~2018-06-20 13:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 19:48 [PATCH v5 0/9] x86: macrofying inline asm for better compilation Nadav Amit
2018-06-19 19:48 ` [PATCH v5 1/9] Makefile: Prepare for using macros for inline asm Nadav Amit
2018-06-19 19:48 ` [PATCH v5 2/9] x86: objtool: use asm macro for better compiler decisions Nadav Amit
2018-06-19 19:48 ` [PATCH v5 3/9] x86: refcount: prevent gcc distortions Nadav Amit
2018-06-19 19:48 ` [PATCH v5 4/9] x86: alternatives: macrofy locks for better inlining Nadav Amit
2018-06-19 19:48 ` [PATCH v5 5/9] x86: bug: prevent gcc distortions Nadav Amit
2018-06-19 19:48 ` [PATCH v5 6/9] x86: prevent inline distortion by paravirt ops Nadav Amit
2018-06-20  5:05   ` kbuild test robot
2018-06-20 10:10   ` Peter Zijlstra
2018-06-19 19:48 ` [PATCH v5 7/9] x86: extable: use macros instead of inline assembly Nadav Amit
2018-06-19 19:48 ` [PATCH v5 8/9] x86: cpufeature: " Nadav Amit
2018-06-19 19:48 ` [PATCH v5 9/9] x86: jump-labels: " Nadav Amit
2018-06-20 13:06   ` Peter Zijlstra [this message]
2018-06-20 10:11 ` [PATCH v5 0/9] x86: macrofying inline asm for better compilation Peter Zijlstra
2018-06-20 16:47   ` Nadav Amit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180620130624.GC2530@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namit@vmware.com \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome