lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250518094202.cVLMUcBN@linutronix.de>
Date: Sun, 18 May 2025 11:42:02 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>, linux-rt-devel@...ts.linux.dev,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
	Waiman Long <longman@...hat.com>, Boqun Feng <boqun.feng@...il.com>
Subject: Re: [PATCH 1/2] local_lock: Move this_cpu_ptr() notation from
 internal to main header.

On 2025-05-14 17:46:43 [-0700], Alexei Starovoitov wrote:
> 
> Are you sure this is correct?

I hope so.

> Have you tested with gcc 14 or higher?

gcc version 14.2.0 (Debian 14.2.0-19) 

> It looks to me that moving this_cpu_ptr() up one level should
> still preserve __seg_gs modifier.

If I compile mm/memcontrol.o as-is I get no warnings. Adding

diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
index b4d7b24882835..112324bc362c1 100644
--- a/include/linux/local_lock_internal.h
+++ b/include/linux/local_lock_internal.h
@@ -102,11 +102,11 @@ do {								\
 		l = (local_lock_t *)(lock);			\
 		tl = (local_trylock_t *)l;				\
 		_Generic((lock),					\
-			local_trylock_t *: ({			\
+			__percpu local_trylock_t *: ({			\
 				lockdep_assert(tl->acquired == 0);	\
 				WRITE_ONCE(tl->acquired, 1);		\
 			}),						\
-			local_lock_t *: (void)0);		\
+			__percpu local_lock_t *: (void)0);		\
 		local_lock_acquire(l);					\
 	} while (0)
 
@@ -171,11 +171,11 @@ do {								\
 		tl = (local_trylock_t *)l;				\
 		local_lock_release(l);					\
 		_Generic((lock),					\
-			local_trylock_t *: ({			\
+			__percpu local_trylock_t *: ({			\
 				lockdep_assert(tl->acquired == 1);	\
 				WRITE_ONCE(tl->acquired, 0);		\
 			}),						\
-			local_lock_t *: (void)0);		\
+			__percpu local_lock_t *: (void)0);		\
 	} while (0)
 
 #define __local_unlock(lock)					\

which I assume is what you mean, results in

| In file included from include/linux/preempt.h:11,
|                  from include/linux/spinlock.h:56,
|                  from include/linux/swait.h:7,
|                  from include/linux/completion.h:12,
|                  from include/linux/crypto.h:15,
|                  from arch/x86/kernel/asm-offsets.c:9:
| include/linux/local_lock.h: In function ‘class_local_lock_destructor’:
| include/linux/local_lock_internal.h:173:26: error: ‘_Generic’ selector of type ‘struct <anonymous> *’ is not compatible with any association
|   173 |                 _Generic((lock),                                        \
|       |                          ^
| include/linux/cleanup.h:246:18: note: in definition of macro ‘DEFINE_CLASS’
|   246 | { _type _T = *p; _exit; }                                               \
|       |                  ^~~~~
| include/linux/local_lock.h:82:1: note: in expansion of macro ‘DEFINE_GUARD’
|    82 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
|       | ^~~~~~~~~~~~
| include/linux/local_lock_internal.h:183:17: note: in expansion of macro ‘__local_lock_release’
|   183 |                 __local_lock_release(lock);                     \
|       |                 ^~~~~~~~~~~~~~~~~~~~
| include/linux/local_lock.h:37:41: note: in expansion of macro ‘__local_unlock’
|    37 | #define local_unlock(lock)              __local_unlock(this_cpu_ptr(lock))
|       |                                         ^~~~~~~~~~~~~~
| include/linux/local_lock.h:84:14: note: in expansion of macro ‘local_unlock’
|    84 |              local_unlock(_T))
|       |              ^~~~~~~~~~~~
| include/linux/local_lock.h: In function ‘class_local_lock_constructor’:
| include/linux/local_lock_internal.h:104:26: error: ‘_Generic’ selector of type ‘struct <anonymous> *’ is not compatible with any association
|   104 |                 _Generic((lock),                                        \
|       |                          ^
| include/linux/cleanup.h:248:13: note: in definition of macro ‘DEFINE_CLASS’
|   248 | { _type t = _init; return t; }
|       |             ^~~~~
| include/linux/local_lock.h:82:1: note: in expansion of macro ‘DEFINE_GUARD’
|    82 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
|       | ^~~~~~~~~~~~
| include/linux/local_lock_internal.h:116:17: note: in expansion of macro ‘__local_lock_acquire’
|   116 |                 __local_lock_acquire(lock);                     \
|       |                 ^~~~~~~~~~~~~~~~~~~~
| include/linux/local_lock.h:16:41: note: in expansion of macro ‘__local_lock’
|    16 | #define local_lock(lock)                __local_lock(this_cpu_ptr(lock))
…

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