dragonfly.git
5 years agolibedit: No need of the bundled fgetln, vis and wcsdup
Aaron LI [Mon, 11 Jun 2018 07:59:11 +0000 (15:59 +0800)]
libedit: No need of the bundled fgetln, vis and wcsdup

All these functions are provided in libc, so remove them from libedit
to avoid symbol conflict (e.g., crunching many tools).

Meanwhile, the libedit's config.h already have proper defines for the
above functions.

5 years agobsd-family-tree: Sync yet again with FreeBSD.
Sascha Wildner [Wed, 4 Jul 2018 08:21:55 +0000 (10:21 +0200)]
bsd-family-tree: Sync yet again with FreeBSD.

5 years agolibssh: No need of compat vis.c as we support VIS_ALL
Aaron LI [Mon, 11 Jun 2018 05:29:31 +0000 (13:29 +0800)]
libssh: No need of compat vis.c as we support VIS_ALL

This helps avoid the vis.o symbol conflicts between libc and libssh.

5 years agovis(1): Add option -a to use VIS_ALL
Aaron LI [Mon, 11 Jun 2018 04:47:36 +0000 (12:47 +0800)]
vis(1): Add option -a to use VIS_ALL

Taken-from: OpenBSD

5 years agovis(3): Add VIS_ALL support
Aaron LI [Mon, 11 Jun 2018 04:44:07 +0000 (12:44 +0800)]
vis(3): Add VIS_ALL support

OpenSSH requires VIS_ALL and therefore uses the version bundled with
itself, but this causes the vis.o symbol conflicts between libc and
libssh when crunching fstyp(8) with ssh(1).

Bump __DragonFly_version.

Based-on: OpenBSD

5 years agolib/libdmsg: Fix compile-time warning on Linux
Tomohiro Kusumi [Wed, 4 Jul 2018 04:39:34 +0000 (21:39 -0700)]
lib/libdmsg: Fix compile-time warning on Linux

warning: pointer targets in passing argument 2 of 'crypto_algos[0].init' differ in signedness
note: expected 'char *' but argument is of type 'uint8_t *'

5 years agoDo not auto build rescue tools when ${DESTDIR} != "/"
Aaron LI [Tue, 3 Jul 2018 12:15:17 +0000 (20:15 +0800)]
Do not auto build rescue tools when ${DESTDIR} != "/"

When installworld to an alternative root (i.e., ${DESTDIR} != "/"),
do not automatically build the rescue tools.

This change won't affect the nrelease build, since it will explicitly
do 'make initrd'.

Suggested-by: swildner
5 years agoobjcache: Fix comment indentation.
Sepherosa Ziehau [Tue, 3 Jul 2018 14:52:30 +0000 (22:52 +0800)]
objcache: Fix comment indentation.

5 years agoobjcache: Use __predict for predictable conditions.
Sepherosa Ziehau [Tue, 3 Jul 2018 14:46:22 +0000 (22:46 +0800)]
objcache: Use __predict for predictable conditions.

5 years ago<sys/gpt.h>: Fix a minor comment issue
Aaron LI [Tue, 3 Jul 2018 11:42:48 +0000 (19:42 +0800)]
<sys/gpt.h>: Fix a minor comment issue

5 years agoobjcache: Fix comment style
Sepherosa Ziehau [Mon, 2 Jul 2018 15:55:41 +0000 (23:55 +0800)]
objcache: Fix comment style

5 years agoobjcache: Constify object cache name.
Sepherosa Ziehau [Mon, 2 Jul 2018 15:05:07 +0000 (23:05 +0800)]
objcache: Constify object cache name.

5 years agoAdd the initrd.7 man page
Aaron LI [Sun, 1 Jul 2018 05:23:59 +0000 (13:23 +0800)]
Add the initrd.7 man page

This man page is partly based on the removed mkinitrd.8 man page
written by Alex Hornung.

Reviewed-by: Sascha Wildner
5 years agobuild.7: Fold CAVEATS into EXAMPLES. No need for an extra section.
Sascha Wildner [Mon, 2 Jul 2018 07:35:56 +0000 (09:35 +0200)]
build.7: Fold CAVEATS into EXAMPLES. No need for an extra section.

5 years agoMakefile.inc1: Remove the obsolete crunch from bootstrap tools
Aaron LI [Fri, 15 Jun 2018 04:41:43 +0000 (12:41 +0800)]
Makefile.inc1: Remove the obsolete crunch from bootstrap tools

Since rescue build is now detached from buildworld, so crunchgen(1)
and crunchide(1) are no longer needed by the buildworld.

5 years agovi(1): Do not build iconv(3) support for the rescue version
Aaron LI [Mon, 11 Jun 2018 04:35:33 +0000 (12:35 +0800)]
vi(1): Do not build iconv(3) support for the rescue version

The iconv(3) support requires dynamic library access, which is impossible for
the statically liked rescue version, so disable it.

Taken-from: FreeBSD

