Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target/riscv: set VLENB/MTOPI/MTOPEI existence on 0.11 targets #1207

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from

Conversation

en-sc
Copy link
Collaborator

@en-sc en-sc commented Jan 16, 2025

commit 5f45b5b ("target/riscv: reg cache entry is initialized before access") introduced an assertion in riscv_reg_impl_gdb_regno_exist().
Link:

assert(false
&& "Existence of other registers is determined "
"depending on existence of these ones, so "
"whether these register exist or not should be "
"set explicitly.");
This assertion fails on RISC-V Debug Spec. 0.11 targets. The commit is intended to fix this.

Change-Id: I20b56df1517f4071f4b6e39c83178a29a9cf95b0

commit 5f45b5b ("target/riscv: reg cache
entry is initialized before access") introduced an assertion in
`riscv_reg_impl_gdb_regno_exist()`.
Link: https://github.com/riscv-collab/riscv-openocd/blob/f82c5a7c048eb70fdc4dff6f53002fa1d3a1bda5/src/target/riscv/riscv_reg.c#L385-L389
This assertion fails on RISC-V Debug Spec. 0.11 targets.
The commit is intended to fix this.

Change-Id: I20b56df1517f4071f4b6e39c83178a29a9cf95b0
Signed-off-by: Evgeniy Naydanov <[email protected]>
@en-sc en-sc self-assigned this Jan 16, 2025
Copy link
Collaborator

@aap-sc aap-sc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, review internally.

@MarekVCodasip
Copy link
Collaborator

Ran riscv-tests on the hifive1-reva board we have. These are the results:

:::::::::::::::::::::::::::[ ran 73 tests in 220s ]:::::::::::::::::::::::::::
19 tests returned not_applicable
42 tests returned pass
4 tests returned exception
   DebugFunctionCall > logs/20250123-175903-HiFive1-DebugFunctionCall.log
   IcountTest > logs/20250123-175928-HiFive1-IcountTest.log
   MemTestReadInvalid > logs/20250123-180059-HiFive1-MemTestReadInvalid.log
   RepeatReadTest > logs/20250123-180132-HiFive1-RepeatReadTest.log
8 tests returned fail
   EtriggerTest > logs/20250123-175917-HiFive1-EtriggerTest.log
   InstantHaltTest > logs/20250123-180013-HiFive1-InstantHaltTest.log
   InterruptTest > logs/20250123-180015-HiFive1-InterruptTest.log
   ItriggerTest > logs/20250123-180041-HiFive1-ItriggerTest.log
   MemorySampleMixed > logs/20250123-180101-HiFive1-MemorySampleMixed.log
   MemorySampleSingle > logs/20250123-180109-HiFive1-MemorySampleSingle.log
   Semihosting > logs/20250123-180134-HiFive1-Semihosting.log
   SemihostingFileio > logs/20250123-180137-HiFive1-SemihostingFileio.log

Copy link
Collaborator

@MarekVCodasip MarekVCodasip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of this solution, but I don't see any other way which does not interfere in the regular 0.13 target.

Please, add the comments I suggested to ensure that future readers know.

Comment on lines +42 to +44
int res = riscv_reg_impl_init_cache(target);
if (res != ERROR_OK)
return res;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int res = riscv_reg_impl_init_cache(target);
if (res != ERROR_OK)
return res;
// This is a workaround an assert in the regular riscv013 target, the cache is never actually used in the 0.11 target
int res = riscv_reg_impl_init_cache(target);
if (res != ERROR_OK)
return res;

Comment on lines +49 to +59
assert(!r->vlenb
&& "VLENB discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopi_readable
&& "MTOPI discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopei_readable
&& "MTOPEI discovery is not supported on RISC-V 0.11 targets");
uint32_t non_discoverable_regs[] = {
GDB_REGNO_VLENB,
GDB_REGNO_MTOPI,
GDB_REGNO_MTOPEI
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(!r->vlenb
&& "VLENB discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopi_readable
&& "MTOPI discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopei_readable
&& "MTOPEI discovery is not supported on RISC-V 0.11 targets");
uint32_t non_discoverable_regs[] = {
GDB_REGNO_VLENB,
GDB_REGNO_MTOPI,
GDB_REGNO_MTOPEI
};
// riscv_reg_impl_gdb_regno_exist() has an assert on these three registers that their existence is determined elsewhere, in riscv011, they never exist.
assert(!r->vlenb
&& "VLENB discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopi_readable
&& "MTOPI discovery is not supported on RISC-V 0.11 targets");
assert(!r->mtopei_readable
&& "MTOPEI discovery is not supported on RISC-V 0.11 targets");
uint32_t non_discoverable_regs[] = {
GDB_REGNO_VLENB,
GDB_REGNO_MTOPI,
GDB_REGNO_MTOPEI
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants