git: vkernel: Restore MAP_VPAGETABLE support with COW/VPTE fix

Antonio Huete Jimenez tuxillo at crater.dragonflybsd.org
Thu Dec 18 14:48:53 PST 2025


commit 41fb76421dce54f90c9cfb9f4f7e2993ae795266
Author: Antonio Huete Jimenez <tuxillo at quantumachine.net>
Date:   Thu Dec 18 09:09:47 2025 +0100

    vkernel: Restore MAP_VPAGETABLE support with COW/VPTE fix
    
    Re-implement MAP_VPAGETABLE support which was removed in commit
    4d4f84f5f26bf5e9fe4d0761b34a5f1a3784a16f. This enables vkernel
    functionality - allowing a full kernel to run in userspace.
    
    Changes:
    - Re-enable VM_MAPTYPE_VPAGETABLE in sys/vm/vm.h
    - Restore vm_fault_vpagetable() for VPTE translation
    - Add PG_VPTMAPPED flag to track pages mapped via VPAGETABLE
    - Handle MADV_SETMAP/MADV_INVAL for vkernel pmap management
    - Fix COW/VPTE synchronization: set FW_DIDCOW for page-level COW
      so pmap_enter() updates VPTEs after copy-on-write
    - Use anonymous memory (unlinked file) for vkernel memory backing
      to ensure proper page reclaim when vkernel exits
    - Fix vkernel build issues (cpu_feature2, COWF_PREFAULT_* constants)
    - Skip callout address validation for vkernels (_KERNEL_VIRTUAL)
    
    NOTE: This code was almost fully generated by Claude Opus 4.5

Summary of changes:
 doc/vpagetable_analysis.txt               | 553 ++++++++++++++++++++++++++++++
 share/man/man7/vkernel.7                  |  62 +++-
 sys/kern/kern_timeout.c                   |  10 +-
 sys/platform/pc64/x86_64/pmap.c           |  58 +++-
 sys/platform/vkernel64/include/md_var.h   |   2 +
 sys/platform/vkernel64/include/pmap.h     |   4 +
 sys/platform/vkernel64/platform/copyio.c  |   1 +
 sys/platform/vkernel64/platform/init.c    |  95 +++--
 sys/platform/vkernel64/platform/pmap.c    |   4 +-
 sys/platform/vkernel64/x86_64/cpu_regs.c  |  12 +
 sys/platform/vkernel64/x86_64/exception.c |  10 -
 sys/platform/vkernel64/x86_64/npx.c       |  15 +-
 sys/platform/vkernel64/x86_64/trap.c      |  17 +-
 sys/sys/mman.h                            |   4 +-
 sys/vm/vm.h                               |   2 +-
 sys/vm/vm_fault.c                         | 268 ++++++++++++++-
 sys/vm/vm_map.c                           |  86 ++++-
 sys/vm/vm_mmap.c                          |  36 +-
 sys/vm/vm_page.h                          |   7 +-
 19 files changed, 1123 insertions(+), 123 deletions(-)
 create mode 100644 doc/vpagetable_analysis.txt

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/41fb76421dce54f90c9cfb9f4f7e2993ae795266


-- 
DragonFly BSD source repository


More information about the Commits mailing list