[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180125124554.vdx7rrnfrxrzl2ng@pd.tnic>
Date: Thu, 25 Jan 2018 13:45:54 +0100
From: Borislav Petkov <bp@...en8.de>
To: David Woodhouse <dwmw2@...radead.org>
Cc: tim.c.chen@...ux.intel.com, pjt@...gle.com, jikos@...nel.org,
gregkh@...ux-foundation.org, dave.hansen@...el.com,
mingo@...nel.org, riel@...hat.com, luto@...capital.net,
torvalds@...ux-foundation.org, ak@...ux.intel.com,
keescook@...gle.com, jpoimboe@...hat.com, peterz@...radead.org,
tglx@...utronix.de, hpa@...or.com, linux-kernel@...r.kernel.org,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/pti] x86/retpoline: Fill return stack buffer on vmexit
On Thu, Jan 25, 2018 at 12:20:49PM +0000, David Woodhouse wrote:
> I haven't had lunch yet, so I don't feel queasy
Oh, I caught you on time then :-)
> and I'm vaguely interested... *why* does it break kABI?
Kernels < 4.1 don't have the insn padding I did back then so when one
tries to backport this, struct alt_instr size changes. Fun.
> > +/* Like alternative_io, but for replacing a direct call with another one. */
> > +#define alternative_void_call(oldfunc, newfunc, feature, input...) \
> > + asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \
> > + : : [old] "i" (oldfunc), [new] "i" (newfunc), ## input)
>
> But you aren't doing the call at all in the other case, and
> alternatives *always* handled the case where the first 'alternative'
> instruction was a branch, didn't it?
>
> So couldn't it just be alternative(nop, call __fill_rsb_func)?
>
> But I still don't understand why it matters.
You need for both to be CALL instructions there so that gcc can manage
the callee clobbers properly - i.e., recognize that there's a function
call there.
Otherwise you need to do uglies like the hunk in arch/x86/Kconfig in
d61931d89be5 ("x86: Add optimized popcnt variants")
which I killed later after all as it broke profiling and other tools.
And besides, calling a NOPpy function on CONFIG_RETPOLINE=n is the least
of our troubles. Also, the installations running CONFIG_RETPOLINE=n are
going to be a very very very small number.
> > +void __fill_rsb(void)
> > +{
> > + unsigned long loops;
> > +
> > + asm volatile (__stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1))
> > + : "=r" (loops), ASM_CALL_CONSTRAINT
> > + : : "memory" );
> > +}
> > +#endif
>
> The out-of-line function should be __clear_rsb() if it's using
> RSB_CLEAR_LOOPS, and __fill_rsb() if it's using RSB_FILL_LOOPS. I think
> we're only using one right now but Andi at least is posting patches
> which use the other, as part of the Skylake clusterfuck.
Ok.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
Powered by blists - more mailing lists