Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727163 > 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 01:10 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-06 07:30 +0200
[PATCH v2 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-07 00:50 +0200
[PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read() Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-07 00:50 +0200
Re: [PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read() Ingo Molnar <mingo@kernel.org> - 2017-09-07 09:20 +0200
[PATCH v2 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:50 +0200
[PATCH v2 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write() Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-07 00:50 +0200
Re: [PATCH v2 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-07 01:10 +0200
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-06 07:30 +0200 |
| Subject | [PATCH 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm |
| Message-ID | <umB4t-5b7-3@gated-at.bofh.it> |
Some warning were showed by objtool using gcc 7.2.0 kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setup kernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setup kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup which means gcc placed an inline asm function and its call instruction before the frame pointer setup. This series forces a stack frame to be created before the call instruction by listing the stack pointer as an output operand in the inline asm statement. Miguel Bernal Marin (3): locking/rwsem/x86: Add stack frame dependency for __up_read() locking/rwsem/x86: Add stack frame dependency for __up_write() locking/rwsem/x86: Add stack frame dependency for __downgrade_write() arch/x86/include/asm/rwsem.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 2.14.1
[toc] | [next] | [standalone]
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-07 00:50 +0200 |
| Subject | [PATCH v2 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm |
| Message-ID | <umRiV-85i-1@gated-at.bofh.it> |
| In reply to | #1727163 |
Some warning were showed by objtool using gcc 7.2.0 kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setup kernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setup kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup which means gcc placed an inline asm function and its call instruction before the frame pointer setup. This series forces a stack frame to be created before the call instruction by listing the stack pointer as an output operand in the inline asm statement. Changes in v2: - Update first parameter from _ASM_ADD to '%3' at __downgrade_write() Miguel Bernal Marin (3): locking/rwsem/x86: Add stack frame dependency for __up_read() locking/rwsem/x86: Add stack frame dependency for __up_write() locking/rwsem/x86: Add stack frame dependency for __downgrade_write() arch/x86/include/asm/rwsem.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 2.14.1
[toc] | [prev] | [next] | [standalone]
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-07 00:50 +0200 |
| Subject | [PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read() |
| Message-ID | <umRiV-85i-7@gated-at.bofh.it> |
| In reply to | #1727802 |
kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setup
The warning means gcc 7.2.0 placed the __up_read() inline asm (and its
call instruction) before the frame pointer setup in up_read(),
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 a34e0d4b957d..762167afaec0 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -166,14 +166,16 @@ static inline bool __down_write_trylock(struct rw_semaphore *sem)
static inline void __up_read(struct rw_semaphore *sem)
{
long tmp;
+ register void *__sp asm(_ASM_SP);
+
asm volatile("# beginning __up_read\n\t"
- LOCK_PREFIX " xadd %1,(%2)\n\t"
+ LOCK_PREFIX " xadd %1,(%3)\n\t"
/* subtracts 1, returns the old value */
" jns 1f\n\t"
" call call_rwsem_wake\n" /* expects old value in %edx */
"1:\n"
"# ending __up_read\n"
- : "+m" (sem->count), "=d" (tmp)
+ : "+m" (sem->count), "=d" (tmp), "+r" (__sp)
: "a" (sem), "1" (-RWSEM_ACTIVE_READ_BIAS)
: "memory", "cc");
}
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2017-09-07 09:20 +0200 |
| Subject | Re: [PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read() |
| Message-ID | <umZgv-5bg-13@gated-at.bofh.it> |
| In reply to | #1727804 |
* Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> wrote:
> kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setup
>
> The warning means gcc 7.2.0 placed the __up_read() inline asm (and its
> call instruction) before the frame pointer setup in up_read(),
> 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 a34e0d4b957d..762167afaec0 100644
> --- a/arch/x86/include/asm/rwsem.h
> +++ b/arch/x86/include/asm/rwsem.h
> @@ -166,14 +166,16 @@ static inline bool __down_write_trylock(struct rw_semaphore *sem)
> static inline void __up_read(struct rw_semaphore *sem)
> {
> long tmp;
> + register void *__sp asm(_ASM_SP);
> +
> asm volatile("# beginning __up_read\n\t"
> - LOCK_PREFIX " xadd %1,(%2)\n\t"
> + LOCK_PREFIX " xadd %1,(%3)\n\t"
> /* subtracts 1, returns the old value */
> " jns 1f\n\t"
> " call call_rwsem_wake\n" /* expects old value in %edx */
> "1:\n"
> "# ending __up_read\n"
> - : "+m" (sem->count), "=d" (tmp)
> + : "+m" (sem->count), "=d" (tmp), "+r" (__sp)
> : "a" (sem), "1" (-RWSEM_ACTIVE_READ_BIAS)
> : "memory", "cc");
Please also convert it to named operands (in separate patches!) - this apparently
BASIC inspired labeling syntax of GCC is utterly confusing, counterproductive and
somewhat embarrasing as well, considering that we write 2017.
Thanks,
Ingo
[toc] | [prev] | [next] | [standalone]
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-07 00:50 +0200 |
| Subject | [PATCH v2 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() |
| Message-ID | <umRiV-85i-11@gated-at.bofh.it> |
| In reply to | #1727802 |
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 "%3,(%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] | [prev] | [next] | [standalone]
| From | Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> |
|---|---|
| Date | 2017-09-07 00:50 +0200 |
| Subject | [PATCH v2 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write() |
| Message-ID | <umRiV-85i-17@gated-at.bofh.it> |
| In reply to | #1727802 |
kernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setup
The warning means gcc 7.2.0 placed the __up_write() inline asm (and its
call instruction) before the frame pointer setup in up_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 762167afaec0..d26b6916b935 100644
--- a/arch/x86/include/asm/rwsem.h
+++ b/arch/x86/include/asm/rwsem.h
@@ -186,14 +186,16 @@ static inline void __up_read(struct rw_semaphore *sem)
static inline void __up_write(struct rw_semaphore *sem)
{
long tmp;
+ register void *__sp asm(_ASM_SP);
+
asm volatile("# beginning __up_write\n\t"
- LOCK_PREFIX " xadd %1,(%2)\n\t"
+ LOCK_PREFIX " xadd %1,(%3)\n\t"
/* subtracts 0xffff0001, returns the old value */
" jns 1f\n\t"
" call call_rwsem_wake\n" /* expects old value in %edx */
"1:\n\t"
"# ending __up_write\n"
- : "+m" (sem->count), "=d" (tmp)
+ : "+m" (sem->count), "=d" (tmp), "+r" (__sp)
: "a" (sem), "1" (-RWSEM_ACTIVE_WRITE_BIAS)
: "memory", "cc");
}
--
2.14.1
[toc] | [prev] | [next] | [standalone]
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Date | 2017-09-07 01:10 +0200 |
| Subject | Re: [PATCH v2 0/3] locking/rwsem/x86: Add stack frame dependency for some inline asm |
| Message-ID | <umRCh-8qR-3@gated-at.bofh.it> |
| In reply to | #1727802 |
On Wed, Sep 06, 2017 at 05:44:58PM -0500, Miguel Bernal Marin wrote: > Some warning were showed by objtool using gcc 7.2.0 > > kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setup > kernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setup > kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup > > which means gcc placed an inline asm function and its call instruction before > the frame pointer setup. > > This series forces a stack frame to be created before the call instruction > by listing the stack pointer as an output operand in the inline asm statement. > > Changes in v2: > - Update first parameter from _ASM_ADD to '%3' at __downgrade_write() > > Miguel Bernal Marin (3): > locking/rwsem/x86: Add stack frame dependency for __up_read() > locking/rwsem/x86: Add stack frame dependency for __up_write() > locking/rwsem/x86: Add stack frame dependency for __downgrade_write() > > arch/x86/include/asm/rwsem.h | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) For the series: Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> -- Josh
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web