Re: [WATCHDOG] v2.6.26 hpwdt.c fixes

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Wim Van Sebroeck <wim@...>
Cc: Andrew Morton <akpm@...>, LKML <linux-kernel@...>, Thomas Mingarelli <Thomas.Mingarelli@...>
Date: Wednesday, June 18, 2008 - 4:30 pm

On Wed, 18 Jun 2008, Linus Torvalds wrote:

Something like the following.

AGAIN! This is totally untested. It's meant as an *example* of how to use 
inline asm properly, not meant to necessarily work or do the right thing. 
It may be buggy as hell, for all I know. And there are probably better 
ways to do this.

(This one does just the 64-bit version, because it's a bit easier: the 
32-bit version needs to probably do some of the loading and storing of 
registers manually in the inline asm just to avoid running out of them, 
since the register pressure is worse).

		Linus

---
 drivers/watchdog/hpwdt.c |   50 +++++++++++++++------------------------------
 1 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 2686f3e..028c957 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -336,39 +336,23 @@ static int __devinit detect_cru_service(void)
 asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
 			       unsigned long *pRomEntry)
 {
-	asm("pushq      %rbp            \n\t"
-	    "movq       %rsp, %rbp      \n\t"
-	    "pushq      %rax            \n\t"
-	    "pushq      %rbx            \n\t"
-	    "pushq      %rdx            \n\t"
-	    "pushq      %r12            \n\t"
-	    "pushq      %r9             \n\t"
-	    "movq       %rsi, %r12      \n\t"
-	    "movq       %rdi, %r9       \n\t"
-	    "movl       4(%r9),%ebx     \n\t"
-	    "movl       8(%r9),%ecx     \n\t"
-	    "movl       12(%r9),%edx    \n\t"
-	    "movl       16(%r9),%esi    \n\t"
-	    "movl       20(%r9),%edi    \n\t"
-	    "movl       (%r9),%eax      \n\t"
-	    "call       *%r12           \n\t"
-	    "pushfq                     \n\t"
-	    "popq        %r12           \n\t"
-	    "popfq                      \n\t"
-	    "movl       %eax, (%r9)     \n\t"
-	    "movl       %ebx, 4(%r9)    \n\t"
-	    "movl       %ecx, 8(%r9)    \n\t"
-	    "movl       %edx, 12(%r9)   \n\t"
-	    "movl       %esi, 16(%r9)   \n\t"
-	    "movl       %edi, 20(%r9)   \n\t"
-	    "movq       %r12, %rax      \n\t"
-	    "movl       %eax, 28(%r9)   \n\t"
-	    "popq       %r9             \n\t"
-	    "popq       %r12            \n\t"
-	    "popq       %rdx            \n\t"
-	    "popq       %rbx            \n\t"
-	    "popq       %rax            \n\t"
-	    "leave                      \n\t" "ret");
+	asm("pushq %0 ; popfq ; call *%6; pushfq; popfq %0"
+		:"=r" (pi86Regs->reflags),
+		 "=a" (pi86Regs->u1.reax),
+		 "=b" (pi86Regs->u2.rebx),
+		 "=c" (pi86Regs->u3.recx),
+		 "=d" (pi86Regs->u4.redx),
+		 "=S" (pi86Regs->resi),
+		 "=D" (pi86Regs->redi)
+		:"r" (pRomEntry),
+		 "0" (pi86Regs->reflags),
+		 "1" (pi86Regs->u1.reax),
+		 "2" (pi86Regs->u2.rebx),
+		 "3" (pi86Regs->u3.recx),
+		 "4" (pi86Regs->u4.redx),
+		 "5" (pi86Regs->resi),
+		 "6" (pi86Regs->redi)
+		:"cc", "memory");
 }
 
 /*
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[WATCHDOG] v2.6.26 hpwdt.c fixes, Wim Van Sebroeck, (Wed Jun 18, 3:49 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, Linus Torvalds, (Wed Jun 18, 4:09 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, Dave Jones, (Fri Jun 20, 3:05 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, Linus Torvalds, (Fri Jun 20, 3:30 pm)
RE: [WATCHDOG] v2.6.26 hpwdt.c fixes, Mingarelli, Thomas, (Fri Jun 20, 4:40 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, S.Çağlar, (Wed Jun 18, 5:58 pm)
RE: [WATCHDOG] v2.6.26 hpwdt.c fixes, Mingarelli, Thomas, (Wed Jun 18, 6:03 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, S.Çağlar, (Wed Jun 18, 6:08 pm)
Re: [WATCHDOG] v2.6.26 hpwdt.c fixes, Linus Torvalds, (Wed Jun 18, 4:30 pm)
RE: [WATCHDOG] v2.6.26 hpwdt.c fixes, Mingarelli, Thomas, (Thu Jun 19, 3:38 pm)
RE: [WATCHDOG] v2.6.26 hpwdt.c fixes, Mingarelli, Thomas, (Thu Jun 19, 10:58 am)