From: Jacob Lifshay <programmerjake@gmail.com>
To: Libre-RISCV General Development <libre-riscv-dev@lists.libre-riscv.org>
Subject: [libre-riscv-dev] Power memory fences and icache handling
Date: Mon, 11 May 2020 18:42:07 -0700
Message-ID: <CAC2bXD6gWCr9GK7m==YP+riR_8J=aEMGXocMKk7nCzXPSFQifQ@mail.gmail.com> (raw)
In-Reply-To: <CAPweEDxHxc4ZWuQtEnY1EQqdRHuXAqgVXpLxqWRewXJdrPpcwA@mail.gmail.com>
On Mon, May 11, 2020, 17:54 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
wrote:
> On Tuesday, May 12, 2020, Yehowshua <yimmanuel3@gatech.edu> wrote:
>
> > > dcache:
> > > https://github.com/paulusmack/microwatt/blob/mmu/dcache.vhdl <
> > https://github.com/paulusmack/microwatt/blob/mmu/dcache.vhdl>
> > >
> > > icache:
> > > https://github.com/paulusmack/microwatt/blob/mmu/icache.vhdl <
> > https://github.com/paulusmack/microwatt/blob/mmu/icache.vhdl>
> >
> >
> > I was actually talking to Michael about that the other day.
> >
> > If you have an instruction that does a store to a location in the icache,
>
>
> that is prohibited by design.
>
If you're trying to run a standard Linux OS, writing to memory that could
be in the icache is required, that's how the dynamic linker works.
Additionally, loading code from disk (e.g. the exec() call) or JIT
compilation also requires writing to memory then executing it. In all of
those cases one or more icache invalidate and then an isync instruction (or
other context synchronizing instruction) are run before running the
modified code.
Note: it turns out that isync doesn't do any icache flushing without
additional icache invalidate instructions, so it's not quite as expensive
as I had originally thought for Power atomics, however, it still restarts
fetching and decoding instructions, so is still more expensive than
necessary for just using it as an atomic fence.
It's standard practice for JITs to map a section of memory with all of R/W
and execute permissions simultaneously, then, once a section of code is
written/modified, it will run the required icache invalidate and isync
instructions (RISC-V just uses a single fence.i instruction that must be
run on all harts using a syscall) before trying to execute the changed code.
Jacob
>
_______________________________________________
libre-riscv-dev mailing list
libre-riscv-dev@lists.libre-riscv.org
http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev
next prev parent reply index
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 22:19 [libre-riscv-dev] ppc-dev linux patch support for microwatt! Luke Kenneth Casson Leighton
2020-05-11 22:23 ` Luke Kenneth Casson Leighton
2020-05-11 22:27 ` Yehowshua
2020-05-11 22:34 ` Luke Kenneth Casson Leighton
2020-05-11 22:53 ` Luke Kenneth Casson Leighton
2020-05-11 23:02 ` Yehowshua
2020-05-12 0:53 ` Luke Kenneth Casson Leighton
2020-05-12 0:56 ` Yehowshua
2020-05-12 1:25 ` Luke Kenneth Casson Leighton
2020-05-12 1:42 ` Jacob Lifshay [this message]
2020-05-12 3:29 ` [libre-riscv-dev] Power memory fences and icache handling Luke Kenneth Casson Leighton
2020-05-11 22:23 ` [libre-riscv-dev] ppc-dev linux patch support for microwatt! Yehowshua
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='CAC2bXD6gWCr9GK7m==YP+riR_8J=aEMGXocMKk7nCzXPSFQifQ@mail.gmail.com' \
--to=programmerjake@gmail.com \
--cc=libre-riscv-dev@lists.libre-riscv.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
Libre RISC-V Mailing list Archives (accessible via public-inbox)
Archives are clonable: git clone --mirror https://inbox.libre-soc.org/libre-riscv-dev
Example config snippet for mirrors
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git