dragonfly.git
7 years agoSync zoneinfo database with tzdata2017b from ftp://ftp.iana.org/tz/releases DragonFly_RELEASE_4_6 v4.6.2
Sascha Wildner [Wed, 22 Mar 2017 08:18:30 +0000 (09:18 +0100)]
Sync zoneinfo database with tzdata2017b from ftp://ftp.iana.org/tz/releases

Haiti resumed observance of DST in 2017.  (Thanks to Steffen Thorsen.)

7 years agonewfs_msdos(8): Sync with FreeBSD.
Sascha Wildner [Fri, 9 Dec 2016 19:13:00 +0000 (20:13 +0100)]
newfs_msdos(8): Sync with FreeBSD.

* New options: '-C size' to create an empty image of the specified
    size and '-@ offset' to add the image at the specfied offset.

* Separate some parts into mkfs_msdos.c for later perusal by
    makefs(8), which we have yet to bring in.

* Numerous improvements and bug fixes.

* Raise WARNS to 6.

Taken-from-and-thanks-to: FreeBSD and NetBSD

7 years agokernel - Fix cluster_write() inefficiency
Matthew Dillon [Tue, 7 Mar 2017 01:36:48 +0000 (17:36 -0800)]
kernel - Fix cluster_write() inefficiency

* A bug in the cluster code was causing HAMMER to write out 64KB buffers in
  32KB overlapping segments, resulting in data being written to the media
  twice.

* This fix just about doubles HAMMER's sequential write bandwidth.

7 years agoRemove old timezone Pacific/Johnston via 'make upgrade'.
Sascha Wildner [Fri, 3 Mar 2017 15:41:37 +0000 (16:41 +0100)]
Remove old timezone Pacific/Johnston via 'make upgrade'.

7 years agoSync zoneinfo database with tzdata2017a from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Thu, 2 Mar 2017 13:43:55 +0000 (14:43 +0100)]
Sync zoneinfo database with tzdata2017a from ftp://ftp.iana.org/tz/releases

* Mongolia no longer observes DST.  (Thanks to Ganbold Tsagaankhuu.)

* Chile's Region of Magallanes moves from -04/-03 to -03 year-round.
    Its clocks diverge from America/Santiago starting 2017-05-13 at
    23:00, hiving off a new zone America/Punta_Arenas.  Although the
    Chilean government says this change expires in May 2019, for now
    assume it's permanent.  (Thanks to Juan Correa and Deborah
    Goldsmith.)  This also affects Antarctica/Palmer.

* Fix many entries for historical time stamps for Europe/Madrid
    before 1979, to agree with tables compiled by Pere Planesas of the
    National Astronomical Observatory of Spain.  As a side effect,
    this changes some time stamps for Africa/Ceuta before 1929, which
    are probably guesswork anyway.  (Thanks to Steve Allen and
    Pierpaolo Bernardi for the heads-ups, and to Michael Deckers for
    correcting the 1901 transition.)

* Ecuador observed DST from 1992-11-28 to 1993-02-05.
    (Thanks to Alois Treindl.)

* Asia/Atyrau and Asia/Oral were at +03 (not +04) before 1930-06-21.
    (Thanks to Stepan Golosunov.)

* Switch to numeric time zone abbreviations for South America, as
    part of the ongoing project of removing invented abbreviations.
    This avoids the need to invent an abbreviation for the new Chilean
    zone.  Similarly, switch from invented to numeric time zone
    abbreviations for a number of other zones.

* For Alaska time from 1900 through 1967, instead of "CAT" use the
    abbreviation "AST", the abbreviation commonly used at the time
    (Atlantic Standard Time had not been standardized yet).  Use "AWT"
    and "APT" instead of the invented abbreviations "CAWT" and "CAPT".

* Use "CST" and "CDT" instead of invented abbreviations for Macau
    before 1999 and Taiwan before 1938, and use "JST" instead of the
    invented abbreviation "JCST" for Japan and Korea before 1938.

* Move the Pacific/Johnston link from 'australasia' to 'backward',
    since Johnston is now uninhabited.

* africa (Africa/Monrovia): The 1972 transition was on January 7,
    not May 1.  (Shanks was wrong again! and Howse was right.)

* The 'Theory' file now better documents choice of historical time
    zone abbreviations.  (Problems reported by Michael Deckers.)

7 years agoFix building 4.6 on 4.6.
Sascha Wildner [Fri, 24 Feb 2017 16:12:07 +0000 (17:12 +0100)]
Fix building 4.6 on 4.6.

Reported-by: Richard Nyberg <rnyberg at murmeldjur.se>
7 years agobuild - Allow release to be built on master
Matthew Dillon [Mon, 20 Feb 2017 21:29:07 +0000 (13:29 -0800)]
build - Allow release to be built on master

* Make a few adjustments so the release branch can be built on master.

Reported-by: tuxillo
7 years agokernel - Support FreeBSD style loader.conf hints for resources
Matthew Dillon [Mon, 20 Feb 2017 01:56:25 +0000 (17:56 -0800)]
kernel - Support FreeBSD style loader.conf hints for resources

* DragonFly uses <device><unit>.<resname>.

* Also support FreeBSD hints which use hint.<device>.<unit>.<resname>.

* Makes it easier for users coming from FreeBSD to bring in sound quirks
  and such.

Reported-by: Damien
7 years agokernel - Fix bug in physio()
Matthew Dillon [Mon, 20 Feb 2017 02:14:17 +0000 (18:14 -0800)]
kernel - Fix bug in physio()

* Fix an integer overflow in physio() when attempting to dd a block size
  >= 2G.  An int was being used instead of size_t.

Reported-by: tpchin
Bug: 2981

7 years agokernel: MFC the recent -Wswitch fixes.
Sascha Wildner [Sat, 18 Feb 2017 08:58:50 +0000 (09:58 +0100)]
kernel: MFC the recent -Wswitch fixes.

From master:

1647c7bd435093709089283aa68ef831b34caef9
2c995f40849b20e79621e20576e89e785a0d92a7
f46681358e7500a0505796f5744110299cdc99d8

7 years agokernel/usb4bsd: Add a quirk for the Corsair STRAFE Gaming keyboard.
Sascha Wildner [Sat, 18 Feb 2017 08:52:18 +0000 (09:52 +0100)]
kernel/usb4bsd: Add a quirk for the Corsair STRAFE Gaming keyboard.

Taken-from: FreeBSD

7 years agokernel - Fix NFS sillyrename code
Matthew Dillon [Sun, 22 Jan 2017 16:36:23 +0000 (08:36 -0800)]
kernel - Fix NFS sillyrename code

* Due to the delayed vnode reclamation changes done several years ago
  the NFS client code was not properly removing silly-renamed files
  on last-close (these are files which NFS renames to .nfs* when
  remove()'d while still open()).

* Fixed by flagging finalization on last-close if a sillyrename occurs.

7 years ago<sys/diskmbr.h>: Rename DOSPTYP_GPT to DOSPTYP_EFI.
Sascha Wildner [Thu, 12 Jan 2017 19:33:49 +0000 (20:33 +0100)]
<sys/diskmbr.h>: Rename DOSPTYP_GPT to DOSPTYP_EFI.

The former name was rather misleading since an EFI system partition can
also exist on an MBR disk (see 79363655e5db).

7 years agokernel: Fix GPT detection a bit.
Sascha Wildner [Thu, 12 Jan 2017 18:32:11 +0000 (19:32 +0100)]
kernel: Fix GPT detection a bit.

Having a legacy MBR partition of type 0xef aka EFI system
partition is a perfectly legal case, and it is covered by
the UEFI specification too (in version 2.6, see section 12.3.1).

That means it is not a sufficient indicator that this is a
disk with a GPT, so don't automatically treat it as one. For
the partition in the PMBR on actual GPT disks, type 0xee
will always be used, so that check alone is sufficient for
what is intended here.

Background: Using legacy MBR and having an EFI system
partition at the same time is the layout most USB installation
media use in order to boot on both UEFI and legacy BIOS systems.
The upcoming UEFI installation support work will do the same.

7 years agosmbfs - Fix rename operation
Matthew Dillon [Fri, 9 Dec 2016 21:46:46 +0000 (13:46 -0800)]
smbfs - Fix rename operation

* The rename operation was not updating smbfs's internal name hash.
  Properly update the hash.

Reported-by: dflyum (Uwe Muenzberg)
7 years agolibc - Take care of minor buffer overrun in link_ntoa()
Matthew Dillon [Tue, 6 Dec 2016 22:34:24 +0000 (14:34 -0800)]
libc - Take care of minor buffer overrun in link_ntoa()

* Take care of a minor buffer overrun in link_ntoa().  It is unlikely
  that any program produces the conditions required to trigger the
  problem.

Taken-from: FreeBSD-SA-16:37.libc
Reported-by: swildner, zrj, others
7 years agodntpd - Fix memory leak
Matthew Dillon [Tue, 6 Dec 2016 18:13:11 +0000 (10:13 -0800)]
dntpd - Fix memory leak

* Every log line leaked a bit of memory.  Fixed.

7 years agokernel - Fix smbfs readdir and umount
Matthew Dillon [Fri, 2 Dec 2016 21:57:02 +0000 (13:57 -0800)]
kernel - Fix smbfs readdir and umount

* Fix a bug in smbfs's readdir that was causing an empty list and also
  a later deadlock.

* Fix a bug in smbfs's umount that was panicing the machine.

7 years agokernel - Remove NETSMBCRYPTO option (make it the default)
Matthew Dillon [Fri, 2 Dec 2016 21:33:19 +0000 (13:33 -0800)]
kernel - Remove NETSMBCRYPTO option (make it the default)

* Remove the NETSMBCRYPTO option entirely, and make its function the
  default.

7 years agosmbfs - Fix mount_smbfs authentication error (but 'ls' still broken)
Matthew Dillon [Fri, 2 Dec 2016 00:32:27 +0000 (16:32 -0800)]
smbfs - Fix mount_smbfs authentication error (but 'ls' still broken)

* Fixes an authentication error with mount_smbfs.  Most windows file servers
  require a later crypto rev and man-in-the-middle protection.

* Note however that while mounting works, and files can be copied by name,
  'ls' currently returns empty and the mount appears to get stuck, so more
  work is needed.

7 years agokernel - Cleanup macros
Matthew Dillon [Thu, 1 Dec 2016 20:52:08 +0000 (12:52 -0800)]
kernel - Cleanup macros

* Fix ssb_insert_knote() and friends to use do { ... } while(0) intead
  of { }, which fixes a double-statement issue with the macro.

7 years agokernel - Fix bug in socket_wait() (used by samba)
Matthew Dillon [Thu, 1 Dec 2016 20:50:01 +0000 (12:50 -0800)]
kernel - Fix bug in socket_wait() (used by samba)

* socket_wait() was not properly initializing the temporary kqueue
  structure, resulting in corruption that prevented the event from being
  properly deleted.

* Fixes mount_smbfs panic.

Reported-by: dflyum
7 years agoSync zoneinfo database with tzdata2016j from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Mon, 28 Nov 2016 07:45:51 +0000 (08:45 +0100)]
Sync zoneinfo database with tzdata2016j from ftp://ftp.iana.org/tz/releases

* Saratov, Russia switches from +03 to +04 on 2016-12-04 at 02:00.
    This hives off a new zone Europe/Saratov from Europe/Volgograd.
    (Thanks to Yuri Konotopov and Stepan Golosunov.)

* The new zone Asia/Atyrau for Atyraū Region, Kazakhstan, is like
    Asia/Aqtau except it switched from +04/+05 to +05/+06 in spring
    1999, not fall 1994.  (Thanks to Stepan Golosunov.)

* Asia/Gaza and Asia/Hebron now use "EEST", not "EET", to denote
    summer time before 1948.  The old use of "EET" was a typo.

* The 'Theory' file now documents UT.

* iso3166.tab now accents "Curaçao", and commentary now mentions
    the names "Cabo Verde" and "Czechia".  (Thanks to Jiří Boháč.)

7 years agorc.subr: Add ${name}_env and ${name}_prepend.
Michael Neumann [Sun, 27 Nov 2016 21:51:40 +0000 (22:51 +0100)]
rc.subr: Add ${name}_env and ${name}_prepend.

${name}_env is an argument list which will be passed to env(1).
${name}_prepend is simply prepended to the command line for $command.

This fixes issues I had with starting up www/h2o as described [here][1].

Taken-From: FreeBSD (commit 77616d41a2ce3744b35e68b8a3c12e562283a322)

[1]: https://github.com/DragonFlyBSD/DeltaPorts/issues/663

7 years agoSync zoneinfo database with tzdata2016i from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 4 Nov 2016 18:49:54 +0000 (19:49 +0100)]
Sync zoneinfo database with tzdata2016i from ftp://ftp.iana.org/tz/releases

* Pacific/Tongatapu begins DST on 2016-11-06 at 02:00, ending on
    2017-01-15 at 03:00.  Assume future observances in Tonga will be
    from the first Sunday in November through the third Sunday in
    January, like Fiji.  (Thanks to Pulu ʻAnau.)  Switch to numeric
    time zone abbreviations for this zone.

* Northern Cyprus is now +03 year round, causing a split in Cyprus
    time zones starting 2016-10-30 at 04:00.  This creates a zone
    Asia/Famagusta.  (Thanks to Even Scharning and Matt Johnson.)

* Antarctica/Casey switched from +08 to +11 on 2016-10-22.
    (Thanks to Steffen Thorsen.)

* Several corrections were made for pre-1975 time stamps in Italy.
    These affect Europe/Malta, Europe/Rome, Europe/San_Marino, and
    Europe/Vatican.

  First, the 1893-11-01 00:00 transition in Italy used the new UT
    offset (+01), not the old (+00:49:56).  (Thanks to Michael
    Deckers.)

  Second, rules for daylight saving in Italy were changed to agree
    with Italy's National Institute of Metrological Research (INRiM)
    except for 1944, as follows (thanks to Pierpaolo Bernardi, Brian
    Inglis, and Michael Deckers):

    The 1916-06-03 transition was at 24:00, not 00:00.

    The 1916-10-01, 1919-10-05, and 1920-09-19 transitions were at
      00:00, not 01:00.

    The 1917-09-30 and 1918-10-06 transitions were at 24:00, not
      01:00.

    The 1944-09-17 transition was at 03:00, not 01:00.  This
      particular change is taken from Italian law as INRiM's table,
      (which says 02:00) appears to have a typo here.  Also, keep the
      1944-04-03 transition for Europe/Rome, as Rome was controlled by
      Germany then.

    The 1967-1970 and 1972-1974 fallback transitions were at 01:00,
      not 00:00.

7 years agokernel - Fix a vty switch/history bug
Matthew Dillon [Mon, 31 Oct 2016 03:31:01 +0000 (20:31 -0700)]
kernel - Fix a vty switch/history bug

* Fail gracefully when a M_NOWAIT allocate of the history
  buffer fails.

Reported-by: Harald Brinkhof
7 years agokernel - Add trackpoint and elantech mouse support (2)
Matthew Dillon [Mon, 31 Oct 2016 18:22:27 +0000 (11:22 -0700)]
kernel - Add trackpoint and elantech mouse support (2)

* Fix bitcount build issue.

7 years agokernel - Add trackpoint and elantech mouse support
Matthew Dillon [Mon, 31 Oct 2016 17:51:15 +0000 (10:51 -0700)]
kernel - Add trackpoint and elantech mouse support

* Add trackpoint and elantech mouse support, generally
  synchronizing psm code with FreeBSD.

Submitted-by: htse (Harald Brinkhof)
Taken-from: FreeBSD

7 years agokernel/psm: Support newer Synaptics touchpads
Daniel Bilik [Mon, 26 Sep 2016 00:47:17 +0000 (02:47 +0200)]
kernel/psm: Support newer Synaptics touchpads

Taken-from: FreeBSD

7 years agoSync zoneinfo database with tzdata2016h from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Fri, 28 Oct 2016 11:15:44 +0000 (13:15 +0200)]
Sync zoneinfo database with tzdata2016h from ftp://ftp.iana.org/tz/releases

* Asia/Gaza and Asia/Hebron end DST on 2016-10-29 at 01:00, not
    2016-10-21 at 00:00.  (Thanks to Sharef Mustafa.)  Predict that
    future fall transitions will be on the last Saturday of October
    at 01:00, which is consistent with predicted spring transitions
    on the last Saturday of March.  (Thanks to Tim Parenti.)

* In Turkey, transitions in 1986-1990 were at 01:00 standard time
    not at 02:00, and the spring 1994 transition was on March 20, not
    March 27.  (Thanks to Kıvanç Yazan.)

* Asia/Colombo now uses numeric time zone abbreviations like "+0530"
    instead of alphabetic ones like "IST" and "LKT".  Various
    English-language sources use "IST", "LKT" and "SLST", with no
    working consensus.  (Usage of "SLST" mentioned by Sadika
    Sumanapala.)

* The 'Theory' file now has a section on interface stability.
    (Requested by Paul Koning.)  It also mentions features like
    tm_zone and localtime_rz that have long been supported by the
    reference code.

* The US commentary now mentions Allen and the "day of two noons".

* The Fiji commentary mentions the government's 2016-10-03 press
    release.  (Thanks to Raymond Kumar.)

7 years agokernel - Fix directory scanning bug in msdosfs
Matthew Dillon [Fri, 21 Oct 2016 20:37:07 +0000 (13:37 -0700)]
kernel - Fix directory scanning bug in msdosfs

* Fix a directory scanning bug in msdosfs where an incorrect d_namlen
  was being returned.

Reported-by: htse, t_dfbsd, tuxillo
7 years agokernel - Fix panic/crash in vm_object_page_remove()
Matthew Dillon [Mon, 17 Oct 2016 19:15:57 +0000 (12:15 -0700)]
kernel - Fix panic/crash in vm_object_page_remove()

* When vm_object_page_remove() is called with one page, the caller is allowed
  to hold a spinlock (typically on that page).  The callback is not supposed
  to call user_yield in that situation.

* Fix missing initialization of info.count which could result in the callback
  issuing a yield when it was not supposed to.

Reported-by: htse
7 years agovkernel - Fix FP corruption in VMX/EPT mode v4.6.1
Matthew Dillon [Mon, 10 Oct 2016 17:22:12 +0000 (10:22 -0700)]
vkernel - Fix FP corruption in VMX/EPT mode

* Properly invalidating the EPT TLB cache when it potentially becomes
  stale.

* When destroying a VMX context, make sure the EPT TLB cache has been
  invalidated for that context as a safety.

* Fix a bug in vmx_vminit() where it was losing track of the currently
  loaded VMX.

* Setup the VMX to clear the host CR0_TS, and the host makes sure the FP
  state is correct prior to vmlaunch.

* Make sure the GUEST_CR0's CR0_TS reflects the vkernel says it should
  reflect.

* The vkernel has a choice of asking the guest user context to #NM fault
  on FP use or not.  Both mechanics work, but its probably better for it
  to ensure that the FP state is valid and tell the user context to not
  fault.  However, this commit makes sure that both mechanics work.

* Document why we shouldn't vmclear the old current context when loading
  a different context.

* Cleanup some of the vkernel's pmap handling.  This isn't perfect and
  probably needs to be rewritten (we need a more powerful guest pmap
  adjustment system call to properly synchronize changes).  For now
  we try to avoid races against detecting the (M)odified flag by clearing
  the RW flag first.

7 years agovkernel - Add COW image capability
Matthew Dillon [Sun, 9 Oct 2016 23:41:17 +0000 (16:41 -0700)]
vkernel - Add COW image capability

* Add a copy-on-write disk image feature.  This allows a vkernel
  to mount a disk image RO or R+W but does not try to write changes
  back to the image file.

  This allows multiple vkernel instances to use the same image
  file.

* Note that when the vkernel operates on an image in this mode,
  modifications will eat up system memory and swap, so the user
  should be cognizant of the use-case.  Still, the flexiblity of
  being able to mount the image R+W should not be underestimated.

7 years agokernel - Refactor VMX code
Matthew Dillon [Sat, 8 Oct 2016 23:57:16 +0000 (16:57 -0700)]
kernel - Refactor VMX code

* Refactor the VMX code to use all three VMM states available to use
  instead of two.  The three states available are:

  active and current (VMPTRLD)
  active not current (replaced by some other context being VMPTRLD'd)
  inactive not current (VMCLEAR)

  In short, there is no need to VMCLEAR the current context when activating
  another via VMPTRLD, doing so greatly reduces performance.  VMCLEAR is
  only really needed when a context is being destroyed or being moved to
  another cpu.

* Also fixes a few bugs along the way.

* Live loop in vmx_vmrun() when necessary, otherwise we wind up with serious
  problems synchronizing IPIs.  The thread will still be subject to its
  process priority.

7 years agokernel - Fix low memory process kill bug
Matthew Dillon [Sat, 8 Oct 2016 02:13:41 +0000 (19:13 -0700)]
kernel - Fix low memory process kill bug

* If a process is being killed, don't let it stay put in a low-memory
  vm_wait loop in kernel mode, it will never exit.

* Try to improve the chances that we can dump by adjusting an assertion in
  the user thread scheduler.

7 years agokernel - Fix a system lockup with vmm
Matthew Dillon [Sat, 8 Oct 2016 02:10:06 +0000 (19:10 -0700)]
kernel - Fix a system lockup with vmm

* Fix an issue where vkernel_lwp_exit() was improperly trying to kfree()
  the vklp->ve pointer for the guest-thread case.  This field holds a
  user-supplied address in that case, not a kernel structure.

* Yield the cpu more aggressively in the VMM_GUEST_RUN loop.  We were
  testing for pending interrupts but we were not calling lwkt_switch()

* Do not exit the vkernel on a call or jump to address 0.  This debugging
  code should have been removed and wasn't.  A user process running under
  the vkernel could cause the vkernel itself to exit.

* Numerous syntactical cleanups.

Reported-by: tuxillo
7 years agokernel - Remove mplock from KTRACE paths
Matthew Dillon [Tue, 27 Sep 2016 21:39:03 +0000 (14:39 -0700)]
kernel - Remove mplock from KTRACE paths

* The mplock is no longer needed for KTRACE, ktrace writes are serialized
  by the vnode lock and everything else is MPSAFE.  Note that this change
  means that even fast system calls may interleave in the ktrace output on
  a multi-threaded program.

* Fix ktrace bug related to vkernels.  The syscall2() code assumes that
  no tokens are held on entry (since we are coming from usermode), but
  a system call made from the vkernel may actually be nested inside
  another syscall2().  The mplock KTRACE held caused this to assert in
  the nested syscall2().  The removal of the mplock from the ktrace path
  also fixes this bug.

* Minor comment adjustment in vm_vmspace.c.

Reported-by: tuxillo
7 years agoUpdate OpenSSL to 1.0.1u.
Peter Avalos [Fri, 14 Oct 2016 19:25:19 +0000 (12:25 -0700)]
Update OpenSSL to 1.0.1u.

This only affects the 4.6 branch, because master has a different OpenSSL
version that is no longer being used.

  Major changes between OpenSSL 1.0.1t and OpenSSL 1.0.1u [22 Sep 2016]
      o OCSP Status Request extension unbounded memory growth (CVE-2016-6304)
      o SWEET32 Mitigation (CVE-2016-2183)
      o OOB write in MDC2_Update() (CVE-2016-6303)
      o Malformed SHA512 ticket DoS (CVE-2016-6302)
      o OOB write in BN_bn2dec() (CVE-2016-2182)
      o OOB read in TS_OBJ_print_bio() (CVE-2016-2180)
      o Pointer arithmetic undefined behaviour (CVE-2016-2177)
      o Constant time flag not preserved in DSA signing (CVE-2016-2178)
      o DTLS buffered message DoS (CVE-2016-2179)
      o DTLS replay protection DoS (CVE-2016-2181)
      o Certificate message OOB reads (CVE-2016-6306)

7 years agokernel - Fix improper user-space access in sys___semctl()
Matthew Dillon [Fri, 14 Oct 2016 16:32:12 +0000 (09:32 -0700)]
kernel - Fix improper user-space access in sys___semctl()

* Fix an improper user-space access in sys__semctl()

* Fix an improper kernel-space access that was using
  a user-supplied pointer.

Reported-by: Mateusz Kocielski - LogicalTrust
7 years agoRelocate private panel library to intended location
John Marino [Mon, 3 Oct 2016 16:19:47 +0000 (11:19 -0500)]
Relocate private panel library to intended location

The only consumer of libpanel is the DF installer.  It wasn't installed in
the correct private area, but the linker found it anyway on the standard
search path.  Fix the installation location and task "make upgrade" to
remove the publically installed private libraries.

7 years agokernel/vmx - Add a missing lwkt_reltoken()
Antonio Huete Jimenez [Mon, 26 Sep 2016 22:45:50 +0000 (00:45 +0200)]
kernel/vmx - Add a missing lwkt_reltoken()

7 years agokernel/vmm - Fix build with VMM_DEBUG
Antonio Huete Jimenez [Sun, 25 Sep 2016 10:57:09 +0000 (12:57 +0200)]
kernel/vmm - Fix build with VMM_DEBUG

7 years agovkernel - Invalidate pte before setting attributes to the vm_page
Antonio Huete Jimenez [Tue, 20 Sep 2016 23:31:58 +0000 (01:31 +0200)]
vkernel - Invalidate pte before setting attributes to the vm_page

- Fixes a problem at mountroot time where it doesn't find any disk
  even though the disk is detected earlier.

7 years agovkernel - Fix a vkernel lockup on startup
Antonio Huete Jimenez [Tue, 20 Sep 2016 22:03:05 +0000 (00:03 +0200)]
vkernel - Fix a vkernel lockup on startup

- During ap_init() any pending IPIs is processed manually so
  clear gd_npoll as the real kernel does.
- Do not disable interrupts for vkernels during lwkt_send_ipiq3()
  because they don't seem to be re-enabled afterwards as they should.
  I'm not entirely sure this is the right fix, more investigation
  is required.

7 years agolocaledef: Fix ctype dump (fixed wide spread errors)
John Marino [Thu, 6 Oct 2016 15:37:06 +0000 (10:37 -0500)]
localedef: Fix ctype dump (fixed wide spread errors)

This was a CTYPE encoding error involving consecutive points of the same
ctype.  It was reported by myself to Illumos over a year ago but I was
unsure if it was only happening on BSD.  Given the cause, the bug is also
present on Illumos.

Basically, if consecutive points were of the exact same ctype, they would
be defined as a range regardless.  For example, all of these would be
considered equivalent:

  <A> ... <C>, <H>  (converts to <A> .. <H>)
  <A>, <B>, <H>     (converts to <A> .. <H>)
  <A>, <J> ... <H>  (converts to <A> .. <H>)

So all the points that shouldn't have been defined got "bridged" by the
extreme points.

The effects were recently reported to FreeBSD on PR 213013.  There are
countless places were the ctype flags are misdefined, so this is a major
fix that has to be MFC'd.

7 years agopc64: Fix typo in wrmsr_safe.
Imre Vadász [Mon, 3 Oct 2016 12:41:29 +0000 (14:41 +0200)]
pc64: Fix typo in wrmsr_safe.

7 years agocpuctl(4): Require write rights for CPUCTL_MSRSBIT and CPUCTL_MSRCBIT.
Imre Vadász [Mon, 26 Sep 2016 23:44:43 +0000 (01:44 +0200)]
cpuctl(4): Require write rights for CPUCTL_MSRSBIT and CPUCTL_MSRCBIT.

* Both CPUCTL_MSRSBIT and CPUCTL_MSRCBIT write MSR registers, so they
  should require write rights like CPUCTL_WRMSR.

7 years agoSync zoneinfo database with tzdata2016g from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Thu, 29 Sep 2016 17:39:30 +0000 (19:39 +0200)]
Sync zoneinfo database with tzdata2016g from ftp://ftp.iana.org/tz/releases

* Turkey switched from EET/EEST (+02/+03) to permanent +03,
    effective 2016-09-07.  (Thanks to Burak AYDIN.)  Use "+03" rather
    than an invented abbreviation for the new time.

* New leap second 2016-12-31 23:59:60 UTC as per IERS Bulletin C 52.
    (Thanks to Tim Parenti.)

* For America/Los_Angeles, spring-forward transition times have been
    corrected from 02:00 to 02:01 in 1948, and from 02:00 to 01:00 in
    1950-1966.

* For zones using Soviet time on 1919-07-01, transitions to UT-based
    time were at 00:00 UT, not at 02:00 local time.  The affected
    zones are Europe/Kirov, Europe/Moscow, Europe/Samara, and
    Europe/Ulyanovsk.  (Thanks to Alexander Belopolsky.)

* The Factory zone now uses the time zone abbreviation -00 instead
    of a long English-language string, as -00 is now the normal way to
    represent an undefined time zone.

* Several zones in Antarctica and the former Soviet Union, along
    with zones intended for ships at sea that cannot use POSIX TZ
    strings, now use numeric time zone abbreviations instead of
    invented or obsolete alphanumeric abbreviations.  The affected
    zones are Antarctica/Casey, Antarctica/Davis,
    Antarctica/DumontDUrville, Antarctica/Mawson, Antarctica/Rothera,
    Antarctica/Syowa, Antarctica/Troll, Antarctica/Vostok,
    Asia/Anadyr, Asia/Ashgabat, Asia/Baku, Asia/Bishkek, Asia/Chita,
    Asia/Dushanbe, Asia/Irkutsk, Asia/Kamchatka, Asia/Khandyga,
    Asia/Krasnoyarsk, Asia/Magadan, Asia/Omsk, Asia/Sakhalin,
    Asia/Samarkand, Asia/Srednekolymsk, Asia/Tashkent, Asia/Tbilisi,
    Asia/Ust-Nera, Asia/Vladivostok, Asia/Yakutsk, Asia/Yekaterinburg,
    Asia/Yerevan, Etc/GMT-14, Etc/GMT-13, Etc/GMT-12, Etc/GMT-11,
    Etc/GMT-10, Etc/GMT-9, Etc/GMT-8, Etc/GMT-7, Etc/GMT-6, Etc/GMT-5,
    Etc/GMT-4, Etc/GMT-3, Etc/GMT-2, Etc/GMT-1, Etc/GMT+1, Etc/GMT+2,
    Etc/GMT+3, Etc/GMT+4, Etc/GMT+5, Etc/GMT+6, Etc/GMT+7, Etc/GMT+8,
    Etc/GMT+9, Etc/GMT+10, Etc/GMT+11, Etc/GMT+12, Europe/Kaliningrad,
    Europe/Minsk, Europe/Samara, Europe/Volgograd, and
    Indian/Kerguelen.  For Europe/Moscow the invented abbreviation MSM
    was replaced by +05, whereas MSK and MSD were kept as they are not
    our invention and are widely used.