5 years agoinitrd: Fix parallel build
Aaron LI [Mon, 2 Jul 2018 01:30:20 +0000 (09:30 +0800)]
initrd: Fix parallel build

Add explicit target orders to oinit/Makefile, because such orders are
set in <bsd.subdir.mk> but not in <bsd.prog.mk>.

Since the make targets (e.g., depend, all, install, clean) are now
ordered, so remove 'clean cleandepend' from the same command as
'depend all install'.

Also allow defining the 'NO_CLEAN" variable to not clean previous builds.

5 years agomk/crunchgen: Fix parallel builds by ordering targets
Aaron LI [Mon, 2 Jul 2018 01:06:31 +0000 (09:06 +0800)]
mk/crunchgen: Fix parallel builds by ordering targets

Order the build targets (clean, cleandepend, cleandir, obj, objlink,
depend, all, install) to avoid the race in parallel building.  This
change is based on <bsd.subdir.mk>.  Meanwhile, add minor comments to
make the hierarchy clearer in <bsd.subdir.mk>.

Add the 'depend' target for the crunchdir's.

5 years agomk/crunchgen: Remove the unimplemented ${_+_}
Aaron LI [Mon, 2 Jul 2018 01:27:29 +0000 (09:27 +0800)]
mk/crunchgen: Remove the unimplemented ${_+_}

The ${_+_} make variable is introduced by FreeBSD in revision 133369,
but we don't implement it, so remove it.

5 years agoinitrd: Add -lpthread for hammer2
Aaron LI [Mon, 2 Jul 2018 02:01:19 +0000 (10:01 +0800)]
initrd: Add -lpthread for hammer2

The 'pthread' library was lost from commit
8692d13918892c3f474fc05d37f17fe125bb61bd when rebasing.

5 years agoinstall(1): Add a -N option, improving NetBSD and FreeBSD compatibility
François Tigeot [Sun, 1 Jul 2018 20:52:31 +0000 (22:52 +0200)]
install(1): Add a -N option, improving NetBSD and FreeBSD compatibility

* -N is the standard NetBSD and FreeBSD install(1) option to use
  alternative user and group databases

* DragonFly previously used -L to do the same thing. Keep this option
  but warn to use -N instead.

5 years agoinitrd: Better check the created initrd before installing
Aaron LI [Sat, 9 Jun 2018 15:47:31 +0000 (23:47 +0800)]
initrd: Better check the created initrd before installing

Improve mkinitrd.sh to check /sbin/oinit, /bin/sh and /etc/rc on the
created initrd image to avoid installing a broken one.

Update to use "install" to install the created initrd image to ensure
user/group of root/wheel and mode of 444.

(The command to remove the temporary initrd image was committed in a
previous patch due to squashing.)

5 years agoinitrd: Crunch lvm(8) with sbin.libcrypto
Aaron LI [Sat, 9 Jun 2018 15:39:49 +0000 (23:39 +0800)]
initrd: Crunch lvm(8) with sbin.libcrypto

Do not build lvm(8) alone since it can be crunched together with
sbin.libcrypto which contains cryptsetup(8).  This also saves about
400KB space.

Tidy up the sbin.libcrypto Makefile in the meantime.

5 years agolvm(8): Do not build readline support for the rescue version
Aaron LI [Sat, 9 Jun 2018 15:36:43 +0000 (23:36 +0800)]
lvm(8): Do not build readline support for the rescue version

Make use of the RESCUE make variable to not build the readline support
for its rescue version (to be installed at /rescue).

Clean up the Makefile.

5 years agocryptsetup(8): Tidy up Makefile
Aaron LI [Sat, 9 Jun 2018 15:35:32 +0000 (23:35 +0800)]
cryptsetup(8): Tidy up Makefile

5 years agomk/crunchgen: Remove the unused CRUNCH_BUILDTOOLS support/hack
Aaron LI [Sat, 9 Jun 2018 05:31:22 +0000 (13:31 +0800)]
mk/crunchgen: Remove the unused CRUNCH_BUILDTOOLS support/hack

The CRUNCH_BUILDTOOLS is commented out in initrd/bin/Makefile.
And we already use pregenerated headers for bin/sh in commit
cbb07feb2f78629297b21609f526fcec6e4ad8ee .

5 years agoinitrd: Tell make to use makefiles from the source tree
Aaron LI [Sat, 9 Jun 2018 12:06:05 +0000 (20:06 +0800)]
initrd: Tell make to use makefiles from the source tree

Otherwise, make uses makefiles from the system installed ones at
/usr/share/mk, therefore, the updated bsd.prog.mk has no effect until
being installed to the system.

Note that the variables assigned by make (i.e., make ... var=value)
will override the shell enviroment variables (e.g., var=value shell
command).  So make sure the make variable assignments (e.g., DESTDIR)
are put after the make.

Also fix mkinitrd.sh to remove the used temporary initrd image file.

5 years agomk/prog: Support CRUNCH_CFLAGS for crunchgen's buildopts
Aaron LI [Sat, 9 Jun 2018 11:22:14 +0000 (19:22 +0800)]
mk/prog: Support CRUNCH_CFLAGS for crunchgen's buildopts

Taken-from: FreeBSD

5 years agomk/crunchgen: Allow to use symlinks for crunched programs
Aaron LI [Sat, 9 Jun 2018 05:42:51 +0000 (13:42 +0800)]
mk/crunchgen: Allow to use symlinks for crunched programs

Add support to create symlinks (i.e., soft links) instead of hard links
for the crunched programs.

If the variable CRUNCH_USE_SYMLINKS is set (default: not set), then use
symlinks instead of hard links.

5 years agomk/crunchgen: Do not hard code the path to the source directories
Aaron LI [Sat, 9 Jun 2018 05:39:18 +0000 (13:39 +0800)]
mk/crunchgen: Do not hard code the path to the source directories

Introduce the variable CRUNCH_PATH_${D} to specify the path to the
base source directory ${D}.

Update the description and initrd makefiles accordingly.

5 years agoopenpam: Since there is no pam(8) manual page, refer to pam(3).
Sascha Wildner [Sat, 30 Jun 2018 18:15:41 +0000 (20:15 +0200)]
openpam: Since there is no pam(8) manual page, refer to pam(3).

5 years agoopenpam: Revert a useless local comment change for better merging.
Sascha Wildner [Sat, 30 Jun 2018 17:54:49 +0000 (19:54 +0200)]
openpam: Revert a useless local comment change for better merging.

5 years agovkernel - Do not re-initialize vcons
Antonio Huete Jimenez [Sat, 30 Jun 2018 19:36:53 +0000 (19:36 +0000)]
vkernel - Do not re-initialize vcons

- Commit fb3cf125d1 introduced a cninit() call in configure_final()
  and vcons should properly handle multiple initialization.
- This fixes the vkernel boot problem in current master.

5 years agocondvar.9: Add MLINKS for recently added functions.
Sascha Wildner [Sat, 30 Jun 2018 06:43:53 +0000 (08:43 +0200)]
condvar.9: Add MLINKS for recently added functions.

5 years agobsd-family-tree: Add dfly 5.2.2; fbsd 11.2
Eitan Adler [Fri, 29 Jun 2018 23:53:21 +0000 (23:53 +0000)]
bsd-family-tree: Add dfly 5.2.2; fbsd 11.2

5 years agosys/kern: Make condvar(9) support mutex(9)
Tomohiro Kusumi [Sat, 30 Jun 2018 00:19:39 +0000 (17:19 -0700)]
sys/kern: Make condvar(9) support mutex(9)

5 years agoSync ACPICA with Intel's version 20180629.
Sascha Wildner [Fri, 29 Jun 2018 21:23:50 +0000 (23:23 +0200)]
Sync ACPICA with Intel's version 20180629.

* Fix regressions in acpiexec(8) and iasl(8).

* Add a warning to iasl(8) on attempted use of Unload().

* Add some ASL extensions that make various arguments optional.

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

5 years agoRemove old mkinitrd config.
Sascha Wildner [Wed, 27 Jun 2018 12:19:28 +0000 (14:19 +0200)]
Remove old mkinitrd config.

5 years agoRemove the old 'most' and 'installmost' targets (they are broken too).
Sascha Wildner [Wed, 27 Jun 2018 09:16:52 +0000 (11:16 +0200)]
Remove the old 'most' and 'installmost' targets (they are broken too).

5 years agormuser(8): Use getopts for commandline options
Aaron LI [Wed, 27 Jun 2018 04:59:19 +0000 (12:59 +0800)]
rmuser(8): Use getopts for commandline options

Improve the option logic a bit and fix whitespaces.

5 years agoUpdate the pciconf(8) database.
Sascha Wildner [Tue, 26 Jun 2018 18:24:19 +0000 (20:24 +0200)]
Update the pciconf(8) database.

June 25, 2018 snapshot from https://pci-ids.ucw.cz

5 years agoMakefile_upgrade.inc: Sort initrd stuff a bit and add a forgotten file.
Sascha Wildner [Tue, 26 Jun 2018 18:22:36 +0000 (20:22 +0200)]
Makefile_upgrade.inc: Sort initrd stuff a bit and add a forgotten file.

5 years agoupdatedb(8): Be simple and search from "/" by default
Aaron LI [Tue, 26 Jun 2018 11:38:17 +0000 (19:38 +0800)]
updatedb(8): Be simple and search from "/" by default

This reverts the behavior change made in commit
6877ea2d2f7caf9b13202f2524abf3b3cf815b45.

That change causes HAMMER PFSes being ignored from indexing, because the
PFSes, which are null-mounted though, behave like different devices and
thus are ignored by "find -x" (the "-x" option prevents find entering
directories with a different device number).

Workaround or properly deal with the PFSes would be too complex, which I
don't think it's a good idea,  therefore revert to the original behavior.

If one person really wants to ignore the root filesystem but have other
directories indexed, he/she should know to configure the search paths.

Meanwhile, tweak comments and fix whitespaces.

5 years agolsvfs(1): Remove an unused define; Avoid a type cast
Aaron LI [Tue, 26 Jun 2018 01:56:36 +0000 (09:56 +0800)]
lsvfs(1): Remove an unused define; Avoid a type cast

5 years agomount(8): Use tab for indentation
Aaron LI [Tue, 26 Jun 2018 01:53:02 +0000 (09:53 +0800)]
mount(8): Use tab for indentation

5 years agodloader: Remove obsolete "linux_load" from config files
Aaron LI [Thu, 11 Jan 2018 11:47:40 +0000 (19:47 +0800)]
dloader: Remove obsolete "linux_load" from config files

Based on the patch submitted by mazocomp in bug #3115.

5 years agosys/vfs/autofs: Install vnops after root dir is initialized
Tomohiro Kusumi [Sun, 24 Jun 2018 12:27:01 +0000 (05:27 -0700)]
sys/vfs/autofs: Install vnops after root dir is initialized

5 years agosys/vfs/autofs: Don't dereference vnode pointer if allocation failed
Tomohiro Kusumi [Sun, 24 Jun 2018 12:52:26 +0000 (05:52 -0700)]
sys/vfs/autofs: Don't dereference vnode pointer if allocation failed

5 years agosys/vfs/autofs: Simplify vfs_root()
Tomohiro Kusumi [Sun, 24 Jun 2018 12:19:47 +0000 (05:19 -0700)]
sys/vfs/autofs: Simplify vfs_root()

The root dir is created on mount time, and must exist by the time
vfs_root() is called.

5 years agovarious: remove incorrect comments
Eitan Adler [Sun, 24 Jun 2018 07:58:54 +0000 (07:58 +0000)]
various: remove incorrect comments

These appear to have come from the initial import and never updated.

5 years agokernel: Remove various definitions related to unimplemented ioctls.
Sascha Wildner [Fri, 22 Jun 2018 06:19:13 +0000 (08:19 +0200)]
kernel: Remove various definitions related to unimplemented ioctls.

These are: DIOCSMBR, CONS_SSAVER, CONS_GSAVER, BT848GCLIP, METEORCAPFRM,
           METEORGETGEO, METEORSCHCV, METEORGCHCV, METEORSBT254,
           METEORGBT254, METEORSHWS, METEORGHWS, METEORSVWS, METEORGVWS,
           METEORSTS, METEORGTS

Thanks to zrj for testing with a dports bulk.

While here, clean up <sys/diskmbr.h> a bit:

* Use standard types.

* Add a CTASSERT() defintion.

5 years agokernel: Remove the definition of the unimplemented FD_DEBUG ioctl.
Sascha Wildner [Thu, 21 Jun 2018 12:18:07 +0000 (14:18 +0200)]
kernel: Remove the definition of the unimplemented FD_DEBUG ioctl.

Remove fdcontrol(8)'s bogus -d option. Also remove -s because it is now
the only option and also default.

Finally, do some style(9) cleanups in fdcontrol(8).

Thanks to zrj for testing with a dports bulk.

5 years agokernel: Remove some old 4.3BSD era ioctls.
Sascha Wildner [Wed, 20 Jun 2018 17:13:48 +0000 (19:13 +0200)]
kernel: Remove some old 4.3BSD era ioctls.

Not all of them were implemented even.

Bump __DragonFly_version, just in case.

Thanks to zrj for testing with a dports bulk.

5 years agohammer2 - Check duplicate H2 partitions during hammer2 cleanup
Matthew Dillon [Wed, 20 Jun 2018 06:33:28 +0000 (23:33 -0700)]
hammer2 - Check duplicate H2 partitions during hammer2 cleanup

* hammer2 cleanup operates on the partition the mount resides on,
  so if multiple hammer2 snapshots from the same partition are mounted
  we do not need to run it for each mount.

5 years agodrm/i915: Add a module_init() directive
François Tigeot [Tue, 19 Jun 2018 21:13:09 +0000 (23:13 +0200)]
drm/i915: Add a module_init() directive

5 years agodiffutils: Update README.DELETED.
Sascha Wildner [Tue, 19 Jun 2018 19:25:39 +0000 (21:25 +0200)]
diffutils: Update README.DELETED.

5 years agoMerge branch 'vendor/DIFFUTILS'
Sascha Wildner [Tue, 19 Jun 2018 19:24:53 +0000 (21:24 +0200)]
Merge branch 'vendor/DIFFUTILS'

5 years agodiffutils: Remove some unneeded files from the vendor branch.
Sascha Wildner [Tue, 19 Jun 2018 19:21:34 +0000 (21:21 +0200)]
diffutils: Remove some unneeded files from the vendor branch.

5 years agodiffutils: Reconfigure and revert some obsolete local changes.
Sascha Wildner [Tue, 19 Jun 2018 18:49:12 +0000 (20:49 +0200)]
diffutils: Reconfigure and revert some obsolete local changes.

Our wcwidth() is by now capable of handling UTF-8 so revert the
changes from d76863bd1dbf9c1e4c04a977e3a7271a23cdb718.

While here, remove two more files from libdiffutils' Makefile.

5 years agox86_64: Eanble X2APIC if it is available.
Sepherosa Ziehau [Tue, 19 Jun 2018 13:16:20 +0000 (21:16 +0800)]
x86_64: Eanble X2APIC if it is available.

5 years agoliby: build with WARNS=6; style
Eitan Adler [Sun, 17 Jun 2018 18:44:07 +0000 (18:44 +0000)]
liby: build with WARNS=6; style

- add header rather than include local details
- add const
- remove extraneous void cast

- See discussion on FreeBSD r335270 for motivation for copyright
details.

5 years agodrm/i915: iic(4) is not used anymore
François Tigeot [Sun, 17 Jun 2018 19:29:59 +0000 (21:29 +0200)]
drm/i915: iic(4) is not used anymore

5 years agosbin/newfs_hammer2: Explicitly include <sys/ioctl.h>
Tomohiro Kusumi [Sat, 16 Jun 2018 15:40:14 +0000 (08:40 -0700)]
sbin/newfs_hammer2: Explicitly include <sys/ioctl.h>

generally helps become more portable on Linux and other platforms.

5 years agosbin/hammer: Explicitly include <sys/ioctl.h>
Tomohiro Kusumi [Sat, 16 Jun 2018 15:39:48 +0000 (08:39 -0700)]
sbin/hammer: Explicitly include <sys/ioctl.h>

generally helps become more portable on Linux and other platforms.

5 years agousr.bin/undo: Explicitly include <sys/ioctl.h>
Tomohiro Kusumi [Sat, 16 Jun 2018 15:37:26 +0000 (08:37 -0700)]
usr.bin/undo: Explicitly include <sys/ioctl.h>

generally helps become more portable on Linux and other platforms.

5 years agoKernel - Fix getvfsstat()/getfsstat() count w/ NULL buffer
Matthew Dillon [Fri, 15 Jun 2018 19:33:03 +0000 (12:33 -0700)]
Kernel - Fix getvfsstat()/getfsstat() count w/ NULL buffer

* Return the correct count when a NULL buffer is passed in,
  instead of a higher count.

Reported-by: tdfbsd
5 years agoinitrd - Add hammer2, fix obj dir
Matthew Dillon [Fri, 15 Jun 2018 17:24:40 +0000 (10:24 -0700)]
initrd - Add hammer2, fix obj dir

* Include the hammer2 binary in the initrd image.

* Properly make the obj hierarchy so make initrd does not
  put temporary object files in /usr/src.

5 years agoKernel - Enable NX for PROT_READ by default
Matthew Dillon [Tue, 12 Jun 2018 17:18:41 +0000 (10:18 -0700)]
Kernel - Enable NX for PROT_READ by default

* We've had NX support for a while, requiring a loader.conf tunable to
  enable (machdep.pmap_nx_enable).

* Enhance the feature to support two modes.  Mode 1 allows NX support
  for PROT_READ mappings, Mode 2 allows NX support for both PROT_READ
  and PROT_WRITE mappings.

  Third party code should work universally with Mode 1, but apparently
  quite a bit still does not work with mode 2.

* Change the default from disabled to Mode 1 in master, lets see if
  anyone has any problems with it.

Suggested-by: Theo de Raadt
5 years agosys/vfs/autofs: Change autofs_softc::sc_lock to use mutex(9)
Tomohiro Kusumi [Tue, 12 Jun 2018 12:25:56 +0000 (05:25 -0700)]
sys/vfs/autofs: Change autofs_softc::sc_lock to use mutex(9)

5 years agokernel/radeon: Check the right variable in an if ().
Sascha Wildner [Tue, 12 Jun 2018 07:11:16 +0000 (09:11 +0200)]
kernel/radeon: Check the right variable in an if ().

This is Linux' 3a61b527b4e1f285d21b6e9e623dc45cf8bb391f.

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3102>

5 years agokernel/bktr: Fix variable types.
Sascha Wildner [Tue, 12 Jun 2018 07:04:36 +0000 (09:04 +0200)]
kernel/bktr: Fix variable types.

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3103>
Taken-from:    FreeBSD (r249798)

5 years agoKernel - Additional cpu bug hardening part 2/2
Matthew Dillon [Mon, 11 Jun 2018 21:30:40 +0000 (14:30 -0700)]
Kernel - Additional cpu bug hardening part 2/2

* Due to speculative instruction execution, the kernel may
  speculatively execute instructions using data from registers that
  still contain userland-controlled content.

  Reduce the chance of this situation arising by proactively clearing
  all user registers after saving them for syscalls, exceptions, and
  interrupts.  In addition, for system calls, zero-out any
  unrestored registers on-return to avoid leaking kernel data back to
  userland.

* This was discussed over the last few months in various
  OS groups and I've decided to implement it.  After the FP
  debacle, it is prudent to also give general registers similar
  protections.

5 years agoKernel - Additional cpu bug hardening part 1/2
Matthew Dillon [Mon, 11 Jun 2018 20:43:22 +0000 (13:43 -0700)]
Kernel - Additional cpu bug hardening part 1/2

* OpenBSD recently made a commit that scraps the use of delayed FP
  state saving due to a rumor that the content of FP registers owned
  by another process can be speculatively detected when they are
  present for the current process, even when the TS bit is used to
  force a DNA trap.

  This rumor has been circulating for a while.  OpenBSD felt that the
  lack of responsiveness from Intel forced their hand.  Since they've
  gone ahead and pushed a fix for this potential problem, we are
  going to as well.

* DragonFlyBSD already synchronously saves FP state on switch-out.
  However, it only cleans the state up afterwords by calling fninit
  and this isn't enough to actually erase the content in the %xmm
  registers.  We want to continue to use delayed FP state restores
  because it saves a considerable amount of switching time when we do
  not have to do a FP restore.

  Most programs touch the FP registers at startup due to rtld linking,
  and more and more programs use the %xmm registers as general purpose
  registers.  OpenBSD's solution of always proactively saving and
  restoring FP state is a reasonable one.  DragonFlyBSD is going to
  take a slightly different tact in order to try to retain more optimal
  switching behavior when the FP unit is not in continuous use.

* Our first fix is to issue a FP restore on dummy state after our
  FP save to guarantee that all FP registers are zerod after FP state
  is saved.  This allows us to continue to support delayed FP state
  loads with zero chance of leakage between processes.

* Our second fix is to add a heuristic which allows the kernel to
  detect when the FP unit is being used seriously (verses just during
  program startup).

  We have added a sysctl machdep.npx_fpu_heuristic heuristic for this
  purpose which defaults to the value 32.  Values can be:

  0 - Proactive FPU state loading disabled (old behavior retained).
  Note that the first fix remains active, the FP register state
  is still cleared after saving so no leakage can occur.  All
  processes will take a DNA trap after a thread switch when they
  access the FP state.

  1 - Proactive FPU state loading is enabled at all times for a thread
  after the first FP access made by that thread.  Upon returning
  from a thread switch, the FPU state will already be ready to go
  and a DNA trap will not occur.

  N - Proactive FPU state loading enabled for N context switches, then
  disabled.  The next DNA fault after disablement then re-enables
  proactive loading for the next N context switches.

  Default value is 32.  This ensures that program startup can use
  the FP unit but integer-centric programs which don't afterwords
  will not incur the FP switching overhead (for either switch-away
  or switch-back).

5 years agokernel - Improve ACPI compatibility with older BIOSes
Matthew Dillon [Mon, 11 Jun 2018 20:21:53 +0000 (13:21 -0700)]
kernel - Improve ACPI compatibility with older BIOSes

* ACPI alignment field in ACPI resources can sometimes be 0, leading
  to passing 0 for 'align' to acpi_res_set_iorange() which panics the
  box with a division-by-zero fault.

* Relax handling of this argument by setting it to 1 if it is found
  to be 0.

* Fixes DFly panics with certain older BIOSes.

Reported-by: myu
5 years agosys/vfs/autofs: Add Copyright
Tomohiro Kusumi [Mon, 11 Jun 2018 15:47:27 +0000 (08:47 -0700)]
sys/vfs/autofs: Add Copyright

5 years agosys/vfs/autofs: #if0 unsupported vfs.autofs.mount_on_stat
Tomohiro Kusumi [Mon, 11 Jun 2018 15:47:08 +0000 (08:47 -0700)]
sys/vfs/autofs: #if0 unsupported vfs.autofs.mount_on_stat

Keep the code since this should be implemented.

5 years agobge.4: Fix a typo.
Sascha Wildner [Sun, 10 Jun 2018 19:31:17 +0000 (21:31 +0200)]
bge.4: Fix a typo.

5 years agosys/vfs/autofs: Add VFCF_MPSAFE
Tomohiro Kusumi [Sun, 10 Jun 2018 18:46:33 +0000 (11:46 -0700)]
sys/vfs/autofs: Add VFCF_MPSAFE

5 years agosys/vfs/autofs: Drop VFCF_NETWORK
Tomohiro Kusumi [Sun, 10 Jun 2018 18:41:59 +0000 (11:41 -0700)]
sys/vfs/autofs: Drop VFCF_NETWORK

VFCF_NETWORK came from FreeBSD implementation, but autofs really has
nothing to do with network.

5 years agosys/vfs/autofs: Drop unneeded bzero on node/request ctor
Tomohiro Kusumi [Sun, 10 Jun 2018 16:57:05 +0000 (09:57 -0700)]
sys/vfs/autofs: Drop unneeded bzero on node/request ctor

5 years agomount_msdos.8: Fix typo
Sascha Wildner [Sun, 10 Jun 2018 14:52:39 +0000 (16:52 +0200)]
mount_msdos.8: Fix typo

5 years agodrm: Define struct page and use it everywhere
François Tigeot [Sat, 9 Jun 2018 16:18:33 +0000 (18:18 +0200)]
drm: Define struct page and use it everywhere

* Removing countless differences with Linux

* struct page is essentially struct vm_page named differently.
  Both can be casted to the other one without further thought.

5 years agore: MACFG50 requires defragmentation in software, but no padding for runt.
Sepherosa Ziehau [Sat, 9 Jun 2018 11:45:55 +0000 (19:45 +0800)]
re: MACFG50 requires defragmentation in software, but no padding for runt.

Reported-by: YONETANI Tomokazu
Tested-by: YONETANI Tomokazu
5 years agoinitrd: don't leave an empty /rescue after switching location
Aaron LI [Sat, 9 Jun 2018 08:45:48 +0000 (16:45 +0800)]
initrd: don't leave an empty /rescue after switching location

The recent initrd change will remove the rescue tools from their old
location (/usr/share/initrd) but leave an empty /rescue directory.  Avoid
such a situation by building the rescue tools after installworld if /rescue
is empty.

Suggested-by: François Tigeot
5 years agolibc/xdr: Add xdr_uint16_t() (it's just like xdr_u_int16_t()).
Sascha Wildner [Sat, 9 Jun 2018 08:13:36 +0000 (10:13 +0200)]
libc/xdr: Add xdr_uint16_t() (it's just like xdr_u_int16_t()).

dports might make use of it.

While here, improve the manual page a bit and also bring in some fixes
from FreeBSD.

5 years agolibc/xdr: Use standard types.
Sascha Wildner [Sat, 9 Jun 2018 07:45:26 +0000 (09:45 +0200)]
libc/xdr: Use standard types.

5 years agorcs: Clean up the Makefiles.
Sascha Wildner [Fri, 8 Jun 2018 21:40:18 +0000 (23:40 +0200)]
rcs: Clean up the Makefiles.

* Close the Makefile.inc chain to gnu/usr.bin/Makefile.inc.

* Use the SCRIPTS variable instead of using afterinstall.

5 years agox86_64: Implement x2apic support.
Sepherosa Ziehau [Tue, 5 Jun 2018 15:03:46 +0000 (23:03 +0800)]
x86_64: Implement x2apic support.

Now LAPIC registers are accessed through MSR at fixed location, instead
of going through MMIO region.

Most noticeable is that ICR operation is greatly simplified, i.e. IPI
sending operation:
- Reserved bits are read as 0; there is no need to read ICR first for
  OR with the new values.
- No more pending bit, i.e. ICR write is synchronized; there is no need
  to read ICR to test pending bit.
- ICR is 64 bits in x2apic mode, i.e. two 32 bits writes to ICR-low and
  ICR-high become one write to ICR.

NOTE:
Though Intel SDM says that wrmsr to LAPIC registers are relaxed, we
don't need to put mfence or sfence before them, especially for sending
IPIs, since the generic IPIQ and the machdep code already uses atomic
operation before doing ICR operation.  For the rest of the code, there
really are no needs to add mfence/sfence before rdmsr/wrmsr to LAPIC
registers.

As of this commit, x2apic mode is _not_ enabled by default.  It can be
enabled through hw.x2apic_enable tuneable, and a read-only sysctl node
with the same name is available for debugging purpose.

Based on work by ivadasz@.

5 years agonrelease/Makefile: Fix to use GITURL_{SRC,DPORTS} and update help
Aaron LI [Fri, 8 Jun 2018 07:58:47 +0000 (15:58 +0800)]
nrelease/Makefile: Fix to use GITURL_{SRC,DPORTS} and update help

The GITHOST and GITHOST_DPORTS were updated to be GITURL_SRC and GITURL_DPORTS
in ad8b70e08d7600e3f4eb3b36556d4540b1a9c119.

5 years agoinitrd: Detach from the world and build on the fly
Aaron LI [Sat, 2 Jun 2018 05:31:45 +0000 (13:31 +0800)]
initrd: Detach from the world and build on the fly

Why
---
Currently, the files for initrd image creation are built and installed at
/usr/share/initrd by "buildworld" and "installworld", respectively, and then
mkinitrd(8) simply packs them to create the initrd.img.gz.

For normal users, the shipped /usr/share/initrd and mkinitrd(8) don't make
much sense, since they don't need to modify the initrd contents and create
a modified initrd image.

From a developer's perspective, the required steps (buildworld, installworld
and mkinitrd) to create and test a new initrd image can be annoying.

How
---
Detach the build and installation of the initrd contents from the world.
Build the (rescue/initrd) tools on-the-fly when creating the initrd image.

As per ftigeot's suggestion, these statically linked tools can be useful when
dealing with a broken system, so install them under /rescue to be more
intuitive and easier to use (similar to FreeBSD and maybe other BSDs).

What
----
* Move "share/initrd" to be top-level, and detach it from world.

  + Update the patch in bsd.crunchgen.mk accordingly.
  + Add Makefile.inc to simplify subdir's makefiles.
  + Rewrite the Makefile with targets:
    - rescue: build and install the rescue tools into /rescue.
    - initrd: further packs the etc and rescue staffs to create the initrd
              image.

* Move "sbin/mkinitrd/mkinitrd.sh" under the new "initrd" directory and adapt
  it to work with the "initrd" make target.  Remove the other parts of
  mkinitrd(8).

* Export the above "rescue" and "initrd" targets to be top-level.

* Update nrelease framework to use the new "make initrd".

* Update build.7 man page accordingly.

* Print the message about updating the initrd image and 3rd-party packages
  after "make upgrade" instead of "make installworld".

* Document this change in UPDATING.

* Other small updates and style cleanups.

TODO
----
* Add initrd.7 man page
* Crunch more useful tools
* Crunch bin/sbin/etc. into a bundle to save space (??)

Reviewed-by: swildner
Thanks-to: dillon, swildner, ftigeot

5 years agoMakefile{,.inc1}: Merge user-driven target descriptions and cleanups
Aaron LI [Sat, 2 Jun 2018 05:09:19 +0000 (13:09 +0800)]
Makefile{,.inc1}: Merge user-driven target descriptions and cleanups

* Merge the descriptions to user-driven targets from Makefile.inc1 to
  Makefile and improve the wordings a bit.

* Delete some obsolete information.

* Whitespace cleanups.

5 years agomkinitrd(8): Use getopts instead of getopt(1) for command options
Aaron LI [Fri, 1 Jun 2018 07:48:13 +0000 (15:48 +0800)]
mkinitrd(8): Use getopts instead of getopt(1) for command options

Use the shell built-in getopts to deal with command line options, which is
more easier to use and allows whitespace in the option values.

5 years agoinitrd: Clean up the real root mount code
Aaron LI [Fri, 1 Jun 2018 07:25:40 +0000 (15:25 +0800)]
initrd: Clean up the real root mount code

Make the real root mount code/scripts much simpler.  Also use the newly
exported NEW_ROOT variable to be more maintainable.

5 years agoinitrd/rc: mount initrd ro; set PATH, HOME, NEW_ROOT; cleanups
Aaron LI [Fri, 1 Jun 2018 07:14:27 +0000 (15:14 +0800)]
initrd/rc: mount initrd ro; set PATH, HOME, NEW_ROOT; cleanups

* The initrd is mounted readonly by default, do not upgrade to be readwrite.

  NOTE: This may cause problem with diskless boot (/etc/rc.d/diskless) and
  needs further tests and tunes (Thanks to ftigeot).

* Set PATH=/bin:/sbin to simplify the command invocations.

* Set HOME=/var/home (Suggested-by: ftigeot)

* Set NEW_ROOT=/new_root that will be used in the mount scripts.

  Make sure that the NEW_ROOT directory exist, otherwise try to remount the
  initrd / readwrite and create it.

* Various cleanups to make it much simpler and cleaner.

* Also clean up the rc.lvm2 a bit.

5 years agoinitrd: symlink tmp to var/tmp to save a second tmpfs mount
Aaron LI [Fri, 1 Jun 2018 06:57:37 +0000 (14:57 +0800)]
initrd: symlink tmp to var/tmp to save a second tmpfs mount

Since a tmpfs is required to mount at /var in the initrd, symlink /tmp to
/var/tmp to save a second tmpfs mount.

Add /mnt to the initrd hierarchy, which may be used by the user to manually
mount filesystems.  (Suggested-by: zrj)

5 years agoinitrd: Make etc/motd more informative
Aaron LI [Fri, 1 Jun 2018 06:08:57 +0000 (14:08 +0800)]
initrd: Make etc/motd more informative

Provide more information about the rescue shell environment, such as how to
mount the real root partition and continue, the mined editor, and more on
network connections.

5 years agomk/crunchgen: Fix the ${MAKE} quotation and improve style
Aaron LI [Fri, 1 Jun 2018 05:06:22 +0000 (13:06 +0800)]
mk/crunchgen: Fix the ${MAKE} quotation and improve style

The fix to the ${MAKE} quotation is brought from FreeBSD.

Various style fixes to make this makefile look much cleaner.

5 years agoperiodic: return $rc instead of "$rc" for several scripts
Aaron LI [Fri, 1 Jun 2018 04:56:05 +0000 (12:56 +0800)]
periodic: return $rc instead of "$rc" for several scripts

Also fix a minor whitespace issue in 200.chkmounts .

5 years agoetc/crontab: Do not set HOME; remove /etc from PATH
Aaron LI [Fri, 1 Jun 2018 04:49:41 +0000 (12:49 +0800)]
etc/crontab: Do not set HOME; remove /etc from PATH

Do not set the HOME environment variable (checked with FreeBSD).

Remove "/etc" from PATH (checked with OpenBSD).

5 years agoREADME: Update descriptions to sys/config files
Aaron LI [Fri, 1 Jun 2018 04:47:58 +0000 (12:47 +0800)]
README: Update descriptions to sys/config files