riscv-non-isa / riscv-semihosting

https://lf-riscv.atlassian.net/browse/RVS-2673
Creative Commons Attribution Share Alike 4.0 International
28 stars 8 forks source link

Consider alternative NOPs which are not custom hints #23

Closed Wren6991 closed 3 weeks ago

Wren6991 commented 1 month ago

slli and srai with rd=x0 are listed in the ratified unprivileged ISA manual as custom hints, with the explicit phrase: Reserved for custom use. This spec codifies the use of slli x0, x0, 0x1f and srai x0, x0, 7 as hints to the debugger, and obligates semihosted software to emit custom hints. This use of custom encodings is already described in an informative note, but this spec standardises their use.

The custom hints may have unintended effects such as stalling the core for many cycles, or putting the core to sleep indefinitely. Practically speaking it's a bit late to eliminate the custom-hint NOPs, but would we at least consider allocating two standard hints for an alternative semihosting NOP sequence?

If debuggers complying with this spec were required to recognise the standard hints, then that leaves space to work around cores which have unintended behaviour when the custom hints are used, perhaps because the designers were not aware of this spec's surprising use of the custom hint space.

ilg-ul commented 1 month ago

I'm afraid it is too late for such proposals, OpenOCD and QEMU, plus lots of applications already use these definitions.

avpatel commented 3 weeks ago

Yes, its too late to change the semihosting instruction sequence which has been around 6+ years and lot of open source projects (OpenOCD, QEMU, U-Boot, OpenSBI, and others) already use it.