* Rename Asia/Rangoon to Asia/Yangon, with a backward compatibility link.
    (Thanks to David Massoud.)

* Comments now cite URLs for some 1917-1921 Russian DST decrees.
    (Thanks to Alexander Belopolsky.)

7 years agopowerd - Detect power state changes
Matthew Dillon [Thu, 8 Sep 2016 23:02:07 +0000 (16:02 -0700)]
powerd - Detect power state changes

* The list of available frequencies changes when the power state changes,
  detect such changes and set parameters for all cpus verses making
  incremental changes.

* Fixes issue with powerd leaving the laptop running at a lower frequency
  when the laptop is unplugged and then plugged back in.

7 years agouipc: Make sure that listen is completed.
Sepherosa Ziehau [Wed, 7 Sep 2016 10:54:24 +0000 (18:54 +0800)]
uipc: Make sure that listen is completed.

For unix socket, only HAVEPCCACHED really means the listen has been
completed.

Reported-by: dillon@
7 years agopowerd - Add temperature-based management
Matthew Dillon [Wed, 7 Sep 2016 18:41:25 +0000 (11:41 -0700)]
powerd - Add temperature-based management

* Add temperature-based management, with a default range of 75:85 (in C).
  If the cpu temperature exceeds the low range, powerd will enter
  temperature control mode and begin ramping-down the cpu frequency
  regardless of the load in order to prevent the laptop from reaching
  the high range.

* Add -H lowtemp:hightemp option to allow the range to be set when
  starting or restarting powerd.

* Add code to automatically kill a previously-running powerd when a new
  powerd is started.  This makes the system operator's life easier as there
  is no need to hunt-down and kill the previously-running powerd when
  restarting it with new options.

* No desktop or server should ever get to 75C unless your cooling is broken,
  so this feature is primarily targetted at laptops.  Many laptops can exceed
  80C due to bad cooling design (and poor-design in general), and a vendor
  propensity to goose the specs to make their laptops look good on paper.
  Even the BIOS HOT cap tends to actually be too hot for continuous use.

  But it just isn't a good idea to exceed 80C regardless of what the specs
  say.  The laptop will last a lot longer and this reduces your chances of
  having melt-down or fire.  People who run BSD or Linux systems on laptops
  often do bulk compiles on them and/or other things, such as multiple
  browser windows, tabs, a lot of multi-media, multiple video windows,
  multiple video outputs, etc, which can utilize all available resources
  on the laptop.  Vendors usually don't take all of this into account.
  This feature can allow all of this to happen without burning the laptop
  up.

  You can also use this feature if your laptop gets too hot when sitting on
  your lap :-).

Tested-by: Multiple people.
7 years agokernel - Deal with lost IPIs (VM related) (2)
Matthew Dillon [Wed, 7 Sep 2016 01:09:14 +0000 (18:09 -0700)]
kernel - Deal with lost IPIs (VM related) (2)

* Fix an issue where Xinvltlb interacts badly with a drm console framebuffer,
  imploding the machine.  The 1/16 second watchdog can trigger during certain
  DRM operations due to excessive interrupt disablement in the linux DRM code.

* Avoid kprintf()ing anything by default.

* Also make a minor fix to the watchdog logic to force the higher-level
  Xinvltlb loop to re-test.

7 years agokernel - Deal with lost IPIs (VM related)
Matthew Dillon [Tue, 6 Sep 2016 00:11:05 +0000 (17:11 -0700)]
kernel - Deal with lost IPIs (VM related)

* Some (all?) VMs appear to be able to lose IPIs.  Hopefully the same can't
  be said for device interrupts!  Add some recovery code for lost Xinvltlb
  IPIs for now.

  For synchronizing invalidations we use the TSC and run a recovery attempt
  after 1/16 second, and every 1 second there-after, if an Xinvltlb is not
  responded to (smp_invltlb() and smp_invlpg()).  The IPI will be re-issued.

* Some basic testing shows that a VM can stall out a cpu thread for an
  indefinite period of time, potentially causing the above watchdog to
  trigger.  Even so it should not have required re-issuing the IPI, but
  it seems it does, so the VM appears to be losing the IPI(!) when a cpu
  thread stalls out on the host!  At least with the VM we tested under,
  type unknown.

* IPIQ IPIs currently do not have any specific recovery but I think each
  cpu will poll for IPIQs slowly in the idle thread, so they might
  automatically recover anyway.

Reported-by: zach
7 years agokernel - Fix indefinite wait buffer during heavy swapping
Matthew Dillon [Mon, 5 Sep 2016 19:33:42 +0000 (12:33 -0700)]
kernel - Fix indefinite wait buffer during heavy swapping

* Fix a deadlock which can occur between CAM and the VM system due to
  a bug in uiomove_nofault() when called via vop_helper_read_shortcut().

  If the backing store is swapped out, vm_fault()/vm_fault_object() attempts
  to page the data in instead of telling uiomove_nofault() to give up.
  This can result in a deadlock against the underlying vm_page's in the
  file that might already be undergoing I/O.

* Probably also reported by other people over the years, but could never
  track it down until now.

Reported-by: Studbolt
7 years agolibc - restir arc4random() on fork()
Matthew Dillon [Thu, 8 Sep 2016 06:09:12 +0000 (23:09 -0700)]
libc - restir arc4random() on fork()

* Fix an issue where the arc4random() function was not being re-stirred
  on a fork.

Reported-by: zrj
7 years agolibc - Fix malloc() alignment for small allocations
Matthew Dillon [Sat, 3 Sep 2016 17:24:56 +0000 (10:24 -0700)]
libc - Fix malloc() alignment for small allocations

* malloc()'s slab allocator was set to use 8-byte alignment
  for any allocation < 128 bytes that was not otherwise on
  an integral alignment boundary.  This breaks GCC-7 which assumes
  16-byte alignment for non-16-integral sizes < 128 bytes.  e.g.
  if 18 bytes is allocated, GCC-7 assumes the resulting pointer will
  be 16-byte-aligned.

* The standard is somewhat deficient in its characterization of what the
  required alignment should be, because there are already instructions
  which prefer 32 and 64 byte alignments, but are relaxed on Intel to
  only require 16-byte alignments (aka %ymm and %zmm registers in the
  vector extensions), and its stupid to enforce even larger alignments
  for tiny allocations.

* But generally speaking it makes sense to enforce a 16-byte alignment
  for any allocations >= 16 bytes, regardless of the size being passed-in
  not being 16-byte aligned, and this change does that.  Allocations of
  less than 16 bytes will still be 8-byte aligned because it is phenominally
  wasteful for them not to be.

Reported-by: marino
7 years agokernel - Fix LOOPMASK debugging for Xinvltlb
Matthew Dillon [Wed, 31 Aug 2016 02:36:53 +0000 (19:36 -0700)]
kernel - Fix LOOPMASK debugging for Xinvltlb

* Fix LOOPMASK debugging for Xinvltlb, the #if 1 can now be set to #if 0
  to turn off the debugging.

7 years agobuildworld - bootstrap compatibility compiling older DragonFly's
zrj [Sun, 21 Aug 2016 08:30:47 +0000 (11:30 +0300)]
buildworld - bootstrap compatibility compiling older DragonFly's

* Fix buildworld issue bootstrapping gencat/uudecode utilities which does not
  expect newer header files (POSIX getline general visibility from <stdio.h>).

Could be MFC'd to DragonFly 4.6 branch for easier switching <-> master.

7 years agokernel - Add workaround for improper yield in ACPI path
Matthew Dillon [Mon, 8 Aug 2016 17:46:35 +0000 (10:46 -0700)]
kernel - Add workaround for improper yield in ACPI path

* For now add a workaround for an improper yield that can occur indirectly
  via the ACPI path.  The problem is that the ACPI contrib code can hold
  a spinlock across a kmalloc() call.

* The ACPI code, in particular AcpiOsAcquireLock(), uses a spin lock.  At
  the same time it MUST use a spinlock because it might be called from
  the idle thread.  But it also appears that the code might call kmalloc()
  while holding a spinlock.

  The kmalloc path ACPI calls is with M_INTWAIT, which reduces the chance
  that kmalloc might try to block.  However, kmalloc is used to execute
  staged kfrees which can create a sequence:

  kmalloc -> kmem_slab_free -> (vm system) ->
  vm_object_page_remove_callback -> lwkt_user_yield().

7 years agokernel - Remove some debug output
Matthew Dillon [Mon, 8 Aug 2016 02:44:33 +0000 (19:44 -0700)]
kernel - Remove some debug output

* Remove "Warning: cache_resolve: ncp '%s' was unlinked" debug output.
  This was originally added to validate a particular code path and is
  no longer needed.

7 years ago<time.h>: Adjust the visibility of CLOCK_REALTIME and TIMER_ABSTIME.
Sascha Wildner [Sun, 7 Aug 2016 09:29:13 +0000 (11:29 +0200)]
<time.h>: Adjust the visibility of CLOCK_REALTIME and TIMER_ABSTIME.

Looks like they came in with IEEE Std 1003.1b-1993.

Helps building math/clblas with GCC.

Reported-by: zrj
7 years agokernel - Fix memcpy assembly ABI
Matthew Dillon [Sun, 7 Aug 2016 04:25:26 +0000 (21:25 -0700)]
kernel - Fix memcpy assembly ABI

* memcpy must return the original (dst) argument, and wasn't for the kernel.
  Nothing used it explicitly, but gcc sometimes decides to call memcpy and
  assumes the correct return value.  It was just luck that it hasn't up until
  now.

7 years agolibc - Include information on the 'e' flag in the popen() manual page.
Matthew Dillon [Sat, 6 Aug 2016 18:05:10 +0000 (11:05 -0700)]
libc - Include information on the 'e' flag in the popen() manual page.

* Include information on the 'e' flag in the popen() manual page.

7 years agokernel - Fix kern.proc.pathname sysctl
Matthew Dillon [Fri, 5 Aug 2016 20:12:08 +0000 (13:12 -0700)]
kernel - Fix kern.proc.pathname sysctl

* kern.proc.pathname is a sysctl used by programs to find the path
  of the running program.  This sysctl was created before we stored
  sufficient information in the proc structure to construct the
  correct path when multiple aliases are present (due to e.g. null-mounts)
  to the same file.

* We do have this information, in p->p_textnch, so change the sysctl to
  use it.  The sysctl will now return the actual full path in the context
  of whomever ran the program, so it should properly take into account
  chroots and such.

7 years agodma - Fix security hole
Matthew Dillon [Fri, 5 Aug 2016 07:18:07 +0000 (00:18 -0700)]
dma - Fix security hole

* dma makes an age-old mistake of not properly checking whether a file
  owned by a user is a symlink or not, a bug which the original mail.local
  also had.

* Add O_NOFOLLOW to disallow symlinks.

Thanks-to: BSDNow Episode 152, made me dive dma to check when they talked
   about the mail.local bug.

7 years agokernel - Fix lwp_fork/exit race (2) (vkernel)
Matthew Dillon [Thu, 4 Aug 2016 02:38:11 +0000 (19:38 -0700)]
kernel - Fix lwp_fork/exit race (2) (vkernel)

* Fix same race as before, in vkernel also.

7 years agokernel - Turn off zeroidle in the release branch.
Matthew Dillon [Wed, 3 Aug 2016 05:32:11 +0000 (22:32 -0700)]
kernel - Turn off zeroidle in the release branch.

* Turn of automatic page zeroing when idle in the release branch.  This
  code has been completely removed in the master branch.  Pre-zeroing of
  pages no longer has any benefit on modern cpus for a multitude of reasons.

* Will result in a small improvement in performance under heavy SMP loads.

7 years agokernel - Fix lwp_fork/exit race
Matthew Dillon [Wed, 3 Aug 2016 05:28:54 +0000 (22:28 -0700)]
kernel - Fix lwp_fork/exit race

* In a multi-threaded program it is possible for the exit sequence to
  deadlock if one thread is trying to exit (exit the entire process)
  while another thread is simultaniously creating a new thread.

* Fix the issue by having the new thread checking for the exit condition and
  sending a SIGKILL to itself.  And kprintf() a message when it happens.

7 years agokernel - Refactor cpu localization for VM page allocations (3) v4.6.0
Matthew Dillon [Sun, 31 Jul 2016 03:40:06 +0000 (20:40 -0700)]
kernel - Refactor cpu localization for VM page allocations (3)

* Instead of iterating the cpus in the mask starting at cpu #0, iterate
  starting at mycpu to the end, then from 0 to mycpu - 1.

  This fixes random masked wakeups from favoring lower-numbered cpus.

* The user process scheduler (usched_dfly) was favoring lower-numbered
  cpus due to a bug in the simple selection algorithm, causing forked
  processes to initially weight improperly.  A high fork or fork/exec
  rate skewed the way the cpus were loaded.

  Fix this by correctly scanning cpus from the (scancpu) rover.

* For now, use a random 'previous' affinity for initially scheduling a
  fork.

7 years agokernel - Refactor cpu localization for VM page allocations (2)
Matthew Dillon [Sat, 30 Jul 2016 19:30:24 +0000 (12:30 -0700)]
kernel - Refactor cpu localization for VM page allocations (2)

* Finish up the refactoring.  Localize backoffs for search failures
  by doing a masked domain search.  This avoids bleeding into non-local
  page queues until we've completely exhausted our local queues,
  regardess of the starting pg_color index.

* We try to maintain 16-way set associativity for VM page allocations
  even if the topology does not allow us to do it perfect.  So, for
  example, a 4-socket x 12-core (48-core) opteron can break the 256
  queues into 4 x 64 queues, then split the 12-cores per socket into
  sets of 3 giving 16 queues (the minimum) to each set of 3 cores.

* Refactor the page-zeroing code to only check the localized area.
  This fixes a number of issues related to the zerod pages in the
  queues winding up severely unbalanced.  Other cpus in the local
  group can help replentish a particular cpu's pre-zerod pages but
  we intentionally allow a heavy user to exhaust the pages.

* Adjust the cpu topology code to normalize the physical package id.
  Some machines start at 1, some machines start at 0.  Normalize
  everything to start at 0.

7 years agokernel - cleanup vfs_cache debugging
Matthew Dillon [Sat, 30 Jul 2016 19:27:09 +0000 (12:27 -0700)]
kernel - cleanup vfs_cache debugging

* Remove the deep namecache recursion warning, we've taken care of it
  properly for a while now so we don't need to know when it happens any
  more.

* Augment the cache_inval_internal warnings with more information.

7 years agoif_iwm - Fix iwm_poll_bit() usage in iwm_stop_device().
Imre Vadász [Sat, 30 Jul 2016 10:32:26 +0000 (12:32 +0200)]
if_iwm - Fix iwm_poll_bit() usage in iwm_stop_device().

* The iwm(4) iwm_poll_bit() returns 1 on success and 0 on failure,
  whereas iwl_poll_bit() in Linux iwlwifi returns >= 0 on success and
  < 0 on failure.

7 years agokernel - Refactor cpu localization for VM page allocations
Matthew Dillon [Sat, 30 Jul 2016 00:03:22 +0000 (17:03 -0700)]
kernel - Refactor cpu localization for VM page allocations

* Change how cpu localization works.  The old scheme was extremely unbalanced
  in terms of vm_page_queue[] load.

  The new scheme uses cpu topology information to break the vm_page_queue[]
  down into major blocks based on the physical package id, minor blocks
  based on the core id in each physical package, and then by 1's based on
  (pindex + object->pg_color).

  If PQ_L2_SIZE is not big enough such that 16-way operation is attainable
  by physical and core id, we break the queue down only by physical id.

  Note that the core id is a real core count, not a cpu thread count, so
  an 8-core/16-thread x 2 socket xeon system will just fit in the 16-way
  requirement (there are 256 PQ_FREE queues).

* When a particular queue does not have a free page, iterate nearby queues
  start at +/- 1 (before we started at +/- PQ_L2_SIZE/2), in an attempt to
  retain as much locality as possible.  This won't be perfect but it should
  be good enough.

* Also fix an issue with the idlezero counters.

7 years agosystat - Adjust extended vmstats display
Matthew Dillon [Fri, 29 Jul 2016 21:59:15 +0000 (14:59 -0700)]
systat - Adjust extended vmstats display

* When the number of devices are few enough (or you explicitly specify
  just a few disk devices, or one), there is enough room for the
  extended vmstats display.  Make some adjustments to this display.

* Display values in bytes (K, M, G, etc) instead of pages like the other
  fields.

* Rename zfod to nzfod and subtract-away ozfod when displaying nzfod
  (only in the extended display), so the viewer doesn't have to do the
  subtraction in his head.

7 years agokernel - Reduce memory testing and early-boot zeroing.
Matthew Dillon [Fri, 29 Jul 2016 20:29:03 +0000 (13:29 -0700)]
kernel - Reduce memory testing and early-boot zeroing.

* Reduce the amount of memory testing and early-boot zeroing that
  we do, improving boot times on systems with large amounts of memory.

* Fix race in the page zeroing count.

* Refactor the VM zeroidle code.  Instead of having just one kernel thread,
  have one on each cpu.

  This significantly increases the rate at which the machine can eat up
  idle cycles to pre-zero pages in the cold path, improving performance
  in the hot-path (normal) page allocations which request zerod pages.

* On systems with a lot of cpus there is usually a little idle time (e.g.
  0.1%) on a few of the cpus, even under extreme loads.  At the same time,
  such loads might also imply a lot of zfod faults requiring zero'd pages.

  On our 48-core opteron we see a zfod rate of 1.0 to 1.5 GBytes/sec and
  a page-freeing rate of 1.3 - 2.5 GBytes/sec.  Distributing the page
  zeroing code and eating up these miniscule bits of idle improves the
  kernel's ability to provide a pre-zerod page (vs having to zero-it in
  the hot path) significantly.

  Under the synth test load the kernel was still able to provide 400-700
  MBytes/sec worth of pre-zerod pages whereas before this change the kernel
  was only able to provide 20 MBytes/sec worth of pre-zerod pages.

7 years agokernel - Cleanup namecache stall messages on console
Matthew Dillon [Fri, 29 Jul 2016 17:22:53 +0000 (10:22 -0700)]
kernel - Cleanup namecache stall messages on console

* Report the proper elapsed time and also include td->td_comm
  in the printed output on the console.

7 years agokernel - Fix rare tsleep/callout race
Matthew Dillon [Fri, 29 Jul 2016 17:02:50 +0000 (10:02 -0700)]
kernel - Fix rare tsleep/callout race

