From: David Daney <ddaney@caviumnetworks.com>
To: "Kevin D. Kissell" <kevink@paralogos.com>
Cc: Brian Foster <brian.foster@innova-card.com>, linux-mips@linux-mips.org
Subject: Re: [PATCH 1/2] MIPS: Preliminary vdso.
Date: Mon, 27 Apr 2009 08:54:46 -0700 [thread overview]
Message-ID: <49F5D546.2000806@caviumnetworks.com> (raw)
In-Reply-To: <49F5AA6A.7010402@paralogos.com>
Kevin D. Kissell wrote:
> Well, he's *almost* right about that. The delay slot emulation function
> executes a single instruction off the user stack/vdso slot, which is
> followed in memory by an instruction that provokes an address
> exception. The address exception handler detects the special case (and
> it should be noted that detecting the special case could be made simpler
> and more reliable if a vdso-type region were used),
Ralf recently changed this to a 'break' instruction, but the logic
remains the same.
> cleans up, and
> restores normal stack behavior. That "clean up" could, of course,
> include any necessary vdso slot management. But what about cases that
> won't get to the magic alignment trap?
>
> As the instruction being executed is extracted from a branch delay slot,
> we know it's not legal for it to be any sort of branch or jump
> instruction.
These we would detect and since the behavior is 'UNPREDICTABLE' we can
treat them as a nop and remain within the specified behavior.
> But it *could* be a trap or system call instruction, or a
> load/store that would provoke a TLB exception. In the usual cases,
> however, as I believe David was alluding, either the exception will
> ultimately unwind to return to execute the magic alignment trap, or the
> thread will exit, and could free the emulation slot as part of general
> cleanup.
>
> But there's a case that isn't handled in this model, and that's the case
> of an exception (or interrupt that falls in the 2-instruction window)
> resulting in a signal that is caught and dispatched, and where either
> the signal handler does a longjmp and restarts FP computation, or where
> the signal handler itself contains a FP branch with yet another delay
> slot to be emulated. One *could* get alarm signal before the original
> delay slot instruction is executed, so recycling the same vdso cache
> line would be premature. It's hard to get away from something
> distinctly stack-like if one wants to cover these cases.
>
System calls we don't have to handle, they will eventually return to the
break instruction following the delay slot instruction and be handled by
the normal processing.
I am thinking that all other exceptions will result in one of three cases:
1) They will work like system calls and return to the 'break'.
2) The thread will exit.
3) They result in a signal being sent to the thread. We can handle it
in force_signal(). In this case we would adjust the eip to point at the
original location of the instruction and clean things up. If the
signal handler tries to restart the instruction, the FP emulator will
re-run the emulation.
> My short-term suggestion would be to leave FP emulator delay slot
> handling on the (executable) user stack, even if signal trampolines use
> the vdso.
They are really two seperate (but related) problems. If we want
eXecute-Inhibit for the stack we need to solve it.
> Longer term, we might consider what sorts of crockery would
> be necessary to deal with delay slot abandonment and recursion. That
> might mean adding cruft to the signal dispatch logic to detect that
> we're in mid-delay-slot-emulation and defer the signal until after the
> alignment trap cleanup is done (adds annoying run-time overhead, but is
> probably the smallest increase in footprint and complexity), or it might
> mean changing the delay slot emulation paradigm completely and bolting a
> full instruction set emulator into the FP emulator, so that the delay
> slot instruction is simulated in kernel mode, rather than requiring
> execution in user mode. I rejected that idea out-of-hand when I first
> did the FP emulator integration with the kernel, years ago, but maybe
> the constraints have changed...
>
I think full instruction set emulation is not so easy. How would you
emulate COP2 instructions?
David Daney
next prev parent reply other threads:[~2009-04-27 15:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 21:30 [PATCH 0/2] MIPS: Move signal return trampolines off the stack David Daney
2009-04-21 21:33 ` [PATCH 1/2] MIPS: Preliminary vdso David Daney
2009-04-22 5:24 ` Shane McDonald
2009-04-22 15:18 ` David Daney
2009-04-22 9:35 ` Kevin D. Kissell
2009-04-22 18:01 ` David Daney
2009-04-24 7:20 ` Brian Foster
2009-04-24 7:50 ` Kevin D. Kissell
2009-04-24 15:30 ` David Daney
2009-04-27 7:19 ` Brian Foster
2009-04-27 12:51 ` Kevin D. Kissell
2009-04-27 15:54 ` David Daney [this message]
2009-04-27 17:27 ` Kevin D. Kissell
2009-04-27 18:26 ` David Daney
2009-04-22 17:50 ` David VomLehn
2009-04-22 18:05 ` David Daney
2009-04-22 18:28 ` David VomLehn
2009-04-21 21:33 ` [PATCH 2/2] MIPS: Move signal trampolines off of the stack David Daney
2009-04-22 17:57 ` David VomLehn
2009-04-22 18:04 ` [PATCH 0/2] MIPS: Move signal return trampolines off " David VomLehn
2009-04-22 18:13 ` David Daney
2009-04-22 18:31 ` David VomLehn
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=49F5D546.2000806@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=brian.foster@innova-card.com \
--cc=kevink@paralogos.com \
--cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.