Re: i8k module and x86_64 kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 09, 2006 at 04:45:13PM -0500, Dave Jones wrote:
> On Thu, Nov 09, 2006 at 02:49:11PM +0100, Marcel J.E. Mol wrote:
> 
>  > I forced compilation of the driver for x86_64 and the basic part seems to
>  > work, but it oopses on the small bit of assembly code in the i8k_smm function
>  > of the driver:
> 
> I'm surprised you got it to build in 64bit at all.  It's 32bit assembly,
> which isn't going to dtrt in a 64bit kernel.  Secondly, SMM is very very
> magical code that has to be done correctly for the CPU its targetting
> otherwise it'll just go bang instantly.

Well, it build after changing the pushl and popl into pushq and popq
(and changing the register names to 64 bit versions). But although this
first attempt got me a insmoddable module, it crashes. I looked a bit further
into it and have working version running for a couple of hours now.
It at least show me the fan status and speeds.
Patch attached. I'm not really into assembly and am not sure if
it is all correct, so if it is usefull maybe someone can check it for
validity.

-Marcel
-- 
     ======--------         Marcel J.E. Mol                MESA Consulting B.V.
    =======---------        ph. +31-(0)6-54724868          P.O. Box 112
    =======---------        marcel@xxxxxxx                 2630 AC  Nootdorp
__==== www.mesa.nl ---____U_n_i_x______I_n_t_e_r_n_e_t____ The Netherlands ____
 They couldn't think of a number,           Linux user 1148  --  counter.li.org
    so they gave me a name!  -- Rupert Hine  --  www.ruperthine.com
--- linux-2.6.18/drivers/char/i8k.c	2006-09-20 05:42:06.000000000 +0200
+++ linux-2.6.18.x86_64/drivers/char/i8k.c	2006-11-09 20:39:02.000000000 +0100
@@ -112,6 +112,32 @@
 	int rc;
 	int eax = regs->eax;
 
+#if defined (__x86_64__)
+	asm("pushq %%rax\n\t"
+	    "movl 0(%%rax),%%edx\n\t"
+	    "pushq %%rdx\n\t"
+	    "movl 4(%%rax),%%ebx\n\t"
+	    "movl 8(%%rax),%%ecx\n\t"
+	    "movl 12(%%rax),%%edx\n\t"
+	    "movl 16(%%rax),%%esi\n\t"
+	    "movl 20(%%rax),%%edi\n\t"
+	    "popq %%rax\n\t"
+	    "out %%al,$0xb2\n\t"
+	    "out %%al,$0x84\n\t"
+	    "xchgq %%rax,(%%rsp)\n\t"
+	    "movl %%ebx,4(%%rax)\n\t"
+	    "movl %%ecx,8(%%rax)\n\t"
+	    "movl %%edx,12(%%rax)\n\t"
+	    "movl %%esi,16(%%rax)\n\t"
+	    "movl %%edi,20(%%rax)\n\t"
+	    "popq %%rdx\n\t"
+	    "movl %%edx,0(%%rax)\n\t"
+	    "lahf\n\t"
+	    "shrl $8,%%eax\n\t"
+	    "andl $1,%%eax\n":"=a"(rc)
+	    :    "a"(regs)
+	    :    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
+#else
 	asm("pushl %%eax\n\t"
 	    "movl 0(%%eax),%%edx\n\t"
 	    "push %%edx\n\t"
@@ -136,6 +162,7 @@
 	    "andl $1,%%eax\n":"=a"(rc)
 	    :    "a"(regs)
 	    :    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
+#endif
 
 	if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
 		return -EINVAL;

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux