locking/rwsem/x86: Add stack frame dependency for some inline asm
cover locking/rwsem/x86: Add stack frame dependency for some inline asm
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(-)
Signature · 1 line
2.14.1
PATCH 1/3 locking/rwsem/x86: Add stack frame dependency for __up_read()
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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
PATCH 2/3 locking/rwsem/x86: Add stack frame dependency for __up_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
PATCH 3/3 locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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"); }
Signature · 1 line
2.14.1
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
Quoted 20 lines · Miguel Bernal Marin
kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupThe warning means gcc 7.2.0 placed the
__downgrade_write()inline asm (and its call instruction) before the frame pointer setup indowngrade_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 <[email protected]>--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/x86/include/asm/rwsem.h +0
-0
arch/x86/include/asm/rwsem.h static inline void __up_write(struct rw_semaphore *sem) · line 211
Quoted 8 lines
arch/x86/include/asm/rwsem.h +3
-1@@ -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); + asmvolatile ("# 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.
Quoted 11 lines
arch/x86/include/asm/rwsem.h +1
-1/* * 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");
Signature · 1 line
Josh
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
Quoted 32 lines · Josh Poimboeuf
Quoted 20 lines · Miguel Bernal Marin
kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupThe warning means gcc 7.2.0 placed the
__downgrade_write()inline asm (and its call instruction) before the frame pointer setup indowngrade_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 <[email protected]>--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/x86/include/asm/rwsem.h +0
-0arch/x86/include/asm/rwsem.h static inline void __up_write(struct rw_semaphore *sem) · line 211
Quoted 8 lines
arch/x86/include/asm/rwsem.h +3
-1@@ -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); + asmvolatile ("# 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'
Quoted 4 lines
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.
Quoted 14 lines
Quoted 11 lines
arch/x86/include/asm/rwsem.h +1
-1/* * 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");Signature · 1 line
Josh
Signature · 4 lines
Regards, Miguel Bernal Marin Open Source Technology Center https://clearlinux.org Intel Corporation
Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
In reply to Josh PoimboeufQuoted 32 lines · Josh Poimboeuf
Quoted 20 lines · Miguel Bernal Marin
kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupThe warning means gcc 7.2.0 placed the
__downgrade_write()inline asm (and its call instruction) before the frame pointer setup indowngrade_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 <[email protected]>--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/x86/include/asm/rwsem.h +0
-0arch/x86/include/asm/rwsem.h static inline void __up_write(struct rw_semaphore *sem) · line 211
Quoted 8 lines
arch/x86/include/asm/rwsem.h +3
-1@@ -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); + asmvolatile ("# 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'
Quoted 3 lines
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.
v2 cover locking/rwsem/x86: Add stack frame dependency for some inline asm
In reply to Miguel Bernal MarinSome 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(-)
Signature · 1 line
2.14.1
PATCH v2 1/3 locking/rwsem/x86: Add stack frame dependency for __up_read()
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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
Re: [PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read()
Quoted 27 lines · Miguel Bernal Marin
kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setupThe warning means gcc 7.2.0 placed the
__up_read()inline asm (and its call instruction) before the frame pointer setup inup_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 <[email protected]>--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/x86/include/asm/rwsem.h +2
-1@@ -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"
arch/x86/include/asm/rwsem.h static inline bool __down_write_trylock(struct rw_semaphore *sem) · line 180
Quoted 10 lines
arch/x86/include/asm/rwsem.h +2
-1+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
Re: [PATCH v2 1/3] locking/rwsem/x86: Add stack frame dependency for __up_read()
Quoted 36 lines · Ingo Molnar
Quoted 33 lines · Miguel Bernal Marin
kernel/locking/rwsem.o: warning: objtool: up_read()+0x11: call without frame pointer save/setupThe warning means gcc 7.2.0 placed the
__up_read()inline asm (and its call instruction) before the frame pointer setup inup_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 <[email protected]>--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)arch/x86/include/asm/rwsem.h +3
-1@@ -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); + asmvolatile ("# 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"
Quoted 8 lines
arch/x86/include/asm/rwsem.h static inline bool __down_write_trylock(struct rw_semaphore *sem) · line 180
Quoted 4 lines
arch/x86/include/asm/rwsem.h +1
-1- : "+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.
Sorry for delay response,
So I will add the named operands on the v3
Quoted 4 lines
Thanks,
Ingo
Signature · 4 lines
Regards, Miguel Bernal Marin Open Source Technology Center https://clearlinux.org Intel Corporation
PATCH v2 2/3 locking/rwsem/x86: Add stack frame dependency for __up_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
PATCH v2 3/3 locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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"); }
Signature · 1 line
2.14.1
Quoted 15 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupwhich 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_ADDto '%3' at__downgrade_write()
Quoted 7 lines
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:
Signature · 1 line
Josh
v3 cover locking/rwsem/x86: Add stack frame dependency for some inline asm
In reply to Miguel Bernal MarinSome 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.
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
Changes in v3:
- Convert to named operands
Changes in v2:
- Update first parameter from _ASM_ADD to '%3' at __downgrade_write()
Miguel Bernal Marin (6):
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() x86, asm/rwsem: Use named operands in __up_read()
x86, asm/rwsem: Use named operands in __up_write()
x86, asm/rwsem: Use named operands in __downgrade_write()
arch/x86/include/asm/rwsem.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
Signature · 1 line
2.14.1
PATCH v3 1/6 locking/rwsem/x86: Add stack frame dependency for __up_read()
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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
PATCH v3 2/6 locking/rwsem/x86: Add stack frame dependency for __up_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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" ); }
Signature · 1 line
2.14.1
PATCH v3 3/6 locking/rwsem/x86: Add stack frame dependency for __downgrade_write()
In reply to Miguel Bernal Marinkernel/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.
--- arch/x86/include/asm/rwsem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +4 -2
@@ -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); + asmvolatile ("# 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"); }
Signature · 1 line
2.14.1
PATCH v3 4/6 x86, asm/rwsem: Use named operands in __up_read()
In reply to Miguel Bernal MarinSince GCC version 3.1, it is possible to specify input and output operands using symbolic names which can be referenced within the assembler code.
Convert to named operands makes easy to understand and maintain for future changes.
--- arch/x86/include/asm/rwsem.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/rwsem.h +3 -3
@@ -169,14 +169,14 @@ static inline void __up_read(struct rw_semaphore *sem) register void *__sp asm(_ASM_SP); asmvolatile ("# beginning __up_read\n\t" -LOCK_PREFIX " xadd %1,(%3)\n\t" +LOCK_PREFIX " xadd %[tmp],(%[sem])\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),"+r" (__sp) - :"a" (sem),"1" (-RWSEM_ACTIVE_READ_BIAS ) + :"+m" (sem->count), [tmp]"=d" (tmp),"+r" (__sp) + : [sem]"a" (sem),"[tmp]" (-RWSEM_ACTIVE_READ_BIAS ) :"memory" ,"cc" ); }
Signature · 1 line
2.14.1
PATCH v3 5/6 x86, asm/rwsem: Use named operands in __up_write()
In reply to Miguel Bernal MarinSince GCC version 3.1, it is possible to specify input and output operands using symbolic names which can be referenced within the assembler code.
Convert to named operands makes easy to understand and maintain for future changes.
--- arch/x86/include/asm/rwsem.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/rwsem.h +3 -3
@@ -189,14 +189,14 @@ static inline void __up_write(struct rw_semaphore *sem) register void *__sp asm(_ASM_SP); asmvolatile ("# beginning __up_write\n\t" -LOCK_PREFIX " xadd %1,(%3)\n\t" +LOCK_PREFIX " xadd %[tmp],(%[sem])\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),"+r" (__sp) - :"a" (sem),"1" (-RWSEM_ACTIVE_WRITE_BIAS ) + :"+m" (sem->count), [tmp]"=d" (tmp),"+r" (__sp) + : [sem]"a" (sem),"[tmp]" (-RWSEM_ACTIVE_WRITE_BIAS ) :"memory" ,"cc" ); }
Signature · 1 line
2.14.1
PATCH v3 6/6 x86, asm/rwsem: Use named operands in __downgrade_write()
In reply to Miguel Bernal MarinSince GCC version 3.1, it is possible to specify input and output operands using symbolic names which can be referenced within the assembler code.
Convert to named operands makes easy to understand and maintain for future changes.
--- arch/x86/include/asm/rwsem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/rwsem.h +2 -2
@@ -208,7 +208,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem) register void *__sp asm(_ASM_SP); asmvolatile ("# beginning __downgrade_write\n\t" -LOCK_PREFIX _ASM_ADD"%3,(%2)\n\t" +LOCK_PREFIX _ASM_ADD"%[inc],(%[sem])\n\t" /* * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386) * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
@@ -218,7 +218,7 @@ static inline void __downgrade_write(struct rw_semaphore *sem)"1:\n\t" "# ending __downgrade_write\n" : "+m" (sem->count), "+r" (__sp) - : "a" (sem), "er" (-RWSEM_WAITING_BIAS) + : [sem] "a" (sem), [inc] "er" (-RWSEM_WAITING_BIAS) : "memory", "cc"); }
Signature · 1 line
2.14.1
Quoted 6 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup
Quoted 8 lines
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.
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
Signature · 1 line
Josh
Quoted 13 lines · Josh Poimboeuf
Quoted 12 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupwhich 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.
Quoted 7 lines
Quoted 2 lines
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
Ok, I will wait to see your changes merged.
Thanks.
Quoted 2 lines
Signature · 1 line
Josh
Signature · 4 lines
Regards, Miguel Bernal Marin Open Source Technology Center https://clearlinux.org Intel Corporation
Quoted 13 lines · Josh Poimboeuf
Quoted 12 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupwhich 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.
Quoted 7 lines
Quoted 2 lines
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
With your new patches (at v4.14.-rc2) the warning is not seen any more, so I will send only the named operand patches (in separate thread), as this fix is not more needed.
Quoted 2 lines
Signature · 1 line
Josh
Signature · 4 lines
Regards, Miguel Bernal Marin Open Source Technology Center https://clearlinux.org Intel Corporation
Quoted 17 lines · Miguel Bernal Marin
Quoted 16 lines · Josh Poimboeuf
Quoted 14 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupwhich 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.
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
Quoted 8 lines
Quoted 4 lines
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
With your new patches (at v4.14.-rc2) the warning is not seen any more, so I will send only the named operand patches (in separate thread), as this fix is not more needed.
Any chance you tested with GCC 7? With GCC 6 and older you might still see the warnings.
Signature · 1 line
Josh
Quoted 23 lines · Josh Poimboeuf
Quoted 22 lines · Miguel Bernal Marin
Quoted 20 lines · Josh Poimboeuf
Quoted 6 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupQuoted 8 lines
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.
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
Quoted 6 lines
Quoted 3 lines
With your new patches (at v4.14.-rc2) the warning is not seen any more, so I will send only the named operand patches (in separate thread), as this fix is not more needed.
Any chance you tested with GCC 7? With GCC 6 and older you might still see the warnings.
Sorry, reading again it looks like your warnings only started showing up in GCC 7.2.0? If so, then it does make sense that your fix isn't needed any more, because my patch fixed this issue for *all* inline asm for GCC 7+.
Signature · 1 line
Josh
Quoted 28 lines · Josh Poimboeuf
Quoted 27 lines · Josh Poimboeuf
Quoted 25 lines · Miguel Bernal Marin
Quoted 13 lines · Josh Poimboeuf
Quoted 12 lines · Miguel Bernal Marin
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/setupkernel/locking/rwsem.o: warning: objtool: up_write()+0x17: call without frame pointer save/setupkernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setupwhich 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.
Quoted 7 lines
Quoted 2 lines
Also to be easy to maintain and understand the operands from the extended assembler instructions were converted to named operands.
I've got a patch going around which will change the way we do this, so you'll probably need to do a v3 after my patch gets merged. I'll add you to cc for the next revision.
With your new patches (at v4.14.-rc2) the warning is not seen any more, so I will send only the named operand patches (in separate thread), as this fix is not more needed.
Quoted 8 lines
Quoted 2 lines
Any chance you tested with GCC 7? With GCC 6 and older you might still see the warnings.
Sorry, reading again it looks like your warnings only started showing up in GCC 7.2.0? If so, then it does make sense that your fix isn't needed any more, because my patch fixed this issue for *all* inline asm for GCC 7+.
Yes it was with GCC 7.2.0
Quoted 2 lines
Signature · 1 line
Josh
Signature · 4 lines
Regards, Miguel Bernal Marin Open Source Technology Center https://clearlinux.org Intel Corporation