All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: loadsegment() optimization
@ 2009-11-25 19:18 Brian Gerst
  2009-11-26  9:55 ` [tip:x86/asm] x86: Optimize loadsegment() tip-bot for Brian Gerst
  2009-11-26  9:56 ` [tip:x86/asm] x86: Clean up the loadsegment() macro tip-bot for Ingo Molnar
  0 siblings, 2 replies; 3+ messages in thread
From: Brian Gerst @ 2009-11-25 19:18 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: x86, linux-kernel

Zero the input register in the exception handler instead of using
an extra register to pass in a zero value.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
 arch/x86/include/asm/system.h |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index f08f973..18ac1ec 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -158,18 +158,19 @@ extern void native_load_gs_index(unsigned);
  * segment if something goes wrong..
  */
 #define loadsegment(seg, value)			\
+do {						\
+	unsigned short __val = value;		\
 	asm volatile("\n"			\
 		     "1:\t"			\
 		     "movl %k0,%%" #seg "\n"	\
-		     "2:\n"			\
 		     ".section .fixup,\"ax\"\n"	\
-		     "3:\t"			\
-		     "movl %k1, %%" #seg "\n\t"	\
-		     "jmp 2b\n"			\
+		     "2:\t"			\
+		     "xorl %k0,%k0\n\t"		\
+		     "jmp 1b\n"			\
 		     ".previous\n"		\
-		     _ASM_EXTABLE(1b,3b)	\
-		     : :"r" (value), "r" (0) : "memory")
-
+		     _ASM_EXTABLE(1b,2b)	\
+		     : "+r" (__val) : : "memory"); \
+} while (0)
 
 /*
  * Save a segment register away
-- 
1.6.5.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-26  9:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25 19:18 [PATCH] x86: loadsegment() optimization Brian Gerst
2009-11-26  9:55 ` [tip:x86/asm] x86: Optimize loadsegment() tip-bot for Brian Gerst
2009-11-26  9:56 ` [tip:x86/asm] x86: Clean up the loadsegment() macro tip-bot for Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.