Use <bsd.dragonfly.mk> to avoid extra path checking
These makefiles need to be included by makefiles in different
directories, so the extra path existence checks are required to handle
this. Now just use <bsd.dragonfly.mk> to simplify this.
cc120,gcc120: Use <bsd.dragonfly.mk> to remove RELUP/TOP_PREFIX hacks
In addition, fix the "tm.h" generation in gnu/lib/csu/Makefile.csu; it
was called from .OBJDIR so the DF.SRCTOP would fail in that case.
share/mk: Add bsd.dragonfly.mk to provide source tree path variables
The include file provides the DF.SRCTOP, DF.RELDIR, DF.RELTOP and
DF.OBJTOP variables to help access the source and object trees, and thus
help avoid the complex and fragile relative paths that depend on the
location of the including makefiles.
In particular, DF.SRCTOP and DF.OBJTOP defines the absolute paths to the
source and object trees, so makefiles using these variables can be
included by any other makefiles, without hacking a variable to fix the
relative-path-based addressing. For example, gnu/usr.bin/cc120 hacks
this need with the "TOP_PREFIX" variable.
This idea is inspired by FreeBSD's SRCTOP, which is defined in
<src.sys.env.mk> and is finally included by <sys.mk>, so it becomes an
early global and can be directly used by any makefiles. We decided to
not touch <sys.mk> but place it in a separate include file (i.e.,
<bsd.dragonfly.mk>), so any makefiles that really want these variables
must explicitly include it. By the way, NetBSD also defines the
[3 lines not shown]
kernel: report the sender in sigwaitinfo() and sigtimedwait()
kern_sigtimedwait() returned only si_signo. lwpsignal() records the
sender's pid and uid in ps_frominfo[] for every signal it posts, and
sendsig() copies them into the siginfo of an SA_SIGINFO handler, but a
signal taken with sigwaitinfo() or sigtimedwait() came back with si_pid
and si_uid 0.
Bug: https://bugs.dragonflybsd.org/issues/3471
Reviewed-by: @dillon
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
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
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
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
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
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]
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
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
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
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
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
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
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