linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: Rich Felker <dalias@libc.org>, linux-sh@vger.kernel.org
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	shumpei.kawasaki@swhwc.com,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	jeff@uclinux.org, Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v2] arch/sh: provide unified syscall trap compatible with all SH models
Date: Tue, 15 Sep 2015 03:17:50 +0000	[thread overview]
Message-ID: <55F78DDE.9060409@landley.net> (raw)
In-Reply-To: <20150825212311.GM32742@brightrain.aerifal.cx>

On 08/25/2015 04:23 PM, Rich Felker wrote:
> From: Rich Felker <dalias@libc.org>
> 
> Historically SH-2 Linux (and originally uClinux) used a syscall
> calling convention incompatible with the established SH-3/4 Linux ABI.
> This choice was made because the trap range used by the existing ABI,
> 0x10-0x17, overlaps with the hardware exception/interrupt trap range
> reserved by SH-2, and in particular, with the SH-2A divide-by-zero and
> division-overflow exceptions.
> 
> Despite the documented syscall convention using the low bits of the
> trap number to signal the number of arguments the kernel should
> expect, no version of the kernel has ever used this information, nor
> is it useful; all of the registers need to be saved anyway. Therefore,
> it is possible to pick a new trap number, 0x1f, that is both supported
> by all existing SH-3/4 kernels and unassigned as a hardware trap in
> the SH-2 range. This makes it possible to produce SH-2 application
> binaries that are forwards-compatible with running on SH-3/4 kernels
> and to treat SH as a unified platform with varying ISA support levels
> rather than multiple gratuitously-incompatible platforms.
> 
> This patch adjusts the range checking SH-2 and SH-2A kernels make for
> the syscall trap to accept the range 0x1f-0x2f rather than just
> 0x20-0x2f. As a result, trap 0x1f now acts as a syscall for all SH
> models.

Except that sh2 is a nommu platform, requiring different binary formats.
You can't run a standard ELF binary on sh2, and sh3/4 usually don't have
fdpic or elf loaders configured in.

Even if you could, basic system calls like fork() don't work on a nommu
system. The workarounds for fork() not working (re-exec yourself
signaling that this is the second instance, then have main() detect the
signal and call a different entry point) are intrusive and cumbersome
enough that you generally don't want them in programs that _don't_ need
them. Therefore you historically always distinguish at build time
whether to include nommu codepaths or not. This is why uClibc doesn't
include those in nommu builds of the library, so you can easily
comple-time probe for it even when cross compiling.

(Speaking of which, I would very much like to be able to pass a NULL
exec to signal "re-exec this same program" without relying on /proc to
be mounted for /proc/self/exe, but alas the kernel can't do that.)

I agree it doesn't hurt anything (other than new binaries built to use
it not running on old kernels, but that's pretty much the case for fdpic
anyway), but what is the actual _advantage_ of this patch?

Rob

  reply	other threads:[~2015-09-15  3:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25  3:03 [PATCH] arch/sh: provide unified syscall trap compatible with all SH models Rich Felker
2015-08-25  7:18 ` Geert Uytterhoeven
2015-08-25  7:22   ` Rich Felker
2015-08-25 21:23 ` [PATCH v2] " Rich Felker
2015-09-15  3:17   ` Rob Landley [this message]
2015-09-15  4:28     ` Rich Felker
2015-09-15  4:11   ` Rich Felker
2015-10-01 22:27     ` Rich Felker

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=55F78DDE.9060409@landley.net \
    --to=rob@landley.net \
    --cc=dalias@libc.org \
    --cc=geert@linux-m68k.org \
    --cc=jeff@uclinux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=shumpei.kawasaki@swhwc.com \
    --cc=ysato@users.sourceforge.jp \
    /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 NNTP newsgroup(s).