Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1727157 > unrolled thread

[PATCH 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write()

Started byMiguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
First post2017-09-06 07:30 +0200
Last post2017-09-06 07:30 +0200
Articles 1 — 1 participant

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.


Contents

  [PATCH 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write() Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com> - 2017-09-06 07:30 +0200

#1727157 — [PATCH 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write()

FromMiguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Date2017-09-06 07:30 +0200
Subject[PATCH 2/3] locking/rwsem/x86: Add stack frame dependency for __up_write()
Message-ID<umB4t-5b7-5@gated-at.bofh.it>
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] | [standalone]


Back to top | Article view | linux.kernel


csiph-web