Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: "Kevin D. Kissell" <kevink@mips.com>
To: Brian Foster <brian.foster@innova-card.com>
Cc: David Daney <ddaney@avtrex.com>,
	linux-mips@linux-mips.org, Thiemo Seufer <ths@networkno.de>,
	"Kevin D. Kissell" <KevinK@paralogos.com>,
	Andrew Dyer <adyer@righthandtech.com>
Subject: Re: Adding(?) XI support to MIPS-Linux?
Date: Wed, 11 Jun 2008 20:51:10 +0200	[thread overview]
Message-ID: <48501E9E.1040202@mips.com> (raw)
In-Reply-To: <200806111516.57406.brian.foster@innova-card.com>

Brian Foster wrote:
>  It's case 2 (above), the trampoline that has “something
>  to do with FPU emulation”, which has me concerned ATM.
>  The 4KSd core does not have an FPU.  That encourages the
>  use of ‘-msoft-float’ (at least for performance), but does
>  not require it.  (Albeit I wonder if, in the restricted
>  world I'm playing in, if it could be “required” (assuming
>  it doesn't have an issue?)?  Hum .... .)
>   
The use of -msoft-float historically required (and as far as I know 
still requires)
a completely different ground-up userland build, so it gets used less 
than you
might think.
>  The quick summary (which I'm sure others on this list can
>  clarify/correct) is the FP trampoline, which is pushed on
>  the user-land stack is, unlike sigreturn, not fixed code.
>  It varies on a per-instance per-thread basis.  Hence the
>  simple ‘vsyscall’ mechanism ((to be?) used for sigreturn)
>  is inappropriate.
>
>  The trampoline is only used to execute a non-FP instruction
>  (<instr>) in the delay slot of an FP-instruction:
>
>      <instr>  # Non-FP instruction to execute in user-land
>      BADINST  # Bad instruction forcing return to FP emulator
>      COOKIE   # Bad instruction (not executed) for verification
>      <epc>    # Where to resume execution after <instr>
>
>  Belch! ;-\  Whilst I can think of a few things that may work
>  (temporarily change page permissions;  or go ahead and use
>  the ‘vsyscall’ page with some interlocking magic;  or a new
>  new dedicated per-thread page;  or ...?) none seem appealing.
>
>  Suggestions?  Comments?  Prior art to study?
>   
As the jerk who originally bolted the FP emulator into the MIPS kernel
and came up with the stack trampoline hack, I can explain why it seemed
sane at the time.  If an FP branch is emulated and to be taken, we have to
find a way for the instruction in the delay slot to be executed prior to the
transfer of control to the branch target.  It has to execute with the user's
permissions.  Putting it on the user's stack and building a trampoline was
the fairly classical way of doing it, but note that it's architecturally 
illegal
to put a branch in a branch delay slot (floating point or otherwise), so
there's no possibility of recursion. So one only needs 3-4 words (one
could substitute another means of validation for the cookie) per
thread.  It just has to be part of the user's address space.  I suppose
that instead of using a few words just above the stack, one could use
a few words just below the current "brk()" point, or, better still (but
far more invasive) pad the text segment, which should always be
executable, with 4 words that the kernel can find in a hurry.

          Regards,

          Kevin K.

  reply	other threads:[~2008-06-11 18:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200806091658.10937.brian.foster@innova-card.com>
2008-06-09 15:37 ` Re: Adding(?) XI support to MIPS-Linux? Brian Foster
2008-06-09 19:32   ` Kevin D. Kissell
2008-06-09 20:46     ` Thiemo Seufer
     [not found]       ` <200806101119.06227.brian.foster@innova-card.com>
2008-06-10  9:32         ` Brian Foster
2008-06-10  9:57           ` Thiemo Seufer
2008-06-10 16:21             ` David Daney
2008-06-11 13:16               ` Brian Foster
2008-06-11 18:51                 ` Kevin D. Kissell [this message]
2008-06-12 12:03                   ` Brian Foster
2008-06-18  8:42                 ` Brian Foster
2008-06-18  9:36                   ` Kevin D. Kissell
2008-06-18  9:45                     ` Brian Foster
2008-06-11  9:06     ` Ralf Baechle
2008-06-11  9:35       ` Kevin D. Kissell
     [not found] <200806091050.m59AoUUl014012@smtp02.msg.oleane.net>
2008-06-09 10:55 ` Brian Foster

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=48501E9E.1040202@mips.com \
    --to=kevink@mips.com \
    --cc=KevinK@paralogos.com \
    --cc=adyer@righthandtech.com \
    --cc=brian.foster@innova-card.com \
    --cc=ddaney@avtrex.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ths@networkno.de \
    /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