Repository navigation
fs/v9fs: Split virtio buffers where their physical pages are not adjacent. - #20548
Merged
Merged
Conversation
|
…cent. virtio_9p_request() gave each buffer to the device as one descriptor, and libmetal translates only its start address. In a kernel build a buffer in a user address environment is contiguous only in virtual memory, so a read that crossed a page wrote into whatever physical page followed the first one. QEMU stops the device with "virtio: bogus descriptor or out of resources" when that range leaves guest memory. With CONFIG_ARCH_ADDRENV, split each buffer at the pages that are not physically adjacent. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
v9fs-virtio-split-pages
branch
from
October 11, 2026 06:36
79a93e6 to
d75940b
Compare
xiaoxiang781216
approved these changes
Oct 11, 2026
acassis
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
virtio_9p_request()gave each buffer to the device as one descriptor, and libmetal translates only its start address withup_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_ADDRENVand the virtio 9P transport. Other builds are unchanged.Testing
qemu-armv8a:knshwithCONFIG_DRIVERS_VIRTIO,CONFIG_DRIVERS_VIRTIO_MMIO,CONFIG_FS_V9FSandCONFIG_V9FS_VIRTIO_9P, QEMU 11 (-m 512M, avirtio-9p-deviceshare). 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) andhold 64 120 &.Before:
After: