CV-Bowen opened a new pull request, #22232:
URL: https://github.com/apache/nuttx/pull/22232
## Summary
Eight rptun core changes, in the order they were made:
- `add PANIC_WITH_MSG()`: a core that panics because its peer told it
to logged "Panic by remote core" with syslog and then called
`PANIC()`, so the assertion report only said "panic". Add
`PANIC_WITH_MSG(msg)` to `<assert.h>` and report
"Panic by remote core: <cpu>" with it.
- `pause the peers while this core prints its panic`: with
`CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER`, the panicking core sets a
new `RPTUN_STATUS_PAUSE` bit for every peer at `PANIC_KERNEL`. A peer
that sees it busy-waits, up to `CONFIG_RPTUN_STATUS_TIMEOUT_MS`, for
the `PANIC` bit sent at `PANIC_KERNEL_FINAL`, so it does not print
into the crash log of the other core.
- `keep a copy of the carveout name`: the carveout heap was registered
with a name pointing into the shared resource table, which the peer
can rewrite or reset; procfs meminfo then reads it with `strnlen()`.
- `add coredump_remove_memory_region()` and `add the peer's coredump
regions to the coredump list`: the master adds every `RSC_CARVEOUT`
whose name starts with "coredump" to its coredump list when the peer
starts, and removes it when the peer stops (`CONFIG_COREDUMP`).
- `dump RSC_TRACE entries in rptun_dump_resource()`: they were printed
as an unsupported resource type.
- `ask the peer to stop itself when the transport cannot`: when the
transport has no stop op or returns `-ENOTSUP` (`rptun_bmp`), set a
new `RPTUN_STATUS_STOP` bit; the peer then stops its own side.
- `release an rptun instance on unlink`: `rm /dev/rptun/<cpu>`, or the
new `rptun_uninitialize(cpuname)`, stops the peer and frees the
instance; nothing could undo `rptun_initialize()` before.
## Impact
- New API: `PANIC_WITH_MSG()` in `<assert.h>`,
`coredump_remove_memory_region()`, `rptun_uninitialize()`, and an
`unlink` op for `/dev/rptun/<cpu>`. No Kconfig change.
- New status bits in the shared resource table: `RPTUN_STATUS_PAUSE`
(`BOARDIOC_SOFTRESETCAUSE_MAX`) and `RPTUN_STATUS_STOP` (`MAX + 1`).
Both cores must run this version; an older peer treats either bit as
a reset request.
- With `CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER`, a peer stops for up
to `CONFIG_RPTUN_STATUS_TIMEOUT_MS` (default 5 s) while the other core
panics. If no `PANIC` follows within that time it resets, as it would
for any unknown status bit.
- A remote-requested panic now reports
`Assertion failed Panic by remote core: <cpu>` instead of
`Assertion failed panic`, and no longer prints the extra
`FATAL: Panic by remote core` line.
- `rptun_bmp` loses its empty stop op; stopping it now tells the peer.
## 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
Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
qemu-armv8a:rpproxy with 0 warnings, plus qemu-armv8a:rpserver with
`CONFIG_COREDUMP=y` + `CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER=y` and
sim:rpserver with `CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y`. (sim does not
build with `CONFIG_COREDUMP` on master: `elf_gregset_t` is undefined.)
Before = apache/nuttx#22192, after = this PR. qemu-armv8a:rpserver +
qemu-armv8a:rpproxy, connected by ivshmem rptun and rpmsg_port_uart,
with `CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER=y` on both, and
`LIBC_ENVPATH`/`BINFMT_CHECKEXEC` disabled (master needs this for nsh to
start there). In-tree transports all stop the peer themselves, so for
the stop and unlink cases a test-only change (not in this PR) makes
`rptun_ivshmem_stop()` return `-ENOTSUP`. Each case is a fresh boot:
```
qemu-system-aarch64 -cpu cortex-a53 -nographic \
-machine virt,virtualization=on,gic-version=3 -serial mon:stdio \
-object
memory-backend-file,discard-data=on,id=shm0,mem-path=/dev/shm/rp,size=4194304,share=yes
\
-device ivshmem-plain,id=shmem0,memdev=shm0,addr=0xb \
-device virtio-serial-device,bus=virtio-mmio-bus.0 \
-chardev socket,path=/tmp/rp.sock,server=on,wait=off,id=foo \
-device virtconsole,chardev=foo -kernel <server nuttx>
# proxy: same, with server=off and the proxy image
```
| case (nsh commands) | before | after |
|---|---|---|
| server `rptun reset /dev/rptun/proxy 2` (PANIC) | proxy: `Assertion failed
panic` | proxy: `Assertion failed Panic by remote core: server` |
| server `rptun reset /dev/rptun/proxy 9` (PAUSE), 2 s later `... 2` | proxy
resets at once: `FATAL: Reset by remote core: server reason: 9` | proxy stays
silent, then `Assertion failed Panic by remote core: server` |
| proxy `rptun reset /dev/rptun/server 2`: the server panics and its panic
notifier pauses, then panics the proxy | both cores report `Assertion failed
panic` | `Panic by remote core: proxy` on the server, `Panic by remote core:
server` on the proxy |
| server `rptun stop /dev/rptun/proxy` | the proxy is not told | proxy:
`Stop by remote core: server` |
| server `rm /dev/rptun/proxy`, `ls /dev/rptun`, `rpmsg ping all 1 64 1 0` |
`nsh: rm: unlink failed: 6`; `proxy` still listed; 2 links answer the ping |
`proxy` gone; 1 link (rpmsg_port_uart) answers the ping |
<details><summary>after, PAUSE then PANIC</summary>
```
server> rptun reset /dev/rptun/proxy 9
server> rptun reset /dev/rptun/proxy 2
[ 5.367999] [ 0] [ ALERT] [proxy] dump_assert_info: Current Version:
NuttX proxy 13.1.1 ... arm64
[ 5.370676] [ 0] [ ALERT] [proxy] dump_assert_info: Assertion failed
Panic by remote core: server: at file: /drivers/rptun/rptun.c:987 task:
Idle_Task process: Kernel 0x404ad...
```
</details>
<details><summary>after, stop and unlink</summary>
```
server> rptun stop /dev/rptun/proxy
[ 3.668442] [ 8] [ WARN] [server] rx_vq: freeing non-empty virtqueue
[ 3.668803] [ 8] [ WARN] [server] tx_vq: freeing non-empty virtqueue
[ 3.246381] [ 0] [ EMERG] [proxy] Stop by remote core: server
server> rm /dev/rptun/proxy
server> ls /dev/rptun
/dev/rptun:
server> rpmsg ping all 1 64 1 0
[ 9.528675] [ 8] [ EMERG] [server] ping times: 1
[ 9.528910] [ 8] [ EMERG] [server] buffer_len: 2008, send_len: 64
```
</details>
**RSC_TRACE in `rptun_dump_resource()` (sim:rpserver + sim:rpproxy).**
No in-tree table has an `RSC_TRACE` entry and nothing calls
`rptun_dump_resource()`, so a test-only change to
`arch/sim/src/sim/sim_rptun.c` adds a 4 KB `RSC_TRACE` entry named
"syslog" and dumps the table once it is built. Before, the dump ends at
`Rsc 7` (the last carveout); after, it also prints:
```
[ 0.010513] [server] [trace] Rsc 8 0xf06b72a0
[ 0.010565] [server] [trace] Trace syslog
[ 0.010604] [server] [trace] da 0x000402d0 len 4096 reserved 0
```
Not tested:
- The coredump regions. No in-tree resource table has a "coredump"
carveout, and sim does not build with `CONFIG_COREDUMP`; only the
qemu-armv8a build is covered.
- The carveout name copy: the fault needs the peer to rewrite its table
while `free` runs.
- `rptun_bmp`, which has no in-tree board to run on. The STOP path it
now uses is the one exercised above with the test-only ivshmem change.
- `rptun start` after a stop does not bring the ivshmem link back on
qemu-armv8a, before or after; this PR does not change restart.
No regression in rpmsg: sim:rpserver/rpproxy and
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping,
rpmsgfs; 15/15). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC
disabled, which current master needs for nxinit to start nsh there; unrelated
to this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]