[Spike] Add "stepout" execution limit (--steps=N) to prevent runaway execs.
Created by: zchamski
This PR re-introduces the Spike execution limit initially proposed in PR #1673, but this time based on the vendorized Spike tree.
The limit is set by adding the option --steps=N
to the Spike command line. The execution will be stopped as soon as the step count reaches or exceeds N
. If the option is not given or the value of N
is 0, the execution will continue until termination (or until the exhaustion of system resources, whichever comes first.)
Proper execution termination was tested on a while(1);
infinite loop program.
File change summary:
- vendor/patches/riscv/riscv-isa-sim/0004-enforce-max-steps-limit.patch: New.
- vendor/riscv/riscv-isa-sim/riscv/sim.cc (sim_t::sim_t): Pass max_steps to the sim_t constructor. Initialize step counters. (sim_t::run): Update step counters and check if limit was reached or exceeded.
- vendor/riscv/riscv-isa-sim/riscv/sim.h (sim_t): Add max_steps param. Add step count and step limit fields.
- vendor/riscv/riscv-isa-sim/spike_main/spike.cc (help): Describe option '--steps='. (main): Initialize max step count. Add max step count option to option parser. Pass max step count option value to sim_t constructor.