riscv / configuration-structure

RISC-V Configuration Structure
https://jira.riscv.org/browse/RVG-50
Creative Commons Attribution 4.0 International
36 stars 16 forks source link

What is the difference between confstrptr0~3 registers and mconfigptr? #122

Closed zhangdujiao closed 2 months ago

zhangdujiao commented 2 months ago

The confstrptr0~3 from debug spec includes the address of configuration structure, and so is the definition of mconfigptr from the privileged spec. What is the difference between them?

pdonahue-ventana commented 2 months ago

mcontigptr is a CSR which is therefore only accessible to SW running on the hart. confstrptr are registers in the DM and are therefore only accessible to the external debugger.

zhangdujiao commented 2 months ago

mcontigptr is a CSR which is therefore only accessible to SW running on the hart. confstrptr are registers in the DM and are therefore only accessible to the external debugger.

From the Unified Discovery spec (https://github.com/riscv/configuration-structure/blob/master/introduction.adoc ): It exposes the discoverable information both for in-band (hosted) and out-of-band (external debug) use-cases.

It semms mcontigptr CSR can be read by SW running on the hart and external debugger both, am I understand correctly?

The difference between confstrptr and mconfigptr may be: confstrptr point to the CS address of DM, mconfigptr point to the CS address of core. Is that right?

pdonahue-ventana commented 2 months ago

It semms mcontigptr CSR can be read by SW running on the hart and external debugger both, am I understand correctly?

That's correct. However, on harts that don't support abstract accesses to CSRs, the external debugger may have to halt a hart in order to run a program buffer to read that CSR. Rather than doing this sort of disruptive action on a system that the debugger doesn't fully understand yet, it's better to just give the external debugger direct access to the configuration structure.

Also, confstrptr existed in Debug 0.13 (which was ratified more than 5 years ago) and probably even in Debug 0.11. On the other hand, mconfigptr was originally proposed in Smdisc which eventually got rolled into the base priv 1.12 (which was ratified years after Debug).

The difference between confstrptr and mconfigptr may be: confstrptr point to the CS address of DM, mconfigptr point to the CS address of core. Is that right?

I believe that there's just one CS that describes the entire system. I would expect confstrptr and mconfigptr to both contain the same address.

zhangdujiao commented 2 months ago

So for external debuggers, customers can first access the first DM (at the bottom of the debug address space), then read the confstrptr register to obtain the CS address (CSR mconfigptr is another optional option), and read the CS data to obtain the configuration of all DMs and harts. And the next DM address can be obtained through the nextdm register.

But for trace components (such as Trace Encoder, SMEM, etc.), it seems that the protocol does not describe how to discover, also, could the configuration of trace components be included in the CS? many thanks!

pdonahue-ventana commented 2 months ago

So for external debuggers, customers can first access the first DM (at the bottom of the debug address space), then read the confstrptr register to obtain the CS address (CSR mconfigptr is another optional option), and read the CS data to obtain the configuration of all DMs and harts. And the next DM address can be obtained through the nextdm register.

Yes.

But for trace components (such as Trace Encoder, SMEM, etc.), it seems that the protocol does not describe how to discover, also, could the configuration of trace components be included in the CS?

I'm not the right person to discuss what can be in the CS. It would seem like useful information to make available, though.