<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/x86/kernel/ftrace.c, branch linux-5.18.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.18.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.18.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-08-17T12:42:19Z</updated>
<entry>
<title>ftrace/x86: Add back ftrace_expected assignment</title>
<updated>2022-08-17T12:42:19Z</updated>
<author>
<name>Steven Rostedt (Google)</name>
</author>
<published>2022-07-26T14:18:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=95229ca105750198d660e143907a9294ce32d6b2'/>
<id>urn:sha1:95229ca105750198d660e143907a9294ce32d6b2</id>
<content type='text'>
commit ac6c1b2ca77e722a1e5d651f12f437f2f237e658 upstream.

When a ftrace_bug happens (where ftrace fails to modify a location) it is
helpful to have what was at that location as well as what was expected to
be there.

But with the conversion to text_poke() the variable that assigns the
expected for debugging was dropped. Unfortunately, I noticed this when I
needed it. Add it back.

Link: https://lkml.kernel.org/r/20220726101851.069d2e70@gandalf.local.home

Cc: "x86@kernel.org" &lt;x86@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: stable@vger.kernel.org
Fixes: 768ae4406a5c ("x86/ftrace: Use text_poke()")
Signed-off-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>x86/ftrace: Use alternative RET encoding</title>
<updated>2022-07-23T10:56:44Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2022-06-14T21:15:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d15b9c30cb222d0e5ac2ff9ba7b93bd9af82d05'/>
<id>urn:sha1:0d15b9c30cb222d0e5ac2ff9ba7b93bd9af82d05</id>
<content type='text'>
commit 1f001e9da6bbf482311e45e48f53c2bd2179e59c upstream.

Use the return thunk in ftrace trampolines, if needed.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Reviewed-by: Josh Poimboeuf &lt;jpoimboe@kernel.org&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Signed-off-by: Thadeu Lima de Souza Cascardo &lt;cascardo@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>x86/ibt,ftrace: Make function-graph play nice</title>
<updated>2022-03-15T09:32:37Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2022-03-08T15:30:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e52fc2cf3f662828cc0d51c4b73bed73ad275fce'/>
<id>urn:sha1:e52fc2cf3f662828cc0d51c4b73bed73ad275fce</id>
<content type='text'>
Return trampoline must not use indirect branch to return; while this
preserves the RSB, it is fundamentally incompatible with IBT. Instead
use a retpoline like ROP gadget that defeats IBT while not unbalancing
the RSB.

And since ftrace_stub is no longer a plain RET, don't use it to copy
from. Since RET is a trivial instruction, poke it directly.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Acked-by: Josh Poimboeuf &lt;jpoimboe@redhat.com&gt;
Link: https://lore.kernel.org/r/20220308154318.347296408@infradead.org
</content>
</entry>
<entry>
<title>x86: Add straight-line-speculation mitigation</title>
<updated>2021-12-09T12:32:25Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2021-12-04T13:43:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e463a09af2f0677b9485a7e8e4e70b396b2ffb6f'/>
<id>urn:sha1:e463a09af2f0677b9485a7e8e4e70b396b2ffb6f</id>
<content type='text'>
Make use of an upcoming GCC feature to mitigate
straight-line-speculation for x86:

  https://gcc.gnu.org/g:53a643f8568067d7700a9f2facc8ba39974973d3
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102952
  https://bugs.llvm.org/show_bug.cgi?id=52323

It's built tested on x86_64-allyesconfig using GCC-12 and GCC-11.

Maintenance overhead of this should be fairly low due to objtool
validation.

Size overhead of all these additional int3 instructions comes to:

     text	   data	    bss	    dec	    hex	filename
  22267751	6933356	2011368	31212475	1dc43bb	defconfig-build/vmlinux
  22804126	6933356	1470696	31208178	1dc32f2	defconfig-build/vmlinux.sls

Or roughly 2.4% additional text.

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Link: https://lore.kernel.org/r/20211204134908.140103474@infradead.org
</content>
</entry>
<entry>
<title>x86/ftrace: Make function graph use ftrace directly</title>
<updated>2021-10-21T03:44:43Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
</author>
<published>2021-10-08T09:13:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c0593b45c9b4e5b212ffb3fb28bb8d3c0ec0dc8'/>
<id>urn:sha1:0c0593b45c9b4e5b212ffb3fb28bb8d3c0ec0dc8</id>
<content type='text'>
We don't need special hook for graph tracer entry point,
but instead we can use graph_ops::func function to install
the return_hooker.

This moves the graph tracing setup _before_ the direct
trampoline prepares the stack, so the return_hooker will
be called when the direct trampoline is finished.

This simplifies the code, because we don't need to take into
account the direct trampoline setup when preparing the graph
tracer hooker and we can allow function graph tracer on entries
registered with direct trampoline.

Link: https://lkml.kernel.org/r/20211008091336.33616-4-jolsa@kernel.org

[fixed compile error reported by kernel test robot &lt;lkp@intel.com&gt;]
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>x86/ftrace: Remove fault protection code in prepare_ftrace_return</title>
<updated>2021-10-20T00:33:21Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
</author>
<published>2021-10-08T09:13:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8646698aefad7547dc7acee8f8c2099d7653dc70'/>
<id>urn:sha1:8646698aefad7547dc7acee8f8c2099d7653dc70</id>
<content type='text'>
Removing the fault protection code when writing return_hooker
to stack. As Steven noted:

