[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180123101532.obioudsu3ecm4rez@gmail.com>
Date: Tue, 23 Jan 2018 11:15:32 +0100
From: Ingo Molnar <mingo@...nel.org>
To: David Woodhouse <dwmw2@...radead.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
KarimAllah Ahmed <karahmed@...zon.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
Arjan van de Ven <arjan@...ux.intel.com>,
Ashok Raj <ashok.raj@...el.com>,
Asit Mallick <asit.k.mallick@...el.com>,
Borislav Petkov <bp@...e.de>,
Dan Williams <dan.j.williams@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"H . Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Janakarajan Natarajan <Janakarajan.Natarajan@....com>,
Joerg Roedel <joro@...tes.org>,
Jun Nakajima <jun.nakajima@...el.com>,
Laura Abbott <labbott@...hat.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Radim Krčmář <rkrcmar@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Tom Lendacky <thomas.lendacky@....com>,
KVM list <kvm@...r.kernel.org>,
the arch/x86 maintainers <x86@...nel.org>,
Arjan Van De Ven <arjan.van.de.ven@...el.com>
Subject: Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict
Indirect Branch Speculation
* David Woodhouse <dwmw2@...radead.org> wrote:
> On Tue, 2018-01-23 at 08:53 +0100, Ingo Molnar wrote:
> >
> > The patch below demonstrates the principle, it forcibly enables dynamic ftrace
> > patching (CONFIG_DYNAMIC_FTRACE=y et al) and turns mcount/__fentry__ into a RET:
> >
> > ffffffff81a01a40 <__fentry__>:
> > ffffffff81a01a40: c3 retq
> >
> > This would have to be extended with (very simple) call stack depth tracking (just
> > 3 more instructions would do in the fast path I believe) and a suitable SkyLake
> > workaround (and also has to play nice with the ftrace callbacks).
> >
> > On non-SkyLake the overhead would be 0 cycles.
>
> The overhead of forcing CONFIG_DYNAMIC_FTRACE=y is precisely zero
> cycles? That seems a little optimistic. ;)
The overhead of the quick hack patch I sent to show what exact code I mean is
obviously not zero.
The overhead of using my proposed solution, to utilize the function call callback
that CONFIG_DYNAMIC_FTRACE=y provides, is exactly zero on non-SkyLake systems
where the callback is patched out, on typical Linux distros.
The callback is widely enabled on distro kernels:
Fedora: CONFIG_DYNAMIC_FTRACE=y
Ubuntu: CONFIG_DYNAMIC_FTRACE=y
OpenSuse (default flavor): CONFIG_DYNAMIC_FTRACE=y
BTW., the reason this is enabled on all distro kernels is because the overhead is
a single patched-in NOP instruction in the function epilogue, when tracing is
disabled. So it's not even a CALL+RET - it's a patched in NOP.
Thanks,
Ingo
Powered by blists - more mailing lists