amd64/124134: [kernel] The kernel doesn't follow the calling convention in the SVR4/i386 ABI

Kostik Belousov kostikbel at
Sun Dec 5 17:30:17 UTC 2010

The following reply was made to PR amd64/124134; it has been noted by GNATS.

From: Kostik Belousov <kostikbel at>
To: pfgshield-freebsd at
Cc: avg at, freebsd-amd64 at, bug-followup at
Subject: Re: amd64/124134: [kernel] The kernel doesn't follow the calling convention in the SVR4/i386 ABI
Date: Sun, 5 Dec 2010 19:24:55 +0200

 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 On Sun, Dec 05, 2010 at 07:08:07AM -0800, pfgshield-freebsd at wrote:
 > The code has certainly changed a lot  ...
 > Reading the posting on the link with a possible fix:
 > "...
 > Can you try to add to kernel sources, into file sys/amd64/amd64/machdep.c
 > function exec_setregs(td, entry, stack, ps_strings)
 > somewhere at the end
 > 	pcb->pcb_flags |=3D PCB_FULLCTX;
 > ... "
 > We don't have anything similar to this in exec_setregs(), and from my und=
 erstanding the issue could not be easily fixed without breaking binary comp=
 atibility so I would think the issue is still there.
 > This PR was only for reference though as it doesn't cause trouble for us:=
  I'm OK with the PR being closed.
 I looked at the PR before. Looking again now, I have the same conclusion,
 that is I do not understand what is the issue.
 On the first return into usermode after the successfull execve(2), kernel
 sets the following registers:
 - %rsp (properly aligned)
 - %rdi (1st parameter in usermode ABI; contains the pointer to startup
   frame, i.e. &argc)
 - all other GP registers are zeroed.
 ABI rev. 0.99 requires the following setup:
 - %rsp properly aligned and has the value &argc
 - %rdx points to a function to be registered with atexit(3), or NULL.
 We do satisfy the ABI requirement for %rdx content in the trivial way,
 by passing 0.
 The layout of the startup frame also seems conforming.
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 Version: GnuPG v1.4.11 (FreeBSD)

More information about the freebsd-amd64 mailing list