About

A cache-block management instruction performs one of the following operations, relative to the copy of a given
cache block allocated in a given cache:
• An invalidate operation deallocates the copy of the cache block
• A clean operation performs a write transfer to another cache or to memory if the data in the copy of the
cache block have been modified by a store operation
• A flush operation atomically performs a clean operation followed by an invalidate operation

Implementation (In EDK2):

EDK2 requires several Cache Management constructs to ensure secure image loading and
other functionalities. Current RV implements fence.i based method to partly manage
such cache operations. RV international has recently added support for CMO and this
work relates to adding that to the edk2 so that RV platforms which support this functionality
can leverage it in edk2.

Adding code to support Cache Management Operations (CMO) defined by RV spec https://github.com/riscv/riscv-CMOs Notes: 1. CMO only supports block based Operations. Meaning complete cache flush/invd/clean Operations are not available 2. Current implementation uses ifence instructions but it maybe platform specific. Many platforms may not support cache Operations based on fence.i 3. For now adding CMO on top of fence.i as it is not supposed to have any adverse effect on CMO operation. 4. This requires support for GCC12.2 onwards.

Status

26-Sept:



Dependency

GCC12 (In EDK2 CI)


Development

COMPLETED

URL: https://github.com/rivosinc/edk2/tree/dev_rv_cmo_v3

Development Timeline

Q3 2023


Upstreaming

COMPLETED

URL: 

Upstream version

Contacts

Dhaval Sharma (Rivos)

Updates

  • Project reported as priority for 2H23


2 Comments

  1. Dhaval Sharma can we see a bit more details on the plan? is the development really completed? This should probably include wiring up the CpuDxe CpuFlushCpuDataCache to the CacheMaintenance implementation in https://github.com/rivosinc/edk2/tree/dev_rv_cmo_v3?

    Suggest any discussions around D&I to be done using https://groups.google.com/a/riscv.org/g/fw-exchange

  2. I submitted another rev and I have some comments to address but primarily a dependency on Extension discovery. So confirming with Sunil before I submit the next patch.