From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Jason Baron <jbaron@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
"H. Peter Anvin" <hpa@linux.intel.com>
Subject: [PATCH 1/5 v2] x86/jump-label: Use best default nops for inital jump label calls
Date: Sat, 28 Jan 2012 11:09:26 -0500 [thread overview]
Message-ID: <20120128161626.576232970@goodmis.org> (raw)
In-Reply-To: 20120128160925.275163704@goodmis.org
[-- Attachment #1: Type: text/plain, Size: 1615 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
As specified by H. Peter Anvin, the best nops for x86 without knowing
the running computer is:
32bit:
0x3e, 0x8d, 0x74, 0x26, 0x00 also known as GENERIC_NOP5_ATOMIC
64bit:
0x0f, 0x1f, 0x44, 0x00, 0x00 also known as P6_NOP5_ATOMIC
Currently the default nop that is used by jump label is:
0xe9 0x00 0x00 0x00 0x00
Which is really a 5byte jump to the next position.
It's better to use a real nop than a jmp.
Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
arch/x86/include/asm/jump_label.h | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index a32b18c..7082743 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -3,18 +3,23 @@
#ifdef __KERNEL__
+#include <linux/stringify.h>
#include <linux/types.h>
#include <asm/nops.h>
#include <asm/asm.h>
#define JUMP_LABEL_NOP_SIZE 5
-#define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
+#ifdef CONFIG_X86_64
+# define JUMP_LABEL_INIT_NOP P6_NOP5_ATOMIC
+#else
+# define JUMP_LABEL_INIT_NOP GENERIC_NOP5_ATOMIC
+#endif
static __always_inline bool arch_static_branch(struct jump_label_key *key)
{
asm goto("1:"
- JUMP_LABEL_INITIAL_NOP
+ ".byte " __stringify(JUMP_LABEL_INIT_NOP) "\n\t"
".pushsection __jump_table, \"aw\" \n\t"
_ASM_ALIGN "\n\t"
_ASM_PTR "1b, %l[l_yes], %c0 \n\t"
--
1.7.8.3
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-01-28 16:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-28 16:09 [PATCH 0/5 v2] [GIT PULL] x86/jump label: Paranoid checks and 2 or 5 byte nops Steven Rostedt
2012-01-28 16:09 ` Steven Rostedt [this message]
2012-01-28 16:09 ` [PATCH 2/5 v2] x86/jump-label: Do not bother updating nops if they are correct Steven Rostedt
2012-01-28 16:09 ` [PATCH 3/5 v2] x86/jump-label: Add safety checks to jump label conversions Steven Rostedt
2012-01-28 16:09 ` [PATCH 4/5 v2] jump labels: Add infrastructure to update jump labels at compile time Steven Rostedt
2012-01-28 16:09 ` [PATCH 5/5 v2] x86/jump labels: Use etiher 5 byte or 2 byte jumps Steven Rostedt
2012-01-30 14:48 ` [PATCH 0/5 v2] [GIT PULL] x86/jump label: Paranoid checks and 2 or 5 byte nops Ingo Molnar
2012-01-30 15:07 ` Steven Rostedt
2012-01-31 19:48 ` Ingo Molnar
2012-02-01 5:08 ` Steven Rostedt
2012-02-01 8:05 ` Ingo Molnar
2012-02-01 13:20 ` Steven Rostedt
2012-02-01 15:21 ` Steven Rostedt
2012-02-02 13:51 ` Ingo Molnar
2012-02-02 14:10 ` H. Peter Anvin
2012-02-02 14:31 ` Steven Rostedt
2012-02-02 22:04 ` Steven Rostedt
2012-02-02 22:07 ` H. Peter Anvin
2012-02-02 22:53 ` Steven Rostedt
2012-02-03 7:36 ` Ingo Molnar
2012-02-03 13:31 ` Steven Rostedt
2012-02-05 11:47 ` Ingo Molnar
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=20120128161626.576232970@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.