Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Add I vs D cache coherence instructions #125

Open
mbitsnbites opened this issue Mar 19, 2021 · 1 comment
Open

Add I vs D cache coherence instructions #125

mbitsnbites opened this issue Mar 19, 2021 · 1 comment

Comments

@mbitsnbites
Copy link
Member

mbitsnbites commented Mar 19, 2021

A common method for synchronizing the I$ with recently updated D$ content (when loading program/patching code, JIT, etc) goes as follows:

  1. Flush affected D$ lines (loop over memory range).
  2. Wait for 1 to complete (take effect in next level memory).
  3. Invalidate affected I$ lines (loop over memory range).
  4. Wait for 3 to complete.
  5. Flush the instruction pipeline.

To support this we need instructions for the following tasks (at least):

  • Query the I & D cache line sizes.
  • Flush a D cache line.
  • Invalidate an I cache line.
  • Instruction barrier (of different kinds).
  • Data barrier (of different kinds).

Some inspiration from AArch64: https://github.com/tianocore/edk2/blob/master/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S

@mbitsnbites
Copy link
Member Author

mbitsnbites commented Apr 13, 2023

Currently implemented:

  • SYNC - Combined instruction and data barrier
  • CCTRL - Cache Control (invalidate, flush, ...)

Querying cache line sizes etc should be implemented via system registers (XCHGSR).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant