]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoFix build after r328020.
Pedro F. Giffuni [Tue, 16 Jan 2018 06:04:39 +0000 (06:04 +0000)]
Fix build after r328020.

Should have noticed earlier but the build was already broken by another
change.

Reported by: Ravi Pokala

6 years agoMake fsl_sata driver work on P1022
Justin Hibbits [Tue, 16 Jan 2018 04:50:23 +0000 (04:50 +0000)]
Make fsl_sata driver work on P1022

P1022 SATA controller may set the wrong CCR bit for a command completion.
This would previously cause an interrupt storm.  Solve this by marking all
commands complete, and letting the end_transaction deal with the successes.
Causes no problems on P5020.

While here, fix a minor bug in collision detection.  The Freescale SATA
controller only has 16 slots, not 32.

6 years agoAdd static inline rtcin_locked() and rtcout_locked() functions for doing a
Ian Lepore [Tue, 16 Jan 2018 03:02:41 +0000 (03:02 +0000)]
Add static inline rtcin_locked() and rtcout_locked() functions for doing a
related series of operations without doing a lock/unlock for each byte.
Use them when reading and writing the entire set of time registers.

The original rtcin() and writertc() functions which do lock/unlock on each
byte still exist, because they are public and called by outside code.

6 years agorandom(4): Add CCP random source definitions
Conrad Meyer [Tue, 16 Jan 2018 02:56:27 +0000 (02:56 +0000)]
random(4): Add CCP random source definitions

The implementation will follow (D12723).  For now, get the changes to
commit-protected files out of the way.

Approved by: secteam (gordon)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13925

6 years agoRename 'recv' to 'receive' to appease shadow warnings from GCC.
John Baldwin [Tue, 16 Jan 2018 01:21:07 +0000 (01:21 +0000)]
Rename 'recv' to 'receive' to appease shadow warnings from GCC.

6 years agoCheck for GCC first rather than clang in the MIPS lib32 rules.
John Baldwin [Tue, 16 Jan 2018 01:05:04 +0000 (01:05 +0000)]
Check for GCC first rather than clang in the MIPS lib32 rules.

This works around a bug with X_COMPILER_TYPE and permits mips64 to build
again with in-tree gcc as well as clang and external gcc.

Sponsored by: DARPA / AFRL

6 years agoSort the list of flags in newsyslog.conf entries.
John Baldwin [Tue, 16 Jan 2018 00:47:53 +0000 (00:47 +0000)]
Sort the list of flags in newsyslog.conf entries.

Move the 'X' and 'Y' entries into their sorted location in the list
of flags just above 'Z'.

Reviewed by: bcr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D13904

6 years agoKeep list sorted. Thanks to jhb@ to pointing out that I put it at the
Michael Tuexen [Mon, 15 Jan 2018 23:17:12 +0000 (23:17 +0000)]
Keep list sorted. Thanks to jhb@ to pointing out that I put it at the
wrong place in r327919.

6 years agoBump date, which I missed in r328014. Thanks to jhb@ for reporting.
Michael Tuexen [Mon, 15 Jan 2018 23:12:54 +0000 (23:12 +0000)]
Bump date, which I missed in r328014. Thanks to jhb@ for reporting.

6 years agoservice(8): Add support for interfacing with services in jails
Kyle Evans [Mon, 15 Jan 2018 22:24:11 +0000 (22:24 +0000)]
service(8): Add support for interfacing with services in jails

Provide a -j option that can take a jail name or id. If -j is specified,
check that the jail exists and proxy the service request through to
service(8) in the jail.

This allows for cleaner workflows when updating services in a jail, turning
the following:

pkg -j dns upgrade
jexec dns service named restart

into:

pkg -j dns upgrade
service -j dns named restart

PR: 223325
Submitted by: David O'Rourke (with slight changes)
MFC after: 2 weeks

6 years agoNeed to free uv after we're done using it.
Warner Losh [Mon, 15 Jan 2018 22:17:39 +0000 (22:17 +0000)]
Need to free uv after we're done using it.

Reported by: andrew@
Sponsored by: Netflix

6 years agoCheck the return value from utf8_to_ucs2 instead of whether or not uv
Warner Losh [Mon, 15 Jan 2018 22:17:34 +0000 (22:17 +0000)]
Check the return value from utf8_to_ucs2 instead of whether or not uv
is NULL. That's more correct and doesn't depend on the error behavior
of utf8_to_ucs2. In practice, we'll never see this though since we
pass utf8_to_ucs2 a well formed string.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13918

6 years agoWhen returning an error and freeing allocated memory from ucs2_to_utf8
Warner Losh [Mon, 15 Jan 2018 22:17:15 +0000 (22:17 +0000)]
When returning an error and freeing allocated memory from ucs2_to_utf8
and utf8_to_ucs2, be sure to NULL out the return pointer too, rather
than return a pointer to free memory.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13917

6 years agoDon't provide a (meaningless) cmsg when proving a notification
Michael Tuexen [Mon, 15 Jan 2018 21:59:20 +0000 (21:59 +0000)]
Don't provide a (meaningless) cmsg when proving a notification
in a recvmsg() call.

MFC after: 1 week

6 years agowsp(4): Update to reflect new sysctl from r314467
Kyle Evans [Mon, 15 Jan 2018 21:53:33 +0000 (21:53 +0000)]
wsp(4): Update to reflect new sysctl from r314467

r314467 introduced hw.usb.wsp.enable_single_tap_clicks to enable/disable
single-tap left click behavior. Update the man page to reflect the new
sysctl.

PR: 196624
MFC after: 3 days
X-MFC-With: r314467

6 years agomisc geom and gnu: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:23:16 +0000 (21:23 +0000)]
misc geom and gnu: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

Differential revision: https://reviews.freebsd.org/D13837

6 years agonet*: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:21:51 +0000 (21:21 +0000)]
net*: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agonetgraph: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:19:21 +0000 (21:19 +0000)]
netgraph: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agokern: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:18:04 +0000 (21:18 +0000)]
kern: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agocam: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:15:25 +0000 (21:15 +0000)]
cam: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agonfsclient: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:14:56 +0000 (21:14 +0000)]
nfsclient: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agomips: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:13:30 +0000 (21:13 +0000)]
mips: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agondis: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:11:38 +0000 (21:11 +0000)]
ndis: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agopowerpc: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:10:40 +0000 (21:10 +0000)]
powerpc: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agoarm: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:09:58 +0000 (21:09 +0000)]
arm: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agox86: make some use of mallocarray(9).
Pedro F. Giffuni [Mon, 15 Jan 2018 21:08:22 +0000 (21:08 +0000)]
x86: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agoDecode msghdr argument of sendmsg() and recvmsg().
Michael Tuexen [Mon, 15 Jan 2018 20:39:42 +0000 (20:39 +0000)]
Decode msghdr argument of sendmsg() and recvmsg().

Sponsored by: Netflix, Inc.

6 years agoAdd support for decoding the nxt_flags, rcv_flags, and snd_flags of
Michael Tuexen [Mon, 15 Jan 2018 20:37:11 +0000 (20:37 +0000)]
Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.

6 years agoExit fsck_ffs with non-zero status when file system is not repaired.
David Bright [Mon, 15 Jan 2018 19:25:11 +0000 (19:25 +0000)]
Exit fsck_ffs with non-zero status when file system is not repaired.

When the fsck_ffs program cannot fully repair a file system, it will
output the message PLEASE RERUN FSCK. However, it does not exit with a
non-zero status in this case (contradicting the man page claim that it
"exits with 0 on success, and >0 if an error occurs."  The fsck
rc-script (when running "fsck -y") tests the status from fsck (which
passes along the exit status from fsck_ffs) and issues a "stop_boot"
if the status fails. However, this is not effective since fsck_ffs can
return zero even on (some) errors. Effectively, it is left to a later
step in the boot process when the file systems are mounted to detect
the still-unclean file system and stop the boot.

This change modifies fsck_ffs so that when it cannot fully repair the
file system and issues the PLEASE RERUN FSCK message it also exits
with a non-zero status.

While here, the fsck_ffs man page has also been updated to document
the failing exit status codes used by fsck_ffs. Previously, only exit
status 7 was documented. Some of these exit statuses are tested for in
the fsck rc-script, so they are clearly depended upon and deserve
documentation.

Reviewed by: mckusick, vangyzen, jilles (manpages)
MFC after: 1 week
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D13862

6 years agoProvide some mitigation against CVE-2017-5715 by clearing registers
Tycho Nightingale [Mon, 15 Jan 2018 18:37:03 +0000 (18:37 +0000)]
Provide some mitigation against CVE-2017-5715 by clearing registers
upon returning from the guest which aren't immediately clobbered by
the host.  This eradicates any remaining guest contents limiting their
usefulness in an exploit gadget.

This was inspired by this linux commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5b6c02f38315b720c593c6079364855d276886aa

Reviewed by: grehan, rgrimes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13573

6 years agoPull in r322473 from upstream llvm trunk (by Andrei Elovikov):
Dimitry Andric [Mon, 15 Jan 2018 18:20:15 +0000 (18:20 +0000)]
Pull in r322473 from upstream llvm trunk (by Andrei Elovikov):

  [LV] Don't call recordVectorLoopValueForInductionCast for
  newly-created IV from a trunc.

  Summary:
  This method is supposed to be called for IVs that have casts in their
  use-def chains that are completely ignored after vectorization under
  PSE. However, for truncates of such IVs the same InductionDescriptor
  is used during creation/widening of both original IV based on PHINode
  and new IV based on TruncInst.

  This leads to unintended second call to
  recordVectorLoopValueForInductionCast with a VectorLoopVal set to the
  newly created IV for a trunc and causes an assert due to attempt to
  store new information for already existing entry in the map. This is
  wrong and should not be done.

  Fixes PR35773.

  Reviewers: dorit, Ayal, mssimpso

  Reviewed By: dorit

  Subscribers: RKSimon, dim, dcaballe, hsaito, llvm-commits, hiraditya

  Differential Revision: https://reviews.llvm.org/D41913

This should fix "Vector value already set for part" assertions when
building the net/iodine and sysutils/daa2iso ports.

Reported by: jbeich
PR: 224867,224868

6 years agostand/fdt: Don't leak next_fdtp if we fail to open overlay
Kyle Evans [Mon, 15 Jan 2018 18:08:01 +0000 (18:08 +0000)]
stand/fdt: Don't leak next_fdtp if we fail to open overlay

MFC after: 1 week
X-MFC-With: r327991

6 years agounits(1): units(1) free savescr in error condition too
Eitan Adler [Mon, 15 Jan 2018 17:27:43 +0000 (17:27 +0000)]
units(1): units(1) free savescr in error condition too

CID: 978392
Reviewed by: des
MFC After: 1 week

6 years agoFix booting on some arm64 systems after r327879 by fixing the call to
Andrew Turner [Mon, 15 Jan 2018 16:58:07 +0000 (16:58 +0000)]
Fix booting on some arm64 systems after r327879 by fixing the call to
utf8_to_ucs2 in boot1.efi. We need to initialise the ucs2 output string
so it will allocate space, and use the return value to determine if the
call was successful.

Reviewed by: imp
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D13915

6 years agoConvert the x86 RTC driver to use new validated BCD<->timespec conversions.
Ian Lepore [Mon, 15 Jan 2018 16:40:43 +0000 (16:40 +0000)]
Convert the x86 RTC driver to use new validated BCD<->timespec conversions.

New common routines were added to kern/subr_clock.c for converting between
calendrical time expressed in BCD and struct timespec. The new functions
return EINVAL on error, as expected when the clock hardware does not provide
valid time.

PR: 224813
Differential Revision: https://reviews.freebsd.org/D13731 (no reviewers)

6 years agoInstall the SLB miss trap-handling code in the SLB-based MMU driver set up,
Nathan Whitehorn [Mon, 15 Jan 2018 16:08:34 +0000 (16:08 +0000)]
Install the SLB miss trap-handling code in the SLB-based MMU driver set up,
to which it is specific, rather than in the generic AIM startup code. This
will be required to support the radix-table-based MMU introduced with POWER9.

6 years agogeom_disk / scsi_da: deny opening write-protected disks for writing
Andriy Gapon [Mon, 15 Jan 2018 11:20:00 +0000 (11:20 +0000)]
geom_disk / scsi_da: deny opening write-protected disks for writing

Ths change consists of two parts.

geom_disk: deny opening a disk for writing if it's marked as
write-protected.  A new disk(9) flag is added to mark write protected
disks.  A possible alternative could be to add another parameter to d_open,
so that the open mode could be passed to it and the disk drivers could
make the decision internally, but the flag required less churn.

scsi_da: add a new phase of disk probing to query the all pages mode
sense page.  We can determine if the disk is write protected using bit 7
of the device specific field in the mode parameter header returned by
MODE SENSE.

PR: 224037
Reviewed by: mav
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D13360

6 years agoAdd support for decoding the type of a cmsg.
Michael Tuexen [Mon, 15 Jan 2018 10:59:04 +0000 (10:59 +0000)]
Add support for decoding the type of a cmsg.

6 years agoSimplify table generation.
Michael Tuexen [Mon, 15 Jan 2018 08:32:49 +0000 (08:32 +0000)]
Simplify table generation.

6 years agoMove the pmap-specific code in copyinout.c that gets pointers to userland
Nathan Whitehorn [Mon, 15 Jan 2018 06:46:33 +0000 (06:46 +0000)]
Move the pmap-specific code in copyinout.c that gets pointers to userland
buffers into a new pmap-module function pmap_map_user_ptr() that can
be implemented by the respective modules. This is required to implement
non-segment-based AIM-ish MMU systems such as the radix-tree page tables
introduced by POWER ISA 3.0 and present on POWER9.

Reviewed by: jhibbits

6 years agostand/fdt: don't send clobbered FDT to the kernel
Kyle Evans [Mon, 15 Jan 2018 05:00:26 +0000 (05:00 +0000)]
stand/fdt: don't send clobbered FDT to the kernel

If fdt_overlay_apply fails at some stage to apply the overlay to the base,
both the base and overlay may be in an inconsistent state (some fixups
applied, some phandles adjusted, some symbols merged). These can be bad for
a number of reasons, to include user frustration if some fixups applied and
not others. Fail a little safer by making a clean copy of the base FDT for
every overlay that we can simply discard if things go awry.

This also allows us the luxury of simply discarding overlays if we hit some
kind of memory limit or if they're malformed and extremely large for some
reason. We'll now leave a nice error message indicating that some overlays
could not be applied due to size restrictions and we apply what we can.

I note that our overlay implementation has some flaws that might still leave
your system in an unbootable state even if an overlay applies correctly;
please exercise caution in using overlays until we can swap it out for
libfdt's implementation.

Tested on: BananaPi-M3 (armv7)
Tested on: Pine64 (aarch64)
Differential Revision: https://reviews.freebsd.org/D13709

6 years agoThe vmm(4) man page is conditional on MK_BHYVE.
Peter Grehan [Mon, 15 Jan 2018 04:52:12 +0000 (04:52 +0000)]
The vmm(4) man page is conditional on MK_BHYVE.

Submitted by: kevlo

6 years agoallwinner: mmc: Multiple improvement
Emmanuel Vadot [Sun, 14 Jan 2018 22:05:29 +0000 (22:05 +0000)]
allwinner: mmc: Multiple improvement

  - Add a per compatible configuration struct
  - Not all SoC uses the same size for DMA transfert, add this into the
    configuration data
  - Use new timing mode for some SoC (A64 mmc)
  - Auto calibrate clock for A64 mmc/emmc
  - A64 mmc controller need masking of data0
  - Add support for vmmc/vqmmc regulator
  - Add more capabilities, r/w speed is better for eMMC
  - MMC_CAP_SIGNALING_180 gives weird result so do not enable it for now.
  - Add new register documented in H3/A64 user manual

Tested-On: Pine64-LTS (A64), eMMC still doesn't work
Tested-On: A64-Olinuxino (A64), sd and eMMC are working
Tested-On: NanoPi Neo Plus2 (H5), sd and eMMC are working
Tested-On: OrangePi PC2 (H5), sd only (no eMMC)
Tested-On: OrangePi One (H3), sd only (no eMMC)
Tested-On: BananaPi M2 (A31s), sd only (no eMMC)

6 years agoAdd metadata_csum feature support.
Fedor Uporov [Sun, 14 Jan 2018 20:46:39 +0000 (20:46 +0000)]
Add metadata_csum feature support.

Reviewed by:   pfg (mentor)
Approved by:   pfg (mentor)
MFC after:     6 months

Differential Revision:    https://reviews.freebsd.org/D13810

6 years agoAdd a rudimentary PWM driver for the RaspberryPi.
Poul-Henning Kamp [Sun, 14 Jan 2018 20:36:21 +0000 (20:36 +0000)]
Add a rudimentary PWM driver for the RaspberryPi.

Control is through sysctl, only GPIO12 supported.

bootverbose creates sysctls for direct mangling of relevant registers.

Only tested on RPI2

6 years agovmm(4): add to Makefile
Eitan Adler [Sun, 14 Jan 2018 20:30:58 +0000 (20:30 +0000)]
vmm(4): add to Makefile

r326281 added the vmm man page, but it needs to be installed.

PR: 205705

6 years agoRemove tst.zonename.d from the list of expected failures.
Mark Johnston [Sun, 14 Jan 2018 17:56:19 +0000 (17:56 +0000)]
Remove tst.zonename.d from the list of expected failures.

X-MFC with: r327888

6 years agoUse the thread's ucred struct when fetching jid or jailname.
Mark Johnston [Sun, 14 Jan 2018 17:55:40 +0000 (17:55 +0000)]
Use the thread's ucred struct when fetching jid or jailname.

Reported by: mjg
X-MFC with: r327888

6 years agoAdd RTC clock conversions for BCD values, with non-panic validation.
Ian Lepore [Sun, 14 Jan 2018 17:01:37 +0000 (17:01 +0000)]
Add RTC clock conversions for BCD values, with non-panic validation.

RTC clock hardware frequently uses BCD numbers.  Currently the low-level
bcd2bin() and bin2bcd() functions will KASSERT if given out-of-range BCD
values.  Every RTC driver must implement its own code for validating the
unreliable data coming from the hardware to avoid a potential kernel panic.

This change introduces two new functions, clock_bcd_to_ts() and
clock_ts_to_bcd().  The former validates its inputs and returns EINVAL if any
values are out of range. The latter guarantees the returned data will be
valid BCD in a known format (4-digit years, etc).

A new bcd_clocktime structure is used with the new functions.  It is similar
to the original clocktime structure, but defines the fields holding BCD
values as uint8_t (uint16_t for year), and adds a PM flag for handling hours
using AM/PM mode.

PR: 224813
Differential Revision: https://reviews.freebsd.org/D13730 (no reviewers)

6 years agoReport CG checksum mismatches. These errors are non-fatal. The
Warner Losh [Sun, 14 Jan 2018 16:55:14 +0000 (16:55 +0000)]
Report CG checksum mismatches. These errors are non-fatal. The
previous behavior is preserved (the CG checksum is fixed). We're just
noisy about it now.

Reviewed by: kirk@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13884

6 years agoEnable VIMAGE in i386 GENERIC (revert r327840)
Ed Maste [Sun, 14 Jan 2018 16:04:51 +0000 (16:04 +0000)]
Enable VIMAGE in i386 GENERIC (revert r327840)

We've switched back to ld.bfd on i386 for now.

PR: 225077
Sponsored by: The FreeBSD Foundation

6 years agoRemove trailing whitespace.
Bjoern A. Zeeb [Sun, 14 Jan 2018 15:01:25 +0000 (15:01 +0000)]
Remove trailing whitespace.
No functional change.

6 years agoImprove support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
Michael Tuexen [Sun, 14 Jan 2018 14:33:22 +0000 (14:33 +0000)]
Improve support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
and add support for sctp_generic_sendmsg_iov().

Handle the struct iovec argument and the struct sctp_sndrcvinfo
arguments.

6 years agoAdd a function is decode the sinfo_flags of struct sctp_sndrcvinfo.
Michael Tuexen [Sun, 14 Jan 2018 14:27:42 +0000 (14:27 +0000)]
Add a function is decode the sinfo_flags of struct sctp_sndrcvinfo.

6 years agoAdd STAC and CLAC instructions wrappers.
Konstantin Belousov [Sun, 14 Jan 2018 12:39:50 +0000 (12:39 +0000)]
Add STAC and CLAC instructions wrappers.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13838

6 years agoEnumerate and print Intel CPU features for Speculative Execution Side
Konstantin Belousov [Sun, 14 Jan 2018 12:36:23 +0000 (12:36 +0000)]
Enumerate and print Intel CPU features for Speculative Execution Side
Channel Mitigations.

The definitions are taken from the document 336996-001.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoWhen re-evaluating cpu_features, also re-print CPU identification.
Konstantin Belousov [Sun, 14 Jan 2018 12:33:05 +0000 (12:33 +0000)]
When re-evaluating cpu_features, also re-print CPU identification.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoAdd suppor for the supported PR-SCTP policies.
Michael Tuexen [Sun, 14 Jan 2018 12:08:41 +0000 (12:08 +0000)]
Add suppor for the supported PR-SCTP policies.

6 years agoMark the iovec parameters of writev() and readv() as IN and OUT.
Michael Tuexen [Sun, 14 Jan 2018 09:51:25 +0000 (09:51 +0000)]
Mark the iovec parameters of writev() and readv() as IN and OUT.
This makes truss work on readv() as expected.

6 years agoSync VirtIO IDs with Linux
Bryan Venteicher [Sun, 14 Jan 2018 06:03:40 +0000 (06:03 +0000)]
Sync VirtIO IDs with Linux

6 years agoMove VM_NUMA_ALLOC and DEVICE_NUMA under the single global config option NUMA.
Jeff Roberson [Sun, 14 Jan 2018 03:36:03 +0000 (03:36 +0000)]
Move VM_NUMA_ALLOC and DEVICE_NUMA under the single global config option NUMA.

Sponsored by: Netflix, Dell/EMC Isilon
Discussed with: jhb

6 years agoFix build after r327949.
Pedro F. Giffuni [Sun, 14 Jan 2018 00:31:34 +0000 (00:31 +0000)]
Fix build after r327949.

Reported by: Cy Schubert

6 years agoUpgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
Dimitry Andric [Sun, 14 Jan 2018 00:08:34 +0000 (00:08 +0000)]
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r321788).  Upstream has branched for the
6.0.0 release, which should be in about 6 weeks.  Please report bugs and
regressions, so we can get them into the release.

Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.

MFC after: 3 months

6 years agoAdd support for Quectel EC25.
Nick Hibma [Sat, 13 Jan 2018 23:31:21 +0000 (23:31 +0000)]
Add support for Quectel EC25.

Submitted by: Samuel Crookes
MFC after: 3 days

6 years agoDocument places we assume that physical memory is direct-mapped at zero by
Nathan Whitehorn [Sat, 13 Jan 2018 23:14:53 +0000 (23:14 +0000)]
Document places we assume that physical memory is direct-mapped at zero by
using a new macro PHYS_TO_DMAP, which deliberately has the same name as the
equivalent macro on amd64. This also sets the stage for moving the direct
map to another base address.

6 years agodev: make some use of mallocarray(9).
Pedro F. Giffuni [Sat, 13 Jan 2018 22:30:30 +0000 (22:30 +0000)]
dev: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these is likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

6 years agoFix possible panic when creating VirtIO console dev aliases
Bryan Venteicher [Sat, 13 Jan 2018 21:39:46 +0000 (21:39 +0000)]
Fix possible panic when creating VirtIO console dev aliases

Since we have no control over the name, the MAKEDEV_CHECKNAME flag must be
used to return an error on an invalid (to devfs) name instead of panicing.

r305900 that originally added this feature also introduced a few other bugs:
  - Proper locking not performed
  - Theoretically broke the expectation that the control event buffer would
    not span more than one pages, but did not update the CTASSERT that was
    in place to prevent this. However, since the struct virtio_console_control
    and the bulk buffer together were quite small, this could not have happened.

Also workaround an QEMU VirtIO spec violation in that it includes the NUL
terminator in the buffer length when the spec says it is not included.

PR: 223531
MFC after: 1 week

6 years agolimits(1): also bump .Dd...
Eitan Adler [Sat, 13 Jan 2018 21:37:14 +0000 (21:37 +0000)]
limits(1): also bump .Dd...

PR: 225147
MFC After: 1 week

6 years agolimits(1): fix grammar
Eitan Adler [Sat, 13 Jan 2018 21:36:39 +0000 (21:36 +0000)]
limits(1): fix grammar

Submitted by: yuri
PR: 225147
MFC After: 1 week

6 years agoInclude only the headers needed
Justin Hibbits [Sat, 13 Jan 2018 21:10:42 +0000 (21:10 +0000)]
Include only the headers needed

The extra headers came through evolution of the file.

6 years agotimed: slave is an infinite loop, mark it as such
Eitan Adler [Sat, 13 Jan 2018 20:35:32 +0000 (20:35 +0000)]
timed: slave is an infinite loop, mark it as such

6 years agozstd: Use mallocarray(9) for calloc macro.
Pedro F. Giffuni [Sat, 13 Jan 2018 19:02:51 +0000 (19:02 +0000)]
zstd: Use mallocarray(9) for calloc macro.

This is in contrib code but since we only have mallocarray(9) in current
we will not upstream this.

This effectively brings back r327934, which was reverted to correct the
log message.

6 years agoAdd SPDX tag to aw_syscon(4)
Kyle Evans [Sat, 13 Jan 2018 19:02:08 +0000 (19:02 +0000)]
Add SPDX tag to aw_syscon(4)

6 years agoAdd SPDX tags to syscon bits, correct inconsistency in Copyright line.
Kyle Evans [Sat, 13 Jan 2018 19:00:41 +0000 (19:00 +0000)]
Add SPDX tags to syscon bits, correct inconsistency in Copyright line.

6 years agoRevert r327934 to fix the log message.
Pedro F. Giffuni [Sat, 13 Jan 2018 18:56:42 +0000 (18:56 +0000)]
Revert r327934 to fix the log message.

6 years agoIntroduce aw_syscon(4) for earlier attachment
Kyle Evans [Sat, 13 Jan 2018 18:46:31 +0000 (18:46 +0000)]
Introduce aw_syscon(4) for earlier attachment

Attaching syscon_generic earlier than BUS_PASS_DEFAULT makes it more
difficult for specific syscon drivers to attach to the syscon node and to
get ordering right. Further discussion yielded the following set of
decisions:

- Move syscon_generic to BUS_PASS_DEFAULT
- If a platform needs a syscon with different attach order or probe
behavior, it should subclass syscon_generic and match on the SoC specific
compat string
- When we come across a need for a syscon that attaches earlier but only
specifies compatible = "syscon", we should create a syscon_exclusive driver
that provides generic access but probes earlier and only matches if "syscon"
is the only compatible. Such fdt nodes do exist in the wild right now, but
we don't really use them at the moment.

Additionally:

- Any syscon provider that has needs any more complex than a spinlock solely
for syscon access and a single memory resource should subclass syscon
directly rather than attempting to subclass syscon_generic or add complexity
to it. syscon_generic's attach/detach methods may be made public should the
need arise to subclass it with additional attach/detach behavior.

We introduce aw_syscon(4) that just subclasses syscon_generic but probes
earlier to meet our requirements for if_awg and implements #2 above for this
specific situation. It currently only matches a64/a83t/h3 since these are
the only platforms that really need it at the time being.

Discussed with: ian
Reviewed by: manu, andrew, bcr (manpages, content unchanged since review)
Differential Revision: https://reviews.freebsd.org/D13793

6 years agoAdd SPDX identifier for the example license.
Pedro F. Giffuni [Sat, 13 Jan 2018 18:28:30 +0000 (18:28 +0000)]
Add SPDX identifier for the example license.

For project files we should use the -FreeBSD prefix but for this example
assume it is going to be used for some general purpose.

Submitted by: kevlo

6 years agozstd: Use memalloc(9) for calloc macro.
Pedro F. Giffuni [Sat, 13 Jan 2018 18:09:09 +0000 (18:09 +0000)]
zstd: Use memalloc(9) for calloc macro.

This is in contrib code but since we only have memalloc(9) in current we
will not upstream this.

6 years agoamd64: Add a 48-bit MAXADDR constant
Conrad Meyer [Sat, 13 Jan 2018 17:55:22 +0000 (17:55 +0000)]
amd64: Add a 48-bit MAXADDR constant

Some devices (e.g., ccp(4) -- to be committed) can only access the low 48
bits of physical memory.

Reviewed by: markj
Sponsored by: Dell EMC Isilon

6 years agoMerge ^/head r327886 through r327930.
Dimitry Andric [Sat, 13 Jan 2018 17:52:55 +0000 (17:52 +0000)]
Merge ^/head r327886 through r327930.

6 years agoPull in r314499 from upstream clang trunk (by Daniel Marjamäki):
Dimitry Andric [Sat, 13 Jan 2018 17:47:34 +0000 (17:47 +0000)]
Pull in r314499 from upstream clang trunk (by Daniel Marjamäki):

  [Sema] Suppress warnings for C's zero initializer

  Patch by S. Gilles!

  Differential Revision: https://reviews.llvm.org/D28148

Pull in r314838 from upstream clang trunk (by Richard Smith):

  Suppress -Wmissing-braces warning when aggregate-initializing a
  struct with a single field that is itself an aggregate.

  In C++, such initialization of std::array<T, N> types is guaranteed
  to work by the standard, is completely idiomatic, and the "suggested"
  alternative from Clang was technically invalid.

Together, these suppress unneeded "suggest braces around initialization
of subobject" warnings for C++11 initializer lists.

MFC after: 3 days

6 years agoUse the correct revision specifier (EXT_CSD revision rather than
Marius Strobl [Sat, 13 Jan 2018 17:36:11 +0000 (17:36 +0000)]
Use the correct revision specifier (EXT_CSD revision rather than
system specification version) for deciding whether the EXT_CSD
register includes the EXT_CSD_GEN_CMD6_TIME field.

Submitted by: Masanobu SAITOH

6 years agoAdd SPDX identifier to header
Justin Hibbits [Sat, 13 Jan 2018 17:25:48 +0000 (17:25 +0000)]
Add SPDX identifier to header

Reported by: pfg

6 years agoFix a bug introduced in r327355; in mmcsd_ioctl_cmd() when ensuring
Marius Strobl [Sat, 13 Jan 2018 16:32:09 +0000 (16:32 +0000)]
Fix a bug introduced in r327355; in mmcsd_ioctl_cmd() when ensuring
that userland doesn't switch partitions on its own, compare against
the partition mmcsd_ioctl_cmd() is going to switch to (based on the
device node used) rather than the currently selected partition.

6 years agoAdd IDs for Nuvoton NCT6793/NCT6795.
Alexander Motin [Sat, 13 Jan 2018 16:31:07 +0000 (16:31 +0000)]
Add IDs for Nuvoton NCT6793/NCT6795.

MFC after: 2 weeks

6 years agoFix a bug introduced in r327339; at the point in time re-tuning is
Marius Strobl [Sat, 13 Jan 2018 16:21:13 +0000 (16:21 +0000)]
Fix a bug introduced in r327339; at the point in time re-tuning is
executed, the interrupt aggregation code might have disabled the
SDHCI_INT_DMA_END and/or SDHCI_INT_RESPONSE bits in slot->intmask
and the SDHCI_SIGNAL_ENABLE register respectively. So when restoring
the interrupt masks based on the previous contents of slot->intmask
in sdhci_exec_tuning(), ensure that the SDHCI_INT_ENABLE register
doesn't lose these two bits.
While at it and in the spirit of r327339, let sdhci_tuning_intmask()
set the tuning error and re-tuning interrupt bits based on the
SDHCI_TUNING_ENABLED rather than the SDHCI_TUNING_SUPPORTED flag
being set, i. e. only when (re-)tuning is actually used. Currently,
this changes makes no net difference, though.

6 years agodwmmc_hisi: Fix build when option MMCCAM is defined
Emmanuel Vadot [Sat, 13 Jan 2018 14:10:45 +0000 (14:10 +0000)]
dwmmc_hisi: Fix build when option MMCCAM is defined

6 years agoFix a typo introduced in r327919.
Michael Tuexen [Sat, 13 Jan 2018 14:10:45 +0000 (14:10 +0000)]
Fix a typo introduced in r327919.

6 years agoAdd support for readv() and writev() to truss.
Michael Tuexen [Sat, 13 Jan 2018 13:59:35 +0000 (13:59 +0000)]
Add support for readv() and writev() to truss.

Sponsored by: Netflix, Inc.

6 years agoBuild llvm-extract with -lz, and add a few objects to liblldb, both of
Dimitry Andric [Sat, 13 Jan 2018 13:53:05 +0000 (13:53 +0000)]
Build llvm-extract with -lz, and add a few objects to liblldb, both of
which turn out to be needed when you don't use -ffunction-sections.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>

6 years agoAdd sysctl debug.kdb.stack_overflow to conveniently test kernel
Konstantin Belousov [Sat, 13 Jan 2018 11:59:49 +0000 (11:59 +0000)]
Add sysctl debug.kdb.stack_overflow to conveniently test kernel
handling of the kstack overflow.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agosx: retry hard shared unlock just like in r327905 for rwlocks
Mateusz Guzik [Sat, 13 Jan 2018 09:26:24 +0000 (09:26 +0000)]
sx: retry hard shared unlock just like in r327905 for rwlocks

6 years agoRemove redundant variable.
Cy Schubert [Sat, 13 Jan 2018 08:28:46 +0000 (08:28 +0000)]
Remove redundant variable.

MFC after: 1 week

6 years agoThough this block of code is not used by FreeBSD, correct a call to
Cy Schubert [Sat, 13 Jan 2018 08:16:10 +0000 (08:16 +0000)]
Though this block of code is not used by FreeBSD, correct a call to
sprintf() with a macro call to SNPRINTF similar to other calls to
SNPRINTF within this same block.

MFC after: 1 week

6 years agoReplace the PMC class struct copy with an explicit memcpy()
Justin Hibbits [Sat, 13 Jan 2018 04:53:04 +0000 (04:53 +0000)]
Replace the PMC class struct copy with an explicit memcpy()

This should be effectively a nop for all archs, but for some reason the codegen
difference on the PowerPC 970 is such that the struct assignment doesn't work
(unless a printf() using one of the elements in the copied struct follows it),
while the memcpy() succeeds.  On all archs the memcpy() should be expanded to an
inline copy, since the copy is bounded to ~16 bytes.

MFC after: 3 weeks

6 years agoRevert r327823, Enable ld.lld as bootstrap linker by default on i386
Ed Maste [Sat, 13 Jan 2018 04:00:55 +0000 (04:00 +0000)]
Revert r327823, Enable ld.lld as bootstrap linker by default on i386

There's a report of some regression in ports.  Revert for now for an
exp run for this change in isolation (previous lld exp run also included
switching the linker used for ports to lld).

Also revert the src.conf.5 regeneration in r327824.

Reported by: antoine
Sponsored by: The FreeBSD Foundation

6 years agoChase removal of FDT fixup code on PowerPC in r327907.
Nathan Whitehorn [Sat, 13 Jan 2018 03:09:05 +0000 (03:09 +0000)]
Chase removal of FDT fixup code on PowerPC in r327907.

6 years agoRemove fdt fixups for powerpc, they are no longer needed.
Justin Hibbits [Sat, 13 Jan 2018 02:56:09 +0000 (02:56 +0000)]
Remove fdt fixups for powerpc, they are no longer needed.

If a fixup really is needed, it should be fixed in u-boot, not in FreeBSD.

Suggested by: nwhitehorn

6 years agoEnable L2 cache on supported PowerQUICC and QorIQ platforms
Justin Hibbits [Sat, 13 Jan 2018 01:36:37 +0000 (01:36 +0000)]
Enable L2 cache on supported PowerQUICC and QorIQ platforms

Some PowerQUICC and QorIQ platforms have a L2 cache managed via the
memory-mapped configuration registers, and appear as a node in the device
tree.  This adds basic support to enable the cache.

6 years agorwlock: try regular read unlock even in the hard path
Mateusz Guzik [Sat, 13 Jan 2018 00:05:31 +0000 (00:05 +0000)]
rwlock: try regular read unlock even in the hard path

Saves on turnstile trips if the lock got more readers.