Skip to content

drivers/rpmsg: verbose dump ops and panic-time dump - #21609

Merged
GUIDINGLI merged 6 commits into
apache:masterfrom
CV-Bowen:up/P61-rpmsg-dump
Nov 11, 2026
Merged

GUIDINGLI merged 6 commits into
apache:masterfrom
CV-Bowen:up/P61-rpmsg-dump

Conversation

@CV-Bowen

@CV-Bowen CV-Bowen commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Make the rpmsg dump useful on a crash and safe to run from the panic
path. Companion apps PR: apache/nuttx-apps#4000.

  • rpmsg_virtio_dump() prints the unretrieved/retrieved counts of
    both rings, not only the pending buffers.
  • rpmsg_ops_s.dump() and rpmsg_port_ops_s.dump() take a
    verbose flag; RPMSGIOC_DUMP passes its argument through. The
    endpoint list and the buffer lists are printed only when it is true,
    so a brief dump is a few lines per link. The rpmsg_port timeout dump
    stays verbose.
  • Each rpmsg device registers a panic notifier and dumps itself at
    PANIC_KERNEL_FINAL. CONFIG_RPMSG_PANIC_DUMP_LEVEL: 0 off,
    1 brief, 2 verbose (default unless DEFAULT_SMALL).
  • verdin-mx8mp:rpmsg sets RPMSG_PANIC_DUMP_LEVEL=0: it runs from the
    128K ITCM and the panic dump made it overflow by 80 bytes.
  • rpmsg_virtio skips the dump until the vdev is started: a panic
    between rpmsg_register() and the end of
    rpmsg_init_vdev_with_config() would otherwise walk an endpoint
    list that is not initialized yet.
  • rpmsg_virtio_dump_buffer() ignores ring entries whose descriptor
    index is not below vq_nentries; a peer that panicked mid-update
    can leave such an index, and reading desc[] with it faulted inside
    the panic dump.

Impact

  • rpmsg_ops_s.dump / rpmsg_port_ops_s.dump signature change; all
    in-tree implementations are updated. Out-of-tree transports add the
    bool verbose argument.
  • RPMSGIOC_DUMP argument: 0 brief, non-zero verbose. nsh's
    "rpmsg dump" passes 0 today, so without the apps PR it prints the
    brief dump.
  • New Kconfig RPMSG_PANIC_DUMP_LEVEL; at 0 nothing is registered on
    the panic chain and the notifier code is not built.
  • Size: verdin-mx8mp:rpmsg (128K ITCM, arm-none-eabi-gcc 13.2) links at
    every commit; 328 bytes are left on master and 32 with this PR (panic
    dump off there), the cost of the verbose flag and the ring counters.

Testing

Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205

Panic dump, qemu-armv8a:rpserver + rpproxy (rptun ivshmem and
rpmsg_port uart), test-only examples/hello that calls PANIC(),
CONFIG_BOARD_RESET_ON_ASSERT=2 so a task assert takes the kernel
panic path (PANIC_KERNEL_FINAL). On the proxy: hello.

tree proxy output after the assert
master register dump and backtrace only
this PR, RPMSG_PANIC_DUMP_LEVEL=2 (default) per link: header, endpoint list, rings, buffer lists
this PR, RPMSG_PANIC_DUMP_LEVEL=1 per link: header and rings, no endpoint/buffer lists
master
[    3.347970] [ 8] [ EMERG] [server] ping times: 3

[    3.348208] [ 8] [ EMERG] [server] buffer_len: 1520, send_len: 64

[    3.348594] [ 8] [ EMERG] [server] avg: 0 s, 489541 ns

this PR, level 2 (rpmsg_virtio link)
[proxy] Local: proxy Remote: server Headrx 8 Headtx 10

[proxy] Dump rpmsg info between cpu (master: no)proxy <==> server:

[proxy]   rpmsg ept list:

[proxy]     ept NS 0x404b1be8: addr=53 dest=53 refcnt=1 priority=127 priv=0x404b1bd8

[proxy]     ept rpmsg-syslog 0x404a3278: addr=1024 dest=1026 refcnt=1 priority=127 priv=0x404a3228

[proxy]     ept rpmsg-sensor 0x404ca230: addr=1025 dest=1024 refcnt=1 priority=127 priv=0x404ca220

[proxy]     ept rpmsg-ping 0x404b1b40: addr=1026 dest=1025 refcnt=1 priority=127 priv=0

[proxy] rpmsg vq RX:

[proxy] VQ: rx_vq - size=8; free=8; queued=0; desc_head_idx=0; available_idx=8; avail.idx=8; used_cons_idx=0; used.idx=8; avail.flags=0x0; u
[proxy] rpmsg vq TX:

[proxy] VQ: tx_vq - size=8; free=8; queued=0; desc_head_idx=0; available_idx=10; avail.idx=18; used_cons_idx=0; used.idx=10; avail.flags=0x0
[proxy]   rpmsg buffer list:

[proxy]     RX buffer total 8

[proxy]       unretrieved 0

