Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

virtualization support, major build system refactoring, heap improvements, and extensive code cleanup for public release.#23

Merged
jerinjoy merged 302 commits intomainfrom
dev/joy/update_for_nov2025
Nov 13, 2025
Merged

virtualization support, major build system refactoring, heap improvements, and extensive code cleanup for public release.#23
jerinjoy merged 302 commits intomainfrom
dev/joy/update_for_nov2025

Conversation

@jerinjoy
Copy link
Contributor

This PR introduces virtualization support, major build system refactoring, heap improvements, and extensive code cleanup for public release.

Key Changes

Virtualization Support

  • Added run_function_in_vumode() and run_function_in_mmode_from_smode() APIs
  • Enhanced VS/VU-mode exception handling and context switching
  • Improved IMSIC setup and virtualization support

Build System

  • Introduced DiagFactory with YAML-based multi-diagnostic build/run
  • Replaced --target with --environment configuration
  • Enhanced Meson integration and build artifact management

Heap & Memory

  • Implemented round-robin allocation strategy
  • Added memory type-specific allocation functions
  • Improved chunk management and error reporting
  • Exposed memalign() in the API

M-Mode & Infrastructure

  • Refactored M-mode initialization and setup
  • Extracted common locking/UART code for cross-mode reuse
  • Added automatic address assignment with NAPOT alignment
  • Improved CPU ID management and thread attributes

Testing & Documentation

  • Added new tests (test049-073) for virtualization and heap features
  • Updated reference manual and README for public release

Code Quality

  • Extensive cleanup and bug fixes for public release
  • Improved error handling and type hints
  • Updated copyright headers for 2025

jerinjoy and others added 30 commits November 10, 2025 15:23
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
Updated the test053 to remove the arbitrary check for the number of
seconds passed.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
This is currently only used to override the diag entry label which
should really be a diag attribute.
I'm also not sure how we can override the attributes for the various
modes.
Will revisit this if it's actually needed.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
to improve readability and reduce verbosity. Future renames of section
attributes will touch only the macros.

Added "cpu" to the names of the .jumpstart sections. This allows us
to distinguish between sections for various MMUs. At this
point we only have the CPU MMU.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
meson setup doesn't like "True"/"False" strings that python puts out.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Override diag attributes to reduce the size of the diag as much as
possible.
Use the elf_start/end_address diag attribute to enforce the LRAM bounds
check.
Signed-off-by: Jerin Joy <joy@rivosinc.com>
If the ELF is moved into the --diag_build_dir after the meson compile
step the meson test step will have to relink the ELF.
The relinking is happening for spike runs but not for qemu runs because
the diag ELF dependency is correctly handled by the meson test call for
spike.

The right thing to do is to copy the ELF and not move it after meson
compile so that meson test can just use that ELF.

The ELF dependency issue for the meson test qemu call will be fixed in
the next commit.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
For the spike target the diag_exe dependency was correctly enforced
because we're using it directly.
For oswis and qemu the dependency wasn't enforced because we're using
diag_exe.full_path().

This was causing issues with build_diag.py flow where we would
(incorrectly) move the ELF to the diag_build_dir after the compile step
instead of copying it. build_diag.py is fixed to copy instead of move
but it's better to enforce this dependency.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
to improve readability.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
The newer version of reuse drops the '='.

Reference:
https://rivosinc.atlassian.net/browse/IT-7582

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
This allows s-mode access to the `stimecmp` register which is required
for s-mode to operate the timer.

Signed-off-by: Mattias Nissler <mnissler@rivosinc.com>
Added ifdefs to gate references in a higher mode to a lower mode that
isn't enabled in the build.

Renamed smode data area to privileged data area.
This is shared by both mmode and smode. We're going to allow builds
without smode regions but we still need this data area for mmode.
Include this privileged data area along with the mmode area.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
This was used to test the code in the mmode section being larger than
the number of pages allocated for it.

This is not needed anymore because generate_diag_sources.py will add a
guard linker section after every linker section that isn't followed by
another section. When a section is overrun and runs into the guard
section the linker will fail the build.

This test required num_pages_for_jumpstart_mmode_text to have more pages
than were actually required just to so that it could build. We can now
reduce num_pages_for_jumpstart_mmode_text.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Let the build scripts that use the class decide.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
The commit ef04a4fb moved data.privileged.S to fw-sbi smode_sources,
but since the public release only supports fw-none, we need to keep
it in mmode_sources where it's needed for hart_status_tracker and
hart_sync_point symbols.
… line

Signed-off-by: Jerin Joy <joy@rivosinc.com>
jerinjoy and others added 19 commits November 11, 2025 21:40
Signed-off-by: Jerin Joy <joy@rivosinc.com>
These functions check compile/run success.
Replace checks in DiagFactory to use these functions.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Add canonical address validation to ensure 64-bit virtual addresses
are valid for the current translation mode (Sv39, Sv48, Sv57, etc.).
Validates that unused upper bits are properly sign-extended from
the most significant used bit.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
The cores were all using the same memory location. Fixes SIVAL-336.

Also removed the explicit addresses so that we can run this on silicon.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Problem:
When scripts using DiagFactory were interrupted with Ctrl+C, Spike
processes continued running in the background.

Solution:
- Track all spawned process groups in a global registry
- Install SIGINT handler that immediately kills all registered processes
- Make cleanup idempotent and thread-safe
- Add atexit handler as backup

Result:
Single Ctrl+C now terminates all subprocesses across all threads.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Don't report fail when we haven't run diags in environments that have no
run targets.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Update memalign_from_memory to use the same search strategy as
malloc_from_memory, starting from last_allocated instead of always
starting from head. This prevents ping-ponging between the same
two buffer addresses when repeatedly allocating and freeing.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Introduce chunk_iterator_t to encapsulate the two-pass search
strategy used by both malloc_from_memory and memalign_from_memory,
eliminating code duplication.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Without this we are clobbering gp register. Fortunately none
of the tests use gp as of now so this issue never came up.

It was fixed in mtvec but not in stvec and vstvec.

Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
- All diagnostics now automatically get unexpected exception reporting.
- Add default_smode_exception_handler() for comprehensive exception reporting
- Register handlers for all exceptions except ECALLs (used for mode switching)

Added defines for the sstatus field positions.

Increased the number of smode text pages for the public build.

Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
@jerinjoy jerinjoy marked this pull request as draft November 12, 2025 19:36
@jerinjoy jerinjoy force-pushed the dev/joy/update_for_nov2025 branch from 4989263 to fa26a97 Compare November 12, 2025 19:54
@jerinjoy jerinjoy marked this pull request as ready for review November 12, 2025 19:56
@jerinjoy jerinjoy force-pushed the dev/joy/update_for_nov2025 branch from fa26a97 to 5b129b8 Compare November 12, 2025 19:57
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
Signed-off-by: Jerin Joy <joy@rivosinc.com>
@jerinjoy jerinjoy force-pushed the dev/joy/update_for_nov2025 branch from 54f884f to a70dd32 Compare November 12, 2025 20:08
Copy link
Contributor

@rajnesh-kanwal rajnesh-kanwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jerinjoy jerinjoy merged commit be6d3b9 into main Nov 13, 2025
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants