<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/scripts/recordmcount.c, branch v5.4.58</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.58</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.58'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-01-29T15:45:27Z</updated>
<entry>
<title>ARM: 8950/1: ftrace/recordmcount: filter relocation types</title>
<updated>2020-01-29T15:45:27Z</updated>
<author>
<name>Alex Sverdlin</name>
<email>alexander.sverdlin@nokia.com</email>
</author>
<published>2020-01-08T14:57:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bccb1568bae8b7adf4de980b2843fecbe9c52c5e'/>
<id>urn:sha1:bccb1568bae8b7adf4de980b2843fecbe9c52c5e</id>
<content type='text'>
commit 927d780ee371d7e121cea4fc7812f6ef2cea461c upstream.

Scenario 1, ARMv7
=================

If code in arch/arm/kernel/ftrace.c would operate on mcount() pointer
the following may be generated:

00000230 &lt;prealloc_fixed_plts&gt;:
 230:   b5f8            push    {r3, r4, r5, r6, r7, lr}
 232:   b500            push    {lr}
 234:   f7ff fffe       bl      0 &lt;__gnu_mcount_nc&gt;
                        234: R_ARM_THM_CALL     __gnu_mcount_nc
 238:   f240 0600       movw    r6, #0
                        238: R_ARM_THM_MOVW_ABS_NC      __gnu_mcount_nc
 23c:   f8d0 1180       ldr.w   r1, [r0, #384]  ; 0x180

FTRACE currently is not able to deal with it:

WARNING: CPU: 0 PID: 0 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1ad/0x230()
...
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.116-... #1
...
[&lt;c0314e3d&gt;] (unwind_backtrace) from [&lt;c03115e9&gt;] (show_stack+0x11/0x14)
[&lt;c03115e9&gt;] (show_stack) from [&lt;c051a7f1&gt;] (dump_stack+0x81/0xa8)
[&lt;c051a7f1&gt;] (dump_stack) from [&lt;c0321c5d&gt;] (warn_slowpath_common+0x69/0x90)
[&lt;c0321c5d&gt;] (warn_slowpath_common) from [&lt;c0321cf3&gt;] (warn_slowpath_null+0x17/0x1c)
[&lt;c0321cf3&gt;] (warn_slowpath_null) from [&lt;c038ee9d&gt;] (ftrace_bug+0x1ad/0x230)
[&lt;c038ee9d&gt;] (ftrace_bug) from [&lt;c038f1f9&gt;] (ftrace_process_locs+0x27d/0x444)
[&lt;c038f1f9&gt;] (ftrace_process_locs) from [&lt;c08915bd&gt;] (ftrace_init+0x91/0xe8)
[&lt;c08915bd&gt;] (ftrace_init) from [&lt;c0885a67&gt;] (start_kernel+0x34b/0x358)
[&lt;c0885a67&gt;] (start_kernel) from [&lt;00308095&gt;] (0x308095)
---[ end trace cb88537fdc8fa200 ]---
ftrace failed to modify [&lt;c031266c&gt;] prealloc_fixed_plts+0x8/0x60
 actual: 44:f2:e1:36
ftrace record flags: 0
 (0)   expected tramp: c03143e9

Scenario 2, ARMv4T
==================

ftrace: allocating 14435 entries in 43 pages
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2029 ftrace_bug+0x204/0x310
CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.5 #1
Hardware name: Cirrus Logic EDB9302 Evaluation Board
[&lt;c0010a24&gt;] (unwind_backtrace) from [&lt;c000ecb0&gt;] (show_stack+0x20/0x2c)
[&lt;c000ecb0&gt;] (show_stack) from [&lt;c03c72e8&gt;] (dump_stack+0x20/0x30)
[&lt;c03c72e8&gt;] (dump_stack) from [&lt;c0021c18&gt;] (__warn+0xdc/0x104)
[&lt;c0021c18&gt;] (__warn) from [&lt;c0021d7c&gt;] (warn_slowpath_null+0x4c/0x5c)
[&lt;c0021d7c&gt;] (warn_slowpath_null) from [&lt;c0095360&gt;] (ftrace_bug+0x204/0x310)
[&lt;c0095360&gt;] (ftrace_bug) from [&lt;c04dabac&gt;] (ftrace_init+0x3b4/0x4d4)
[&lt;c04dabac&gt;] (ftrace_init) from [&lt;c04cef4c&gt;] (start_kernel+0x20c/0x410)
[&lt;c04cef4c&gt;] (start_kernel) from [&lt;00000000&gt;] (  (null))
---[ end trace 0506a2f5dae6b341 ]---
ftrace failed to modify
[&lt;c000c350&gt;] perf_trace_sys_exit+0x5c/0xe8
 actual:   1e:ff:2f:e1
Initializing ftrace call sites
ftrace record flags: 0
 (0)
 expected tramp: c000fb24

The analysis for this problem has been already performed previously,
refer to the link below.

Fix the above problems by allowing only selected reloc types in
__mcount_loc. The list itself comes from the legacy recordmcount.pl
script.

Link: https://lore.kernel.org/lkml/56961010.6000806@pengutronix.de/
Cc: stable@vger.kernel.org
Fixes: ed60453fa8f8 ("ARM: 6511/1: ftrace: add ARM support for C version of recordmcount")
Signed-off-by: Alexander Sverdlin &lt;alexander.sverdlin@nokia.com&gt;
Acked-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
Signed-off-by: Russell King &lt;rmk+kernel@armlinux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>recordmcount: Clarify what cleanup() does</title>
<updated>2019-08-31T16:19:40Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-31T18:24:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4fbcf0741697a75eb766835cb34836cf4f3803da'/>
<id>urn:sha1:4fbcf0741697a75eb766835cb34836cf4f3803da</id>
<content type='text'>
cleanup() mostly frees/unmaps the malloc'd/privately-mapped
copy of the ELF file recordmcount is working on, which is
set up in mmap_file(). It also deals with positioning within
the pseduo prive-mapping of the file and appending to the ELF
file.

Split into two steps:
	mmap_cleanup() for the mapping itself
	file_append_cleanup() for allocations storing the
		appended ELF data.

Also, move the global variable initializations out of the main,
per-object-file loop and nearer to the alloc/init (mmap_file())
and two cleanup functions so we can more clearly see how they're
related.

Link: http://lkml.kernel.org/r/2a387ac86d133d22c68f57b9933c32bab1d09a2d.1564596289.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Remove redundant cleanup() calls</title>
<updated>2019-08-31T16:19:40Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-31T18:24:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c97fea26254b284c93a67b788968622f9cc03b30'/>
<id>urn:sha1:c97fea26254b284c93a67b788968622f9cc03b30</id>
<content type='text'>
Redundant cleanup calls were introduced when transitioning from
the old error/success handling via setjmp/longjmp -- the longjmp
ensured the cleanup() call only happened once but replacing
the success_file()/fail_file() calls with cleanup() meant that
multiple cleanup() calls can happen as we return from function
calls.

In do_file(), looking just before and after the "goto out" jumps we
can see that multiple cleanups() are being performed. We remove
cleanup() calls from the nested functions because it makes the code
easier to review -- the resources being cleaned up are generally
allocated and initialized in the callers so freeing them there
makes more sense.

Other redundant cleanup() calls:

mmap_file() is only called from do_file() and, if mmap_file() fails,
then we goto out and do cleanup() there too.

write_file() is only called from do_file() and do_file()
calls cleanup() unconditionally after returning from write_file()
therefore the cleanup() calls in write_file() are not necessary.

find_secsym_ndx(), called from do_func()'s for-loop, when we are
cleaning up here it's obvious that we break out of the loop and
do another cleanup().

__has_rel_mcount() is called from two parts of do_func()
and calls cleanup(). In theory we move them into do_func(), however
these in turn prove redundant so another simplification step
removes them as well.

Link: http://lkml.kernel.org/r/de197e17fc5426623a847ea7cf3a1560a7402a4b.1564596289.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Kernel style formatting</title>
<updated>2019-08-31T16:19:39Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-31T18:24:14Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2e63152bc1909e10b7bc844bbbef5a815f585b45'/>
<id>urn:sha1:2e63152bc1909e10b7bc844bbbef5a815f585b45</id>
<content type='text'>
Fix up the whitespace irregularity in the ELF switch
blocks.

Swapping the initial value of gpfx allows us to
simplify all but one of the one-line switch cases even
further.

Link: http://lkml.kernel.org/r/647f21f43723d3e831cedd3238c893db03eea6f0.1564596289.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Kernel style function signature formatting</title>
<updated>2019-08-31T16:19:39Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-31T18:24:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3aec8638246ff284e4075aac4f72ab160ebccaf2'/>
<id>urn:sha1:3aec8638246ff284e4075aac4f72ab160ebccaf2</id>
<content type='text'>
The uwrite() and ulseek() functions are formatted inconsistently
with the rest of the file and the kernel overall. While we're
making other changes here let's fix this.

Link: http://lkml.kernel.org/r/4c67698f734be9867a2aba7035fe0ce59e1e4423.1564596289.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Rewrite error/success handling</title>
<updated>2019-08-31T16:19:39Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-31T18:24:12Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3f1df12019f333442b12c3b5d110b8fc43eb0b36'/>
<id>urn:sha1:3f1df12019f333442b12c3b5d110b8fc43eb0b36</id>
<content type='text'>
Recordmcount uses setjmp/longjmp to manage control flow as
it reads and then writes the ELF file. This unusual control
flow is hard to follow and check in addition to being unlike
kernel coding style.

So we rewrite these paths to use regular return values to
indicate error/success. When an error or previously-completed object
file is found we return an error code following kernel
coding conventions -- negative error values and 0 for success when
we're not returning a pointer. We return NULL for those that fail
and return non-NULL pointers otherwise.

One oddity is already_has_rel_mcount -- there we use pointer comparison
rather than string comparison to differentiate between
previously-processed object files and returning the name of a text
section.

Link: http://lkml.kernel.org/r/8ba8633d4afe444931f363c8d924bf9565b89a86.1564596289.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Remove unused fd from uwrite() and ulseek()</title>
<updated>2019-08-31T16:19:38Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-24T21:04:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=17e262e9954bc3b6c857670f60b5b015f53509a7'/>
<id>urn:sha1:17e262e9954bc3b6c857670f60b5b015f53509a7</id>
<content type='text'>
uwrite() works within the pseudo-mapping and extends it as necessary
without needing the file descriptor (fd) parameter passed to it.
Similarly, ulseek() doesn't need its fd parameter. These parameters
were only added because the functions bear a conceptual resemblance
to write() and lseek(). Worse, they obscure the fact that at the time
uwrite() and ulseek() are called fd_map is not a valid file descriptor.

Remove the unused file descriptor parameters that make it look like
fd_map is still valid.

Link: http://lkml.kernel.org/r/2a136e820ee208469d375265c7b8eb28570749a0.1563992889.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Remove uread()</title>
<updated>2019-08-31T16:19:38Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-24T21:04:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a146207916092a49bd01ef861ac9582fd318c21a'/>
<id>urn:sha1:a146207916092a49bd01ef861ac9582fd318c21a</id>
<content type='text'>
uread() is only used to initialize the ELF file's pseudo
private-memory mapping while uwrite() and ulseek() work within
the pseudo-mapping and extend it as necessary.  Thus it is not
a complementary function to uwrite() and ulseek(). It also makes
no sense to do cleanups inside uread() when its only caller,
mmap_file(), is doing the relevant allocations and associated
initializations.

Therefore it's clearer to use a plain read() call to initialize the
data in mmap_file() and remove uread().

Link: http://lkml.kernel.org/r/31a87c22b19150cec1c8dc800c8b0873a2741703.1563992889.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>recordmcount: Remove redundant strcmp</title>
<updated>2019-08-31T16:19:38Z</updated>
<author>
<name>Matt Helsley</name>
<email>mhelsley@vmware.com</email>
</author>
<published>2019-07-24T21:04:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1bd95be204aa3c9456e950d5ab36588dbdbb05f1'/>
<id>urn:sha1:1bd95be204aa3c9456e950d5ab36588dbdbb05f1</id>
<content type='text'>
The strcmp is unnecessary since .text is already accepted as a
prefix in the strncmp().

Link: http://lkml.kernel.org/r/358e590b49adbe4185e161a8b364e323f3d52857.1563992889.git.mhelsley@vmware.com

Signed-off-by: Matt Helsley &lt;mhelsley@vmware.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 378</title>
<updated>2019-06-05T15:37:10Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2019-05-31T08:09:38Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4317cf95ca02411cf788d10c1972a38582e8c34d'/>
<id>urn:sha1:4317cf95ca02411cf788d10c1972a38582e8c34d</id>
<content type='text'>
Based on 1 normalized pattern(s):

  licensed under the gnu general public license version 2 gplv2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 5 file(s).

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Kate Stewart &lt;kstewart@linuxfoundation.org&gt;
Reviewed-by: Armijn Hemel &lt;armijn@tjaldur.nl&gt;
Reviewed-by: Allison Randal &lt;allison@lohutok.net&gt;
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531081036.993848054@linutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
