From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, brgerst@gmail.com, luto@kernel.org,
dvlasenk@redhat.com, arjan@linux.intel.com, hpa@zytor.com,
bp@alien8.de, peterz@infradead.org, jpoimboe@redhat.com,
torvalds@linux-foundation.org
Subject: [tip:x86/pti] x86/debug: Use UD2 for WARN()
Date: Wed, 14 Feb 2018 16:27:07 -0800 [thread overview]
Message-ID: <tip-3b3a371cc9bc980429baabe0a8e5f307f3d1f463@git.kernel.org> (raw)
In-Reply-To: <20180208194406.GD25181@hirez.programming.kicks-ass.net>
Commit-ID: 3b3a371cc9bc980429baabe0a8e5f307f3d1f463
Gitweb: https://git.kernel.org/tip/3b3a371cc9bc980429baabe0a8e5f307f3d1f463
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Fri, 9 Feb 2018 13:16:59 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 15 Feb 2018 01:15:50 +0100
x86/debug: Use UD2 for WARN()
Since the Intel SDM added an ModR/M byte to UD0 and binutils followed
that specification, we now cannot disassemble our kernel anymore.
This now means Intel and AMD disagree on the encoding of UD0. And instead
of playing games with additional bytes that are valid ModR/M and single
byte instructions (0xd6 for instance), simply use UD2 for both WARN() and
BUG().
Requested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20180208194406.GD25181@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/include/asm/bug.h | 15 ++++++---------
arch/x86/kernel/traps.c | 2 +-
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 71e6f4bf..6804d66 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -5,23 +5,20 @@
#include <linux/stringify.h>
/*
- * Since some emulators terminate on UD2, we cannot use it for WARN.
- * Since various instruction decoders disagree on the length of UD1,
- * we cannot use it either. So use UD0 for WARN.
+ * Despite that some emulators terminate on UD2, we use it for WARN().
*
- * (binutils knows about "ud1" but {en,de}codes it as 2 bytes, whereas
- * our kernel decoder thinks it takes a ModRM byte, which seems consistent
- * with various things like the Intel SDM instruction encoding rules)
+ * Since various instruction decoders/specs disagree on the encoding of
+ * UD0/UD1.
*/
-#define ASM_UD0 ".byte 0x0f, 0xff"
+#define ASM_UD0 ".byte 0x0f, 0xff" /* + ModRM (for Intel) */
#define ASM_UD1 ".byte 0x0f, 0xb9" /* + ModRM */
#define ASM_UD2 ".byte 0x0f, 0x0b"
#define INSN_UD0 0xff0f
#define INSN_UD2 0x0b0f
-#define LEN_UD0 2
+#define LEN_UD2 2
#ifdef CONFIG_GENERIC_BUG
@@ -79,7 +76,7 @@ do { \
#define __WARN_FLAGS(flags) \
do { \
- _BUG_FLAGS(ASM_UD0, BUGFLAG_WARNING|(flags)); \
+ _BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \
annotate_reachable(); \
} while (0)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 446c9ef..3d9b230 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -181,7 +181,7 @@ int fixup_bug(struct pt_regs *regs, int trapnr)
break;
case BUG_TRAP_TYPE_WARN:
- regs->ip += LEN_UD0;
+ regs->ip += LEN_UD2;
return 1;
}
next prev parent reply other threads:[~2018-02-15 0:37 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 11:44 [linus:master] BUILD REGRESSION a2e5790d841658485d642196dbb0927303d6c22f kbuild test robot
2018-02-07 18:13 ` Linus Torvalds
2018-02-07 18:35 ` Borislav Petkov
2018-02-07 18:49 ` Peter Zijlstra
2018-02-07 19:03 ` Linus Torvalds
2018-02-07 19:14 ` Peter Zijlstra
2018-02-07 19:28 ` Borislav Petkov
2018-02-07 19:43 ` Linus Torvalds
2018-02-07 20:24 ` Borislav Petkov
2018-02-08 9:13 ` Peter Zijlstra
2018-02-08 9:35 ` Peter Zijlstra
2018-02-08 9:46 ` Borislav Petkov
2018-02-08 9:47 ` David Laight
2018-02-08 10:13 ` Peter Zijlstra
2018-02-08 17:27 ` Linus Torvalds
2018-02-08 18:03 ` Peter Zijlstra
2018-02-08 18:15 ` Linus Torvalds
2018-02-08 19:44 ` Peter Zijlstra
2018-02-08 20:02 ` Linus Torvalds
2018-02-08 20:31 ` Borislav Petkov
2018-02-08 23:09 ` [PATCH 0/2] objtool fixes on top of Peter's WARN UD2 patch Josh Poimboeuf
2018-02-08 23:09 ` [PATCH 1/2] objtool: Fix seg fault in ignore_unreachable_insn() Josh Poimboeuf
2018-02-13 11:29 ` [tip:x86/pti] objtool: Fix segfault " tip-bot for Josh Poimboeuf
2018-02-15 0:26 ` tip-bot for Josh Poimboeuf
2018-02-08 23:09 ` [PATCH 2/2] x86: Annotate WARN-related UD2 as reachable Josh Poimboeuf
2018-02-13 11:30 ` [tip:x86/pti] x86/debug, objtool: Annotate WARN()-related " tip-bot for Josh Poimboeuf
2018-02-15 0:26 ` tip-bot for Josh Poimboeuf
2018-02-09 8:13 ` [PATCH 0/2] objtool fixes on top of Peter's WARN UD2 patch Peter Zijlstra
2018-02-09 8:12 ` [linus:master] BUILD REGRESSION a2e5790d841658485d642196dbb0927303d6c22f Peter Zijlstra
2018-02-13 11:30 ` [tip:x86/pti] x86/debug: Use UD2 for WARN() tip-bot for Peter Zijlstra
2018-02-15 0:27 ` tip-bot for Peter Zijlstra [this message]
2018-02-07 18:38 ` [linus:master] BUILD REGRESSION a2e5790d841658485d642196dbb0927303d6c22f Randy Dunlap
2018-02-07 19:01 ` Linus Torvalds
2018-02-07 19:06 ` Peter Zijlstra
2018-02-07 19:10 ` Peter Zijlstra
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=tip-3b3a371cc9bc980429baabe0a8e5f307f3d1f463@git.kernel.org \
--to=tipbot@zytor.com \
--cc=arjan@linux.intel.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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