mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tracing/user_events: fix long size check in the ABI selftest
@ 2023-09-11 16:09 Alexander Lobakin
  2023-09-13 10:07 ` Alexander Lobakin
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2023-09-11 16:09 UTC (permalink / raw)
  To: Shuah Khan, Steven Rostedt (Google)
  Cc: Alexander Lobakin, Beau Belgrave, Ira Weiny, linux-kselftest,
	stable, linux-kernel

The current check for 64-bit architecture is double-bugged.
First of all, %BITS_PER_LONG is not available in the userspace,
the underscored version from <asm/bitsperlong.h> must be used.
The following check:

 #if BITS_PER_LONG == 0
 #error
 #endif

triggers the error in this source file -- the macro is undefined and
thus is implicitly evaluated to 0.
Next, %BITS_PER_LONG means "bits", not "bytes". In the Linux kernel,
it can be 32 or 64, never 8. Given that the tests guarded by that check
are meant to be run on a 64-bit system, the correct value would be 64.

Prefix the macro name and fix the value it's compared to.

Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
Cc: stable@vger.kernel.org # 6.4+
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
 tools/testing/selftests/user_events/abi_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
index 5125c42efe65..4b30461fc741 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -129,7 +129,7 @@ TEST_F(user, bit_sizes) {
 	ASSERT_EQ(0, reg_disable(&self->check, 0));
 	ASSERT_EQ(0, reg_disable(&self->check, 31));
 
-#if BITS_PER_LONG == 8
+#if __BITS_PER_LONG == 64
 	/* Allow 0-64 bits for 64-bit */
 	ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63));
 	ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64));
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tracing/user_events: fix long size check in the ABI selftest
  2023-09-11 16:09 [PATCH] tracing/user_events: fix long size check in the ABI selftest Alexander Lobakin
@ 2023-09-13 10:07 ` Alexander Lobakin
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Lobakin @ 2023-09-13 10:07 UTC (permalink / raw)
  To: Shuah Khan, Steven Rostedt (Google)
  Cc: Beau Belgrave, Ira Weiny, linux-kselftest, stable, linux-kernel

From: Alexander Lobakin <aleksander.lobakin@intel.com>
Date: Mon, 11 Sep 2023 18:09:35 +0200

> The current check for 64-bit architecture is double-bugged.
> First of all, %BITS_PER_LONG is not available in the userspace,
> the underscored version from <asm/bitsperlong.h> must be used.
> The following check:
> 
>  #if BITS_PER_LONG == 0
>  #error
>  #endif
> 
> triggers the error in this source file -- the macro is undefined and
> thus is implicitly evaluated to 0.
> Next, %BITS_PER_LONG means "bits", not "bytes". In the Linux kernel,
> it can be 32 or 64, never 8. Given that the tests guarded by that check
> are meant to be run on a 64-bit system, the correct value would be 64.
> 
> Prefix the macro name and fix the value it's compared to.
> 
> Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
> Cc: stable@vger.kernel.org # 6.4+
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>

Patchwork says "Accepted", but I don't see it anywhere on korg O_o

[...]

Thanks,
Olek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-13 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 16:09 [PATCH] tracing/user_events: fix long size check in the ABI selftest Alexander Lobakin
2023-09-13 10:07 ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®