DragonFlyBSD/src 7ee46dd — sbin/mount_fuse mount_fusefs.c

mount_fusefs(8): accept and ignore the "nempty" option

ntfs-3g mounts with "nonempty" by default and libfuse passes it to
mount_fusefs.  getmntopts() treats the leading "no" as negation and
looks up "nempty", which is not in the option table, so the mount fails
with "-o nempty: option not supported".  Add the ignore entry that
FreeBSD's mount_fusefs(8) has.

Bug: https://bugs.dragonflybsd.org/issues/3459
DeltaFile
+3-1sbin/mount_fuse/mount_fusefs.c
+3-11 files

DragonFlyBSD/src 053116c — sys/vfs/fuse fuse_vnops.c

fuse: fix a lost wakeup in the I/O helper

fuse_io_thread() slept first and drained the queue only after waking.
After draining it released helper_spin and called tsleep()
unconditionally.  fuse_vop_strategy() queues a bio under helper_spin,
drops the lock and then calls wakeup(), so a wakeup that arrived
between that final spin_unlock() and the interlock taken inside
tsleep() was lost.  The helper then slept forever with the bio queued
and the caller hung in biowait().

Hold helper_spin while checking the queue and use ssleep(), which
takes the sleep-queue interlock and drops the spinlock in one step,
so the wakeup cannot be lost.

Bug: https://bugs.dragonflybsd.org/issues/3459
DeltaFile
+4-1sys/vfs/fuse/fuse_vnops.c
+4-11 files

DragonFlyBSD/src 222a25d — sys/vfs/fuse fuse_vnops.c

fuse: honor an explicit ftruncate() size

An earlier write extension sets fnp->sizeoverride, which made
fuse_set_attr() keep the old size and ignore an explicit
ftruncate().  Clear the override for FATTR_SIZE setattrs.

Bug: https://bugs.dragonflybsd.org/issues/3459
DeltaFile
+2-0sys/vfs/fuse/fuse_vnops.c
+2-01 files

DragonFlyBSD/src 5174c27 — sys/vfs/fuse fuse_vnops.c

fuse: zero-fill the tail of a short read

A short FUSE_READ reply copied only the returned bytes into the 4 KiB
BIO buffer, leaving the rest stale, so an mmap read of an unwritten
hole returned old data.  Clamp the copy to b_bcount and zero the
remainder.

Bug: https://bugs.dragonflybsd.org/issues/3459
DeltaFile
+10-2sys/vfs/fuse/fuse_vnops.c
+10-21 files

DragonFlyBSD/src 84e673f — sys/vfs/fuse fuse.h fuse_vnops.c

fuse: treat a zero file handle as a valid handle

ntfs-3g returns file handle 0 for regular files.  The driver used
fh == 0 as its "no handle" state, so it reopened the file on every
open and skipped FUSE_RELEASE and FUSE_FSYNC.  The userspace daemon
then still considered the file open and renamed unlinked files to
.fuse_hidden*.

Add an explicit fh_valid flag to struct fuse_node and use it instead
of the fh value.

Bug: https://bugs.dragonflybsd.org/issues/3459
DeltaFile
+6-4sys/vfs/fuse/fuse_vnops.c
+1-0sys/vfs/fuse/fuse.h
+7-42 files

DragonFlyBSD/src caceac6 — sys/bus/u4b usb_busdma.c

u4b: Do not assume page-aligned busdma segments in the DMA page table

usb_pc_common_mem_cb() walked the busdma segment list assuming every
segment after the first begins on a page boundary (rem reset to 0 and
the next entry always taken from the new segment's base address).
busdma splits segments at physical page boundaries, at physical
discontinuities and at maxsegsz; the first two begin a new segment on
a page boundary, but when a buffer starts mid-page and consecutive
pages are physically adjacent, the maxsegsz split ends a segment in
the middle of a page and its continuation begins mid-page.  When that
happened, the walk recorded the continuation's frame a second time
under the next page index, shifting every later entry by one page.

usbd_get_page() then handed the host controller wrong bus addresses
for all pages after the duplicated entry, so multi-page USB storage
reads returned the content of the following page and left the tail of
the transfer with unrelated memory.  This needs a buffer whose first
byte is not page aligned together with such a mid-page split, which is
why 1 KiB and 2 KiB block filesystems on USB storage were affected

    [17 lines not shown]
DeltaFile
+21-12sys/bus/u4b/usb_busdma.c
+21-121 files

DragonFlyBSD/src 64ff743 — sys/kern kern_environment.c

kernel: Skip oversized loader environment entries

kenv_init() copies every loader environment string into the dynamic
kenv without a length limit, and kgetenv() later copies the value
into a 258-byte stack buffer with strcpy().  A long value overflows
the buffer when it is read, for example by an unprivileged kenv(1)
call, and causes a fatal trap.

Skip entries longer than KENV_MNAMELEN + KENV_MVALLEN + 2 bytes and
print a warning, like FreeBSD's init_dynamic_kenv() does.  An entry
(name, '=' and value) of up to 257 characters keeps working.

Bug: https://bugs.dragonflybsd.org/issues/3466
DeltaFile
+6-0sys/kern/kern_environment.c
+6-01 files

DragonFlyBSD/src f1b9cbd — gnu/usr.bin/cc120 Makefile.langs

cc120: Include all tree codes in all-tree.def to fix LTO compatibility

Before this fix, the base GCC 12 and the lang/gcc12 package couldn't
link each other's LTO objects. This was caused by the enumeration
mismatch of LTO tags, because the two compilers had different
all-tree.def: the base GCC 12 removed ada-tree.def, d-tree.def and
objc-tree.def because those languages are disabled.

Fix this LTO compatibility issue by adding back the removed tree codes,
and thus generate the same all-tree.def as the GCC's own configure does.

Bug: https://bugs.dragonflybsd.org/issues/3470
DeltaFile
+7-1gnu/usr.bin/cc120/Makefile.langs
+7-11 files

DragonFlyBSD/src d486d43 — contrib/gcc-12 README.DELETED

contrib/gcc-12: Update README.DELETED
DeltaFile
+612-3contrib/gcc-12/README.DELETED
+612-31 files

DragonFlyBSD/src 353ed18 — contrib/gcc-12/gcc/ada/gcc-interface ada-tree.def, contrib/gcc-12/gcc/d d-tree.def

Merge branch 'vendor/GCC120'
DeltaFile
+79-0contrib/gcc-12/gcc/ada/gcc-interface/ada-tree.def
+76-0contrib/gcc-12/gcc/objc/objc-tree.def
+29-0contrib/gcc-12/gcc/d/d-tree.def
+184-03 files

DragonFlyBSD/src 45d2e78 — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Introduce a dynamic xcr0_valid

Similar to the existing dynamical cr4_valid and efer_valid.

Obtained-from: NVMM Reference Implementation
DeltaFile
+17-14sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+17-14sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+34-282 files

DragonFlyBSD/src dcdce33 — sys/dev/virtual/nvmm/x86 nvmm_x86.c

nvmm: Don't advertise FMA4/XOP as the required AVX is not exposed

Obtained-from: NVMM Reference Implementation
DeltaFile
+2-2sys/dev/virtual/nvmm/x86/nvmm_x86.c
+2-21 files

DragonFlyBSD/src 280a73f — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Improve CPUID handling

- If the emulator wants to exit on a leaf, don't overwrite the
  registers.
- On AMD, out-of-range leaves return zero, not the highest supported
  leaf, so return zero.

Obtained-from: NVMM Reference Implementation
DeltaFile
+49-34sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+41-35sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+90-692 files

DragonFlyBSD/src 02283a7 — lib/libnvmm libnvmm.3, sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Change the meaning of TPR_CHANGED

Currently we return TPR_CHANGED if the guest changes its TPR. But the only
change the emulator is interested in is if the TPR is lowered, as that
unblocks certain classes of interrupts; the emulator doesn't care if the
TPR is increased.

Change the behavior to return TPR_CHANGED only if the TPR is lowered.
Then, implement an optimization on SVM: instead of intercepting all
writes to CR8 and returning to userland, use a TPR trap to get VMEXITs
only when the guest lowers its TPR.

This effectively eliminates VMEXITs on TPR increases, which significantly
improves the performance of Windows guests (because they frequently
increase and decrease the TPR).

Update the libnvmm.3 man page and the test cases as well.

Obtained-from: NVMM Reference Implementation
DeltaFile
+44-52sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+5-4sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+3-3test/testcases/libnvmm/h_misc.c
+2-2lib/libnvmm/libnvmm.3
+1-0test/testcases/libnvmm/h_os.h
+55-615 files

DragonFlyBSD/src 08f50a6 — lib/libnvmm libnvmm_x86.c

libnvmm: Fix -Winline warnings (2)

Rework the fix by by removing the `inline` keyword on `x86_gva_to_gpa()`,
because it has grown much bigger than the initial version.

Obtained-from: NVMM Reference Implementation
DeltaFile
+4-6lib/libnvmm/libnvmm_x86.c
+4-61 files

DragonFlyBSD/src 9e1d3d6 — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Improve XSETBV handling

XSETBV uses ECX, not RCX.

Obtained-from: NVMM Reference Implementation
DeltaFile
+3-1sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+3-1sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+6-22 files

DragonFlyBSD/src b20d49e — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c

nvmm: Use dynamic cr4_valid/efer_valid values in VMX

Implement the same feature like SVM.  Also filter out EFER in setstate().

Obtained-from: NVMM Reference Implementation
DeltaFile
+49-31sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+49-311 files

DragonFlyBSD/src 22d5c0b — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c

nvmm: Fix the handling of CR0.NE in VMX

CR0.NE must be forced to 1, so add it to CR0_STATIC_MASK. Otherwise
a #GP can be raised in the guest.

Bug: https://bugs.dragonflybsd.org/issues/3452
DeltaFile
+4-4sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+4-41 files

DragonFlyBSD/src 95330b0 — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Fix the filtering on event injections

The code wants to forbid the INT3/INTO vectors. These are vectors
3/4, not 3/0. Fix this.

Obtained-from: NVMM Reference Implementation
DeltaFile
+4-2sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+4-2sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+8-42 files

DragonFlyBSD/src dc2e531 — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Rename 'maxcpus' to 'max_cpus' to fix -Wshadow on NetBSD
DeltaFile
+7-7sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+7-7sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+14-142 files

DragonFlyBSD/src 7ae3b60 — sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm: Harmonize event reinjection

Never reinject a SW event, just let the guest re-execute the instruction
that caused it. Apply the same behavior to both SVM and VMX.

Obtained-from: NVMM Reference Implementation
DeltaFile
+13-10sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+14-7sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+27-172 files

DragonFlyBSD/src 942b05d — sys/dev/virtual/nvmm nvmm.c nvmm_os.h, sys/dev/virtual/nvmm/x86 nvmm_x86.h

nvmm: Misc changes

The introduction of OS_ASSERT_MTX_OWNED() is to help port to Haiku OS
that doesn't have a mtx_owned() or lockstatus() API for a mutex.

Obtained-from: NVMM Reference Implementation
DeltaFile
+7-7sys/dev/virtual/nvmm/x86/nvmm_x86.h
+4-3sys/dev/virtual/nvmm/nvmm_os.h
+1-1sys/dev/virtual/nvmm/nvmm.c
+12-113 files

DragonFlyBSD/src ac7fc80 — contrib/gcc-12/gcc/ada/gcc-interface ada-tree.def, contrib/gcc-12/gcc/d d-tree.def

vendor/GCC120: Add back ada-tree.def, d-tree.def and objc-tree.def
DeltaFile
+79-0contrib/gcc-12/gcc/ada/gcc-interface/ada-tree.def
+76-0contrib/gcc-12/gcc/objc/objc-tree.def
+29-0contrib/gcc-12/gcc/d/d-tree.def
+184-03 files

DragonFlyBSD/src 3351c65 — sys/kern kern_exit.c

kernel: reset the tty drain timeout after a session exits

exit1() forces t_timeout to one second while it drains the
controlling terminal of an exiting session leader, and leaves it
there. The tty outlives the session, so the next session on it (a
reused pty) gets EIO from any write that waits more than a second for
output space. dsynth runs into this, with gmake failing with "write
error: stdout".

Reset it to 0, the default, after ttywait(). Restoring the old value
would also carry over a timeout the session set with TIOCSDRAINWAIT.

Bug: https://bugs.dragonflybsd.org/issues/3469
DeltaFile
+3-1sys/kern/kern_exit.c
+3-11 files

DragonFlyBSD/src d7452fd — contrib/file README.DRAGONFLY, contrib/file/src readelf.c

contrib/file: Fix the DragonFly ABI note version decoding

The ABI note stores __DragonFly_version, which is encoded as
major * 100000 + minor * 100 + rev.  file(1) decoded the minor and bump
fields as major * 100000 + minor * 10000 + bump, so a 6.5.22 binary was
reported as "for DragonFly 6.0.522".

Fix the version decoding, similar to my previous patch to readelf(1) in
commit c0de80f6b41e2add4684d84fa92d7abb0fc9b656.

Before:
% file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /libexec/ld-elf.so.2, for DragonFly 6.0.522, stripped

After:
% file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /libexec/ld-elf.so.2, for DragonFly 6.5.22, stripped
DeltaFile
+3-2contrib/file/README.DRAGONFLY
+2-1contrib/file/src/readelf.c
+5-32 files

DragonFlyBSD/src d1f14a3 — test/testcases/vfs dfregress.run Makefile, test/testcases/vfs/dotdot run.sh dotdot.c

testcases: Add regression tests for open() and openat()

With the previous open(2) fixes, all the tests pass:

vfs/dotdot testcase:
```
--- open() of dot/dotdot ---
ok:   open(.) O_WRONLY|O_CREAT                 Is a directory (21)
ok:   open(.) O_RDWR|O_CREAT                   Is a directory (21)
ok:   open(.) O_RDONLY|O_CREAT                 Is a directory (21)
ok:   open(.) O_WRONLY                         Is a directory (21)
ok:   open(.) O_RDONLY                         OK
ok:   open(.) O_WRONLY|O_TRUNC|O_CREAT         Is a directory (21)
ok:   open(.) O_WRONLY|O_CREAT|O_EXCL          File exists (17)
ok:   open(.) O_RDONLY|O_CREAT|O_EXCL          File exists (17)
ok:   open(.) O_RDONLY|O_CREAT|O_DIRECTORY     Is a directory (21)
ok:   open(..) O_WRONLY|O_CREAT                Is a directory (21)
ok:   open(..) O_RDONLY|O_CREAT                Is a directory (21)
ok:   open(..) O_WRONLY|O_CREAT|O_EXCL         File exists (17)

    [54 lines not shown]
DeltaFile
+232-0test/testcases/vfs/dotdot/dotdot.c
+103-0test/testcases/vfs/openat/openat.c
+33-0test/testcases/vfs/openat/run.sh
+33-0test/testcases/vfs/dotdot/run.sh
+13-0test/testcases/vfs/Makefile
+3-0test/testcases/vfs/dfregress.run
+417-05 files not shown
+428-011 files

DragonFlyBSD/src 325bdd3 — sys/kern vfs_nlookup.c vfs_vnops.c

open(2): Fix open(O_CREAT) to correctly return EISDIR

* Skip "." and ".." terminating paths in nlookup() for NLC_OPEN, so
  they'll be handled in vn_open() to correctly return EISDIR instead of
  EEXIST.

* Let open("/", O_CREAT) through in nlookup(), so this case can be
  handled in vn_open() to return EISDIR.

* Fix vn_open() to return EISDIR if the target is a directory and is
  opened with O_CREAT or O_RDWR/O_TRUNC.

* Fix vn_open() to handle the mount-point target normally when the
  target already exists, instead of simply return EINVAL.

Bug: https://bugs.dragonflybsd.org/issues/3282
Tested-by: pjdfstest (https://github.com/pjd/pjdfstest)
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)
DeltaFile
+18-6sys/kern/vfs_vnops.c
+14-4sys/kern/vfs_nlookup.c
+32-102 files

DragonFlyBSD/src e20053b — sys/kern vfs_syscalls.c

rename(2): Fix permission check on cross-parent directory rename

Cross-parent directory rename did not require write permission on the
source directory, although its ".." entry is modified. POSIX requires
EACCES there. UFS already performs this check, but HAMMER2 and tmpfs
don't. Fix the bug by adding a generic check in kern_rename().

To reproduce the bug:
```
$ d=$(mktemp -d)
$ mkdir -p ${d}/p1/dir1 ${d}/p2
$ touch ${d}/p1/dir1/file1
$ chmod 0444 ${d}/p1/dir1
$ mv ${d}/p1/dir1 ${d}/p2
```

Before the fix, the last "mv" command succeeded; after the fix, it would
fail with "Permission denied" (EACCES).


    [2 lines not shown]
DeltaFile
+19-0sys/kern/vfs_syscalls.c
+19-01 files

DragonFlyBSD/src 911533c — sys/kern vfs_vnops.c, sys/vfs/devfs devfs_vnops.c

stat(2): Fix 'st_rdev' to report correct (major, minor) numbers

* Fix vn_stat() to fill 'st_rdev' with makeudev() for character and
  block devices that have a valid device number.
* In addition, fix devfs_vop_getattr() to fill 'va_rmajor' in addition to
  'va_rminor', and fix hammer2_vop_getattr() to fill 'va_rmajor' and
  'va_rminor'.

Before the fix, a manually mknod()-created device would have a 'st_rdev'
of NODEV (i.e., -1), for example:
```
$ ~/mknod /tmp/dev-1-2 1 2
dev: 0x102 (major=1, minor=2)
$ ls -l /tmp/dev-1-2
crw-------  1 root  wheel  255, 0xffff00ff Nov  7 18:34 dev-1-2
$ stat -f '%Z' /tmp/dev-1-2
255,4294902015
```


    [12 lines not shown]
DeltaFile
+12-1sys/kern/vfs_vnops.c
+2-2sys/vfs/hammer2/hammer2_vnops.c
+1-0sys/vfs/devfs/devfs_vnops.c
+15-33 files

DragonFlyBSD/src 1e56f00 — sys/kern vfs_syscalls.c

unlink(2): Fail with EPERM when trying to unlink a directory

As specified by POSIX and documented in the unlink(2) man page,
unlinking a directory fails with EPERM instead of EISDIR.  Fix
kern_unlink() to return EPERM when trying to unlink a directory.

Found-by: pjdfstest (https://github.com/pjd/pjdfstest)
Assisted-by: DeepSeek-v4.1-flash (with Pi Coding Agent)
DeltaFile
+7-1sys/kern/vfs_syscalls.c
+7-11 files