From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jann Horn <jannh@google.com>, Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
the arch/x86 maintainers <x86@kernel.org>,
kernel list <linux-kernel@vger.kernel.org>,
alexandre.chartre@oracle.com
Subject: Re: x86 entry perf unwinding failure (missing IRET_REGS annotation on stack switch?)
Date: Tue, 28 Apr 2020 16:35:36 +0200 [thread overview]
Message-ID: <20200428143536.GC13592@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200428141457.4il3bgjjhifs47zc@treble>
On Tue, Apr 28, 2020 at 09:14:57AM -0500, Josh Poimboeuf wrote:
> On Tue, Apr 28, 2020 at 02:46:27PM +0200, Peter Zijlstra wrote:
> > > I'm thinking something like this should fix it. Peter, does this look
> > > ok?
> >
> > Unfortunate. But also, I fear, insufficient. Specifically consider
> > things like:
> >
> > ALTERNATIVE "jmp 1f",
> > "alt...
> > "..."
> > "...insn", X86_FEAT_foo
> > 1:
> >
> > This results in something like:
> >
> >
> > .text .altinstr_replacement
> > e8 xx ...
> > 90
> > 90
> > ...
> > 90
> >
> > Where all our normal single byte nops (0x90) are unreachable with
> > undefined CFI, but the alternative might have CFI, which is never
> > propagated.
> >
> > We ran into this with the validate_alternative stuff from Alexandre.
>
> I don't get what you're saying. We decided not to allow CFI changes in
> alternatives. And how does this relate to my patch?
Ah, I went with a slightly looser invariant rule that allows CFI but
ensures they're the same for all alternatives, and the above orig text
has a giant unreachable hole (that we don't report because NOP), I'm
allowing the alternative CFI changes in that.
Maybe that's too much leaway, but I'm thinking it ought to work.
> > > @@ -773,12 +772,26 @@ static int handle_group_alt(struct objtool_file *file,
> > > struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL;
> > > unsigned long dest_off;
> > >
> > > + /*
> > > + * For uaccess checking, propagate the STAC/CLAC from the alternative
> > > + * to the original insn to avoid paths where we see the STAC but then
> > > + * take the NOP instead of CLAC (and vice versa).
> > > + */
> > > + if (!orig_insn->ignore_alts && orig_insn->type == INSN_NOP &&
> > > + *new_insn &&
> > > + ((*new_insn)->type == INSN_STAC ||
> > > + (*new_insn)->type == INSN_CLAC))
> > > + orig_insn->type = (*new_insn)->type;
> >
> > Also, this generates a mis-match between actual instruction text and
> > type. We now have a single byte instruction (0x90) with the type of a 3
> > byte (SLAC/CLAC). Which currently isn't a problem, but I'm looking at
> > adding infrastructure for having objtool rewrite instructions.
>
> But it doesn't actually change the original instruction bytes, it just
> changes the decoding. Is that really going to be a problem? We do that
> in other places as well, and it helps simplify code flow.
It will probably work just fine, it just feels off to me.
> Also might I ask why you're going to be rewriting instructions? That
> sounds scary.
Variable length jump label support, I can't make gnu-as (I so hate that
thing) emit the right instruction at compile-time :/
> > So rather than hacking around this issue, should we not make
> > create_orc() smarter?
>
> Maybe, though I don't see how that logic belongs in create_orc(). It
> might be tricky distinguishing between normal undefined and "undefined
> because of a skip_orig". Right now create_orc() is blissfully ignorant.
Yeah, you're right. I'll look for a better place to stick it. Perhaps I
can frob it in validate_branch() somewhere.
And you're also right on the unreachable because of skip_orig thing,
I'll thnk about that.
next prev parent reply other threads:[~2020-04-28 14:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-01 6:02 x86 entry perf unwinding failure (missing IRET_REGS annotation on stack switch?) Jann Horn
2020-03-02 14:58 ` Peter Zijlstra
2020-03-02 15:18 ` Josh Poimboeuf
2020-03-02 15:52 ` Josh Poimboeuf
2020-04-28 7:04 ` Josh Poimboeuf
2020-04-28 12:46 ` Peter Zijlstra
2020-04-28 14:14 ` Josh Poimboeuf
2020-04-28 14:35 ` Peter Zijlstra [this message]
2020-04-28 14:16 ` Peter Zijlstra
2020-04-28 14:31 ` Josh Poimboeuf
2020-04-28 15:25 ` Peter Zijlstra
2020-04-28 15:49 ` Josh Poimboeuf
2020-04-28 15:54 ` Josh Poimboeuf
2020-04-28 16:25 ` Sean Christopherson
2020-04-28 16:33 ` Josh Poimboeuf
2020-04-28 18:28 ` Peter Zijlstra
2020-04-28 16:44 ` Peter Zijlstra
2020-04-28 17:01 ` Josh Poimboeuf
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=20200428143536.GC13592@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=alexandre.chartre@oracle.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.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;
as well as URLs for NNTP newsgroup(s).