Repository navigation
Add mmio_hash to hf task - #2765
Merged
Merged
Conversation
This was missed
mkeeter
approved these changes
Nov 6, 2026
labbott
enabled auto-merge (rebase)
November 6, 2026 15:41
Merged
mkeeter
added a commit
that referenced
this pull request
Nov 9, 2026
We recently had a bug where we forgot to add a `uses = ["mmio_hash"]` to a manifest. This presented as a runtime task panic loop, which is not ideal. In many cases, we can statically detect load addresses and compare them against valid memory regions. This PR does just that. It adds a post-processing pass to look for a pattern of (1) `pc`-relative load, followed by (2) a memory operation using that register; that statically-known memory location is then recorded and checked against valid memory regions. I did this as part of the existing `build-stack` pass, now renamed to `asmcheck`, to avoid disassembling every task twice. I split the `build-stack` logic into separate "get function info" (`extract_function_items`) and "check stack depth" (`get_max_stack`) functions, then reused the function info in a new "check memory accesses" pass. As it turns out, everything using `fmc_demo` was vulnerable to this kind of issue: there are hiffy endpoints to configure the `fmc` peripheral itself (e.g. bus turnaround cycles), but `fmc` was missing from everyone's `uses = [..]` list. Adding it required the Grapefruit image to use the entire FMC memory space, where previously it was using individual MMIO peripherals, because otherwise we run out of memory regions. If I revert #2765, this correctly flags the issue: ``` task hf accesses memory outside of its allowed regions: in <(core[5585419f9effd512]::marker::PhantomData<drv_cosmo_metro_hf[d535be46e41cfe49]::hf::idl::HostFlashOperation>, &mut drv_cosmo_metro_hf[d535be46e41cfe49]::hf::ServerImpl) as idol_runtime[fff5c87e8641ad14]::Server<drv_cosmo_metro_hf[d535be46e41cfe49]::hf::idl::HostFlashOperation>>::handle: 0x0800add2: ldr r2, [r1] => 0xc0000704 [0] 0x0800add8: str r2, [r1] => 0xc0000704 [0] 0x0800adda: ldr r2, [r1, #4] => 0xc0000708 [0] 0x0800ade0: str r2, [r1, #4] => 0xc0000708 [0] 0x0800ade2: ldr r2, [r1, #8] => 0xc000070c [0] 0x0800adee: str r2, [r1, #8] => 0xc000070c [0] 0x0800adf0: ldr r2, [r1, #0xc] => 0xc0000710 [0] 0x0800adf6: str r2, [r1, #0xc] => 0xc0000710 [0] 0x0800adfa: ldr.w r3, [r2, #0x600] => 0xc0000700 [0] 0x0800ae02: str.w r3, [r2, #0x600] => 0xc0000700 [0] accessed regions: [0] mmio peripheral 'mmio_hash' (missing from `uses`?) Error: tasks access memory outside of their allowed regions: ["hf"]; see logs above ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was missed