mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Wim Van Sebroeck <wim@iguana.be>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thomas Mingarelli <Thomas.Mingarelli@hp.com>
Subject: Re: [WATCHDOG] v2.6.26 hpwdt.c fixes
Date: Wed, 18 Jun 2008 13:30:12 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0806181327390.2907@woody.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.10.0806181256010.2907@woody.linux-foundation.org>



On Wed, 18 Jun 2008, Linus Torvalds wrote:
> 
> Quite frankly, this is *not* the right thing to do either: the proper 
> thing to do is to just move the low-level call into the "asm" statement, 
> and leave all the function prologue/epilogue entirely to the compiler.

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");
 }
 
 /*

  reply	other threads:[~2008-06-18 20:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-18 19:49 Wim Van Sebroeck
2008-06-18 20:09 ` Linus Torvalds
2008-06-18 20:30   ` Linus Torvalds [this message]
2008-06-19 14:58     ` Mingarelli, Thomas
2008-06-19 19:38     ` Mingarelli, Thomas
2008-06-18 21:58   ` S.Çağlar Onur
2008-06-18 22:03     ` Mingarelli, Thomas
2008-06-18 22:08       ` S.Çağlar Onur
2008-06-20 19:05   ` Dave Jones
2008-06-20 19:30     ` Linus Torvalds
2008-06-20 20:40       ` Mingarelli, Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.10.0806181327390.2907@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=Thomas.Mingarelli@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®