CV-Bowen opened a new pull request, #22044:
URL: https://github.com/apache/nuttx/pull/22044
## Summary
Fixes to the rpmsg syslog client buffer (`drivers/syslog/syslog_rpmsg.c`),
following the buffer rework in apache/nuttx#22034:
- `ignore writes before the buffer is set up`: with
`CONFIG_SYSLOG_RPMSG_BUFSIZE=0` the platform sets the buffer later; drop
writes that come before it instead of dereferencing a NULL header.
- `always reset the buffer size on boot`: a buffer kept in no-init memory
kept the size of the previous firmware even when the option changed.
- `dump a full buffer and print the header`: `syslog_rpmsg_dump()` printed
nothing for head == tail, which after an overwrite is a full buffer.
- `recheck the space after a transfer`: the overwrite decision used the
return value of `syslog_rpmsg_transfer()`, which does not say whether
space was freed.
- `do not transfer during reset or panic`: leave the log in the buffer
instead of sending it over rpmsg.
- `invalidate the dcache before a dump`: the dumped buffer may have been
written by another core.
- `keep the log when the buffer overflows`: on overflow `tail = head`
marked the buffer empty; keep the newest `size - 1` bytes instead.
- `reset a buffer with a corrupted header`: a kept buffer with a valid
magic but head or tail out of range made the transfer copy from outside
the buffer.
- `compare the length with 0 using ==`: `len` is a `size_t` (Coverity).
- `remove the suspend/resume commands`: nothing sends them, and a lost
RESUME stopped log delivery for good.
## Impact
- Protocol: `SYSLOG_RPMSG_SUSPEND` (1) and `SYSLOG_RPMSG_RESUME` (2) are
removed and `SYSLOG_RPMSG_SYNC` changes from 3 to 1. Client and server
must be updated together; `FIOC_DUMP` on the server device sends SYNC.
- Behaviour: during reset or panic the client no longer sends log over
rpmsg. A buffer kept across a reboot is reset if its head or tail is out
of range.
- No Kconfig or API change.
## 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
**Corrupted header (sim:rpserver + sim:rpproxy, unchanged configs).** A
test-only patch (not in this PR) makes the proxy's buffer look like one
kept across a reboot with a valid magic but head and tail out of range,
the first time the buffer is initialized:
```c
if (!corrupted)
{
corrupted = true;
header->magic = SYSLOG_RPMSG_MAGIC_NUMBER;
header->head = 0x40000000;
header->tail = 0x40001000;
}
```
Then: start `sim:rpserver`, start `sim:rpproxy`, on the server
`cu /dev/ttyproxy`, `echo P109MARK > /dev/logrpmsg`.
| | master (with #22034) | this PR |
|---|---|---|
| proxy (3 runs) | killed by SIGSEGV during start-up | runs |
| `[proxy] P109MARK` on the server console | no | yes |
```
server> cu /dev/ttyproxy
proxy> echo P109MARK > /dev/logrpmsg
[ 8.170396] [proxy] P109MARK
```
**Every commit** builds without warnings for sim:rpproxy, sim:rpserver
and qemu-armv8a:rpproxy, and with each one the sim proxy boots and its
log reaches the server.
Not tested: the overflow and space recheck paths, reset/panic,
`syslog_rpmsg_dump()` (no in-tree caller yet), dcache invalidation (sim
has no cache), `CONFIG_SYSLOG_RPMSG_BUFSIZE=0`, and the buffer size
change across a reboot.
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]