mbox series

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

Message ID 20230925230829.341-1-beaub@linux.microsoft.com (mailing list archive)
Headers show
Series tracing/user_events: Fix alignment issues for 32 on 64-bit and BE | expand

Message

Beau Belgrave Sept. 25, 2023, 11:08 p.m. UTC
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/713f4916-00ff-4a24-82d1-72884500a2d3@rivosinc.com/

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