dragonfly.git
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

5 years agoREADME: Remove the secure entry; add the doc entry.
Aaron LI [Fri, 1 Jun 2018 04:46:21 +0000 (12:46 +0800)]
README: Remove the secure entry; add the doc entry.

Those contents resided under secure were merged into crypto some time ago.

5 years agoetc/Makefile: Do not install rc.firewall as executable
Aaron LI [Fri, 1 Jun 2018 04:19:07 +0000 (12:19 +0800)]
etc/Makefile: Do not install rc.firewall as executable

/etc/rc.firewall doesn't need to be installed as executable, similar to
/etc/rc.firewall6 .

5 years agohammer2: do not print error=0x0000 on bulkfree
Aaron LI [Fri, 1 Jun 2018 04:09:59 +0000 (12:09 +0800)]
hammer2: do not print error=0x0000 on bulkfree

Make hammer2 bulkfree do not print "error=0x0000" (i.e., no error occurred).
This makes the system log messages (/var/log/messages) a bit cleaner.

Fix minor whitespace issues as well.

5 years agodrm: rman_get_start() returns u_longs, not ints
François Tigeot [Wed, 6 Jun 2018 20:37:43 +0000 (22:37 +0200)]
drm: rman_get_start() returns u_longs, not ints

This had not been correctly handled in 183e2373896e4ea605435a6bd8f943e8273bf8cd

5 years agocpdup - Fix NULL pointer indirection on lost socket
Matthew Dillon [Wed, 6 Jun 2018 15:34:43 +0000 (08:34 -0700)]
cpdup - Fix NULL pointer indirection on lost socket

* Fix a crash which can occur due to a lost socket.  Generate a
  nice error message and exit() instead.

5 years agokernel - Fix umtx (pthread_mutex etc) race in kernel
Matthew Dillon [Wed, 6 Jun 2018 15:29:37 +0000 (08:29 -0700)]
kernel - Fix umtx (pthread_mutex etc) race in kernel

* The umtx code could still race a fork despite the wakeup
  due to certain access paths leading into umtx_sleep() only
  issuing reads, thus not triggering a COW operation post-fork.
  This results in a loss of the interlock.

* Fix the issue by having umtx_sleep() fetch the user data
  with a read-modify-write instead of a read.  It now essentially
  does a lock xadd, adding $0 to the memory to force a write
  fault if necessary.

* Fixes 'go' tests and probably other situations that can arise
  when heavily threaded programs use fork/exec.

Reported-by: Tim Darby (+testing)
5 years agokernel - Add fuwordadd32(), fuwordadd64()
Matthew Dillon [Wed, 6 Jun 2018 15:28:49 +0000 (08:28 -0700)]
kernel - Add fuwordadd32(), fuwordadd64()

* Add locked-bus-cycle fetchadd equivalents for kernel access to
  userland.  Will be used by kern_umtx.c

5 years agox86_64: Prepare for x2apic support.
Sepherosa Ziehau [Sun, 3 Jun 2018 10:15:52 +0000 (18:15 +0800)]
x86_64: Prepare for x2apic support.

- Use macro to access and modify LAPIC registers.
- Use function pointers for hot LAPIC operation, i.e. IPI and timer.
- Refactor the related code a bit.

Global variable 'lapic' is renamed to 'lapic_mem' to ease code search.

Based on work by ivadasz@.

5 years agomtree: Remove a no longer used directory.
Sascha Wildner [Tue, 5 Jun 2018 07:25:23 +0000 (09:25 +0200)]
mtree: Remove a no longer used directory.

5 years agoResolve some kernel option / .Cd mismatches.
Sascha Wildner [Mon, 4 Jun 2018 07:27:42 +0000 (09:27 +0200)]
Resolve some kernel option / .Cd mismatches.

* There is no WATCHDOG option. kern_wdog.c is compiled into the kernel
  by default.

* SC_NO_PALETTE_LOADING was never a kernel option, so remove the
  associated #ifndefs.

* powernow(4) can't be compiled into the kernel

5 years agoinit/oinit: Remove some old, unused/obsolete paths and comments.
Sascha Wildner [Sun, 3 Jun 2018 10:26:44 +0000 (12:26 +0200)]
init/oinit: Remove some old, unused/obsolete paths and comments.

Seems the _PATH_SLOGGER was defined but not used since at least 4.4BSD.

Reported-by: aly
5 years agoacpica: Allow designated initialization by defining ACPI_STRUCT_INIT().
Sascha Wildner [Sat, 2 Jun 2018 20:05:10 +0000 (22:05 +0200)]
acpica: Allow designated initialization by defining ACPI_STRUCT_INIT().

To make it compile, bring in a small fix from ACPICA's master that
adjusts a number of names from Linux style to ACPICA style.

5 years agoSync ACPICA with Intel's version 20180531.
Sascha Wildner [Sat, 2 Jun 2018 19:12:38 +0000 (21:12 +0200)]
Sync ACPICA with Intel's version 20180531.

* Implemented additional support to help ensure that a DSDT or SSDT is
  fully loaded even if errors are incurred during the load.

* The 'Unload' AML operator is no longer supported.

* Additional improvements and fixes.

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

5 years agoRemove some old, now obsolete, examples.
Sascha Wildner [Fri, 1 Jun 2018 10:04:25 +0000 (12:04 +0200)]
Remove some old, now obsolete, examples.

5 years agosh(1): Exclude a file that is only needed for debugging.
Sascha Wildner [Wed, 30 May 2018 19:09:33 +0000 (21:09 +0200)]
sh(1): Exclude a file that is only needed for debugging.

Reported-by: zrj
5 years agoieee80211_crypto.9: Ouch, removed too much in a42bad2dd166ad.
Sascha Wildner [Wed, 30 May 2018 13:49:59 +0000 (15:49 +0200)]
ieee80211_crypto.9: Ouch, removed too much in a42bad2dd166ad.

5 years agoFix some it's -> its typos in our manual pages.
Sascha Wildner [Wed, 30 May 2018 13:46:02 +0000 (15:46 +0200)]
Fix some it's -> its typos in our manual pages.

Also some minor fixes in rc.conf.5.

5 years agoDefine ioctl names that are used in *_ioctl(), not alternative spellings.
Sascha Wildner [Wed, 30 May 2018 05:50:41 +0000 (07:50 +0200)]
Define ioctl names that are used in *_ioctl(), not alternative spellings.

This makes searching unimplemented ioctls easier.

While here, fix cdcontrol(8) to use the "main" ioctl name.

5 years agoacpi: Use X2APIC entries, if there are only X2APIC entries in MADT.
Sepherosa Ziehau [Tue, 29 May 2018 13:42:15 +0000 (21:42 +0800)]
acpi: Use X2APIC entries, if there are only X2APIC entries in MADT.

5 years agokernel: Add simpler make depend variant for kernel.
zrj [Mon, 28 May 2018 15:07:31 +0000 (18:07 +0300)]
kernel: Add simpler make depend variant for kernel.

For now only for make {build,native}kernel -DNO_MODULES. The modules part
is more involved and will follow next.

Idea is to avoid a seprate mkdep(1) run before the actual compilation by
simply writing out separate dependency files while compiling in one go.
This variant reuses depenency information from last compilation, while
mkdep(1) variant reconstructs the dep chains on the current tree.
Depending if headers where removed or added both variants can miss out.

Due to several constraints (checks in makefiles if .depend file already
exists and implicit handling of device firmware stub files) try to mimic
previous behaviour by reconstructing depend on next quickkernel.
Later on we could remove anchoring on hack.So, creation of .depend file
and include all foo.d dependency files directly using bmake's .dinclude
directive that acts on stale dependencies as .MAKE.DEPENDFILE .depend.
Also turns out mkdep(1) was not tracking deps for ${MFILES:S/.m$/.c/}},
this simpler variant catches them and only vmx_genassym.d is not hooked
in .depend (coming from sys/platform/pc64/conf/files).
Shaves ~30s for make -jN nativekernel -DNO_MODULES.

5 years agokernel/hpt*: Mangle names of foreign binary objects.
zrj [Mon, 28 May 2018 14:51:38 +0000 (17:51 +0300)]
kernel/hpt*: Mangle names of foreign binary objects.

We already do it for the firmware objects (.fwo). Explictly handle
unpacked precompiled objects to separate them from other generic ones.
These are not device firmware and they do run on CPU, also they have
different osabi tag, so without adjustment the ld.gold (default ld)
will change osabi for the whole linked object.
Having them seprated from the rest simplifies the depend logic, such
objects have no source or headers dependencies other than hardcoded
one in Makefiles. Add missing dependencies on .uu in kernel modules.

5 years agobuild: Remove use of unsupported flag.
zrj [Mon, 28 May 2018 14:34:59 +0000 (17:34 +0300)]
build: Remove use of unsupported flag.

It looks like a inherited feature that was used in patched GCC.

5 years agokernel: Normalize conf/files rules.
zrj [Mon, 28 May 2018 14:24:32 +0000 (17:24 +0300)]
kernel: Normalize conf/files rules.

Prefer to use config(8) variables to reduce duplication
In the recipies for atomic.c we override global -fno-frame-pointer only
if not profiling (at the moment unusable .mcount), add missing ${WERROR}.
For vkernel64/mp.c just swap additions for consistency.

We could merge the ${WERROR} directly into ${NORMAL_C} later on.

5 years agokernel - Add support for MosChip PCIe serial com, and console support (2)
Matthew Dillon [Tue, 29 May 2018 03:10:01 +0000 (20:10 -0700)]
kernel - Add support for MosChip PCIe serial com, and console support (2)

* Fix oops in last commit.

5 years agokernel - Add support for MosChip PCIe serial com, and console support
Matthew Dillon [Tue, 29 May 2018 02:58:03 +0000 (19:58 -0700)]
kernel - Add support for MosChip PCIe serial com, and console support

* Add support for the MosChip PCIe serial com (brand is typically
  'StarTech' 'Natikve PCI Express RS232 serial adapter card with
  16550 UART'.

* Add late console support.  Console operation works the same
  way, set it up in /boot/loader.conf.  Typically:

  sio0.flags=0x00
  sio4.flags=0x30
  sio4.baud=115200
  #set boot_serial="YES" <-- commented out, do not set this

  Note that at the point a late-configured serial port
  wants to become the console, syscons is probably already
  the console, so you have to use flags 0x30 instead of
  0x10 to force it to change the console.

* Note, you do not have to set boot_serial="YES", because it
  won't really help since the adapter isn't accessible to the
  boot loader or to the kernel until the PCIe device probes
  in the middle of the boot sequence.

* The kernel now retests for consoles at the end of its normal
  configuration sequence, which allows the now-available
  sioN devices from PCIe card(s) to become the console.

* Remove syscons sccnterm() code that tried to undo the syscons
  console designation.  This code was never called in the past
  because the system console couldn't actually change once
  selected.  But now it can, and the code completely blows up
  syscons for numerous reasons.  Just leave the console
  designation intact from syscons's point of view (the main
  system will be vectored elsewhere so syscons will simply
  not receive new kernel console reads and writes).

* Add a siocntxwait() call before changing com parameters,
  since we are potentially changing the baud rate here.

* Change how the SIO driver assigns baud rates for the console
  to handle late-console configurations.  Also, allow sio*.baud
  variables in loader.conf to override the default com rate.

* Add entries for com5 and com6 to /etc/remote, and default to
  a more reasonable baud rate of 115200.

5 years agoFix missing make depend for quickkernel.
zrj [Mon, 28 May 2018 05:41:08 +0000 (08:41 +0300)]
Fix missing make depend for quickkernel.

Only realquickkernel should skip it.

5 years agokernel - Fix rare pmap_scan_callback() panic
Matthew Dillon [Sun, 27 May 2018 15:45:28 +0000 (08:45 -0700)]
kernel - Fix rare pmap_scan_callback() panic

* Fix a panic where pmap_scan_callback() can sometimes call
  pv_put() with a NULL pd_pv.

5 years agohammer2 - Fix missing initialization (fix broken root mount)
Matthew Dillon [Sun, 27 May 2018 15:31:06 +0000 (08:31 -0700)]
hammer2 - Fix missing initialization (fix broken root mount)

* For hammer2 root mounts a missing initialization resulted in
  a garbage test, causing root mounts to fail under some
  circumstances.

* Properly initialize the 'done' variable.

5 years agohammer2 - Be a be more verbose in the mount and getroot path
Matthew Dillon [Sun, 27 May 2018 15:26:21 +0000 (08:26 -0700)]
hammer2 - Be a be more verbose in the mount and getroot path

* kprintf more info when a hammer2 mount fails with EINVAL

5 years agolibipfw3: Clean up the Makefiles a bit.
Sascha Wildner [Sat, 26 May 2018 21:41:15 +0000 (23:41 +0200)]
libipfw3: Clean up the Makefiles a bit.

5 years agoMakefile.inc1: Do not continue the build upon an error in various cases.
Sascha Wildner [Sat, 26 May 2018 16:41:33 +0000 (18:41 +0200)]
Makefile.inc1: Do not continue the build upon an error in various cases.

Before this commit, the build would limp on even though a library
failed building, for example, leading to sometimes confusing followup
errors later in the build. It was also more difficult to see directly
why a build really failed in the first place.

To prevent this, make various targets use '&&' instead of ';' to
chain commands.

People wanting the build to carry on for as long as possible, can
always use make's -k option.

5 years agohammer2 - Fix focus vs modify race
Matthew Dillon [Fri, 25 May 2018 02:22:52 +0000 (19:22 -0700)]
hammer2 - Fix focus vs modify race

* Fixes rare panics when e.g. removing large numbers (as in hundreds of
  millions) of directory entries.

  The XOP collection code holds the collected cluster but cannot
  safely lock it without risking a deadlock against backend operations
  or dead backends.  The hold on the chain prevents its destruction,
  but does not prevent another thread from locking it and issuing
  hammer2_chain_modify().

* Fix bugs due to the unsafe nature of an unlocked chain's content,
  especially chain->data and chain->dio, by adding an interlock between
  frontend access to the data and backend hammer2_chain_modify() calls.
  Held but unlocked chains are used by the XOP API to pass chains back to
  the frontend.

* Remove the automatic (because it is unsafe) dio synchronization
  in hammer2_xop_collect() and instead implement an API that the
  frontend can use to safely access the data. The API is
  hammer2_xop_gdata()/hammer2_xop_pdata().

* Remove the unsafe hammer2_cluster_rdata().  Use gdata/pdata for this
  too.

* Rewire hammer2_inode_get() to pass-in a hammer2_xop_head instead
  of a hammer2_cluster so it can use the gdata/pdata API too.

5 years agohammer2 - remove hammer2_cluster_wdata()
Matthew Dillon [Thu, 24 May 2018 23:48:31 +0000 (16:48 -0700)]
hammer2 - remove hammer2_cluster_wdata()

* Remove hammer2_cluster_wdata(), function is not applicable for
  context any more since the focus chain is held, but no longer
  locked.

5 years agoncurses: Add few missing dependencies.
zrj [Sat, 26 May 2018 12:15:11 +0000 (15:15 +0300)]
ncurses: Add few missing dependencies.

The lib_gen.c is generated source and it's dependencies too.
This should solve rare races where lib_gen.c is partially constructed,
even if it is not fatal problem (only XSI req for callable functions).

5 years agodrm/i915: Sync hpd_pulse return values with Linux
François Tigeot [Sat, 26 May 2018 11:32:07 +0000 (13:32 +0200)]
drm/i915: Sync hpd_pulse return values with Linux

Now that we know how to handle irqreturn enums, we can use more
Linux code unmodified.

5 years agoMakefile.inc1: Reduce strict ordering where not needed.
zrj [Sat, 26 May 2018 10:02:04 +0000 (13:02 +0300)]
Makefile.inc1: Reduce strict ordering where not needed.

Helps with parallel builds. Shaves off about 40s from make buildworld.

5 years agoMakefile.inc1: Update _prebuild_libs dependencies.
zrj [Sat, 26 May 2018 09:54:22 +0000 (12:54 +0300)]
Makefile.inc1: Update _prebuild_libs dependencies.

The lib/libdevattr is not strictly needed in _prebuild_libs, because
it has dependency on libprop only if libdevattr/mktest is hooked.

5 years agoMakefile.inc1: Reduce strict ordering for libc.
zrj [Sat, 26 May 2018 09:44:57 +0000 (12:44 +0300)]
Makefile.inc1: Reduce strict ordering for libc.

Mark lib/csu as a hard dep for lib/libc (needed only for libc.so link).
Even if lib/libc_rtld is not strictly needed to be handled at all in
Makefile.inc1 (its _pic.a archive only used by libexec/rtld-elf),
having it here is not a big issue since both libc and libc_rtld spend a
lot of time in make depend and running those in parallel helps somewhat.

5 years agostrip(1): Perform safe install.
zrj [Sat, 26 May 2018 06:56:08 +0000 (09:56 +0300)]
strip(1): Perform safe install.

Pass -S flag to install(1) as it is currently done for /bin/sh.
The install(1) might call strip(1) on itself when installing.

5 years agobuildworld: Add support to skip toolchain if requested.
zrj [Fri, 25 May 2018 07:50:12 +0000 (10:50 +0300)]
buildworld: Add support to skip toolchain if requested.

These two new features are mainly aimed at developers, to speed up their
rebuilds on development branches. Often there are no changes that would
influence the toolchain components in any way. So it is reasonable to
skip rebuild of certain parts (mostly to avoid building c++ sources).

Previously we were rebuilding both main and alternative compilers twice
during buildworld for a full bootstrap that allowed us to avoid certain
breakages and not to keep adding lots of backwards compatibility hacks.

The new additions:
  * -DNO_CROSSTOOLS - skip compiler and binutils bootstrap;
  * -DNO_TOOLCHAINS - do not build compilers/binutils for installworld.

Both features are aimed for testing DESTDIR targets. Decision to
activate any of these features is left to the user's own discretion
based on reviewing the commits to the git repository or local clone.

The NO_CROSSTOOLS feature is implemented by installing the shell script
wrappers that add a sysroot and patch the specs. Idea is not to disturb
in any way the Makefile.inc1 or objformat logic at this moment. Since
all the main toolchain tools are installed as shell scripts this has a
nice bonus for quick hooks/probes and other hacky/pretty stuff without
disturbing the rest of the buildworld. You can even add your favorite
static analyser tool, just don't forget to change default include path
to /usr/obj/../world_x86_64/usr/include for it.

The objformat changes for sysroot would only make sense when we make a
port for another architecture. None of the new features are considered
to be guessTM enabled automatically at this moment. To be sure that
nothing has changed since previous buildworld from other changes in the
source tree one would have to compile and hex-diff the final products.
Keep in mind that libraries coming with the compilers will be rebuilt
even with both knobs passed. This should help catching most of the
issues before installworld step and not on the next {build,quick}world.

Both knobs are not documented in make.conf(5) on purpose. It is highly
advised *not* adding any of these knobs into make.conf, sooner or later
you will forget it and *will* get yourself in world recovery situation:
 a) world backup machinery (unless you had NO_BACKUP=true in make.conf);
 b) perform manual bootstrap to fix up the breakage;
 c) restore from H1/H2 snapshots (toolchain components are located in
    /usr/libexec/* and /usr/lib/${CCVER}/ directories);
 d) clean overwrite by mounting from other system (like usb img stick).

Features should work with quickworld too.
To put things in perspective here is a little chart of the cleaned
fresh 'make -jX buildworld' times impact on few setups:

 netbook:      hw.model: Intel(R) Core(TM) i3 CPU  U380  @ 1.33GHz
 compiler:     gcc50 as cc(1) (4gb usb stick for /, ironlake cpu)
 make -j3  buildworld [-DNO_CROSSTOOLS] [-DNO_TOOLCHAIN]

      min:sec      | STANDARD |   NO_C   |   NO_T   | NO_C/NO_T |
 ----------------------------------------------------------------
 gcc50             |   73:56  |   59:57  |   54:11  |   39:38   |
 gcc47 (host+world)|    N/I   |    N/I   |    N/I   |   37:51   |
 ----------------------------------------------------------------

 laptop setup: hw.model: Intel(R) Core(TM) i7-4712MQ CPU @ 2.30GHz
 compiler:     gcc50 as cc(1) (default)
 make -j9  buildworld [-DNO_CROSSTOOLS] [-DNO_TOOLCHAIN]

      min:sec      | STANDARD |   NO_C   |   NO_T   | NO_C/NO_T |
 ----------------------------------------------------------------
 gcc50             |   17:06  |   13:57  |   12:58  |   09:42   |
 gcc50 gcc47 (def) |   20:18  |   16:03  |   14:58  |   10:37   |
 gcc50 gcc80       |   24:24  |   18:06  |   17:31  |   11:23   |
 gcc50 gcc47 gcc80 |   27:47  |   20:17  |   19:23  |   12:00   |
 ----------------------------------------------------------------

 blade setup:  dual hw.model: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
 compiler:     gcc80 as cc(1) (soon gcc80 will replace gcc50 in master)
 make -j32 buildworld [-DNO_CROSSTOOLS] [-DNO_TOOLCHAIN]

      min:sec      | STANDARD |   NO_C   |   NO_T   | NO_C/NO_T |
 ----------------------------------------------------------------
 gcc80             |   06:58  |   05:19  |   05:33  |   03:51   |
 gcc80 gcc47 (def*)|   08:03  |   06:06  |   06:02  |   04:05   |
 gcc80 gcc50       |   08:23  |   06:12  |   06:19  |   04:08   |
 gcc80 gcc47 gcc50 |   09:24  |   06:59  |   06:51  |   04:21   |
 ----------------------------------------------------------------

5 years agogcc80: Shorten build time in libraries target.
zrj [Thu, 24 May 2018 12:35:30 +0000 (15:35 +0300)]
gcc80: Shorten build time in libraries target.

When compiling compiler libraries build the minimal set of tools
required to generated the needed headers. Rest of the tools including
libcpp.na will be built during more parallel gnu/usr.bin stage.
Shaves off ~30s from make buildworld.

While there, do the same for gcc47 and gcc50. Also clean stale file.

5 years agoMakefile.inc1: Add libelf to _prebuilt_libs.
zrj [Thu, 24 May 2018 12:33:03 +0000 (15:33 +0300)]
Makefile.inc1: Add libelf to _prebuilt_libs.

Even if it is internallib for libexecinfo it is very close to race in
_generic_libs.

While there, add ordering for liblzma against libpthread.

5 years agotools/make_libdeps.sh: Use sys.mk from src/.
zrj [Thu, 24 May 2018 12:16:00 +0000 (15:16 +0300)]
tools/make_libdeps.sh: Use sys.mk from src/.

While there, remove not needed /bin from PATH.

Suggested-by: swildner
5 years agoRemove some duplicated includes.
Sascha Wildner [Thu, 24 May 2018 12:23:51 +0000 (14:23 +0200)]
Remove some duplicated includes.

5 years agotools/make_libdeps.sh: Add needed mangling rules.
zrj [Thu, 24 May 2018 09:21:09 +0000 (12:21 +0300)]
tools/make_libdeps.sh: Add needed mangling rules.

For tool to work properly:
 * suppess all of the -Wl,--foo (yes, we have those unfortunately);
 * mangle all of pthread references;
 * ignore libstdc++'s ../components/blah/libfoo_pic.a (used as int libs);
 * remangle internallib libelf_pic.a for libexecinfo;
 * mangle all of the privatelibs to get correct lib location.

5 years agotools/make_libdeps.sh: Adjust invocation.
zrj [Thu, 24 May 2018 09:16:49 +0000 (12:16 +0300)]
tools/make_libdeps.sh: Adjust invocation.

Small changes:
 * add /sbin to the patch for `sysctl hw.platform` in sys.mk;
 * use tr(1) from /bin instead of rs(1) that might truncate;
 * enforce C collate;
 * explicitly sort find(1) results.

5 years agotools/make_libdeps.sh: Update directory list.
zrj [Thu, 24 May 2018 09:13:53 +0000 (12:13 +0300)]
tools/make_libdeps.sh: Update directory list.

5 years agohammer2 - Fix kmalloc pool blowout on low-memory machines
Matthew Dillon [Thu, 24 May 2018 00:25:44 +0000 (17:25 -0700)]
hammer2 - Fix kmalloc pool blowout on low-memory machines

* Fix a kmalloc pool blown that can occur on low-memory machines due
  to too many disconnected hammer2_inode structures building up.

* Was previously fixed for things like rm -rf and bulk renames,
  but not for setattr (aka chown/chmod -R ops).

Reported-by: gjs278
5 years agodrm/linux/timer.h: No need to protect a callout struct from MP accesses
François Tigeot [Wed, 23 May 2018 20:33:36 +0000 (22:33 +0200)]
drm/linux/timer.h: No need to protect a callout struct from MP accesses

Spotted-by: Imre Vadász <imre@vdsz.com>
5 years agodrm - No need to protect a callout struct from MP accesses.
Imre Vadász [Wed, 23 May 2018 18:21:10 +0000 (20:21 +0200)]
drm - No need to protect a callout struct from MP accesses.

5 years agobsd-family-tree: Fix SVN tag.
Sascha Wildner [Wed, 23 May 2018 12:24:41 +0000 (14:24 +0200)]
bsd-family-tree: Fix SVN tag.

5 years agoAnnounce DragonFly 5.2.1
Eitan Adler [Wed, 23 May 2018 04:57:54 +0000 (04:57 +0000)]
Announce DragonFly 5.2.1

5 years agobsd.kern.mk: Remove gcc80 workaround.
zrj [Wed, 23 May 2018 05:50:36 +0000 (08:50 +0300)]
bsd.kern.mk: Remove gcc80 workaround.

No longer needed.

5 years agodrm/i915: Disable few unused const structs and functions.
zrj [Wed, 23 May 2018 05:30:46 +0000 (08:30 +0300)]
drm/i915: Disable few unused const structs and functions.

No functional change.

5 years agobtxld(8): Convert to hostprog.
zrj [Mon, 21 May 2018 16:52:20 +0000 (19:52 +0300)]
btxld(8): Convert to hostprog.

There is no point to provide this utility in base. We are not planing to
bring back i386 support. Move it into sys/boot/pc32/ for easier handling.

This way the AOUT_H_FORCE32 now is confined to the same pc32/ directory.
The <sys/imgact_aout.h> has override for it to create proper btx header.

For future we should make btxld endian neutral.

5 years agobtools: Obsolete pre hostprog era cc_tools.
zrj [Mon, 21 May 2018 09:38:00 +0000 (12:38 +0300)]
btools: Obsolete pre hostprog era cc_tools.

We no longer depend on them so this shaves about 1 min from buildworld.

Verified by comparing intermediates and final products.

5 years agohammer2(8): Clean up the Makefile a bit.
Sascha Wildner [Mon, 21 May 2018 08:46:20 +0000 (10:46 +0200)]
hammer2(8): Clean up the Makefile a bit.

Reported-by: zrj
5 years agoacpi: Add SUBDIR_ORDERED for the ACPICA tools for better parallelism.
Sascha Wildner [Mon, 21 May 2018 08:17:44 +0000 (10:17 +0200)]
acpi: Add SUBDIR_ORDERED for the ACPICA tools for better parallelism.

Reported-by: zrj