this PR, level 1
[    3.417465] [ 8] [ EMERG] [server] ping times: 3

[    3.417728] [ 8] [ EMERG] [server] buffer_len: 1520, send_len: 64

[    3.418171] [ 8] [ EMERG] [server] avg: 0 s, 800034 ns

[    3.418549] [ 8] [ EMERG] [server] min: 0 s, 226249 ns

[    3.418883] [ 8] [ EMERG] [server] max: 0 s, 1917556 ns

[    3.419290] [ 8] [ EMERG] [server] rate: 0.639972 Mbits/sec

Manual dump: "rpmsg dump all" on sim and qemu-armv8a with the apps
PR prints the verbose dump; with nsh passing 0 it prints the header and
the rings only.

baseline (results.md, with the apps PR)

Baseline (test.sh, cases: baseline.yaml):

  • host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
  • tested: nuttx d745c9c apps 6942415f7
  • qemu-armv8a:rpserver qemu-armv8a:rpproxy built with test-only overlay: disabled LIBC_ENVPATH BINFMT_CHECKEXEC
  • sim:rpserver + sim:rpproxy: PASS
    • uname -a (server)
    • rpmsg dump all (server)
    • rpmsg ping all 10 1024 3 0 (server)
    • uname -a (proxy)
    • rpmsg ping all 10 1024 3 0 (proxy)
    • mount -t rpmsgfs -o cpu=server,fs=/proc /sp (proxy)
    • cat /sp/version (proxy)
    • rpmsg dump all (proxy)
  • qemu-armv8a:rpserver + qemu-armv8a:rpproxy: PASS
    • uname -a (server)
    • uname -a (proxy)
    • rpmsg dump all (server)
    • rpmsg ping all 10 1024 3 0 (server)
    • rpmsg ping all 10 1024 3 0 (proxy)
    • mount -t rpmsgfs -o cpu=server,fs=/proc /sp (proxy)
    • cat /sp/version (proxy)

@github-actions github-actions Bot added Area: Drivers Drivers issues Size: M The size of the change in this PR is medium labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

wyr-7 and others added 2 commits November 10, 2026 14:58
rpmsg_virtio_dump_buffer() printed only the total and the pending
buffers, so a stuck link did not show whether the buffers were still
unretrieved in the ring or already taken by an endpoint. Print, for
both rings, the total, how many entries are unretrieved, how many are
retrieved, and then the pending (rx) or sent (tx) buffers.

Signed-off-by: Yongrong Wang <[email protected]>
rpmsg_ops_s.dump() and rpmsg_port_ops_s.dump() always printed the
endpoint list and every rx/tx buffer, which is too much for a quick
look or for a dump taken on a small system. Add a verbose argument:
RPMSGIOC_DUMP passes its ioctl argument through, the transports print
the endpoint list and the buffer lists only when it is true, and the
port timeout dump keeps the full output.

Signed-off-by: chenzihan1 <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
CV-Bowen and others added 4 commits November 10, 2026 22:47
When a core panics, the state of its rpmsg links (rings, buffers,
endpoints) is often what explains the crash, but nothing dumps it.
Register a panic notifier per rpmsg device and run RPMSGIOC_DUMP at
PANIC_KERNEL_FINAL.

CONFIG_RPMSG_PANIC_DUMP_LEVEL selects how much is printed: 0 disables
the dump, 1 prints the brief dump, 2 the verbose one (default unless
DEFAULT_SMALL). The rpmsg dump command is not affected.

Signed-off-by: Bowen Wang <[email protected]>
verdin-mx8mp:rpmsg runs from the 128K ITCM and the rpmsg panic dump
added by the previous patch makes the image overflow it:

  arm-none-eabi-ld: region `flash' overflowed by 80 bytes

Set CONFIG_RPMSG_PANIC_DUMP_LEVEL=0 for this config, which keeps it
the same as before the panic dump was added.

Signed-off-by: Bowen Wang <[email protected]>
rpmsg_register() adds the panic notifier before the vdev is started.
rvdev->vdev is set at the start of rpmsg_init_vdev_with_config(), but
rdev->endpoints is initialized only near its end, so a panic in that
window walks an endpoint list whose next pointer is still NULL and
faults inside the panic handler.

rpmsg_virtio_start() sets rdev->ns_unbind_cb after
rpmsg_init_vdev_with_config() returns; skip the dump until it is set.

Signed-off-by: wangyongrong <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
rpmsg_virtio_dump_buffer() reads desc_idx from the ring (avail->ring[]
or used->ring[].u.id) and indexes vq_ring.desc[] with it unchecked.
When the peer panics in the middle of a ring update the ring can hold
a stale or out-of-range index; desc[] then reads into the avail/used
area, and on sim UBSan reports the misaligned 64-bit desc.addr load,
which aborts the panic dump.

Skip entries whose index is not below vq_nentries and keep printing
the others.

Signed-off-by: dengwenqi <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
@GUIDINGLI
GUIDINGLI merged commit d383e57 into apache:master Nov 11, 2026
54 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Board: arm Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants