Skip to content

Conversation

@jserv
Copy link
Collaborator

@jserv jserv commented Oct 24, 2025

This adds TLB to cache virtual-to-physical address translations:

  • cache_fetch: 1-entry direct-mapped for instruction fetch
  • cache_load: 2-entry direct-mapped with hash-based indexing
  • cache_store: 1-entry direct-mapped for data stores

Cache invalidation handled at all necessary points: SATP writes, fence instructions, mode switches, and trap entry/exit.

Optional statistics support via MMU_CACHE_STATS compile flag shows ~96% fetch, ~69% load, and ~84% store hit rates during kernel boot.


Summary by cubic

Add a small TLB for MMU translations: 1-entry caches for fetch/store and a 2-way cache for loads. This cuts page-table walks and speeds up memory access, with optional per-hart hit/miss stats.

  • New Features

    • 1-entry direct-mapped fetch and store translation caches.
    • 2-way set-associative load translation cache (indexed by VPN bit 0).
    • Central mmu_invalidate clears all caches; RFENCE now calls it.
    • MMU_CACHE_STATS flag: per-hart hit/miss counters and a summary printout; run exits after 15s to dump stats.
    • Observed hit rates: ~96% fetch, ~69% load, ~84% store during kernel boot.
  • Bug Fixes

    • LR/SC reservations now track physical addresses to avoid alias issues.

@jserv jserv requested a review from ChinYikMing October 24, 2025 17:57
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv requested a review from Mes0903 October 24, 2025 18:22
@jserv jserv force-pushed the mmu-caching branch 2 times, most recently from 388c5b7 to bc00cfb Compare October 25, 2025 04:09
@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Oct 25, 2025
@sysprog21 sysprog21 deleted a comment from cubic-dev-ai bot Oct 25, 2025
cubic-dev-ai[bot]

This comment was marked as duplicate.

cubic-dev-ai[bot]

This comment was marked as resolved.

This adds TLB to cache virtual-to-physical address translations:
- cache_fetch: 1-entry direct-mapped for instruction fetch
- cache_load: 2-entry direct-mapped with hash-based indexing
- cache_store: 1-entry direct-mapped for data stores

Cache invalidation handled at all necessary points: SATP writes,
fence instructions, mode switches, and trap entry/exit.

Optional statistics support via MMU_CACHE_STATS compile flag shows
~96% fetch, ~69% load, and ~84% store hit rates during kernel boot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant