* [PATCH -tip] cleanup: Remove address space of returned pointer
@ 2024-08-19 7:41 Uros Bizjak
2024-10-18 11:22 ` Peter Zijlstra
2024-10-26 7:35 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
0 siblings, 2 replies; 6+ messages in thread
From: Uros Bizjak @ 2024-08-19 7:41 UTC (permalink / raw)
To: linux-kernel; +Cc: Uros Bizjak, Peter Zijlstra, Thomas Gleixner
Guard functions in local_lock.h are defined using DEFINE_GUARD() and
DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
the percpu address space. The functions, defined by these macros
return value in generic address space, causing:
cleanup.h:157:18: error: return from pointer to non-enclosed address space
and
cleanup.h:214:18: error: return from pointer to non-enclosed address space
when strict percpu checks are enabled.
Add explicit casts to remove address space of the returned pointer.
Found by GCC's named address space checks.
Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/cleanup.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
index 9c6b4f2c0176..48da01c1c082 100644
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -290,7 +290,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
#define DEFINE_GUARD(_name, _type, _lock, _unlock) \
DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
- { return *_T; }
+ { return (void *)(__force unsigned long)*_T; }
#define DEFINE_GUARD_COND(_name, _ext, _condlock) \
EXTEND_CLASS(_name, _ext, \
@@ -347,7 +347,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T) \
\
static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
{ \
- return _T->lock; \
+ return (void *)(__force unsigned long)_T->lock; \
}
--
2.46.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH -tip] cleanup: Remove address space of returned pointer
2024-08-19 7:41 [PATCH -tip] cleanup: Remove address space of returned pointer Uros Bizjak
@ 2024-10-18 11:22 ` Peter Zijlstra
2024-10-25 7:35 ` Uros Bizjak
2024-10-26 7:35 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
1 sibling, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2024-10-18 11:22 UTC (permalink / raw)
To: Uros Bizjak; +Cc: linux-kernel, Thomas Gleixner
On Mon, Aug 19, 2024 at 09:41:15AM +0200, Uros Bizjak wrote:
> Guard functions in local_lock.h are defined using DEFINE_GUARD() and
> DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
> the percpu address space. The functions, defined by these macros
> return value in generic address space, causing:
>
> cleanup.h:157:18: error: return from pointer to non-enclosed address space
>
> and
>
> cleanup.h:214:18: error: return from pointer to non-enclosed address space
>
> when strict percpu checks are enabled.
>
> Add explicit casts to remove address space of the returned pointer.
>
> Found by GCC's named address space checks.
>
> Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Thanks!
Now lives in queue locking/core, and barring robot screams will make its
way into tip.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -tip] cleanup: Remove address space of returned pointer
2024-10-18 11:22 ` Peter Zijlstra
@ 2024-10-25 7:35 ` Uros Bizjak
2024-10-25 7:49 ` Peter Zijlstra
0 siblings, 1 reply; 6+ messages in thread
From: Uros Bizjak @ 2024-10-25 7:35 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: linux-kernel, Thomas Gleixner
On Fri, Oct 18, 2024 at 1:23 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Mon, Aug 19, 2024 at 09:41:15AM +0200, Uros Bizjak wrote:
> > Guard functions in local_lock.h are defined using DEFINE_GUARD() and
> > DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
> > the percpu address space. The functions, defined by these macros
> > return value in generic address space, causing:
> >
> > cleanup.h:157:18: error: return from pointer to non-enclosed address space
> >
> > and
> >
> > cleanup.h:214:18: error: return from pointer to non-enclosed address space
> >
> > when strict percpu checks are enabled.
> >
> > Add explicit casts to remove address space of the returned pointer.
> >
> > Found by GCC's named address space checks.
> >
> > Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
>
> Thanks!
>
> Now lives in queue locking/core, and barring robot screams will make its
> way into tip.
I noticed that the patch was removed from the queue. Was there
something wrong with it?
Uros.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -tip] cleanup: Remove address space of returned pointer
2024-10-25 7:35 ` Uros Bizjak
@ 2024-10-25 7:49 ` Peter Zijlstra
2024-10-25 8:00 ` Peter Zijlstra
0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2024-10-25 7:49 UTC (permalink / raw)
To: Uros Bizjak; +Cc: linux-kernel, Thomas Gleixner
On Fri, Oct 25, 2024 at 09:35:29AM +0200, Uros Bizjak wrote:
> On Fri, Oct 18, 2024 at 1:23 PM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Mon, Aug 19, 2024 at 09:41:15AM +0200, Uros Bizjak wrote:
> > > Guard functions in local_lock.h are defined using DEFINE_GUARD() and
> > > DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
> > > the percpu address space. The functions, defined by these macros
> > > return value in generic address space, causing:
> > >
> > > cleanup.h:157:18: error: return from pointer to non-enclosed address space
> > >
> > > and
> > >
> > > cleanup.h:214:18: error: return from pointer to non-enclosed address space
> > >
> > > when strict percpu checks are enabled.
> > >
> > > Add explicit casts to remove address space of the returned pointer.
> > >
> > > Found by GCC's named address space checks.
> > >
> > > Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
> > > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> >
> > Thanks!
> >
> > Now lives in queue locking/core, and barring robot screams will make its
> > way into tip.
>
> I noticed that the patch was removed from the queue. Was there
> something wrong with it?
Uhh.. damn. I thought I pushed things to tip, but instead I seem to have
lost a bunch of patches.
Let me try and figure out what all went missing :/
Sorry, and thanks for noticing!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -tip] cleanup: Remove address space of returned pointer
2024-10-25 7:49 ` Peter Zijlstra
@ 2024-10-25 8:00 ` Peter Zijlstra
0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2024-10-25 8:00 UTC (permalink / raw)
To: Uros Bizjak; +Cc: linux-kernel, Thomas Gleixner
On Fri, Oct 25, 2024 at 09:49:39AM +0200, Peter Zijlstra wrote:
> Uhh.. damn. I thought I pushed things to tip, but instead I seem to have
> lost a bunch of patches.
>
> Let me try and figure out what all went missing :/
Just this patch it seems.. I restored it and hopefully I'll not loose it
again.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: locking/core] cleanup: Remove address space of returned pointer
2024-08-19 7:41 [PATCH -tip] cleanup: Remove address space of returned pointer Uros Bizjak
2024-10-18 11:22 ` Peter Zijlstra
@ 2024-10-26 7:35 ` tip-bot2 for Uros Bizjak
1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2024-10-26 7:35 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Uros Bizjak, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: f730fd535fc51573f982fad629f2fc6b4a0cde2f
Gitweb: https://git.kernel.org/tip/f730fd535fc51573f982fad629f2fc6b4a0cde2f
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Mon, 19 Aug 2024 09:41:15 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 25 Oct 2024 10:01:50 +02:00
cleanup: Remove address space of returned pointer
Guard functions in local_lock.h are defined using DEFINE_GUARD() and
DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
the percpu address space. The functions, defined by these macros
return value in generic address space, causing:
cleanup.h:157:18: error: return from pointer to non-enclosed address space
and
cleanup.h:214:18: error: return from pointer to non-enclosed address space
when strict percpu checks are enabled.
Add explicit casts to remove address space of the returned pointer.
Found by GCC's named address space checks.
Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20240819074124.143565-1-ubizjak@gmail.com
---
include/linux/cleanup.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
index 038b2d5..518bd1f 100644
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -290,7 +290,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
#define DEFINE_GUARD(_name, _type, _lock, _unlock) \
DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
- { return *_T; }
+ { return (void *)(__force unsigned long)*_T; }
#define DEFINE_GUARD_COND(_name, _ext, _condlock) \
EXTEND_CLASS(_name, _ext, \
@@ -347,7 +347,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T) \
\
static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
{ \
- return _T->lock; \
+ return (void *)(__force unsigned long)_T->lock; \
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-26 7:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 7:41 [PATCH -tip] cleanup: Remove address space of returned pointer Uros Bizjak
2024-10-18 11:22 ` Peter Zijlstra
2024-10-25 7:35 ` Uros Bizjak
2024-10-25 7:49 ` Peter Zijlstra
2024-10-25 8:00 ` Peter Zijlstra
2024-10-26 7:35 ` [tip: locking/core] " tip-bot2 for Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox