mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Tom Storey <tom@snnap.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Building for m68k
Date: Thu, 23 Apr 2020 22:37:28 -0400	[thread overview]
Message-ID: <20200424023728.GD11469@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAFDgZgWhZeQ18C5w8ejqTvSc+6A8v-v0fe5mCSYODvBUZM-zSQ@mail.gmail.com>

On Fri, Apr 24, 2020 at 12:29:51PM +1000, Tom Storey wrote:
> Ah yeah. Cool.
> 
> I did something similar in a recent Z80 based project, shouldn't be too
> difficult to do that on m68k.
> 
> Only trouble I can see arising from this is enabling and disabling
> interrupts is privileged, and from the 68010 onwards you can't even see the
> status register to know if interrupts are on/off outside of supervisor
> mode, so you wouldn't be able to execute this code from any application
> running in user mode.

Yes, the cli/sti approach only works without separate privilege
domains, which normally corresponds to having an MMU (without MMU
privilege domains are pretty much "cooperative" anyway).

> I suppose that is why it's better trapped as an invalid instruction and
> emulated lower down?

Trap-and-emulate is the easy/clean way to do atomic cas when you do
have a separate kernel privilege domain and can't mask interrupts, but
it's also very inefficient. The efficient way is by having a contract
with the kernel where the kernel can detect interruption of the
critical section and restart it at the beginning if a context switch
interrupted it. Lookup ARM (pre-v6) kuser_helper to see how this
worked. It's a really elegant design (aside from the hard-coded
addresses) and not hard to implement.

SH3/4 also had a similar mechanism but with a different contract where
userspace was responsible for more of it, and that was incompatible
with large address spaces because it assigned special meaning to
"negative" stack pointer values. I wouldn't recommend copying it but
it's possibly worth taking a look and comparing it to the ARM
kuser_helper approach.

Rich

      reply	other threads:[~2020-04-24  2:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  2:05 Tom Storey
2020-04-23  2:32 ` Rich Felker
2020-04-23  5:04   ` Tom Storey
2020-04-23 16:30     ` Rich Felker
2020-04-24  0:36       ` Tom Storey
2020-04-24  0:51         ` Rich Felker
2020-04-24  1:14           ` Tom Storey
2020-04-24  1:20             ` Rich Felker
2020-04-24  2:29               ` Tom Storey
2020-04-24  2:37                 ` Rich Felker [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=20200424023728.GD11469@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=tom@snnap.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).