* Fix a rare tsleep/callout race.  The callout timer can trigger before
  the tsleep() releases its lwp_token (or if someone else holds the
  calling thread's lwp_token).

  This case is detected, but failed to adjust lwp_stat before
  descheduling and switching away.  This resulted in an endless sleep.

7 years agohyperv/vmbus: Passthrough interrupt resource allocation to nexus
Sepherosa Ziehau [Fri, 29 Jul 2016 08:56:10 +0000 (16:56 +0800)]
hyperv/vmbus: Passthrough interrupt resource allocation to nexus

This greatly simplies interrupt allocation.  And reenable the interrupt
resource not found warning in acpi.

7 years agolibthread_xu - Don't override vfork()
Matthew Dillon [Fri, 29 Jul 2016 01:05:42 +0000 (18:05 -0700)]
libthread_xu - Don't override vfork()

* Allow vfork() to operate normally in a threaded environment.  The kernel
  can handle multiple concurrent vfork()s by different threads (only the
  calling thread blocks, same as how Linux deals with it).

7 years agokernel - Be nicer to pthreads in vfork()
Matthew Dillon [Thu, 28 Jul 2016 17:12:39 +0000 (10:12 -0700)]
kernel - Be nicer to pthreads in vfork()

* When vfork()ing, give the new sub-process's lwp the same TID as the one
  that called vfork().  Even though user processes are not supposed to do
  anything sophisticated inside a vfork() prior to exec()ing, some things
  such as fileno() having to lock in a threaded environment might not be
  apparent to the programmer.

* By giving the sub-process the same TID, operations done inside the
  vfork() prior to exec that interact with pthreads will not confuse
  pthreads and cause corruption due to e.g. TID 0 clashing with TID 0
  running in the parent that is running concurrently.

7 years agoed(1): Sync with FreeBSD.
Sascha Wildner [Thu, 28 Jul 2016 17:10:40 +0000 (19:10 +0200)]
ed(1): Sync with FreeBSD.

7 years agoed(1): Remove handling of non-POSIX environment.
Sascha Wildner [Thu, 28 Jul 2016 17:18:46 +0000 (19:18 +0200)]
ed(1): Remove handling of non-POSIX environment.

7 years agolibc - Fix more popen() issues
Matthew Dillon [Thu, 28 Jul 2016 17:03:08 +0000 (10:03 -0700)]
libc - Fix more popen() issues

* Fix a file descriptor leak between popen() and pclose() in a threaded
  environment.  The control structure is removed from the list, then the
  list is unlocked, then the file is closed.  This can race a popen
  inbetween the unlock and the closure.

* Do not use fileno() inside vfork, it is a complex function in a threaded
  environment which could lead to corruption since the vfork()'s lwp id may
  clash with one from the parent process.

7 years agokernel - Fix getpid() issue in vfork() when threaded
Matthew Dillon [Thu, 28 Jul 2016 16:39:57 +0000 (09:39 -0700)]
kernel - Fix getpid() issue in vfork() when threaded

* upmap->invfork was a 0 or 1, but in a threaded program it is possible
  for multiple threads to be in vfork() at the same time.  Change invfork
  to a count.

* Fixes improper getpid() return when concurrent vfork()s are occuring in
  a threaded program.

7 years agodrm/linux: Clean-up pci_resource_start()
François Tigeot [Thu, 28 Jul 2016 06:56:12 +0000 (08:56 +0200)]
drm/linux: Clean-up pci_resource_start()

Making it less verbose

7 years agomktemp.3: Fix a typo and bump .Dd
Sascha Wildner [Thu, 28 Jul 2016 20:16:33 +0000 (22:16 +0200)]
mktemp.3: Fix a typo and bump .Dd

7 years agosystat - Restrict %rip sampling to root
Matthew Dillon [Wed, 27 Jul 2016 23:22:11 +0000 (16:22 -0700)]
systat - Restrict %rip sampling to root

* Only allow root to sample the %rip and %rsp on all cpus.  The sysctl will
  not sample and return 0 for these fields if the uid is not root.

  This is for security, as %rip sampling can be used to break cryptographic
  keys.

* systat -pv 1 will not display the sampling columns if the sample value
  is 0.

7 years agotest - Add umtx1 code
Matthew Dillon [Wed, 27 Jul 2016 18:22:56 +0000 (11:22 -0700)]
test - Add umtx1 code

* Add umtx1 code - fast context switch tests

* Make blib.c thread-safe.

7 years agolibc - Fix numerous fork/exec*() leaks, also add mkostemp() and mkostemps().
Matthew Dillon [Wed, 27 Jul 2016 18:13:44 +0000 (11:13 -0700)]
libc - Fix numerous fork/exec*() leaks, also add mkostemp() and mkostemps().

* Use O_CLOEXEC in many places to prevent temporary descriptors from leaking
  into fork/exec'd code (e.g. in multi-threaded situations).

* Note that the popen code will close any other popen()'d descriptors in
  the child process that it forks just prior to exec.  However, there was
  a descriptor leak where another thread issuing popen() at the same time
  could leak the descriptors into their exec.

  Use O_CLOEXEC to close this hole.

* popen() now accepts the 'e' flag (i.e. "re") to retain O_CLOEXEC in the
  returned descriptor.  Normal "r" (etc) will clear O_CLOEXEC in the returned
  descriptor.

  Note that normal "r" modes are still fine for most use cases since popen
  properly closes other popen()d descriptors in the fork().  BUT!! If the
  threaded program calls exec*() in other ways, such descriptors may
  unintentionally be passed onto sub-processes.  So consider using "re".

* Add mkostemp() and mkostemps() to allow O_CLOEXEC to be passed in,
  closing a thread race that would otherwise leak the temporary descriptor
  into other fork/exec()s.

Taken-from: Mostly taken from FreeBSD

7 years agokernel - refactor CPUMASK_ADDR()
Matthew Dillon [Tue, 26 Jul 2016 19:53:39 +0000 (12:53 -0700)]
kernel - refactor CPUMASK_ADDR()

* Refactor CPUMASK_ADDR(), removing the conditionals and just indexing the
  array as appropriate.

7 years agocpumask.9: Add short manpage.
zrj [Wed, 20 Jul 2016 16:59:28 +0000 (19:59 +0300)]
cpumask.9: Add short manpage.

7 years agocpumask.h: Turn CPUMASK_ELEMENTS as implementation defined.
zrj [Tue, 19 Jul 2016 16:35:16 +0000 (19:35 +0300)]
cpumask.h: Turn CPUMASK_ELEMENTS as implementation defined.

No functional change intended.

7 years agosys: Extract CPUMASK macros to new <machine/cpumask.h>
zrj [Tue, 19 Jul 2016 07:07:45 +0000 (10:07 +0300)]
sys: Extract CPUMASK macros to new <machine/cpumask.h>

There are plenty enough CPUMASK macros already for them to have their own header.
So far only userspace users are powerd(8), usched(8) and kern_usched.c(VKERNEL64).
After recent change to expose kernel internal CPUMASK macros those got available
for userland codes even through <time.h> header. It is better to avoid that.
Also this reduces POSIX namespace pollution and keeps cpu/types.h header slim.

For now leave CPUMASK_ELEMENTS (not sure about ASSYM() macro handling the _ prefix)
and cpumask_t typedef (forward decl of struct cpumask would be better in prototypes).

7 years agokernel - Disable lwp->lwp optimization in thread switcher
Matthew Dillon [Tue, 26 Jul 2016 23:24:14 +0000 (16:24 -0700)]
kernel - Disable lwp->lwp optimization in thread switcher

* Put #ifdef around the existing lwp->lwp switch optimization and then
  disable it.  This optimizations tries to avoid reloading %cr3 and avoid
  pmap->pm_active atomic ops when switching to a lwp that shares the same
  process.

  This optimization is no longer applicable on multi-core systems as such
  switches are very rare.  LWPs are usually distributed across multiple cores
  so rarely does one switch to another on the same core (and in cpu-bound
  situations, the scheduler will already be in batch mode).  The conditionals
  in the optimization, on the other hand, did measurably (just slightly)
  reduce performance for normal switches.  So turn it off.

* Implement an optimization for interrupt preemptions, but disable it for
  now.  I want to keep the code handy but so far my tests show no improvement
  in performance with huge interrupt rates (from nvme devices), so it is
  #undef'd for now.

7 years agokernel - Minor cleanup swtch.s
Matthew Dillon [Tue, 26 Jul 2016 20:12:51 +0000 (13:12 -0700)]
kernel - Minor cleanup swtch.s

* Minor cleanup

7 years agokernel - Fix namecache race & panic
Matthew Dillon [Tue, 26 Jul 2016 20:01:27 +0000 (13:01 -0700)]
kernel - Fix namecache race & panic

* Properly lock and re-check the parent association when iterating its
  children, fixing a bug in a code path associated with unmounting
  filesystems.

  The code improperly assumed that there could be no races because there
  are were no accessors left.  In fact, under heavy loads, the namecache
  scan in this routine can race against the negative-name-cache management
  code.

* Generally speaking can only happen when lots of mounts and unmounts are
  done under heavy loads (for example, tmpfs mounts during a poudriere or
  synth run).

7 years agokernel - Reduce atomic ops in switch code
Matthew Dillon [Tue, 26 Jul 2016 19:56:31 +0000 (12:56 -0700)]
kernel - Reduce atomic ops in switch code

* Instead of using four atomic 'and' ops and four atomic 'or' ops, use
  one atomic 'and' and one atomic 'or' when adjusting the pmap->pm_active.

* Store the array index and simplified cpu mask in the globaldata structure
  for the above operation.

7 years agokernel - Fix VM bug introduced earlier this month
Matthew Dillon [Tue, 26 Jul 2016 00:06:52 +0000 (17:06 -0700)]
kernel - Fix VM bug introduced earlier this month

* Adding the yields to the VM page teardown and related code was a great
  idea (~Jul 10th commits), but it also introduced a bug where the page
  could get torn-out from under the scan due to the vm_object's token being
  temporarily lost.

* Re-check page object ownership and (when applicable) its pindex before
  acting on the page.

7 years agosystat - Refactor memory displays for systat -vm
Matthew Dillon [Mon, 25 Jul 2016 23:05:40 +0000 (16:05 -0700)]
systat - Refactor memory displays for systat -vm

* Report paging and swap activity in bytes and I/Os instead of pages and
  I/Os (I/Os usually matched pages).

* Report zfod and cow in bytes instead of pages.

* Replace the REAL and VIRTUAL section with something that makes a bit
  more sense.

  Report active memory (this is just active pages), kernel memory
  (currently just wired but we can add more stuff later), Free
  (inactive + cache + free is considered free/freeable memory), and
  total system memory as reported at boot time.

  Report total RSS - basically how many pages the system is mapping to
  user processes.  Due to sharing this can be a large value.

  Do not try to report aggregate VSZ as there's no point in doing so
  any more.

  Reported swap usage on the main -vm display as well as total swap
  allocated.

* Fix display bug in systat -sw display.

* Add "nvme" device type match for the disk display.