Skip to content

Conversation

@jasonbu
Copy link
Contributor

@jasonbu jasonbu commented Feb 3, 2026

Summary

This PR adds VirtIO 9P filesystem (v9fs) support for BUILD_KERNEL configuration and enables it on the qemu-armv7a knsh board.

Changes

  1. v9fs: add va_to_pa for kernel build compatible
    Add up_addrenv_va_to_pa() conversion for buffer addresses in v9fs client read/write operations
    This is required because in kernel build mode, virtual addresses need to be converted to physical addresses for VirtIO device DMA operations
  2. fs/v9fs: add support for KERNEL build, only transfer 4K once
    Limit read/write transfer size to page boundary (CONFIG_MM_PGSIZE) in kernel build
    This handles non-contiguous physical memory pages - each transfer stays within a single physical page
    Use bufptr instead of directly modifying buffer pointer for proper iteration
  3. board/armv7a/knsh: enable fdt/virtiommio/virtiov9fs support
    Enable CONFIG_DEVICE_TREE=y
    Enable CONFIG_DRIVERS_VIRTIO=y and CONFIG_DRIVERS_VIRTIO_MMIO=y
    Enable CONFIG_FS_V9FS=y and CONFIG_V9FS_VIRTIO_9P=y
    Adjust RAM settings: start from 0x40100000 with size 15728640 to accommodate FDT
  4. Documents/boards/qemu-armv7a: add knsh v9fs launch method
    Add documentation for launching KNSH with VirtIO 9P filesystem
    Include QEMU command with -fsdev and -device virtio-9p-device options
    Document mount command: mount -t v9fs -o trans=virtio,tag=share /share

Testing

CI-test, qemu-v7a v9fs mount and ls check if working for review hostfiles.

# Build knsh
$ ./tools/configure.sh qemu-armv7a:knsh
$ make V=1 -j`nproc`
$ make export V=1
$ cd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
$ make import -j`nproc`
$ cd ../nuttx

# Run with v9fs
$ qemu-system-arm -semihosting -M virt -m 1024 -nographic \
    -fsdev local,security_model=none,id=localshared,path=. \
    -device virtio-9p-device,id=fs0,fsdev=localshared,mount_tag=share \
    -kernel ./nuttx

# Inside nsh
nsh> mount -t v9fs -o trans=virtio,tag=share /share
nsh> ls /share

test result:

ostest_main: Exiting with status 0
nsh> ls -l /share/nuttx
 -rwxrwxr-x     3367716 /share/nuttx

crafcat7 and others added 4 commits February 3, 2026 22:08
For Kernel build, the va should not use for virtio transfer

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
The physic memory is not contiguous, need every page do up_addrenv_va_to_pa
The void * += may less compatible, we should use char*.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
The v9fs will more efficiency support qemu access host filesystem.
Also fix the hostfs did support ls hostfs problem.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
The v9fs will more efficiency support qemu access host filesystem.
Also fix the hostfs did support ls hostfs problem.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation Area: File System File System issues Board: arm Size: S The size of the change in this PR is small labels Feb 3, 2026
Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split the PR into separate contributions (PR)

fs/v9fs: Add KERNEL build support
boards/qemu: enable v9fs for qemu-armv7a knsh

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonbu nice work! Thanks for adding Documentation!

@jasonbu
Copy link
Contributor Author

jasonbu commented Feb 3, 2026

please split the PR into separate contributions (PR)

fs/v9fs: Add KERNEL build support boards/qemu: enable v9fs for qemu-armv7a knsh

hi, please view #18345, as the test should work with this patch, will rebase after the #18345 merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Area: File System File System issues Board: arm Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants