Linux-man Archive mirror
 help / color / mirror / Atom feed
From: Eugene Syromyatnikov <evgsyr@gmail.com>
To: Ronald Monthero <debug.penguin32@gmail.com>
Cc: alx@kernel.org, linux-man@vger.kernel.org
Subject: Re: Documentation: Architecture/ABI calling convention table - syscall( )
Date: Wed, 14 Feb 2024 17:39:05 +0100	[thread overview]
Message-ID: <20240214163905.456v76p67vgyih2e@nurgle> (raw)
In-Reply-To: <CALk6Uxoss7s-rxsKW=dcGWd9rmj3xnLksQvLn7Cyb7EvdSA2Ag@mail.gmail.com>

On Wed, Feb 14, 2024 at 11:26:39PM +1000, Ronald Monthero wrote:
> Hello,
> Below is in relation to architecture calling standards table for man
> syscall, for the indicated at [1] , [2]  and [3]   need to be changed
> perhaps.  ( arg4 of x86-64 architecture needs to be rcx instead of r10
> and the x32 arch table values needs replacement with exx register
> naming respectively. And also the return value register table for x32
> needs to be eax and edx for return val and return val2 respectively )
> ------------
> 
>        Arch/ABI      arg1  arg2  arg3  arg4  arg5  arg6  arg7  Notes
>        ─────────────────────────────
> ────────
>        alpha            a0    a1    a2    a3    a4    a5    -
>        arc                r0    r1    r2    r3    r4    r5    -
>        arm/OABI     r0    r1    r2    r3    r4    r5    r6
>        arm/EABI      r0    r1    r2    r3    r4    r5    r6
>        arm64          x0    x1    x2    x3    x4    x5    -
>        blackfin       R0    R1    R2    R3    R4    R5    -
>        i386            ebx   ecx   edx   esi   edi   ebp   -
>        ia64            out0  out1  out2  out3  out4  out5  -
>        m68k          d1    d2    d3    d4    d5    a0    -
>        microblaze    r5    r6    r7    r8    r9    r10   -
>        mips/o32      a0    a1    a2    a3    -     -     -     1
>        mips/n32,64   a0    a1    a2    a3    a4    a5    -
>        nios2          r4    r5    r6    r7    r8    r9    -
>        parisc        r26   r25   r24   r23   r22   r21   -
>        powerpc       r3    r4    r5    r6    r7    r8    r9
>        powerpc64     r3    r4    r5    r6    r7    r8    -
>        riscv         a0    a1    a2    a3    a4    a5    -
>        s390          r2    r3    r4    r5    r6    r7    -
>        s390x         r2    r3    r4    r5    r6    r7    -
>        superh        r4    r5    r6    r7    r0    r1    r2
>        sparc/32      o0    o1    o2    o3    o4    o5    -
>        sparc/64      o0    o1    o2    o3    o4    o5    -
>        tile          R00   R01   R02   R03   R04   R05   -
>        x86-64        rdi   rsi   rdx   r10   r8    r9    -
>                                                  ^^-----   ==> need to
> be rcx ?          <<   [1]
>        x32           rdi   rsi   rdx   r10   r8    r9    - ==>  to be
> exx regs   << [2]
> 
> 
>        =>  For x86-64 architecture the function calling standards
>          the arg4 register should be rcx

On what basis are you suggesting that?  [1] says otherwise, and [2]
concurs.

> 
>        => And for x32 it needs to be replaced with x86 32 bit register variants
>          as arg1 = edi , arg2 = esi , arg3 = edx, arg4 = ecx

I'm pretty sure that x32 ABI uses the same registers as x86_64.
strace's src/linux/x32/get_syscall_args.c[3] corroborates that.

>     2)  Also noticed the return value register table needs similar
> change for x86-32 bit
>      it needs to be eax instead of rax and edx instead of rdx.
> 
>        Arch/ABI    Instruction      System  Ret  Ret  Error    Notes
>                                                  call #    val   val2
>        ─────────────────────────────
> 
>       < snipped >
> 
>        sparc/32    t 0x10                 g1      o0   o1   psr/csr  1, 6
>        sparc/64    t 0x6d                 g1      o0   o1   psr/csr  1, 6
>        tile             swint1                R10     R00  -    R01      1
>        x86-64      syscall                rax     rax  rdx  -        5
>        x32            syscall               rax     rax  rdx  -        5
> 
> ^^^-----^^^--^^^------------------->            <<  [3]
> 
>          =>      for x32 return register has to be changed as
>                    rax => eax  and rdx => edx
> 

Same, x32 ABI is identical to x86_64 in that regard.

[1] https://www.uclibc.org/docs/psABI-x86_64.pdf#page=125
[2] https://gitlab.com/strace/strace/-/blob/8fa8a8886966fb873a67074c67eabf6be63535c0/src/linux/x86_64/get_syscall_args.c#L31
[3] https://gitlab.com/strace/strace/-/blob/8fa8a8886966fb873a67074c67eabf6be63535c0/src/linux/x32/get_syscall_args.c#L31

      reply	other threads:[~2024-02-14 16:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 13:26 Documentation: Architecture/ABI calling convention table - syscall( ) Ronald Monthero
2024-02-14 16:39 ` Eugene Syromyatnikov [this message]

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=20240214163905.456v76p67vgyih2e@nurgle \
    --to=evgsyr@gmail.com \
    --cc=alx@kernel.org \
    --cc=debug.penguin32@gmail.com \
    --cc=linux-man@vger.kernel.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).