Skip to content

tracing/user_events: Fix alignment issues for 32 on 64-bit and BE

Beau Belgrave linux-kselftest linux-trace-kernel lkml 1 version Applied

Status from this message: I applied the first patch to my tree, I think the second patch is fine to go

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 8 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2tracing/user_events: Align set_bit() address for all archskernel/trace/trace_events_user.c+51 -70 replies
2/2selftests/user_events: Fix abi_test for BE archstools/testing/selftests/user_events/abi_test.c+9 -78 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] tracing/user_events: Fix alignment issues for 32 on 64-bit and BE

All architectures should use a long aligned address passed to set_bit(). User processes can pass either a 32-bit or 64-bit sized value to be updated when tracing is enabled when on a 64-bit kernel. Both cases are ensured to be naturally aligned, however, that is not enough. The address must be long aligned without affecting checks on the value within the user process which require different adjustments for the bit for little and big endian CPUs.

32 bit on 64 bit, even when properly long aligned, still require a 32 bit offset to be done for BE. Due to this, it cannot be easily put into a generic method.

The abi_test also used a long, which broke the test on 64-bit BE machines. The change simply uses an int for 32-bit value checks and a long when on 64-bit kernels for 64-bit specific checks.

I've run these changes and self tests for user_events on ppc64 BE, x86_64 LE, and aarch64 LE. It'd be great to test this also on RISC-V, but I do not have one.

Clément Léger originally put a patch together for the alignment issue, but we uncovered more issues as we went further into the problem. Clément felt my version was better [1] so I am sending this series out that addresses the selftest, BE bit offset, and the alignment issue.

1. https://lore.kernel.org/linux-trace-kernel/[email protected]/

Beau Belgrave (2):
tracing/user_events: Align set_bit() address for all archs selftests/user_events: Fix abi_test for BE archs

 kernel/trace/trace_events_user.c              | 58 ++++++++++++++++---
 .../testing/selftests/user_events/abi_test.c  | 16 ++---
 2 files changed, 60 insertions(+), 14 deletions(-)

base-commit: fc1653abba0d554aad80224e51bcad42b09895ed

Signature · 1 line
2.34.1