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

Fix: Memory access halting heuristic #1962

Merged
merged 5 commits into from
Oct 17, 2024
Merged

Conversation

dragonmux
Copy link
Member

Detailed description

In this PR we address the incredibly broken target halting for memory access heuristic, replacing it fully with a TOPT which can be set on targets that are confirmed to work without bad reads, CPU halts or perturbed timings (such as stolen bus cycles that upset hard real-time applications).

For now this is only enabled on RISC-V targets that use the System Bus mechanism for memory access as that's guaranteed to be okay by the RISC-V Debug specification, however it can be easily enabled for targets where it's confirmed okay by simply adding target->target_options |= TOPT_NON_HALTING_MEM_IO; in the probe routine for that target.

This method has been chosen on account of how difficult it is to find out if a target can do this correctly, and the numerous counter-examples shown for, eg, saying "all Cortex-M are okay" as this is not true on the Tiva-C series, instantly striking down this statement and requiring a narrower enablement. Before a target can be enabled as allowing non-halting memory I/O it must be shown to: be able to read memory correctly without halting (this is the problem for the Tiva-C, you will get back garbled reads if you try this); be able to read without halting the CPU (eg, checking SysTick timings); be able to show that the reads to not perturb the CPU using the bus (indication of stolen cycles) in a way that throws off timings (eg, by wiggling a GPIO in a loop).

With this change done, some sort of memory monitoring command becomes possible as was being requested/talked about in #1532 and Koen's PRs for "memwatch". These were not taken before as it introduced obvious unsafety into the code on account it did not block reading on Cortex-A/R targets where, short of the vendor providing a secondary AP for memory I/O, it is not possible to do a non-halting read, and this heuristic did not stop attempts on RISC-V parts that use the Abstract Command mechanism or progbuf mechanism for access.

Your checklist for this pull request

Closing issues

@dragonmux dragonmux added Bug Confirmed bug Enhancement General project improvement labels Oct 15, 2024
@dragonmux dragonmux added this to the v2.0 release milestone Oct 15, 2024
@dragonmux dragonmux requested a review from esden October 15, 2024 07:11
@dragonmux dragonmux force-pushed the fix/memory-access-halting-heuristic branch 2 times, most recently from 89d4710 to 3de3089 Compare October 15, 2024 19:24
@dragonmux dragonmux force-pushed the fix/memory-access-halting-heuristic branch from 3de3089 to 260eea3 Compare October 17, 2024 13:57
Copy link
Member

@esden esden left a comment

Choose a reason for hiding this comment

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

LGTM, great to see that we are getting closer to having non halting memory access. :)

@esden esden merged commit 260eea3 into main Oct 17, 2024
23 of 26 checks passed
@dragonmux dragonmux deleted the fix/memory-access-halting-heuristic branch October 17, 2024 18:28
@dragonmux
Copy link
Member Author

💯 we're glad to have got this heuristic situation fixed as well as it'd been bothering us as we do actually want to see more features for memory debugging merged, just.. safely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bug Enhancement General project improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants