3 years agoMerge branch 'vendor/DHCPCD'
Aaron LI [Wed, 14 Nov 2018 12:51:02 +0000 (20:51 +0800)]
Merge branch 'vendor/DHCPCD'

Import dhcpcd 7.0.8

3 years agodhcpcd: Add READMEs
Aaron LI [Fri, 19 Oct 2018 06:32:39 +0000 (14:32 +0800)]
dhcpcd: Add READMEs

3 years agoImport dhcpcd 7.0.8
Aaron LI [Fri, 19 Oct 2018 06:22:17 +0000 (14:22 +0800)]
Import dhcpcd 7.0.8

Version: 7.0.8
Date: 2018 August 20
URL: https://github.com/rsmarples/dhcpcd/releases
Homepage: https://roy.marples.name/projects/dhcpcd

3 years agokernel - Fix sack NULL pointer dereference
Matthew Dillon [Tue, 13 Nov 2018 19:12:36 +0000 (11:12 -0800)]
kernel - Fix sack NULL pointer dereference

* sack_block_lookup() can get confused when the passed-in sequence
  number appears to be less than sblk_start and greater than sblk_end.
  This situation can occur when the signed integer delta test has an
  overflow due to (sblk_end - seq) overflowing the sign bit verses
  (sblk_start - seq).

  The result is that sack_block_lookup() can crash on a NULL pointer

* Check for the case, complain, and try to allow it.  Though I suspect
  if the case occurs at all SACK will wind up with a broken list anyway.

* I don't think this case can occur under normal conditions since TCP
  buffers do not grow to 2GB+ in size, so the crash we got was triggered
  by either an accidently malformed packet or an intentional one.

3 years agokernel - Fix SMP race in procfs
Matthew Dillon [Tue, 13 Nov 2018 19:10:47 +0000 (11:10 -0800)]
kernel - Fix SMP race in procfs

* procfs was not locking its pid hash table.  Implement a per-slot
  spinlock.  The hash is populated only for pid directories that are
  pushed into (e.g. ls /proc/<pid> vs ls /proc).

* Fixes a fairly rare crash that can only occur when procfs is used

3 years agodrm/ttm: Sync ttm_execbuf_util.c with Linux
François Tigeot [Sun, 11 Nov 2018 08:18:03 +0000 (09:18 +0100)]
drm/ttm: Sync ttm_execbuf_util.c with Linux

3 years agodrm/ttm: Sync ttm_lock.c with Linux
François Tigeot [Sat, 10 Nov 2018 08:31:20 +0000 (09:31 +0100)]
drm/ttm: Sync ttm_lock.c with Linux

3 years agoterminfo: Build and install tmux and tmux-256color
Aaron LI [Sat, 10 Nov 2018 01:08:23 +0000 (09:08 +0800)]
terminfo: Build and install tmux and tmux-256color

3 years agodrm/linux: Add send_sig()
François Tigeot [Fri, 9 Nov 2018 17:34:19 +0000 (18:34 +0100)]
drm/linux: Add send_sig()

3 years agorc.conf.5: Document ip6addrctl_{policy,verbose} explicitly
Aaron LI [Thu, 8 Nov 2018 01:13:04 +0000 (09:13 +0800)]
rc.conf.5: Document ip6addrctl_{policy,verbose} explicitly

Suggested-by: swildner
3 years agodrm/ttm: Rework ttm_io_prot()
François Tigeot [Wed, 7 Nov 2018 22:18:51 +0000 (23:18 +0100)]
drm/ttm: Rework ttm_io_prot()

Change it to be as close to the Linux version as possible.

3 years agokernel - Fix typo from b227f3f50d5dc0f when filling in kpmap header.
Imre Vadász [Tue, 6 Nov 2018 19:52:36 +0000 (20:52 +0100)]
kernel - Fix typo from b227f3f50d5dc0f when filling in kpmap header.

3 years agocrypto - Avoid including opensslconf.h when using openssl/md5.h in kernel.
Imre Vadász [Mon, 5 Nov 2018 22:14:40 +0000 (23:14 +0100)]
crypto - Avoid including opensslconf.h when using openssl/md5.h in kernel.

3 years agokernel - Make the wdog.h and gpio.h includes conditional in kern_shutdown.c.
Imre Vadász [Mon, 5 Nov 2018 22:13:00 +0000 (23:13 +0100)]
kernel - Make the wdog.h and gpio.h includes conditional in kern_shutdown.c.

3 years agokernel - Fix build when neither INET nor INET6 options are set.
Imre Vadász [Sat, 3 Nov 2018 19:51:06 +0000 (20:51 +0100)]
kernel - Fix build when neither INET nor INET6 options are set.

3 years agodrm/linux: fix pgprot_xxx functions
François Tigeot [Tue, 6 Nov 2018 17:32:51 +0000 (18:32 +0100)]
drm/linux: fix pgprot_xxx functions

3 years agorc.d/Makefile: Break some long lines, sort dntpd.
Sascha Wildner [Tue, 6 Nov 2018 04:28:07 +0000 (05:28 +0100)]
rc.d/Makefile: Break some long lines, sort dntpd.

3 years agodrm/linux: Fix vmap()
François Tigeot [Mon, 5 Nov 2018 21:15:18 +0000 (22:15 +0100)]
drm/linux: Fix vmap()

Page protection information was not being used.

3 years agorc.subr: Add list_vars() function
Aaron LI [Mon, 5 Nov 2018 20:31:38 +0000 (04:31 +0800)]
rc.subr: Add list_vars() function

Taken-from: FreeBSD

3 years agorc.d: Add ip6addrctl (enabled by default with policy AUTO)
Aaron LI [Mon, 5 Nov 2018 20:25:17 +0000 (04:25 +0800)]
rc.d: Add ip6addrctl (enabled by default with policy AUTO)

Bring in the ip6addrctl rc script from FreeBSD.  It is enabled by
default with policy "AUTO", so the IPv4/IP6 preference is configured on
startup.  The rc variable "ip6addrctl_policy" is used to adjust the
preference (AUTO, ipv6_prefer, ipv6_prefer).

See the rc.conf(5) man page for more details.

3 years agoBring in ip6addrctl(8) from FreeBSD
Aaron LI [Mon, 5 Nov 2018 19:22:15 +0000 (03:22 +0800)]
Bring in ip6addrctl(8) from FreeBSD

The ip6addrctl(8) manages the policy table of source and destination
address selection for ougoing IPv4 and IPv6 packets.

For example, this utility can be used to configure that IPv4 is
preferred on a dual-stack machine, which by default prefers IPv6.

3 years agolibc/mktemp: Pass flags to open()
Simon Arlott [Sat, 3 Nov 2018 20:08:07 +0000 (20:08 +0000)]
libc/mktemp: Pass flags to open()

The flags from the functions that call _gettemp() are never used.

They should be included in the call to open(), otherwise features like
O_CLOEXEC don't work.

(1) Checked FreeBSD and it behaves the same way as this fix.
(2) Improve the style a bit.

3 years agonet/if: Call if_ioctl() if the protocol didn't handle the ioctl
Aaron LI [Sun, 4 Nov 2018 09:55:53 +0000 (17:55 +0800)]
net/if: Call if_ioctl() if the protocol didn't handle the ioctl

This allows for a non-interface socket (like AF_LOCAL which ifconfig(8)
now uses since commit d4e856128472e2e79172aebf65f19f527ac0010f) to use
a broader class of interface ioctls.

This fixes the regression in ifconfig(8) that is introduced by the above
mentioned commit, which changed ifconfig(8) to use AF_LOCAL socket by
default and thus caused some ioctls failures.  For example:

dfly# ifconfig tap0 create
dfly# ifconfig tap0 up
dfly# ifconfig bridge0 create
dfly# ifconfig bridge0 addm tap0

dfly# ifconfig bridge0
bridge0: flags=8002<BROADCAST,MULTICAST> mtu 1500
        ether be:48:6d:6d:a6:1f
        groups: bridge

dfly# ifconfig bridge0
bridge0: flags=8002<BROADCAST,MULTICAST> mtu 1500
        ether be:48:6d:6d:a6:1f
        priority 32768 hellotime 2 fwddelay 15 maxage 20
        member: tap0 flags=3<LEARNING,DISCOVER>
        groups: bridge

Do not pass the SIOCSIF{ADDR,BRDADDR,DSTADDR,NETMASK} iotcls to the
drivers because they may assume these ioctls come from an already
privileged layer and thus skip credentials check and input validation.

While there, improve a NULL check.

Taken-from: FreeBSD (r190151, r255442)
Reviewed-by: dillon, sephe
3 years agoboot - Slow down the nfs twiddle
Matthew Dillon [Sun, 4 Nov 2018 06:55:49 +0000 (23:55 -0700)]
boot - Slow down the nfs twiddle

* Slow down the twiddle rate when reading via nfs, it unnecessarily
  slows down the boot, by a lot.

3 years agodrm/ttm: Remove ttm_bo_unreserve_core()
François Tigeot [Sat, 3 Nov 2018 14:18:38 +0000 (15:18 +0100)]
drm/ttm: Remove ttm_bo_unreserve_core()

* This function was DragonFly-specific and apparently
  isn't even needed anymore

* Sync the changed code with Linux as of ecff665f5e3f1c6909353e00b9420e45ae23d995
  "drm/ttm: make ttm reservation calls behave like reservation calls"

3 years agodrm: Add linux/rwlock.h
François Tigeot [Sat, 3 Nov 2018 13:07:50 +0000 (14:07 +0100)]
drm: Add linux/rwlock.h

3 years agovkernel - Fix tty panic
Matthew Dillon [Sat, 3 Nov 2018 00:25:35 +0000 (17:25 -0700)]
vkernel - Fix tty panic

* Fix messed up gettoken/reltoken sequence for the vkernel,
  bug was introduced in recent tty work.

Reported-by: tuxillo
3 years agodmesg(8): Allow seeing backslashes in dmesg output.
Sascha Wildner [Fri, 2 Nov 2018 16:28:53 +0000 (17:28 +0100)]
dmesg(8): Allow seeing backslashes in dmesg output.

This caused confusion already in ACPICA bug reports with pathnames
containing backslashes.

Taken-from: NetBSD

3 years agolibc/vis: Use thread-safe mbrtoc() and wcrtomb().
Sascha Wildner [Fri, 2 Nov 2018 16:26:59 +0000 (17:26 +0100)]
libc/vis: Use thread-safe mbrtoc() and wcrtomb().

Taken-from: FreeBSD

3 years agoSync ACPICA with Intel's version 20181031.
Sascha Wildner [Fri, 2 Nov 2018 08:58:43 +0000 (09:58 +0100)]
Sync ACPICA with Intel's version 20181031.

* Fix an Operation Region regression, fixing accurate checking for
  region conflicts.

* Add support for 2-byte extended opcodes in the code that continues
  parsing during the table load phase.

* Eliminate a no longer used global variable.

For detailed list, please see sys/contrib/dev/acpica/changes.txt.

3 years agoSync zoneinfo database with tzdata2018g from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 2 Nov 2018 08:04:13 +0000 (09:04 +0100)]
Sync zoneinfo database with tzdata2018g from ftp://ftp.iana.org/tz/releases

* Morocco switched to permanent +01 on 2018-10-27.

* Change HDT to HWT/HPT for WWII-era abbreviations in Hawaii.

For a detailed list of changes, see share/zoneinfo/NEWS.

3 years agoboot - Handle tftp block overflows
Matthew Dillon [Fri, 2 Nov 2018 02:06:14 +0000 (19:06 -0700)]
boot - Handle tftp block overflows

* Properly truncate the block number when comparing against the
  incoming packet.  TFTP only implements 16-bit block numbers.
  This allows the boot loader to access files larger than 32MB
  via TFTP.

* Twiddle every 256 reads instead of every 16.

* Note that TFTP is not really a suitable protocol for loading the
  kernel because the ELF loader seeks past the debug info which
  can be well over a hundred megabytes in order to get to the syms.
  NFS is preferred.

3 years agoJust note that the previous commit was to hammer2 only.
Sascha Wildner [Wed, 31 Oct 2018 09:34:00 +0000 (10:34 +0100)]
Just note that the previous commit was to hammer2 only.

The tmpfs logic turned out to be correct after closer review.

3 years agokernel/{hammer2,tmpfs}: Fix ENOTDIR/EISDIR logic.
Sascha Wildner [Wed, 31 Oct 2018 09:27:27 +0000 (10:27 +0100)]
kernel/{hammer2,tmpfs}: Fix ENOTDIR/EISDIR logic.

It caused confusion like this:

vm64# touch /usr/obj/t
vm64# rmdir /usr/obj/t
rmdir: /usr/obj/t: Is a directory

Likewise unlink(2) on a directory also gives the wrong error
("Not a directory").

This also causes Ruby's unlink() file method to fail.

Reported-by: tuxillo
3 years agotmpfs - Use atomic_fetchadd_long() to allocate inode numbers
Matthew Dillon [Wed, 31 Oct 2018 01:50:03 +0000 (18:50 -0700)]
tmpfs - Use atomic_fetchadd_long() to allocate inode numbers

* Since DFly inode numbers are 64 bits wide, tmpfs just increments a
  per-mount counter to allocate a new inode.

* We had some old code in tmpfs to allocate inode numbers which wrapped
  a tmpfs mount lock around the increment.  This is totally unnecessary.
  Use atomic_fetchadd_long() instead.

Reported-by: mjg
3 years agokernel - Fix getsockname() on unnamed AF_LOCAL sockets
Matthew Dillon [Wed, 31 Oct 2018 01:48:35 +0000 (18:48 -0700)]
kernel - Fix getsockname() on unnamed AF_LOCAL sockets

* Fix getsockname() on unnamed AF_LOCAL sockets.  The socket structure
  does not actually bother storing a sockaddr, so sa is returned NULL.
  In this situation, just dummy-up an AF_LOCAL sockaddr.

* Don't bother copyout()ing sa_len unless it has changed.

Reported-by: tuxillo
3 years agobsd-family-tree: Sync with FreeBSD (OpenBSD 6.4).
Sascha Wildner [Sun, 28 Oct 2018 16:53:12 +0000 (17:53 +0100)]
bsd-family-tree: Sync with FreeBSD (OpenBSD 6.4).

3 years agosound - Allow /dev/sndstat to be opened multiple times from one process.
Imre Vadász [Fri, 26 Oct 2018 20:14:47 +0000 (22:14 +0200)]
sound - Allow /dev/sndstat to be opened multiple times from one process.

* This still isn't great, but at least it's enough to make pulseaudio's
  oss module detect the audio devices correctly.

* This now uses the buf->uio_offset, instead of trying to track the read
  position ourselves in the driver with sndstat_bufptr.

3 years ago<sys/sysproto.h>: Add back one needed newline and regenerate header.
Sascha Wildner [Sat, 27 Oct 2018 07:45:04 +0000 (09:45 +0200)]
<sys/sysproto.h>: Add back one needed newline and regenerate header.

3 years ago<sys/sysproto.h>: Fix excessive newlines.
Sascha Wildner [Sat, 27 Oct 2018 07:39:25 +0000 (09:39 +0200)]
<sys/sysproto.h>: Fix excessive newlines.

3 years ago<sys/wait.h>: Put the enum name under __BSD_VISIBLE.
Sascha Wildner [Sat, 27 Oct 2018 06:26:44 +0000 (08:26 +0200)]
<sys/wait.h>: Put the enum name under __BSD_VISIBLE.

POSIX only defines idtype_t. In <sys/procctl.h> i just left it because
that whole file isn't covered by the standard anyway.

While here, cleanup whitespace a little bit and clarify DragonFly or
FreeBSD a bit better in a comment.

3 years agobuild - refactor rescue and initrd handling
Matthew Dillon [Sat, 27 Oct 2018 01:33:57 +0000 (18:33 -0700)]
build - refactor rescue and initrd handling

* buildworld now builds the rescue directory tree and initrd
  image in /usr/obj.

* installworld will install the rescue and initrd stuff if it
  does not exist on the destination.  If rescue or initrd stuff
  is already installed, it is not overwritten.

* Add 'installrescue' and 'installinitrd' targets.  These will
  copy the rescue and initrd image built by buildworld.

* The normal 'rescue' and 'initrd' targets are unchanged and
  should build (from scratch) and install the rescue and initrd

* NOTE: crunchgen is currently hacked to add system paths when
  WORLDBUILD is defined, in order to access native binaries
  for 'uniq' and a few others, instead of building them in

  In particular, we have to use the native 'vnconfig' binary
  as building one in crosstools might not be compatible with
  the currently running system.  buildworld now uses 'vn' to
  create the initrd image.

  Possibly needs some work.

3 years agokernel - Refactor kbmux arrays
Matthew Dillon [Sat, 27 Oct 2018 01:17:36 +0000 (18:17 -0700)]
kernel - Refactor kbmux arrays

* Get rid of the generally insane dynamic reallocation code for
  these tiny arrays and set a fixed limit of 16 keyboards.

* Add a sanity check in kbd_intr() to deal with potential interrupt
  races against installation of a new keyboard.

3 years agolibc - Add kpmap shortcut for gettimeofday()
Matthew Dillon [Sat, 27 Oct 2018 01:08:35 +0000 (18:08 -0700)]
libc - Add kpmap shortcut for gettimeofday()

* If the kern.gettimeofday_quick sysctl is set to 1, libc's
  gettimeofday() will use the tick-granular realtime in
  the kpmap instead of making a system call.  The sysctl
  defaults to 0 (off).

* Useful in situations where gettimeofday() interferes with
  benchmarks, but otherwise not recommended.

* Running programs react instantly to changes in this sysctl.

3 years agosys/conf/files: Move vmx a bit up.
Sascha Wildner [Fri, 26 Oct 2018 13:38:02 +0000 (15:38 +0200)]
sys/conf/files: Move vmx a bit up.

3 years agoVirtio_Balloon implementation for DragonFly
Diederik de Groot [Mon, 1 Oct 2018 23:00:05 +0000 (01:00 +0200)]
Virtio_Balloon implementation for DragonFly

- Initial check-in of fbsd virtio_balloon (freebsd/freebsd@1537078)
- Update virtio_balloon man page
- Fix vtballoon_alloc_intrs to deal nicely with number of provided interrupts.
- Use a backoff scheme when allocating vm_pages:
  - VM_ALLOC_NORMAL for normal (low memory presure) situation;
  - VM_ALLOC_SYSTEM + increased sleep timeout, for high memory presure circumstances.
  The latter will allow the system to swap other pages out if necessary.
- Implemented suggestions made by ivadasz
  - Added virtio_teardown_intr handling to vtballoon_detach
  - Added config_change_intr handling
  - Fixed virtio_setup_intr
- Add debug_level sysctl for tracing.
- Add collection of guest memory/pagefault statistics
- Completed/Updated header definitions
- Don't use VM_ALLOC_INTERRUPT. Add better inflate/deflate debug output to thread_sleep function
- Don't collect stats when initialially loaded (Reported by tuxillo).

3 years agoLINT64: Add comments to the virtio devices.
Sascha Wildner [Fri, 26 Oct 2018 12:42:29 +0000 (14:42 +0200)]
LINT64: Add comments to the virtio devices.

3 years agobuild - Fix buildworld from DFly releases prior to 5.0.
Matthew Dillon [Fri, 26 Oct 2018 02:56:40 +0000 (19:56 -0700)]
build - Fix buildworld from DFly releases prior to 5.0.

* Fix mkmagic to not use the magic.h in /usr/include.  It
  needs the magic.h generated via libmagic.  Since mkmagic
  must be built prior to libmagic, we generate a local magic.h
  just for mkmagic.

* Fixes buildworld from DFly releases prior to 5.0.

3 years agosound - Fix mmap handling for /dev/dsp* devices.
Imre Vadász [Thu, 25 Oct 2018 22:53:08 +0000 (00:53 +0200)]
sound - Fix mmap handling for /dev/dsp* devices.

* The d_mmap function is expected to return a page index, not an address,
  the the atop() function for this as usual.

3 years ago<sys/signal.h>: Discard old non-POSIX union members.
Sascha Wildner [Thu, 25 Oct 2018 17:31:53 +0000 (19:31 +0200)]
<sys/signal.h>: Discard old non-POSIX union members.

The only thing I found that still uses the old names is www/nginx,
a fix for which is in DeltaPorts:


While here, fix a small whitespace issue.

3 years agorc.conf.5: Remove the obsolete reference to named(8)
Aaron LI [Thu, 25 Oct 2018 12:07:18 +0000 (20:07 +0800)]
rc.conf.5: Remove the obsolete reference to named(8)

3 years agoSync /etc/pccard_ether with FreeBSD
Aaron LI [Thu, 25 Oct 2018 05:48:56 +0000 (13:48 +0800)]
Sync /etc/pccard_ether with FreeBSD

Our original 'pccard_ether' became unnecessarily complex as a big part of
the work is already implemented in 'network.subr', so just bring FreeBSD's
version over (with 'checkauto()' ignored as we don't support it).

NOTE: The 'pccard_ether' is still disabled by default on DragonFly.

3 years agoarp(8): Add option -i to limit operations to one interface
Aaron LI [Thu, 25 Oct 2018 05:16:47 +0000 (13:16 +0800)]
arp(8): Add option -i to limit operations to one interface

This allows to limit the scope of operation to the ARP entries on a
particular interface, which should be useful on machines with lots of
network interfaces, e.g., inter-VLAN routers.

This new option will also be used in /etc/pccard_ether.

Taken from FreeBSD (r117729, r154162) with modifications.

3 years ago<sys/eventhandler.h>: Move the include inside the guard.
Sascha Wildner [Thu, 25 Oct 2018 08:27:37 +0000 (10:27 +0200)]
<sys/eventhandler.h>: Move the include inside the guard.

3 years ago<sys/stdint.h>: Move the includes inside the guard.
Sascha Wildner [Thu, 25 Oct 2018 07:54:46 +0000 (09:54 +0200)]
<sys/stdint.h>: Move the includes inside the guard.

3 years agoSync zoneinfo database with tzdata2018f from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Wed, 24 Oct 2018 18:27:06 +0000 (20:27 +0200)]
Sync zoneinfo database with tzdata2018f from ftp://ftp.iana.org/tz/releases

* Volgograd moves from +03 to +04 on 2018-10-28.

* Fiji ends DST 2019-01-13, not 2019-01-20.

* Most of Chile changes DST dates, effective 2019-04-06.

* Use PST and PDT for Philippine time.

* Various adjustments to past timestamps.

* Miscellaneous fixes and adjustments.

For a detailed list of changes, see share/zoneinfo/NEWS.

3 years agoUpdate the pciconf(8) database.
Sascha Wildner [Mon, 22 Oct 2018 18:12:22 +0000 (20:12 +0200)]
Update the pciconf(8) database.

October 13, 2018 snapshot from https://pci-ids.ucw.cz

3 years agokernel - Remove two debug messages
Matthew Dillon [Sat, 20 Oct 2018 03:58:11 +0000 (20:58 -0700)]
kernel - Remove two debug messages

* Remove the debug messages for two cases which have been validated
  to occur under synth loads, thus these code paths have been tested.

3 years agonrelease - Use built boot blocks instead of system boot blocks
Matthew Dillon [Fri, 19 Oct 2018 23:24:40 +0000 (16:24 -0700)]
nrelease - Use built boot blocks instead of system boot blocks

* Adjust the nrelease Makefile to install the boot blocks from
  the nrelease build into the image instead of the boot blocks
  from the running system.

Submitted-by: NI33 (irc)
3 years agoopenresolv: Bind to system as resolvconf(8)
Aaron LI [Thu, 18 Oct 2018 17:23:51 +0000 (01:23 +0800)]
openresolv: Bind to system as resolvconf(8)

The resolvconf(8) will be used by dhcpcd(8), which will be imported
later to provide out-of-box IPv6 DHCP support, replacing the IPv4-only
dhclient(8) in base and the rtsold(8).

Thanks to swildner for reviewing and providing suggestions.

3 years agoopenresolv: Add READMEs
Aaron LI [Thu, 18 Oct 2018 17:11:18 +0000 (01:11 +0800)]
openresolv: Add READMEs

3 years agoMerge branch 'vendor/OPENRESOLV'
Aaron LI [Fri, 19 Oct 2018 15:59:51 +0000 (23:59 +0800)]
Merge branch 'vendor/OPENRESOLV'

3 years agoImport openresolv 3.9.0
Aaron LI [Thu, 18 Oct 2018 17:00:16 +0000 (01:00 +0800)]
Import openresolv 3.9.0

Version: 3.9.0
Date: 2016-Dec-30
Homepage: https://roy.marples.name/projects/openresolv

3 years agodrm/linux: Fix potential ww mutex induced panics
François Tigeot [Mon, 15 Oct 2018 20:17:54 +0000 (22:17 +0200)]
drm/linux: Fix potential ww mutex induced panics

ww mutex locking functions can be called with a NULL ctx and were
happily setting both lock->acquired to non-zero and lock->ctx to
NULL, a combination which other parts of our ww mutex implementation
assume is not possible.

Obtained-from: OpenBSD

3 years agokernel - Fix NUMA contention due to assymetric memory
Matthew Dillon [Mon, 15 Oct 2018 03:09:47 +0000 (20:09 -0700)]
kernel - Fix NUMA contention due to assymetric memory

* Fix NUMA contention in situations where memory is associated
  with CPU cores assymetrically.  In particular, with the 2990WX,
  half the cores will have no memory associated with them.

* This was forcing DFly to allocate memory from queues belonging to
  other nearby cores, causing unnecessary SMP contention, as well
  as burn extra time iterating queues.

* Fix by calculating the average number of free pages per-core,
  and then adjust any VM page queue with pages less than the average
  by stealing pages from queues with greater than the average.
  We use a simple iterator to steal pages, so the CPUs with less
  (or zero) direct-attached memory will operate more UMA-like
  (just on 4K boundaries instead of 256-1024 byte boundaries).

* Tested with a 64-thread concurrent compile test.  systat -pv 1
  showed all remaining contention disappear.  Literally, *ZERO*
  contention when we run the test with each thread in its own jail
  with no shared resources.

* NOTE!  This fix is specific to asymetric NUMA configurations
  which are fairly rare in the wild and will not speed up more
  conventional systems.

* Before and after timings on the 2990WX.

  cd /tmp/src
  time make -j 128 nativekernel NO_MODULES=TRUE > /dev/null

  703.915u 167.605s 0:49.97 1744.0%       9993+749k 22188+8io 216pf+0w
  699.550u 171.148s 0:50.87 1711.5%       9994+749k 21066+8io 150pf+0w

  678.406u 108.857s 0:45.66 1724.1%       10105+757k 22188+8io 216pf+0w
  674.805u 115.256s 0:46.67 1692.8%       10077+755k 21066+8io 150pf+0w

  This is a 4.2 second difference on the second run, an over 8%
  improvement which is nothing to sneeze at.

3 years agodrm/radeon: add missing ttm_eu_backoff_reservation to radeon_bo_list_validate
François Tigeot [Fri, 12 Oct 2018 20:50:58 +0000 (22:50 +0200)]
drm/radeon: add missing ttm_eu_backoff_reservation to radeon_bo_list_validate

3 years agodrm/radeon: Finish replacing task queues by Linux work queues
François Tigeot [Thu, 11 Oct 2018 20:40:30 +0000 (22:40 +0200)]
drm/radeon: Finish replacing task queues by Linux work queues

3 years agodrm/radeon: Reduce differences with Linux 3.18
François Tigeot [Thu, 11 Oct 2018 20:38:26 +0000 (22:38 +0200)]
drm/radeon: Reduce differences with Linux 3.18

No functional changes

3 years agodrm/linux: Add a few headers
François Tigeot [Thu, 11 Oct 2018 20:26:42 +0000 (22:26 +0200)]
drm/linux: Add a few headers

3 years agokernel: Clean up syscalls.master a bit more.
Sascha Wildner [Thu, 11 Oct 2018 13:19:43 +0000 (15:19 +0200)]
kernel: Clean up syscalls.master a bit more.

All this and also f29ea48f7a62b011be75119d46acd81bee2dd8ee could have
been cleaned up in d6e8ab2d2508bde32ad7b7daaf86d44ec7330986.

While here, also remove some obsolete comments.

3 years ago<vm/vm_extern.h>: Remove some dead code.
Sascha Wildner [Thu, 11 Oct 2018 13:10:05 +0000 (15:10 +0200)]
<vm/vm_extern.h>: Remove some dead code.

3 years agosyscalls.master: Remove a leftover semicolon.
Sascha Wildner [Thu, 11 Oct 2018 12:48:08 +0000 (14:48 +0200)]
syscalls.master: Remove a leftover semicolon.

3 years agokernel/libc: Remove sigstack() remains.
Sascha Wildner [Thu, 11 Oct 2018 12:44:46 +0000 (14:44 +0200)]
kernel/libc: Remove sigstack() remains.

There is no sigstack() syscall anymore in DragonFly, besides being
obsolete, so remove some remains like the manual page and prototype,
and do some related cleanup.

3 years agodrm: Add linux/interval_tree.h
François Tigeot [Sun, 7 Oct 2018 12:47:03 +0000 (14:47 +0200)]
drm: Add linux/interval_tree.h

3 years agodrm/linux: Add rcu_dereference_protected()
François Tigeot [Sun, 7 Oct 2018 12:27:27 +0000 (14:27 +0200)]
drm/linux: Add rcu_dereference_protected()

3 years agokernel: Add further support for fixed-width integer type sysctls.
Sascha Wildner [Sat, 6 Oct 2018 07:29:28 +0000 (09:29 +0200)]
kernel: Add further support for fixed-width integer type sysctls.

U32 support was added in c48b2bac286ed1aaa6b974adfbc844e82bc65f38.

QUAD and UQUAD are now aliases of S64 and U64.

Taken-from: FreeBSD

3 years agokernel - Refactor tty clist code (2)
Matthew Dillon [Sat, 6 Oct 2018 04:32:48 +0000 (21:32 -0700)]
kernel - Refactor tty clist code (2)

* Fix initialization of high water mark, the last commit accidently
  removed it.

* Fixes issue with slow console output (emacs, alt-x "shell", then
  'ls' or whatever).

Reported-by: tuxillo
3 years agoRemove <sys/clist.h> via 'make upgrade'.
Sascha Wildner [Fri, 5 Oct 2018 06:32:18 +0000 (08:32 +0200)]
Remove <sys/clist.h> via 'make upgrade'.

3 years agokernel - Fix missing tokens in killalllwps()
Matthew Dillon [Thu, 4 Oct 2018 22:28:11 +0000 (15:28 -0700)]
kernel - Fix missing tokens in killalllwps()

* There appears to be at least one code path where killalllwps()
  is being called without the necessary tokens held.

* Just have the routine itself obtain the necessary tokens.

* Might be responsible for extremely rare core-dump stop/wait

3 years agokernel - Refactor tty clist code
Matthew Dillon [Thu, 4 Oct 2018 21:37:12 +0000 (14:37 -0700)]
kernel - Refactor tty clist code

* Remove all the old cruft, completely rewrite the clist code to use
  a single linear buffer and a FIFO mechanism.

* The linear buffer just uses 16-bit elements in order to record
  TTY_QUOTE along with the character.

* Fixes bug in last commit (lack of global locks around global clist
  caches) by removing the cache entirely.

3 years agokernel - Refactor tty_token, fix SMP performance issues
Matthew Dillon [Thu, 4 Oct 2018 17:22:35 +0000 (10:22 -0700)]
kernel - Refactor tty_token, fix SMP performance issues

* Remove most uses of tty_token in favor of per-tty tp->t_token.
  This is particularly important for removing bottlenecks related to PTYs,
  which are used all over the place.  tty_token remains in a few places
  managing overall registration and global list manipulation.

* tty structures are now required to be persistent.  Implement a sepearate
  ttyinit() function.  Continue to allow ttyregister() and ttyunregister()
  calls, but these no longer presume destruction of the structure.

* Refactor ttymalloc() to take a **tty pointer and interlock allocations.
  Allocations are intended to be one-time.  ttymalloc() only requires the
  tty_token for initial allocations.

* Remove all critical section use that was combined with tty_token and
  tp->t_token.  Leave only the tokens.  The critical sections were
  hold-overs going all the way back to pre-SMP days.

* syscons now gets its own token, vga_token.  The ISA VGA code and
  the framebuffer code also now use this token instead of tty_token.

* The keyboard subsystem now uses kbd_token instead of tty_token.

* A few remaining serial-like devices (snp, nmdm) also get their own
  tokens, as well as use the now required tp->t_token.

* Remove use of tty_token in the session management code.  This fixes
  a niggling performance path since sessions almost universally go
  hand-in-hand with fork/exec/exit sequences.  Instead we use the
  already-existing per-hash session token.

3 years agoichwd - Fix typo in TCO2_CNT register #define.
Imre Vadász [Thu, 4 Oct 2018 19:08:28 +0000 (21:08 +0200)]
ichwd - Fix typo in TCO2_CNT register #define.

* The TCO2_CNT isn't actually used in the driver at the moment.

3 years agoioctl.9: nwfs(4) is no longer in our tree.
Sascha Wildner [Thu, 4 Oct 2018 16:44:36 +0000 (18:44 +0200)]
ioctl.9: nwfs(4) is no longer in our tree.

It was removed in 6f25d5554e6df42aa5235bf7e3e8e1cc9da25eec.

3 years agokernel: Remove some old serial drivers.
Sascha Wildner [Thu, 4 Oct 2018 15:51:01 +0000 (17:51 +0200)]
kernel: Remove some old serial drivers.

Namely digi(4), rp(4) and si(4) (the latter along with its userland
utility sicontrol(8)). It is unlikely that these work properly any

In preparation for the upcoming tty_token work by dillon.

Requested-by: dillon
3 years agokernel/lwkt_token: Fix indent.
Sascha Wildner [Thu, 4 Oct 2018 06:44:53 +0000 (08:44 +0200)]
kernel/lwkt_token: Fix indent.

3 years agokernel - Change pool token hash
Matthew Dillon [Thu, 4 Oct 2018 04:17:51 +0000 (21:17 -0700)]
kernel - Change pool token hash

* Change the pool token hash to something less stupid.

* Improve lwkt.tokens_debug_output to also output the address of
  the actual token instead of just its name.  This will help us
  track down pool token collisions a bit better.

3 years agoichsmb - Add additional PCI IDs to ichsmb.
Imre Vadász [Wed, 3 Oct 2018 20:56:19 +0000 (22:56 +0200)]
ichsmb - Add additional PCI IDs to ichsmb.

* This moves from a long switch statement to a lookup table.

Taken-From: FreeBSD

3 years agoSync ACPICA with Intel's version 20181003:
Sascha Wildner [Wed, 3 Oct 2018 16:43:21 +0000 (18:43 +0200)]
Sync ACPICA with Intel's version 20181003:

* Fix a regression that could cause the compiler to fault.

* New remark for excessively long Sleep()s.

For detailed list, please see sys/contrib/dev/acpica/changes.txt.

3 years agokernel - Remove duplicate TRIM, only trim with the 'trim' mount opt
Matthew Dillon [Tue, 2 Oct 2018 04:12:28 +0000 (21:12 -0700)]
kernel - Remove duplicate TRIM, only trim with the 'trim' mount opt

* ffs_blkfree_cg() was improperly issuing a synchronous
  VOP_FREEBLKS() on the underlying device.  This issues a
  BUF_CMD_FREEBLKS stategy op to the underlying device,
  which is executed unconditionally.  This basically runs
  an unconditional TRIM whether the 'trim' mount flag is
  specified or not.

  Remove the VOP_FREEBLKS() call.

