Skip to content

Add mmio_hash to hf task - #2765

Merged
labbott merged 2 commits into
masterfrom
fix_cosmo_hf
Nov 6, 2026
Merged

labbott merged 2 commits into
masterfrom
fix_cosmo_hf

Conversation

@labbott

@labbott labbott commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

This was missed

This was missed
@labbott
labbott enabled auto-merge (rebase) November 6, 2026 15:41
@labbott
labbott merged commit 953a13f into master Nov 6, 2026
199 checks passed
@labbott
labbott deleted the fix_cosmo_hf branch November 6, 2026 15:54
@mkeeter mkeeter mentioned this pull request Nov 6, 2026
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
```
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.

2 participants