From: Borislav Petkov <bp@alien8.de>
To: Andy Lutomirski <luto@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>, x86-ml <x86@kernel.org>,
Joerg Roedel <jroedel@suse.de>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Have insn decoder functions return success/failure
Date: Fri, 23 Oct 2020 11:20:10 +0200 [thread overview]
Message-ID: <20201023092010.GB23324@zn.tnic> (raw)
In-Reply-To: <CALCETrWhzzZ=EAoKZ4=k3FjffvS_3R4o5N1Rkj9FkHQdiUag6A@mail.gmail.com>
On Thu, Oct 22, 2020 at 10:58:32AM -0700, Andy Lutomirski wrote:
> I'm guessing that the confusion here is that the kernel instruction
> decoder was originally designed to be used to decode kernel
> instructions, which are generally trusted to be valid, but that it's
> starting to be used to decode user code and such as well.
>
> Masami, could we perhaps have an extra API like:
>
> extern int insn_decode_fully(struct insn *insn);
insn_decode(). Simple. :)
> that decodes the *entire* instruction, returns success if the decoder
> thinks the instruction is valid, and returns an error if the decoder
> thinks it's invalid?
Yap, exactly.
> We would use this when decoding arbitrary bytes
> when we're not really sure that there's a valid instruction there.
> For user code emulation, we don't really care much about performance
> -- the overhead of getting #GP in the first place is much, much higher
> than the overhead of decoding more of the instruction than needed.
Ack.
> Ideally we would solve another little problem at the same time. Right
> now, we are quite sloppy about how we fetch the instruction bytes, and
> it might be nice to fix this. It would be nice if we could have a
> special error code saying "more bytes are needed". So
> insn_decode_fully() would return 0 (or the length) on a successful
> decode, -EINVAL if the bytes are not a valid instruction, and -EAGAIN
> (or something more appropriate) if the bytes are a valid *prefix* of
> an instruction but more bytes are needed. Then the caller would do:
Yah, lemme see if that can be done easily.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2020-10-23 9:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 12:02 Borislav Petkov
2020-10-20 14:27 ` Masami Hiramatsu
2020-10-20 14:37 ` Borislav Petkov
2020-10-21 0:50 ` Masami Hiramatsu
2020-10-21 9:27 ` Borislav Petkov
2020-10-21 14:26 ` Masami Hiramatsu
2020-10-21 16:45 ` Borislav Petkov
2020-10-22 7:31 ` Masami Hiramatsu
2020-10-22 9:30 ` Borislav Petkov
2020-10-22 13:21 ` Masami Hiramatsu
2020-10-22 17:58 ` Andy Lutomirski
2020-10-23 9:20 ` Borislav Petkov [this message]
2020-10-23 9:28 ` Masami Hiramatsu
2020-10-23 9:32 ` Borislav Petkov
2020-10-23 10:47 ` Masami Hiramatsu
2020-10-23 23:27 ` Borislav Petkov
2020-10-24 0:12 ` Andy Lutomirski
2020-10-24 7:21 ` Masami Hiramatsu
2020-10-24 8:23 ` Borislav Petkov
2020-10-24 16:10 ` Andy Lutomirski
2020-10-27 13:42 ` Borislav Petkov
2020-10-28 11:36 ` Masami Hiramatsu
2020-10-24 7:13 ` Masami Hiramatsu
2020-10-24 8:24 ` Borislav Petkov
2020-10-29 12:42 ` Borislav Petkov
2020-10-30 1:24 ` Masami Hiramatsu
2020-10-30 13:07 ` Borislav Petkov
2020-10-23 9:17 ` Borislav Petkov
2020-10-22 8:04 ` 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=20201023092010.GB23324@zn.tnic \
--to=bp@alien8.de \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--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®