From: Borislav Petkov <bp@alien8.de>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Willy Tarreau <w@1wt.eu>, Steven Rostedt <rostedt@goodmis.org>,
X86 ML <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Brian Gerst <brgerst@gmail.com>
Subject: Re: Dealing with the NMI mess
Date: Fri, 31 Jul 2015 10:03:03 +0200 [thread overview]
Message-ID: <20150731080303.GA2128@nazgul.tnic> (raw)
In-Reply-To: <CALCETrX4wrVhXToC9oqo3Ma+smKf_8bhHD-D2FGxj3iGZ=ag6g@mail.gmail.com>
On Thu, Jul 30, 2015 at 10:11:40PM -0700, Andy Lutomirski wrote:
> This instruction is awesome. Binutils can disassemble it (it's called
> "icebp") but it can't assemble it. KVM has special handling for it on
> VMX and actually reports it to QEMU on SVM (complete with a defined
> ABI).
Fun.
> We have an asm macro so we can assemble it for 32-bit but not
> 64-bit, despite the fact that it works on 64-bit.
>
> The kernel instruction decoder can't decode it.
Yeah, the kernel insn decoder needs to be fixed. Even my decoder can
decode it:
$ echo "0xf1" | ./x86d -
0: f1 icebp
Big deal. :-)
Let's do some fun and games:
$ cat icebp.c
int main()
{
asm volatile(".byte 0xf1");
return 0;
}
$ gcc -Wall -o icebp{,.c}
$ objdump -d icebp
...
00000000004004ac <main>:
4004ac: 55 push %rbp
4004ad: 48 89 e5 mov %rsp,%rbp
4004b0: f1 icebp
4004b1: b8 00 00 00 00 mov $0x0,%eax
4004b6: 5d pop %rbp
4004b7: c3 retq
4004b8: 90 nop
...
$ ./icebp
Trace/breakpoint trap
^ this in qemu.
On baremetal it gets a SIGTRAP with TRAP_BRKPT. Looks like signal
handling knows about it...
$ strace /tmp/icebp
execve("/tmp/icebp", ["/tmp/icebp"], [/* 27 vars */]) = 0
brk(0) = 0x1680000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f71e243d000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=127070, ...}) = 0
mmap(NULL, 127070, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f71e241d000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1729984, ...}) = 0
mmap(NULL, 3836448, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f71e1e76000
mprotect(0x7f71e2015000, 2097152, PROT_NONE) = 0
mmap(0x7f71e2215000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19f000) = 0x7f71e2215000
mmap(0x7f71e221b000, 14880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f71e221b000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f71e241c000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f71e241b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f71e241a000
arch_prctl(ARCH_SET_FS, 0x7f71e241b700) = 0
mprotect(0x7f71e2215000, 16384, PROT_READ) = 0
mprotect(0x7f71e243f000, 4096, PROT_READ) = 0
munmap(0x7f71e241d000, 127070) = 0
--- SIGTRAP {si_signo=SIGTRAP, si_code=TRAP_BRKPT, si_pid=4195505, si_uid=0} ---
+++ killed by SIGTRAP +++
Trace/breakpoint trap
> Fortunately, it looks like the vm86 case is correct (or as correct as
> any of the vm86 junk can be), although I haven't tested it. I bet
> that icebp is like int3 in that it punches through vm86 mode instead
> of sending #GP.
Yeah, INT 1. I wonder whether INT 1, i.e. CD imm8 does the same thing.
But why do you say it is special - it simply raises #DB, i.e. vector 1.
Web page seems to say so when interrupt redirection is disabled. It
sounds like a nice and quick way to generate a breakpoint. You can do
that with INT 01, i.e., the CD opcode, too.
If I'd had to guess, it isn't documented because of the proprietary ICE
aspect. And no one uses ICEs anymore so it is going to be forgotten with
people popping off and on and asking about the undocumented opcode.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
next prev parent reply other threads:[~2015-07-31 8:03 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 20:21 Andy Lutomirski
2015-07-23 20:38 ` Linus Torvalds
2015-07-23 20:49 ` Andy Lutomirski
2015-07-23 21:08 ` Linus Torvalds
2015-07-23 21:31 ` Steven Rostedt
2015-07-23 21:46 ` Willy Tarreau
2015-07-23 21:46 ` Andy Lutomirski
2015-07-23 21:50 ` Willy Tarreau
2015-07-23 21:48 ` Linus Torvalds
2015-07-23 21:50 ` Andy Lutomirski
2015-07-23 21:59 ` Linus Torvalds
2015-07-24 8:13 ` Peter Zijlstra
2015-07-24 9:02 ` Willy Tarreau
2015-07-24 11:58 ` Steven Rostedt
2015-07-24 12:43 ` Peter Zijlstra
2015-07-24 13:03 ` Steven Rostedt
2015-07-24 13:21 ` Willy Tarreau
2015-07-24 13:30 ` Peter Zijlstra
2015-07-24 13:33 ` Peter Zijlstra
2015-07-24 14:31 ` Steven Rostedt
2015-07-24 14:59 ` Willy Tarreau
2015-07-24 15:16 ` Steven Rostedt
2015-07-24 15:26 ` Willy Tarreau
2015-07-24 15:30 ` Peter Zijlstra
2015-07-24 15:33 ` Willy Tarreau
2015-07-24 18:29 ` Linus Torvalds
2015-07-24 18:41 ` Linus Torvalds
2015-07-24 19:05 ` Steven Rostedt
2015-07-24 19:55 ` Peter Zijlstra
2015-07-24 20:22 ` Linus Torvalds
2015-07-24 20:51 ` Peter Zijlstra
2015-07-24 21:07 ` Steven Rostedt
2015-07-24 21:08 ` Andy Lutomirski
2015-07-30 15:41 ` Paolo Bonzini
2015-07-30 21:22 ` Andy Lutomirski
2015-07-30 21:58 ` Brian Gerst
2015-07-30 22:59 ` Thomas Gleixner
2015-07-31 4:22 ` Borislav Petkov
2015-07-31 5:11 ` Andy Lutomirski
2015-07-31 7:51 ` Paolo Bonzini
2015-07-31 8:03 ` Borislav Petkov [this message]
2015-07-31 9:27 ` Paolo Bonzini
2015-07-31 10:25 ` Borislav Petkov
2015-07-31 10:26 ` Paolo Bonzini
2015-07-31 10:32 ` Borislav Petkov
2015-09-07 5:39 ` Maciej W. Rozycki
2015-09-07 7:42 ` Ingo Molnar
2015-09-07 8:19 ` Maciej W. Rozycki
2015-09-07 10:19 ` Paolo Bonzini
2015-09-07 17:01 ` Maciej W. Rozycki
2015-09-07 17:22 ` Andy Lutomirski
2015-09-07 19:30 ` Maciej W. Rozycki
2015-09-07 21:56 ` Andy Lutomirski
2015-09-08 16:21 ` Maciej W. Rozycki
2015-07-24 23:53 ` Linus Torvalds
2015-07-24 15:34 ` Steven Rostedt
2015-07-24 15:49 ` Willy Tarreau
2015-07-24 15:48 ` Andy Lutomirski
2015-07-24 16:02 ` Steven Rostedt
2015-07-24 16:08 ` Willy Tarreau
2015-07-24 16:31 ` Steven Rostedt
2015-07-24 16:06 ` Steven Rostedt
2015-07-24 16:25 ` Willy Tarreau
2015-07-24 17:21 ` Andy Lutomirski
2015-07-24 17:10 ` Willy Tarreau
2015-07-24 17:20 ` Andy Lutomirski
2015-07-30 15:54 ` Paolo Bonzini
2015-07-24 17:21 ` Willy Tarreau
2015-07-23 20:52 ` Willy Tarreau
2015-07-23 20:53 ` Andy Lutomirski
2015-07-23 21:07 ` Willy Tarreau
2015-07-23 21:13 ` Linus Torvalds
2015-07-23 21:18 ` Willy Tarreau
2015-07-23 21:20 ` Peter Zijlstra
2015-07-23 21:35 ` Linus Torvalds
2015-07-23 21:45 ` Andy Lutomirski
2015-07-23 21:54 ` Linus Torvalds
2015-07-23 21:59 ` Andy Lutomirski
2015-07-23 22:03 ` Linus Torvalds
2015-07-24 10:28 ` Peter Zijlstra
2015-07-24 11:06 ` Peter Zijlstra
2015-07-23 21:17 ` Peter Zijlstra
2015-07-23 21:20 ` Steven Rostedt
2015-07-23 21:46 ` Andy Lutomirski
2015-07-24 16:33 ` Raymond Jennings
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=20150731080303.GA2128@nazgul.tnic \
--to=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
--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
all inboxes | Powered by JetHome®