Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727156 > unrolled thread
| Started by | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| First post | 2017-09-06 07:30 +0200 |
| Last post | 2017-09-07 09:10 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-06 07:30 +0200
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-06 23:40 +0200
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-07 00:20 +0200
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() Peter Zijlstra <peterz@infradead.org> - 2017-09-07 09:10 +0200
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-06 07:30 +0200 |
| Subject | [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() |
| Message-ID | <umB4t-5b7-1@gated-at.bofh.it> |
kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup
The warning means gcc 7.2.0 placed the __downgrade_write() inline asm (and
its call instruction) before the frame pointer setup in downgrade_write(),
which breaks frame pointer convention and can result in incorrect
stack traces.
Force a stack frame to be created before the call instruction by listing
the stack pointer as an output operand in the inline asm statement.
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
---
arch/x86/include/asm/rwsem.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
index d26b6916b935..a749dc6a3103 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -205,8 +205,10 @@ static inline void __up_write(struct rw_semaphore *sem)
*/
static inline void __downgrade_write(struct rw_semaphore *sem)
{
+ register void *__sp asm(_ASM_SP);
+
asm volatile("# beginning __downgrade_write\n\t"
- LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
+ LOCK_PREFIX _ASM_ADD "%2,(%2)\n\t"
/*
* transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
* 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
@@ -215,7 +217,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
" call call_rwsem_downgrade_wake\n"
"1:\n\t"
"# ending __downgrade_write\n"
- : "+m" (sem->count)
+ : "+m" (sem->count), "+r" (__sp)
: "a" (sem), "er" (-RWSEM_WAITING_BIAS)
: "memory", "cc");
}
--
2.14.1
[toc] | [next] | [standalone]
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Date | 2017-09-06 23:40 +0200 |
| Subject | Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() |
| Message-ID | <umQdd-7qi-35@gated-at.bofh.it> |
| In reply to | #1727156 |
On Wed, Sep 06, 2017 at 12:26:13AM -0500, Miguel Bernal Marin wrote:
> kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup
>
> The warning means gcc 7.2.0 placed the __downgrade_write() inline asm (and
> its call instruction) before the frame pointer setup in downgrade_write(),
> which breaks frame pointer convention and can result in incorrect
> stack traces.
>
> Force a stack frame to be created before the call instruction by listing
> the stack pointer as an output operand in the inline asm statement.
>
> Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
> ---
> arch/x86/include/asm/rwsem.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
> index d26b6916b935..a749dc6a3103 100644
> --- a/arch/x86/include/asm/rwsem.h
> +++ b/arch/x86/include/asm/rwsem.h
> @@ -205,8 +205,10 @@ static inline void __up_write(struct rw_semaphore *sem)
> */
> static inline void __downgrade_write(struct rw_semaphore *sem)
> {
> + register void *__sp asm(_ASM_SP);
> +
> asm volatile("# beginning __downgrade_write\n\t"
> - LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
> + LOCK_PREFIX _ASM_ADD "%2,(%2)\n\t"
The '%2' should be changed to '%3'
LOCK_PREFIX _ASM_ADD "%3,(%2)\n\t"
because both inputs' indices are shifted by the new output constraint.
> /*
> * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
> * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
> @@ -215,7 +217,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
> " call call_rwsem_downgrade_wake\n"
> "1:\n\t"
> "# ending __downgrade_write\n"
> - : "+m" (sem->count)
> + : "+m" (sem->count), "+r" (__sp)
> : "a" (sem), "er" (-RWSEM_WAITING_BIAS)
> : "memory", "cc");
--
Josh
[toc] | [prev] | [next] | [standalone]
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-07 00:20 +0200 |
| Subject | Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() |
| Message-ID | <umQPU-7Vj-11@gated-at.bofh.it> |
| In reply to | #1727764 |
On Wed, Sep 06, 2017 at 04:33:02PM -0500, Josh Poimboeuf wrote:
> On Wed, Sep 06, 2017 at 12:26:13AM -0500, Miguel Bernal Marin wrote:
> > kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup
> >
> > The warning means gcc 7.2.0 placed the __downgrade_write() inline asm (and
> > its call instruction) before the frame pointer setup in downgrade_write(),
> > which breaks frame pointer convention and can result in incorrect
> > stack traces.
> >
> > Force a stack frame to be created before the call instruction by listing
> > the stack pointer as an output operand in the inline asm statement.
> >
> > Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
> > ---
> > arch/x86/include/asm/rwsem.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
> > index d26b6916b935..a749dc6a3103 100644
> > --- a/arch/x86/include/asm/rwsem.h
> > +++ b/arch/x86/include/asm/rwsem.h
> > @@ -205,8 +205,10 @@ static inline void __up_write(struct rw_semaphore *sem)
> > */
> > static inline void __downgrade_write(struct rw_semaphore *sem)
> > {
> > + register void *__sp asm(_ASM_SP);
> > +
> > asm volatile("# beginning __downgrade_write\n\t"
> > - LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
> > + LOCK_PREFIX _ASM_ADD "%2,(%2)\n\t"
>
> The '%2' should be changed to '%3'
>
> LOCK_PREFIX _ASM_ADD "%3,(%2)\n\t"
>
> because both inputs' indices are shifted by the new output constraint.
>
Thanks, I will send the V2.
> > /*
> > * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
> > * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
> > @@ -215,7 +217,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
> > " call call_rwsem_downgrade_wake\n"
> > "1:\n\t"
> > "# ending __downgrade_write\n"
> > - : "+m" (sem->count)
> > + : "+m" (sem->count), "+r" (__sp)
> > : "a" (sem), "er" (-RWSEM_WAITING_BIAS)
> > : "memory", "cc");
>
> --
> Josh
--
Regards,
Miguel Bernal Marin Open Source Technology Center
https://clearlinux.org Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-09-07 09:10 +0200 |
| Subject | Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() |
| Message-ID | <umZ6O-56x-25@gated-at.bofh.it> |
| In reply to | #1727764 |
On Wed, Sep 06, 2017 at 04:33:02PM -0500, Josh Poimboeuf wrote:
> On Wed, Sep 06, 2017 at 12:26:13AM -0500, Miguel Bernal Marin wrote:
> > kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup
> >
> > The warning means gcc 7.2.0 placed the __downgrade_write() inline asm (and
> > its call instruction) before the frame pointer setup in downgrade_write(),
> > which breaks frame pointer convention and can result in incorrect
> > stack traces.
> >
> > Force a stack frame to be created before the call instruction by listing
> > the stack pointer as an output operand in the inline asm statement.
> >
> > Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
> > ---
> > arch/x86/include/asm/rwsem.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
> > index d26b6916b935..a749dc6a3103 100644
> > --- a/arch/x86/include/asm/rwsem.h
> > +++ b/arch/x86/include/asm/rwsem.h
> > @@ -205,8 +205,10 @@ static inline void __up_write(struct rw_semaphore *sem)
> > */
> > static inline void __downgrade_write(struct rw_semaphore *sem)
> > {
> > + register void *__sp asm(_ASM_SP);
> > +
> > asm volatile("# beginning __downgrade_write\n\t"
> > - LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
> > + LOCK_PREFIX _ASM_ADD "%2,(%2)\n\t"
>
> The '%2' should be changed to '%3'
>
> LOCK_PREFIX _ASM_ADD "%3,(%2)\n\t"
>
> because both inputs' indices are shifted by the new output constraint.
Even better would be to used named operands.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web