Commit be0272b
committed
[ot] hw/riscv: dm: Handle haltreqs for unresponsive harts
This patch works around the Debug Module's current non-conformance with
the RISC-V debug specification in how it handles halt requests
(haltreqs) to unresponsive harts (e.g. harts currently in reset).
Several parts of the RISC-V Debug Specification refer to this behaviour
(see sections 3.2, 3.4, 3.5) but section C.1.3 is specifically a bug
fix defined just for this behaviour.
The current DM implementation just ignores incoming halt requests if the
hart is unresponsive. This commit instead latches these requests in a
bitmask, so that when the hart comes out of reset (i.e. starts executing
instructions) it can be checked and used to immediately halt the hart.
Unfortunately, a fully correct implementation of this behaviour would
likely require a direct link between the RISC-V CPU and the DM to allow
the hart to be halted at this point. Such links are not currently
supported by QEMU. This commit introduces a reasonable workaround where
we poll the availability of cores on a `dmstatus` read and halt newly
responsive harts with latched haltreqs there, relying on the fact that
most debuggers interacting with the DM will write the haltreq and then
repeatedly poll `dmstatus` to watch the harts halt (see e.g. section
B.3 of the RISC-V Debug specification).
This is not 100% conformant (if dmstatus is not polled for a while then
the hart will execute some instructions whereas in real HW it would
halt immediately before executing guest code) but is a small workaround
/ hack that can support the majority of practical use cases reasonably
enough.
Signed-off-by: Alex Jones <[email protected]>1 parent 1247809 commit be0272b
1 file changed
+26
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
| |||
1335 | 1336 | | |
1336 | 1337 | | |
1337 | 1338 | | |
| 1339 | + | |
| 1340 | + | |
1338 | 1341 | | |
1339 | 1342 | | |
1340 | 1343 | | |
| |||
1538 | 1541 | | |
1539 | 1542 | | |
1540 | 1543 | | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
1541 | 1565 | | |
1542 | 1566 | | |
1543 | 1567 | | |
| |||
2412 | 2436 | | |
2413 | 2437 | | |
2414 | 2438 | | |
| 2439 | + | |
2415 | 2440 | | |
2416 | 2441 | | |
2417 | 2442 | | |
| |||
2573 | 2598 | | |
2574 | 2599 | | |
2575 | 2600 | | |
| 2601 | + | |
2576 | 2602 | | |
2577 | 2603 | | |
2578 | 2604 | | |
| |||
0 commit comments