Skip to contentSkip to conversation

tracing: More fixes for v6.15

PATCH New Steven Rostedt 1 participant 3 messages Apr 2, 2025

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: More fixes for v6.15

More tracing fixes for 6.15

- Fix mcount sorttable building for different endian type target

When modifying the ELF file to sort the mcount_loc table in the sorttable.c code, the endianess of the file and the host is used to determine if the bytes need to be swapped when calculations are done. A change was made to the sorting of the mcount_loc that read the values from the ELF file into an array and the swap happened on the filling of the array. But one of the calculations of the array still did the swap when it did not need to. This caused building on a little endian machine for a big endian target to not find the mcount function in the 'nm' table and it zeroed it out, causing there to be no functions available to trace.

- Add goto out_unlock jump to rv_register_monitor() on error path

One of the error paths in rv_register_monitor() just returned the error when it should have jumped to the out_unlock label to release the mutex.

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/fixes

Head SHA1: fc0585c7faa9fffa0ecdd6e2466e3293cd3239ac

Gabriele Monaco (1):
rv: Fix missing unlock on double nested monitors return path

Vasily Gorbik (1):
scripts/sorttable: Fix endianness handling in build-time mcount sort

----

 kernel/trace/rv/rv.c | 3 ++-
 scripts/sorttable.c  | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 scripts/sorttable: Fix endianness handling in build-time mcount sort

From: Vasily Gorbik <[email protected]>

Kernel cross-compilation with BUILDTIME_MCOUNT_SORT produces zeroed mcount values if the build-host endianness does not match the ELF file endianness.

The mcount values array is converted from ELF file
endianness to build-host endianness during initialization in fill_relocs()/fill_addrs(). Avoid extra conversion of these values during weak-function zeroing; otherwise, they do not match nm-parsed addresses and all mcount values are zeroed out.

---
 scripts/sorttable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/sorttable.c +1 -1
index 7b4b3714b1af..deed676bfe38 100644
@@ -857,7 +857,7 @@ static void *sort_mcount_loc(void *arg)
 		for (void *ptr = vals; ptr < vals + size; ptr += long_size) {
 			uint64_t key;
 
-			key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr);
+			key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr;
 			if (!find_func(key)) {
 				if (long_size == 4)
 					*(uint32_t *)ptr = 0;
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH 2/2 Fix missing unlock on double nested monitors return path

In reply to Steven Rostedt

From: Gabriele Monaco <[email protected]>

RV doesn't support nested monitors having children monitors themselves and exits with the EINVAL code. However, it returns without unlocking the rv_interface_lock.

Unlock the lock before returning from the initialisation function.

---
 kernel/trace/rv/rv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/rv/rv.c +2 -1
index 50344aa9f7f9..968c5c3b0246 100644
@@ -809,7 +809,8 @@ int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent)
 	if (p && rv_is_nested_monitor(p)) {
 		pr_info("Parent monitor %s is already nested, cannot nest further\n",
 			parent->name);
-		return -EINVAL;
+		retval = -EINVAL;
+		goto out_unlock;
 	}
 
 	r = kzalloc(sizeof(struct rv_monitor_def), GFP_KERNEL);
Signature · 1 line
2.47.2