casaroli opened a new pull request, #20548: URL: https://github.com/apache/nuttx/pull/20548
## Summary `virtio_9p_request()` gave each buffer to the device as one descriptor, and libmetal translates only its start address with `up_addrenv_va_to_pa()`. In a kernel build, a buffer in a user address environment is contiguous only in virtual memory. A read that crossed a page boundary was written into whatever physical page followed the first one: the data was wrong and other memory was overwritten. When that range left guest memory, QEMU stopped the device with "virtio: bogus descriptor or out of resources". With `CONFIG_ARCH_ADDRENV`, this PR splits each buffer at the pages that are not physically adjacent, so each descriptor covers one physical range. ## Impact Builds with `CONFIG_ARCH_ADDRENV` and the virtio 9P transport. Other builds are unchanged. ## Testing `qemu-armv8a:knsh` with `CONFIG_DRIVERS_VIRTIO`, `CONFIG_DRIVERS_VIRTIO_MMIO`, `CONFIG_FS_V9FS` and `CONFIG_V9FS_VIRTIO_9P`, QEMU 11 (`-m 512M`, a `virtio-9p-device` share). The test programs were built outside the tree against the export package. A program reads a 1 MB file from the 9P share in one `read()` into a heap buffer and checks every byte. Two other programs run first, so that the heap pages of the test program are not physically contiguous: `hold 512 3 &` (exits after 3 s) and `hold 64 120 &`. Before: ``` nsh> readbig /mnt/data.bin readbig: read 1048576 bytes, first wrong byte at 462840 ``` After: ``` nsh> readbig /mnt/data.bin readbig: read 1048576 bytes, all correct ``` -- 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]
