Skip to content

Commit 0b2125b

Browse files
rivos-eblotloiclefort
authored andcommitted
[ot] hw/opentitan: ot_rstmgr: add a debug property to shutdown the VM on reset
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent cd134c3 commit 0b2125b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

docs/opentitan/darjeeling.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ See [`tools.md`](tools.md)
135135
is set to 10 MHz. This option is very useful/mandatory to run many OpenTitan tests that rely on
136136
time or CPU cycle to validate features. Using `-icount` option slows down execution speed though,
137137
so it is not recommended to use it when the main goal is to develop SW to run on the virtual
138-
machine.
138+
machine. An alternative is to use `-icount shift=auto`, which offers fatest emulation execution,
139+
while preserving an accurate ratio between the vCPU clock and the virtual devices.
139140

140141
* `no_epmp_cfg=true` can be appended to the machine option switch, _i.e._
141142
`-M ot-darjeeeling,no_epmp_cfg=true` to disable the initial ePMP configuration, which can be very
@@ -162,6 +163,10 @@ See [`tools.md`](tools.md)
162163
* `-cpu lowrisc-ibex,x-zbr=false` can be used to force disable the Zbr experimental-and-deprecated
163164
RISC-V bitmap extension for CRC32 extension.
164165

166+
* `-global ot-rstmgr.fatal_reset=N`, where `N` is an unsigned integer. Force QEMU VM to exit the
167+
N^th^ time the reset manager received a reset request, rather than rebooting the whole machine as
168+
the default behavior.
169+
165170
### AES
166171

167172
* `-global ot-aes.fast-mode=false` can be used to better emulate AES HW IP, as some OT tests expect

hw/opentitan/ot_rstmgr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "hw/riscv/ibex_irq.h"
4545
#include "hw/sysbus.h"
4646
#include "sysemu/hw_accel.h"
47+
#include "sysemu/runstate.h"
4748
#include "trace.h"
4849

4950

@@ -154,6 +155,7 @@ struct OtRstMgrState {
154155
uint32_t *regs;
155156

156157
char *ot_id;
158+
uint32_t fatal_reset;
157159
bool por; /* Power-On Reset property */
158160
};
159161

@@ -381,6 +383,14 @@ static void ot_rstmgr_regs_write(void *opaque, hwaddr addr, uint64_t val64,
381383
* hardware."
382384
*/
383385
ibex_irq_set(&s->sw_reset, (int)true);
386+
if (s->fatal_reset) {
387+
s->fatal_reset--;
388+
if (!s->fatal_reset) {
389+
error_report("fatal reset triggered");
390+
qemu_system_shutdown_request_with_code(
391+
SHUTDOWN_CAUSE_GUEST_SHUTDOWN, 1);
392+
}
393+
}
384394
}
385395
break;
386396
case R_RESET_INFO:
@@ -469,6 +479,7 @@ static void ot_rstmgr_regs_write(void *opaque, hwaddr addr, uint64_t val64,
469479

470480
static Property ot_rstmgr_properties[] = {
471481
DEFINE_PROP_STRING("ot_id", OtRstMgrState, ot_id),
482+
DEFINE_PROP_UINT32("fatal_reset", OtRstMgrState, fatal_reset, 0),
472483
/* this property is only used to store initial reset reason state */
473484
DEFINE_PROP_BOOL("por", OtRstMgrState, por, true),
474485
DEFINE_PROP_END_OF_LIST(),

0 commit comments

Comments
 (0)