Re: Assembly code for calling a function on amd machine

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

 



Hi,

> correct me please, are u intending to write assembly for 64 or 32 bit
> CPU (intel or AMD does not matter)?
>
> Your previous post on PAGE_NX implied 64bit, but here below the
> assembly is for 32 bit.
>

I'm running a 32 bit OS on a 64 bit machine.

[root@dev]# uname -a
Linux xx@xxxxxxx 2.6.18.8 #1 SMP Tue Jul 15 10:46:42 CDT 2008 i686
athlon i386 GNU/Linux


> In userspace, if u have 32bit packages on the 64bit kernel, u can
> still execute and run 32bit applications.
> But not in kernel, as all must be the same bit size.
>
>> Below is the code for intel machines. it is for calling a function
>> using arguments for the stack. Any obvious mistakes for an AMD
>> machine. Is there any recourse for me for calling kernel driver
>> functions? Please help.
>>
>> #define FUNCTONCALL(f, n, r) \
>>  asm ( \
>>        "movl %0, %%eax\n" \
>>        "subl %%eax, %%esp\n" \
>>        "pushl %%esi\n" \
>>        "pushl %%edi\n" \
>>        "movl %%esp, %%edi\n" \
>>        "movl %%ebp, %%esi\n" \
>>        "addl $8, %%edi\n" \
>>        "addl $8, %%esi\n" \
>>        "shr  $2, %%eax\n" \
>>        "movl %%eax, %%ecx\n" \
>>        "repz movsd\n" \
>>        "popl %%edi\n" \
>>        "popl %%esi\n" \
>>        : : "r" (n*4) : "esi","edi","eax","ecx","esp" ); \
>>  r ( (int (*)(void)) f)(); \
>>  asm ("addl %0, %%esp\n" : : "r" (n*4))
>>
>

I also figured out that I'm not using fastcall and I can see the
argument in stack so the bug is in the assembly. What changes would
there be for 64 bit? Is there any document for it. Also, I realize in
that case this does not become a kernel related question as such for
this mailing list.

Regards,
Asim

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux