Skip to content

[dv] Rewrite dpi_memutil to avoid exceptions#30397

Open
RKNAGA18 wants to merge 2 commits into
lowRISC:masterfrom
RKNAGA18:fix-dpi-memutil-exceptions
Open

[dv] Rewrite dpi_memutil to avoid exceptions#30397
RKNAGA18 wants to merge 2 commits into
lowRISC:masterfrom
RKNAGA18:fix-dpi-memutil-exceptions

Conversation

@RKNAGA18

Copy link
Copy Markdown

Overview

This PR continues the effort to remove C++ exceptions from the Verilator support infrastructure to comply with the project's C++ style guide.

Specifically, this targets the memory utility bridging files (hw/dv/verilator/cpp/dpi_memutil.cc and dpi_memutil.h).

Changes Made

  • Removed Custom Exceptions: Completely removed the ElfError class.
  • Two-Phase Initialization: Refactored the ElfFile class to use an empty constructor and a new bool Load() method, preventing exceptions during object instantiation.
  • API Signature Updates: Changed public methods like RegisterMemoryArea() and StageElf() to return bool success flags instead of throwing std::runtime_error.
  • Standard Logging: Replaced all throw statements with explicit std::cerr error prints and safe returns.
  • Enum Safety: Updated GetMemImageTypeByName to return kMemImageUnknown on failure instead of crashing.

Testing

  • Verified local compilation of the updated DPI targets using Bazel:
    ./bazelisk.sh build //hw/ip/otbn/...

Fixes #5801

RKNAGA18 added 2 commits May 19, 2026 04:26
This replaces the privileged `ip netns` setup with an unprivileged
`unshare` user and network namespace, allowing the airgapped build
test to run successfully on GCP containerized runners without requiring
host-level CAP_NET_ADMIN capabilities.

Note: Local testing confirms the unshare namespace successfully
blocks network access (yielding the expected Unknown Host errors
when the offline cache is missing dependencies).

Fixes lowRISC#19512

Signed-off-by: RKNAGA18 <rknarjun396@gmail.com>
This replaces the internal ElfError exception class and std::runtime_error
throws with boolean return codes and standard error logging, adhering to
the project's exception-free C++ style guide.

Fixes lowRISC#5801
@RKNAGA18 RKNAGA18 requested review from a team as code owners June 13, 2026 15:39
@RKNAGA18 RKNAGA18 requested review from rswarbrick and removed request for a team June 13, 2026 15:39
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.

[c++] Rewrite bits of the verilator-support infrastructure to avoid exceptions

1 participant