&gt; That protection was there from the beginning due to being "paranoid",
&gt; considering ftrace was bricking network cards. But that protection
&gt; would not have even protected against that.

Link: https://lkml.kernel.org/r/20211008091336.33616-3-jolsa@kernel.org

Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>ftrace: Cleanup ftrace_dyn_arch_init()</title>
<updated>2021-10-08T23:41:39Z</updated>
<author>
<name>Weizhao Ouyang</name>
</author>
<published>2021-09-09T09:02:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6644c654ea70e0d8b8d5111e1272f8f29df00f21'/>
<id>urn:sha1:6644c654ea70e0d8b8d5111e1272f8f29df00f21</id>
<content type='text'>
Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
ftrace_dyn_arch_init() to cleanup them.

Link: https://lkml.kernel.org/r/20210909090216.1955240-1-o451686892@gmail.com

Acked-by: Heiko Carstens &lt;hca@linux.ibm.com&gt; (s390)
Acked-by: Helge Deller &lt;deller@gmx.de&gt; (parisc)
Signed-off-by: Weizhao Ouyang &lt;o451686892@gmail.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>x86: Remove dynamic NOP selection</title>
<updated>2021-03-15T15:24:59Z</updated>
<author>
<name>Peter Zijlstra</name>
</author>
<published>2021-03-12T11:32:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a89dfde3dc3c2dbf56910af75e2d8b11ec5308f6'/>
<id>urn:sha1:a89dfde3dc3c2dbf56910af75e2d8b11ec5308f6</id>
<content type='text'>
This ensures that a NOP is a NOP and not a random other instruction that
is also a NOP. It allows simplification of dynamic code patching that
wants to verify existing code before writing new instructions (ftrace,
jump_label, static_call, etc..).

Differentiating on NOPs is not a feature.

This pessimises 32bit (DONTCARE) and 32bit on 64bit CPUs (CARELESS).
32bit is not a performance target.

Everything x86_64 since AMD K10 (2007) and Intel IvyBridge (2012) is
fine with using NOPL (as opposed to prefix NOP). And per FEATURE_NOPL
being required for x86_64, all x86_64 CPUs can use NOPL. So stop
caring about NOPs, simplify things and get on with life.

[ The problem seems to be that some uarchs can only decode NOPL on a
single front-end port while others have severe decode penalties for
excessive prefixes. All modern uarchs can handle both, except Atom,
which has prefix penalties. ]

[ Also, much doubt you can actually measure any of this on normal
workloads. ]

After this, FEATURE_NOPL is unused except for required-features for
x86_64. FEATURE_K8 is only used for PTI.

 [ bp: Kernel build measurements showed ~0.3s slowdown on Sandybridge
   which is hardly a slowdown. Get rid of X86_FEATURE_K7, while at it. ]

Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Borislav Petkov &lt;bp@suse.de&gt;
Acked-by: Alexei Starovoitov &lt;alexei.starovoitov@gmail.com&gt; # bpf
Acked-by: Linus Torvalds &lt;torvalds@linuxfoundation.org&gt;
Link: https://lkml.kernel.org/r/20210312115749.065275711@infradead.org
</content>
</entry>
<entry>
<title>x86/ftrace: Do not jump to direct code in created trampolines</title>
<updated>2020-06-29T15:42:48Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
</author>
<published>2020-04-22T16:25:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fe58acefd5a66d33a8fb94da53c3af4374b6d376'/>
<id>urn:sha1:fe58acefd5a66d33a8fb94da53c3af4374b6d376</id>
<content type='text'>
When creating a trampoline based on the ftrace_regs_caller code, nop out the
jnz test that would jmup to the code that would return to a direct caller
(stored in the ORIG_RAX field) and not back to the function that called it.

Link: http://lkml.kernel.org/r/20200422162750.638839749@goodmis.org

Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>x86/ftrace: Only have the builtin ftrace_regs_caller call direct hooks</title>
<updated>2020-06-29T15:42:47Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
</author>
<published>2020-04-22T16:25:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5da7cd11d0811c35a6988d416053b5421bc61521'/>
<id>urn:sha1:5da7cd11d0811c35a6988d416053b5421bc61521</id>
<content type='text'>
If a direct hook is attached to a function that ftrace also has a function
attached to it, then it is required that the ftrace_ops_list_func() is used
to iterate over the registered ftrace callbacks. This will also include the
direct ftrace_ops helper, that tells ftrace_regs_caller where to return to
(the direct callback and not the function that called it).

As this direct helper is only to handle the case of ftrace callbacks
attached to the same function as the direct callback, the ftrace callback
allocated trampolines (used to only call them), should never be used to
return back to a direct callback.

Only copy the portion of the ftrace_regs_caller that will return back to
what called it, and not the portion that returns back to the direct caller.

The direct ftrace_ops must then pick the ftrace_regs_caller builtin function
as its own trampoline to ensure that it will never have one allocated for
it (which would not include the handling of direct callbacks).

Link: http://lkml.kernel.org/r/20200422162750.495903799@goodmis.org

Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