* For softupdates operation, ffs_blkfree() handles the
  'trim' mount flag by issuing a BUF_CMD_FREEBLKS and
  sequencing the call to ffs_blkfree_cg() when it completes.

  When 'trim' was enabled, *two* TRIM operations were being
  executed on the underlying device, and prior to our fix,
  if 'trim' was not enabled, *one* TRIM operation would
  still be executed instead of zero.

* In many situations... possibly even most situations,
  trim operations seriously reduce performance due to
  being serialized by AHCI or by the target device.  It
  is not as useful as people often think it should be
  on normal filesystems.

* The removal of the unconditional TRIM significantly improves
  UFS performance, meaning primarily installkernel's
  since DragonFly doesn't use UFS for its main filesystem by
  default any more.

* The 'trim' mount option for UFS will still work as advertised
  when coupled with softupdates.

3 years agonmalloc - Try bigcache in posix_memalign() for big PAGE_SIZE aligned allocs.
Imre Vadász [Mon, 1 Oct 2018 19:14:01 +0000 (21:14 +0200)]
nmalloc - Try bigcache in posix_memalign() for big PAGE_SIZE aligned allocs.

* This improves performance (by reducing the amount of mmap() calls required
  and avoiding some amount of page faults) for applications which frequently
  call posix_memalign() with a 4096 byte alignment for allocations bigger
  than 8KB. Allocations of 8KB and smaller are efficiently handled by the
  SLAB allocator already.

3 years agonmalloc - Cache 4K and 8K allocations in posix_memalign()
Matthew Dillon [Mon, 1 Oct 2018 18:43:13 +0000 (11:43 -0700)]
nmalloc - Cache 4K and 8K allocations in posix_memalign()

* Adjust posix_memalign() to use the slab allocator for 4K and 8K
  allocations same as malloc() does, to improve performance for
  programs using posix_memalign().

3 years agopciconf - Enhance output
Matthew Dillon [Mon, 1 Oct 2018 18:40:23 +0000 (11:40 -0700)]
pciconf - Enhance output

* Add more registers defs from FreeBSD to pcireg.h

* Bring expanded pciconf code in form FreeBSD.  This code
  displays more configuration data for bridges and control
  registers, and fixes a broken bus error reporting conditional.

* Also normalize SLT -> SLOT naming in pcireg.h

3 years agoBump __DragonFly_version for adding wait6() and waitid()
Aaron LI [Mon, 1 Oct 2018 00:51:28 +0000 (08:51 +0800)]
Bump __DragonFly_version for adding wait6() and waitid()

3 years agosystem - Add wait6(), waitid(), and si_pid/si_uid siginfo support
Matthew Dillon [Sun, 30 Sep 2018 19:45:14 +0000 (12:45 -0700)]
system - Add wait6(), waitid(), and si_pid/si_uid siginfo support

* Add the wait6() system call (header definitions taken from FreeBSD).
  This required rearranging kern_wait() a bit.  In particular, we now
  maintain a hold count of 1 on the process during processing instead
  of releasing the hold count early.

* Add waitid() to libc (waitid.c taken from FreeBSD).

* Adjust manual pages (taken from FreeBSD).

* Add siginfo si_pid and si_uid support.  This basically allows a process
  taking a signal to determine where the signal came from.  The fields
  already existed in siginfo but were not implemented.

  Implemented using a non-queued per-process array of signal numbers.
  The last originator sending any given signal is recorded and passed
  through to userland in the siginfo.

* Fixes the 'lightdm' X display manager.  lightdm relies on si_pid
  support.  In addition, note that avoiding long lightdm related
  latencies and timeouts require a softlink from libmozjs-52.so to
  libmozjs-52.so.0 (must be addressed in dports, not addressed in this

Loosely-taken-from: FreeBSD (wait6, waitid support only)
Reviewed-by: swildner
3 years agokernel/virtio: Remove some last traces of virtio_if.m.
Sascha Wildner [Sun, 30 Sep 2018 14:59:53 +0000 (16:59 +0200)]
kernel/virtio: Remove some last traces of virtio_if.m.

It was removed in b817dce2e30a257b86b253a698e63a418758d76d.

3 years agokernel: Bring in a port of FreeBSD's virtio_random(4) driver.
Sascha Wildner [Sun, 30 Sep 2018 14:34:15 +0000 (16:34 +0200)]
kernel: Bring in a port of FreeBSD's virtio_random(4) driver.

Tested-by: Diederik de Groot <info@talon.nl>
3 years agolibstand/hammer1: One more -Wundef fix.
Sascha Wildner [Sat, 29 Sep 2018 21:55:11 +0000 (23:55 +0200)]
libstand/hammer1: One more -Wundef fix.

3 years agolibcrypt: Fix -Wundef (no functional change).
Sascha Wildner [Sat, 29 Sep 2018 21:11:49 +0000 (23:11 +0200)]
libcrypt: Fix -Wundef (no functional change).

3 years agodrm/radeon: drop btc_get_max_clock_from_voltage_dependency_table
François Tigeot [Sat, 29 Sep 2018 19:48:35 +0000 (21:48 +0200)]
drm/radeon: drop btc_get_max_clock_from_voltage_dependency_table

3 years agodrm/radeon/dpm: drop clk/voltage dependency filters for SI
François Tigeot [Sat, 29 Sep 2018 19:33:40 +0000 (21:33 +0200)]
drm/radeon/dpm: drop clk/voltage dependency filters for SI