aboutsummaryrefslogtreecommitdiff
path: root/c_emulator/riscv_callbacks_log.cpp
AgeCommit message (Collapse)AuthorFilesLines
2026-04-13Add --trace-tlb trace flag for TLB tracing (#1652)Nadime Barhoumi1-0/+94
Add a --trace-tlb feature to log changes to the TLB. This also changes the `--trace-all` CLI option to just `--trace` and removes especially verbose options that people probably don't want by default.
2026-03-27Add the Svade and Svadu extensions. (#1599)Prashanth Mundkur1-2/+2
This removes the `dirty_update` configuration attribute under `memory.translation`, since the behavior that attribute configured can now be modeled using the Svade and Svadu extensions. This check for Svade/Svadu is centralized in a `update_and_write_pte` helper. The Svadu PMA requirement is validated by requiring that at least one PMA region support hardware PTE writes if Svadu is supported. While here, fix a couple of newline issues in the execution trace for PTEs. --------- Co-authored-by: Mingzhu Yan <trdthg@users.noreply.github.com> Co-authored-by: Tim Hutt <tdhutt@gmail.com>
2026-03-15Split --trace-reg into separate GPR and CSR trace flags (#1609)KotorinMinami1-7/+13
This allows finer control over whether `x`/ `f`/`v` register and CSR state changes are printed. Fixes #1602.
2026-03-12Fix and simplify log output for hex values (#1608)Tim Hutt1-20/+10
There was a small off-by-a-factor-of-8 bug in this code, but we can also greatly simplify it by just using gmp's printing functions. Fixes #1607
2026-03-10Gate ptw_fail_callback on config_print_ptw flag (#1601)Nadime Barhoumi1-2/+1
`ptw_fail_callback` was unconditionally printing PTW failures unlike the other PTW callbacks which are gated on `config_print_ptw`.
2026-02-08Make `config` settings non-global (#1535)2026-02-09-de7c9e8Tim Hutt1-1/+0
Move the `config_..` settings into `CLIOptions` and `ModelImpl` so they are no longer global.
2026-01-14Rename the `ext_access_type` type to `mem_payload`. (#1479)Prashanth Mundkur1-1/+1
This was initially introduced as a hook for CHERI to override as an external (`ext_`) extension. However, this type can also be used to support memory accesses for standard extensions such as Zicfiss (and possibly others in addition to CHERI). The type is also redefined to an `enum` (from `unit`) to support these forthcoming extensions.
2025-12-27Fix compiler warnings on macOS and enable more warnings. (#1443)Prashanth Mundkur1-3/+15
Use `PRId64` instead of `%ld` for portability. Enable more warning flags for the C++ code, and also warnings-as-errors in CI. --------- Signed-off-by: Tim Hutt <tdhutt@gmail.com> Co-authored-by: Tim Hutt <tdhutt@gmail.com>
2025-12-22Improved clang-format style (#1396)Tim Hutt1-76/+72
This fixes various annoyances in our clang-format style that have been bothering me for a while: * Binpacking arguments/parameters and aligning them to the opening `(` is *really* bad for diffs/conflict resolution. This changes it to try to match the "prettier" algorithm (also used by Sail's autoformatter), which has much simpler and better behaviour - if the arguments fit on one line do that, otherwise put each argument on its own line. * Don't put functions on one line. This is also a little diff-unfriendly and feels unnecessarily inconsistent to me. * The line length limit of 80 characters is very constrictive so I increased it to 120 characters. * For some reason it didn't put `{` on a new line... except for function bodies, which is weirdly inconsistent. Now `{` never starts on a new line. * Sort `#include`s. This might have been needed in the past but I verified it builds with sorted includes now.
2025-12-10Add callbacks and logging for page table walks (#1370)Ariel Xiong1-1/+57
Add callbacks for each step of the page table walk process, and an option to log them. This required some quite awkward changes to resolve a dependency loop. We can fix this better with [a change to the Sail compiler](https://github.com/rems-project/sail/issues/1560#issuecomment-3628341263). Fixes #1356 --------- Signed-off-by: Ariel Xiong <ArielHeleneto@outlook.com> Co-authored-by: Tim Hutt <tdhutt@gmail.com>
2025-12-05Use C++ Sail output (#1274)Tim Hutt1-17/+22
This switches from using Sail's C output to using C++. The output code gets wrapped in a `class`, which means we can create more than one instance of it (e.g. for multicore). The `Model` class is currently *not* thread safe due to the use of temporary globals in `sail.c`. So although you can simulate multicore systems, you have to execute them one at a time. The handling of platform callbacks is a little convoluted but I think this is a quite flexible solution. Sail is instructed to derive the `Model` class from `PlatformImpl` which has virtual methods for all of the platform callbacks with default nop implementations. This means the default `Model` can be constructed and has a "nop" platform. Then we add our implementation of the platform with `ModelImpl` which overrides those methods. `ModelImpl` also allows registering callback receivers. This is not 100% perfect yet. We still have a global `g_model`, which is not ideal. --------- Signed-off-by: Tim Hutt <tdhutt@gmail.com> Co-authored-by: Tim Hutt <timothy.hutt@codasip.com> Co-authored-by: Nadime Barhoumi <nadime@riscv.org>
2025-11-07Provide default callback implementations (#1372)Ariel Xiong1-23/+0
Remove callbacks which are empty. Add default implementation in base class. --------- Signed-off-by: Ariel Xiong <ArielHeleneto@outlook.com>
2025-10-28Add more state change callbacks (#1354)Tim Hutt1-2/+19
This adds a few state change callbacks that we needed for an internal binary logging format. They aren't used by the RVFI or log callback handlers but they should also be useful for the open source binary logging format that we eventually add (#545). * Add a `fetch_callback` that says which instruction was executed (if any). * Add `redirect_callback` that is called for taken and unconditional branches. * Add `is_interrupt` and `cause` to `trap_callback`. I also renamed `value` to `new_pc` to be a bit more explicit. Fixes #1352
2025-09-05Fix Clang warnings: format strings and a variable-length array. (#1258)Prashanth Mundkur1-1/+1
Variable length arrays are a language extension. Clang warns about this. MacOS builds use Clang so we see these in CI. Also fix `uint64_t` printf specifier.
2025-08-07Support for the E base architecture (#646)Nathaniel Wesley Filardo1-2/+2
Allow configuring `regidx` to be 4 bits instead of 5, so only 16 `x` registers are supported. Instruction encodings to access `x16` - `x31` are reserved and will cause an illegal instruction exception if `E` is enabled. --------- Co-authored-by: Prashanth Mundkur <103736+pmundkur@users.noreply.github.com>
2025-07-31Decouple callbacks impl from model by introducing callback interface (#1146)Mingzhu Yan1-0/+109
Currently the callbacks implementation depends directly on the RVFI implementation. This commit avoids that by introducing a callback registration mechanism, allowing multiple targets to receive the callbacks. Currently the targets are text logs, and RVFI. In future we will add a binary log format, and probably a C lockstep verification API. --------- Co-authored-by: Prashanth Mundkur <prashanth.mundkur@gmail.com> Co-authored-by: Tim Hutt <timothy.hutt@codasip.com>