]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoStrip trailing whitespace.
trasz [Tue, 10 Apr 2018 08:14:31 +0000 (08:14 +0000)]
Strip trailing whitespace.

MFC after: 2 weeks

6 years agoStrip trailing whitespace.
trasz [Tue, 10 Apr 2018 08:13:59 +0000 (08:13 +0000)]
Strip trailing whitespace.

MFC after: 2 weeks

6 years agoMake development(7) mention tests and section 9 of manual pages.
trasz [Tue, 10 Apr 2018 08:01:55 +0000 (08:01 +0000)]
Make development(7) mention tests and section 9 of manual pages.

MFC after: 2 weeks

6 years agoFix the position of $bootable so that -o platformid=efi applies correctly.
benno [Tue, 10 Apr 2018 02:49:53 +0000 (02:49 +0000)]
Fix the position of $bootable so that -o platformid=efi applies correctly.

Sponsored by: iXsystems, Inc.
Pointy hat to: benno (again)

6 years agoFix makefs invocation after r331843.
benno [Tue, 10 Apr 2018 02:43:07 +0000 (02:43 +0000)]
Fix makefs invocation after r331843.

Reported by: gjb
Reviewed by: gjb
Sponsored by: iXsystems, Inc.
Pointy hat to: benno

6 years agoEnable cesa driver to work with Linux DT binding
mw [Mon, 9 Apr 2018 23:36:52 +0000 (23:36 +0000)]
Enable cesa driver to work with Linux DT binding

Linux device tree binding, whose usage is obligatory,
comprises faulty representation of Marvell cryptographic
engine (CESA) - two engines are artificially gathered into
single DT node, in order to avoid certain SW limitation.

This patch improves the cesa driver to support above binding,
depending on compatible string, which helps to ensure
backward compatibility.

Submitted by: Patryk Duda
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D14760

6 years agoRefactor PCIOCGETCONF for improved readability.
brooks [Mon, 9 Apr 2018 22:59:10 +0000 (22:59 +0000)]
Refactor PCIOCGETCONF for improved readability.

The code now has a single, consistant flow for all three ioctl
variants. ifdefs and for pre-FreeBSD-7 compatability are moved to
functions and macros. So the flow is alwasy the same, we impose
the cost of allocating, copying to, updating from, and freeing a
copy of struct pci_conf_io on all paths.

This change will allow PCIOCGETCONF32 support currently in
sys/compat/freebsd32/freebsd32_ioctl.c to be moved here.

Reviewed by: kib, jhb
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14978

6 years ago[man] Add documentation for OpenFirmware API
gonzo [Mon, 9 Apr 2018 22:23:45 +0000 (22:23 +0000)]
[man] Add documentation for OpenFirmware API

Add man pages for following OpenFirmware functions:

OF_child, OF_parent, OF_peer, OF_device_from_xref,
OF_device_register_xref, OF_xref_from_device, OF_getprop,
OF_getencprop, OF_getencprop_alloc, OF_getprop_alloc, OF_getproplen,
OF_hasprop, OF_nextprop, OF_prop_free, OF_searchencprop,
OF_searchprop, OF_setprop

Edited by: wblock
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D14511

6 years agoAlign OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
gonzo [Mon, 9 Apr 2018 22:06:16 +0000 (22:06 +0000)]
Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc

Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.

6 years agolinuxulator: add else case braces to reduce diffs between archs
emaste [Mon, 9 Apr 2018 19:11:24 +0000 (19:11 +0000)]
linuxulator: add else case braces to reduce diffs between archs

Sponsored by: Turing Robotic Industries Inc.

6 years agoRetire the geom_aes class
kevans [Mon, 9 Apr 2018 17:30:30 +0000 (17:30 +0000)]
Retire the geom_aes class

It's had a good life, but it's not really configurable and not really used.

Obtained from: opBSD (with some changes)
Differential Revision: https://reviews.freebsd.org/D14991

6 years agolinuxulator: deduplicate linux_exec_imgact_try
emaste [Mon, 9 Apr 2018 17:24:01 +0000 (17:24 +0000)]
linuxulator: deduplicate linux_exec_imgact_try

Previously linuxulator had three identical copies of
linux_exec_imgact_try.  Deduplicate before adding another arch to
linuxulator.

Sponsored by: Turing Robotic Industries Inc
Differential Revision: https://reviews.freebsd.org/D14856

6 years agoif_awg: Add support for allwinner,{tx,rx}-delay-ps bindings
kevans [Mon, 9 Apr 2018 14:05:43 +0000 (14:05 +0000)]
if_awg: Add support for allwinner,{tx,rx}-delay-ps bindings

Split out delay parsing into a separate function; we'll support both
{tx,rx}-delay as well as the new versions.

While here, validate that they're within the expected range and fail to
attach if they are not. Assuming that we can clamp the delay is a bad idea
that might result in a non-working awg anyways, so we'll fail early to make
it easier to catch.

This version also unsets the tx and rx delay registers unconditionally and
then sets them if we read a non-zero delay. These delay properties should
default to 0 if not specified, as declared in the binding documentation.
Presumably the delays will be set via hardware configuration if they're not
explicitly set in FDT.

6 years agocfumass(4) no longer requires iscsi(4).
trasz [Mon, 9 Apr 2018 13:32:12 +0000 (13:32 +0000)]
cfumass(4) no longer requires iscsi(4).

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agonetmap: align codebase to upstream version v11.4
vmaffione [Mon, 9 Apr 2018 09:24:26 +0000 (09:24 +0000)]
netmap: align codebase to upstream version v11.4

Changelist:
  - remove unused nkr_slot_flags
  - new nm_intr adapter callback to enable/disable interrupts
  - remove unused sysctls and document the other sysctls
  - new infrastructure to support NS_MOREFRAG for NIC ports
  - support for external memory allocator (for now linux-only),
    including linux-specific changes in common headers
  - optimizations within netmap pipes datapath
  - improvements on VALE control API
  - new nm_parse() helper function in netmap_user.h
  - various bug fixes and code clean up

Approved by: hrs (mentor)

6 years ago[man] Fix return type of BUS_ADD_CHILD(9)
gonzo [Mon, 9 Apr 2018 05:48:12 +0000 (05:48 +0000)]
[man] Fix return type of BUS_ADD_CHILD(9)

Fix return type of BUS_ADD_CHILD(9) in SYNOPSYS section,
it should be device_t, not int

PR: 207389
MFC after: 3 days

6 years agoMake OF_searchencprop signature consistent with OF_getencprop
gonzo [Mon, 9 Apr 2018 00:38:24 +0000 (00:38 +0000)]
Make OF_searchencprop signature consistent with OF_getencprop

Use pcell_t* as a destination buffer argument instead of void
pointer to be consistent with OF_getencprop signature.

6 years agoFix one more OF_getprop_alloc instance missed in r332310
gonzo [Sun, 8 Apr 2018 23:17:51 +0000 (23:17 +0000)]
Fix one more OF_getprop_alloc instance missed in r332310

X-MFC-With: r332310

6 years agoClean up OF_getprop_alloc API
gonzo [Sun, 8 Apr 2018 22:59:34 +0000 (22:59 +0000)]
Clean up OF_getprop_alloc API

OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by: ian, manu
Differential Revision: https://reviews.freebsd.org/D14850

6 years agoReplace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
andrew [Sun, 8 Apr 2018 22:07:06 +0000 (22:07 +0000)]
Replace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
are almost identical so there is no need to keep the former around.

Sponsored by: DARPA, AFRL

6 years agoDocument ofw_bus_subr helpers "compatible" and "status" properties
gonzo [Sun, 8 Apr 2018 20:53:00 +0000 (20:53 +0000)]
Document ofw_bus_subr helpers "compatible" and "status" properties

Add documentation for following functions:

- ofw_bus_is_compatible
- ofw_bus_is_compatible_strict
- ofw_bus_node_is_compatible
- ofw_bus_search_compatible
- ofw_bus_get_status
- ofw_bus_status_okay
- ofw_bus_node_status_okay

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14724

6 years agoFix typo
jhibbits [Sun, 8 Apr 2018 19:33:05 +0000 (19:33 +0000)]
Fix typo

Reserved cause is 6, not 5.

Reported by: cem

6 years agoAdd the ability to control the CPU topology of created VMs
rgrimes [Sun, 8 Apr 2018 19:24:49 +0000 (19:24 +0000)]
Add the ability to control the CPU topology of created VMs
from userland without the need to use sysctls, it allows the old
sysctls to continue to function, but deprecates them at
FreeBSD_version 1200060 (Relnotes for deprecate).

The command line of bhyve is maintained in a backwards compatible way.
The API of libvmmapi is maintained in a backwards compatible way.
The sysctl's are maintained in a backwards compatible way.

Added command option looks like:
bhyve -c [[cpus=]n][,sockets=n][,cores=n][,threads=n][,maxcpus=n]
The optional parts can be specified in any order, but only a single
integer invokes the backwards compatible parse.  [,maxcpus=n] is
hidden by #ifdef until kernel support is added, though the api
is put in place.

bhyvectl --get-cpu-topology option added.

Reviewed by: grehan (maintainer, earlier version),
Reviewed by: bcr (manpages)
Approved by: bde (mentor), phk (mentor)
Tested by: Oleg Ginzburg <olevole@olevole.ru> (cbsd)
MFC after: 1 week
Relnotes: Y
Differential Revision: https://reviews.freebsd.org/D9930

6 years agoPedantic polishing of code to please FlexeLint.
phk [Sun, 8 Apr 2018 19:23:50 +0000 (19:23 +0000)]
Pedantic polishing of code to please FlexeLint.

Approved by: ed

6 years agoPowerpc64: Add the facility unavailable trap subsystem
jhibbits [Sun, 8 Apr 2018 19:11:25 +0000 (19:11 +0000)]
Powerpc64: Add the facility unavailable trap subsystem

Summary:
This code adds the basic infrastructure for the facility subsystem. A facility
trap is raised when an unavailable instruction is executed. One example is
executing a Hardware Transactional Memory instruction while the MSR[TM] is
disabled. In the past, there was a specific interrupt for it (FP, VEC), but the
new instructions seem to be multiplexed on this facility interrupt.

The root cause of the trap is provided on Facility Status and Control Register
(FSCR) register.

Submitted by: Breno Leitao
Reviewed by: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D14566

6 years agoFix LINT (and static COMPAT_LINUX32) after r332122.
brooks [Sun, 8 Apr 2018 17:10:32 +0000 (17:10 +0000)]
Fix LINT (and static COMPAT_LINUX32) after r332122.

6 years agoAllow hinted attachment on FDT-based systems. Instead of returning ENXIO
ian [Sun, 8 Apr 2018 17:06:30 +0000 (17:06 +0000)]
Allow hinted attachment on FDT-based systems.  Instead of returning ENXIO
when the FDT data doesn't enable the device instance, return
BUS_PROBE_NOWILDCARD, the same as for non-FDT systems.

6 years agopowerpc64: Print current MSR on printtrap()
jhibbits [Sun, 8 Apr 2018 16:55:28 +0000 (16:55 +0000)]
powerpc64: Print current MSR on printtrap()

Summary:
Print current MSR on printtrap(). Currently, printtrap just prints srr1, which
contains part of the MSR prior to the exception. I find useful to dump the
current value of the MSR, since it changes when there is an interruption.

With this patch, this is the new printtrap model:

handled user trap:

    exception       = 0x700 (program)
    srr0            = 0x100008a0 (0x100008a0)
    srr1            = 0x800000000002f032
    current msr     = 0x8000000000009032
    lr              = 0x1000089c (0x1000089c)
    curthread       = 0x7a50000
pid = 714, comm = ttrap2

Submitted by: Breno Leitao
Reviewed by: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D14600

6 years agopowerpc64: Avoid calling isync twice
jhibbits [Sun, 8 Apr 2018 16:46:24 +0000 (16:46 +0000)]
powerpc64: Avoid calling isync twice

Summary:
It is not necessary to call isync() after calling mtmsr() function, mainly
because the mtmsr() calls 'isync' internally to synchronize the machine state
register. Other than that, isync() just calls the 'isync' instruction, thus,
the 'isync' instruction is being called twice, and that seems to be unnecessary.

This patch just remove the unecessary calls to isync() after mtmsr().

Submitted by: Breno Leitao
Differential Revision: https://reviews.freebsd.org/D14583

6 years agopowerpc/ofw: Fix malloc inside lock
jhibbits [Sun, 8 Apr 2018 16:43:56 +0000 (16:43 +0000)]
powerpc/ofw: Fix malloc inside lock

Summary:
Currently ofw_real_bounce_alloc() is requesting memory, using WAITOK, holding a
non-sleepable locks, called 'OF Bounce Page'.

Fix this by allocating the pages outside of the lock, and only updating the
global variables while holding the lock.

Submitted by: Breno Leitao
Differential Revision: https://reviews.freebsd.org/D14955

6 years agolocks: tweak backoff a little bit
mjg [Sun, 8 Apr 2018 16:34:10 +0000 (16:34 +0000)]
locks: tweak backoff a little bit

Previous limits were chosen when locking primitives had spurious lock
accesses.

Flipping the starting point to 1 (or rather 2 as the first call shifts it)
provides a modest win when mild contention is seen while not hurting worse
cases. Tested on a bunch of one, two and four socket old and new systems
(Westmere, Skylake, Threadreaper and others) by doing concurrent page faults,
buildkernel/buildworld and other stuff (although not all systems got all the
tests).

Another thing is the upper limit. It is semi-arbitrarily chosen as it was
getting out of hand for slightly less small systems (e.g. a 128-thread one).

Note that backoff is fundamentally a speculative bandaid and this change just
makes it fit a little bit better. It remains completely oblivious to the
hardware topology or the contention pattern. This is being experimented with.

6 years agoRevert r332277, it contained an unintended extra change
andrew [Sun, 8 Apr 2018 15:21:12 +0000 (15:21 +0000)]
Revert r332277, it contained an unintended extra change

6 years agoReplace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
andrew [Sun, 8 Apr 2018 15:12:36 +0000 (15:12 +0000)]
Replace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
are almost identical so there is no need to keep the former around.

Sponsored by: DARPA, AFRL

6 years agoloader: 332270 did left out stand/i386/loader/loader.rc
tsoome [Sun, 8 Apr 2018 13:40:38 +0000 (13:40 +0000)]
loader: 332270 did left out stand/i386/loader/loader.rc

we have 2 instances of loader.rc...

6 years agoMove fdt_is_type to be a Marvell specific function. It's not used by any
andrew [Sun, 8 Apr 2018 12:20:06 +0000 (12:20 +0000)]
Move fdt_is_type to be a Marvell specific function. It's not used by any
other SoCs.

Sponsored by: DARPA, AFRL

6 years agoFix a logical inversion bug.
tuexen [Sun, 8 Apr 2018 12:08:20 +0000 (12:08 +0000)]
Fix a logical inversion bug.

Thanks to Irene Ruengeler for finding and reporting this bug.

MFC after: 3 days

6 years agoloader: 332270 did use wrong path for efi.4th
tsoome [Sun, 8 Apr 2018 11:55:27 +0000 (11:55 +0000)]
loader: 332270 did use wrong path for efi.4th

The correct  path is still /boot/efi.4th

6 years agoSmall cleanup, no functional change.
tuexen [Sun, 8 Apr 2018 11:50:06 +0000 (11:50 +0000)]
Small cleanup, no functional change.

MFC after: 3 days

6 years agoloader: include efi.4th only if we do have uefi
tsoome [Sun, 8 Apr 2018 11:39:27 +0000 (11:39 +0000)]
loader: include efi.4th only if we do have uefi

Also simplify efi.4th.

6 years agoFix a signed/unsigned warning showing up for the userland stack
tuexen [Sun, 8 Apr 2018 11:37:00 +0000 (11:37 +0000)]
Fix a signed/unsigned warning showing up for the userland stack
on some platforms.
Thanks to Felix Weinrank for reporting the issue.

MFC after:i 3 days

6 years agoAdd (intmax_t) type casts to some printf parameters to keep i386 happy.
mckusick [Sun, 8 Apr 2018 07:18:29 +0000 (07:18 +0000)]
Add (intmax_t) type casts to some printf parameters to keep i386 happy.

6 years agoWhen using the fsdb `blocks' command, replace the long and ugly list of
mckusick [Sun, 8 Apr 2018 07:06:12 +0000 (07:06 +0000)]
When using the fsdb `blocks' command, replace the long and ugly list of
blocks with the much more concise and readable block list shown by the
prtblknos() function imported from tools/diag/prtblknos.

6 years agoThe ufs_disk_write() function is used to upgrade a read-only descriptor
mckusick [Sun, 8 Apr 2018 06:59:42 +0000 (06:59 +0000)]
The ufs_disk_write() function is used to upgrade a read-only descriptor
to a read-write descriptor. Do not close the read-only descriptor until
the read-write is successfully obtained. Before this fix, a failed upgrade
left no usable descriptor with which to work.

6 years agoSplit tools/diag/prtblknos into two parts:
mckusick [Sun, 8 Apr 2018 06:52:58 +0000 (06:52 +0000)]
Split tools/diag/prtblknos into two parts:
main.c - opens disk and processes the argument list
 of inodes to be printed
prtblknos.c - prints out the list of blocks used by an inode

This change allows the fsdb program to import prtblknos() to use when
printing out the set of blocks used by an inode.

This program was switched to using the libufs library to ease its
integration with fsdb and any other filesystem utility that might
want to use it in the future.

6 years agoDefensive programming when reading inodes in getino().
mckusick [Sun, 8 Apr 2018 05:15:34 +0000 (05:15 +0000)]
Defensive programming when reading inodes in getino().
Specifically check for out-of-range inodes, and whether
return-value pointers are NULL.

6 years agoUpdate VMCI license based on comments from core, the FreeBSD Foundation,
mp [Sun, 8 Apr 2018 01:32:56 +0000 (01:32 +0000)]
Update VMCI license based on comments from core, the FreeBSD Foundation,
and VMware legal:
- Add a dual BSD-2 Clause/GPLv2 LICENSE file in the VMCI directory
- Remove the use of "All Rights Reserved"
- Per best practice, remove copyright/license info from Makefile

Reviewed by: imp, emaste, jhb, Vishnu Dasa <vdasa@vmware.com>
Approved by: VMware legal via Mark Peek <markpeek@vmware.com>
Differential Revision:  https://reviews.freebsd.org/D14979

6 years ago[rpi] Add fdt_pinctrl(4) support to Raspberry Pi GPIO driver
gonzo [Sun, 8 Apr 2018 00:56:19 +0000 (00:56 +0000)]
[rpi] Add fdt_pinctrl(4) support to Raspberry Pi GPIO driver

On Raspberry Pi platform GPIO controller also responsible for pins
multiplexing. Pi code predates proper FDT support in FreeBSD so a
lot of pinmux info is hardcoded. This patch:

- Implements pinctl methods in bcm2835_gpio
- Converts all devices with ad-hoc pinmux info to proper pin control
  mechanisms and adds pinmux info in FreeBSD's custom dts files.
- Adds fdt_pinctrl option to RPI2 and RPI-B kernels
- Adds SPI pinmux config to FreeBSD's customization of GNU DTS.

Reviewed by: imp, manu
Differential Revision: https://reviews.freebsd.org/D14104

6 years agoAdd a manpage for spigen(4).
ian [Sat, 7 Apr 2018 23:31:55 +0000 (23:31 +0000)]
Add a manpage for spigen(4).

6 years agoAdd a83t overlays for sid and emac
kevans [Sat, 7 Apr 2018 22:28:43 +0000 (22:28 +0000)]
Add a83t overlays for sid and emac

The sun8i-a83t-bananapi-m3-emac overlay technically doesn't match what will
be coming from upstream. The tx-delay and rx-delay should be specified in
terms of allwinner,tx-delay-ps and allwinner,rx-delay-ps respectively. The
values are still technically correct for what we write in if_awg, and
support for the new bindings will be coming soon.

6 years agoCast the data pointer to the correct type for the data being accessed (as
ian [Sat, 7 Apr 2018 22:21:06 +0000 (22:21 +0000)]
Cast the data pointer to the correct type for the data being accessed (as
opposed to one that accidentally worked on the one arch I test-compiled for
on my first try).

Reported by: np@, O. Hartmann <ohartmann@walstatt.org>
Pointy hat: ian@

6 years agoDon't check for impossible NULL return from malloc(..., M_WAITOK).
ian [Sat, 7 Apr 2018 21:31:09 +0000 (21:31 +0000)]
Don't check for impossible NULL return from malloc(..., M_WAITOK).

6 years agoAdd the ioctl definitions for spigen get/set spi mode. Should have been
ian [Sat, 7 Apr 2018 20:53:34 +0000 (20:53 +0000)]
Add the ioctl definitions for spigen get/set spi mode.  Should have been
part of r332233.

6 years agoAdd an ioctl to get/set the SPI transfer mode. Also, make the bus clock
ian [Sat, 7 Apr 2018 20:38:01 +0000 (20:38 +0000)]
Add an ioctl to get/set the SPI transfer mode.  Also, make the bus clock
frequency ioctl actually set the corresponding ivar instead of just storing
the value locally in the softc (and then not using it for anything).  Also,
return the correct error code if the ioctl cmd is not recognized.

6 years agoGenerate a spibus_set_[ivarname]() convenience function for each ivar,
ian [Sat, 7 Apr 2018 20:34:57 +0000 (20:34 +0000)]
Generate a spibus_set_[ivarname]() convenience function for each ivar,
now that they can be set.

6 years agoRemove the existing identify() hack to force-add a spigen device on
ian [Sat, 7 Apr 2018 20:04:03 +0000 (20:04 +0000)]
Remove the existing identify() hack to force-add a spigen device on
FDT-based systems, and instead add proper FDT probe code.  Because this
driver is freebsd-specific and just provides generic userland access to run
spibus transactions, there is no bindings document to mandate a compatible
string, so just arbitrarily use "freebsd,spigen".

6 years agoAdd nvme_util.c to cam.ko.
imp [Sat, 7 Apr 2018 19:29:19 +0000 (19:29 +0000)]
Add nvme_util.c to cam.ko.

cam.ko can't load onto the kernel w/o nvme in the kernel. Add
nvme_util.c to cam.ko.

Noticed by: kib@

6 years agoArrange the list of generated sources as 1-per-line alphbetical, and add
ian [Sat, 7 Apr 2018 19:09:57 +0000 (19:09 +0000)]
Arrange the list of generated sources as 1-per-line alphbetical, and add
the files required when building for FDT-based systems.

6 years agoReturn BUS_PROBE_DEFAULT, not zero, because this is not the one driver
ian [Sat, 7 Apr 2018 18:58:58 +0000 (18:58 +0000)]
Return BUS_PROBE_DEFAULT, not zero, because this is not the one driver
implementation that must be used, it's just the base system default driver.

Also add a comment noting that we're being more liberal about the bus
frequency property than the dts binding documents require.

6 years agoA couple minor improvements to spibus.c...
ian [Sat, 7 Apr 2018 18:25:07 +0000 (18:25 +0000)]
A couple minor improvements to spibus.c...

 - Change the description string to "SPI bus" (was "spibus bus").

 - This is the default driver for a SPI bus, not a generic implementation,
   so return the probe value that indicates such.

 - Use device_delete_children() at detach time, instead of a local loop
   to enumerate the children and detach each one individually.

6 years agoAdd support for writing/changing spi device ivars. The SPI mode (polarity
ian [Sat, 7 Apr 2018 18:09:31 +0000 (18:09 +0000)]
Add support for writing/changing spi device ivars.  The SPI mode (polarity
and phase) and the maximum bus speed can be changed.  The chip select
number cannot be changed, because the device instances which are children
of spibus are inherently associated with the chip select number they were
instantiated for.

6 years agoHandle Skylake-X errata SKZ63.
kib [Sat, 7 Apr 2018 17:06:13 +0000 (17:06 +0000)]
Handle Skylake-X errata SKZ63.

SKZ63 Processor May Hang When Executing Code In an HLE Transaction
Region

Problem: Under certain conditions, if the processor acquires an HLE
(Hardware Lock Elision) lock via the XACQUIRE instruction in the Host
Physical Address range between 40000000H and 403FFFFFH, it may hang
with an internal timeout error (MCACOD 0400H) logged into
IA32_MCi_STATUS.

Move the pages from the range into the blacklist.  Add a tunable to
not waste 4M if local DoS is not the issue.

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

6 years agoallwinner: a83t_r_ccu: Add proper IR clock support
manu [Sat, 7 Apr 2018 15:40:00 +0000 (15:40 +0000)]
allwinner: a83t_r_ccu: Add proper IR clock support

Now that NM clocks support prediv, add proper support for the IR clock found
on the A83T SoC.

Tested On:  BananaPi M3
Reported by: kevans

6 years agoallwinner: aw_clk_nm: Add prediv value
manu [Sat, 7 Apr 2018 15:38:42 +0000 (15:38 +0000)]
allwinner: aw_clk_nm: Add prediv value

Some NM clocks needs a fixed prediv value applied to the parent frequency
on some conditions. Add support for it.

6 years agolibsa: name is not used in dirmatch()
tsoome [Sat, 7 Apr 2018 14:42:47 +0000 (14:42 +0000)]
libsa: name is not used in dirmatch()

Seems like variable 'name' is leftover.

6 years agolibsa: cd9660: warning: 'lenskip' may be used uninitialized in this function
tsoome [Sat, 7 Apr 2018 14:40:09 +0000 (14:40 +0000)]
libsa: cd9660: warning: 'lenskip' may be used uninitialized in this function

We better provide value for lenskip in both instances.

6 years agoaxp81x: Do not fail if regulators aren't properly defined
manu [Sat, 7 Apr 2018 14:17:17 +0000 (14:17 +0000)]
axp81x: Do not fail if regulators aren't properly defined

If a regulator is missing a mandatory property (like 'regulator-name'), do
not fail, regulator_parse_ofw_stdparam is returning a non-zero value so just
skip this regulator.
Also if any regulator fails to attach continue with the rest of the regulators
instead of returning ENXIO in axp8xx_attach

Tested On: BananaPi M3

6 years agoFix enough warnings that we can build syslogd on all targets at WARNS=6.
ed [Sat, 7 Apr 2018 09:03:51 +0000 (09:03 +0000)]
Fix enough warnings that we can build syslogd on all targets at WARNS=6.

This also fixes the build on MIPS.

Reported by: cy (MIPS build failure)

6 years agoRemove the thread argument from ifr_buffer_*() accessors.
brooks [Fri, 6 Apr 2018 23:25:54 +0000 (23:25 +0000)]
Remove the thread argument from ifr_buffer_*() accessors.

They are always used in a context where curthread is the correct thread.
This makes them more similar to the ifr_data_get_ptr() accessor.

6 years agoAdd a way to temporarily suspend and resume virtual CPUs.
jhb [Fri, 6 Apr 2018 22:03:43 +0000 (22:03 +0000)]
Add a way to temporarily suspend and resume virtual CPUs.

This is used as part of implementing run control in bhyve's debug
server.  The hypervisor now maintains a set of "debugged" CPUs.
Attempting to run a debugged CPU will fail to execute any guest
instructions and will instead report a VM_EXITCODE_DEBUG exit to
the userland hypervisor.  Virtual CPUs are placed into the debugged
state via vm_suspend_cpu() (implemented via a new VM_SUSPEND_CPU ioctl).
Virtual CPUs can be resumed via vm_resume_cpu() (VM_RESUME_CPU ioctl).

The debug server suspends virtual CPUs when it wishes them to stop
executing in the guest (for example, when a debugger attaches to the
server).  The debug server can choose to resume only a subset of CPUs
(for example, when single stepping) or it can choose to resume all
CPUs.  The debug server must explicitly mark a CPU as resumed via
vm_resume_cpu() before the virtual CPU will successfully execute any
guest instructions.

Reviewed by: avg, grehan
Tested on: Intel (jhb), AMD (avg)
Differential Revision: https://reviews.freebsd.org/D14466

6 years agoifconf(): correct handling of sockaddrs smaller than struct sockaddr.
brooks [Fri, 6 Apr 2018 20:26:56 +0000 (20:26 +0000)]
ifconf(): correct handling of sockaddrs smaller than struct sockaddr.

Portable programs that use SIOCGIFCONF (e.g. traceroute) assume
that each pseudo ifreq is of length MAX(sizeof(struct ifreq),
sizeof(ifr_name) + ifr_addr.sa_len).  For short sockaddrs we copied
too much from the source sockaddr resulting in a heap leak.

I believe only one such sockaddr exists (struct sockaddr_sco which
is 8 bytes) and it is unclear if such sockaddrs end up on interfaces
in practice.  If it did, the result would be an 8 byte heap leak on
current architectures.

admbugs: 869
Reviewed by: kib
Obtained from: CheriBSD
MFC after: 3 days
Security: kernel heap leak
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14981

6 years agoRe-sort LOADER options
kevans [Fri, 6 Apr 2018 19:49:57 +0000 (19:49 +0000)]
Re-sort LOADER options

These have become unsorted from everything else. This is desync'd from
stable/11 due to some hand-merging that was done there, so the MFC of this
will look slightly different.

MFC after: 3 days

6 years agoDo not fail devices just for errors in descriptor format.
mav [Fri, 6 Apr 2018 19:47:44 +0000 (19:47 +0000)]
Do not fail devices just for errors in descriptor format.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

6 years agopf tests: Basic ioctl validation
kp [Fri, 6 Apr 2018 19:37:15 +0000 (19:37 +0000)]
pf tests: Basic ioctl validation

Basic validation tests for DIOCRADDADDRS, DIOCRDELADDRS, DIOCRSETADDRS,
DIOCRGETADDRS, DIOCRGETASTATS, DIOCRCLRASTATS, DIOCRTSTADDRS,
DIOCRINADEFINE, DIOCXBEGIN and DIOCXROLLBACK.

MFC after: 1 week

6 years agopf: Improve ioctl validation
kp [Fri, 6 Apr 2018 19:36:35 +0000 (19:36 +0000)]
pf: Improve ioctl validation

Ensure that multiplications for memory allocations cannot overflow, and
that we'll not try to allocate M_WAITOK for potentially overly large
allocations.

MFC after: 1 week

6 years agopf tests: Try to provoke a memory leak
kp [Fri, 6 Apr 2018 19:22:22 +0000 (19:22 +0000)]
pf tests: Try to provoke a memory leak

There was a memory leak in the DIOCRADDTABLES ioctl() code which could
be triggered by trying to add tables with the same name.
Try to provoke this memory leak. It was fixed in r331225.

MFC after: 1 week

6 years agopf tests: Basic ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT
kp [Fri, 6 Apr 2018 19:21:29 +0000 (19:21 +0000)]
pf tests: Basic ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT

Validate the DIOCIGETIFACES and DIOCXCOMMIT ioctls with invalid values.

MFC after: 1 week

6 years agopf: Improve ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT
kp [Fri, 6 Apr 2018 19:20:45 +0000 (19:20 +0000)]
pf: Improve ioctl validation for DIOCIGETIFACES and DIOCXCOMMIT

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

There's no obvious limit to the request size for these, so we limit the
requests to something which won't overflow. Change the memory allocation
to M_NOWAIT so excessive requests will fail rather than stall forever.

MFC after: 1 week

6 years agoAdd an unused _COMPAT_LINUX32 option to ensure opt_compat.h exists on
brooks [Fri, 6 Apr 2018 19:11:22 +0000 (19:11 +0000)]
Add an unused _COMPAT_LINUX32 option to ensure opt_compat.h exists on
platforms without COMPAT_LINUX32.

Reported by: kib

6 years agoMove most of the contents of opt_compat.h to opt_global.h.
brooks [Fri, 6 Apr 2018 17:35:35 +0000 (17:35 +0000)]
Move most of the contents of opt_compat.h to opt_global.h.

opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by: kib, cem, jhb, jtl
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14941

6 years agoSupport -DNO_CLEAN builds across r332119.
brooks [Fri, 6 Apr 2018 17:23:47 +0000 (17:23 +0000)]
Support -DNO_CLEAN builds across r332119.

6 years agoIf a user closes the socket before we call tcp_usr_abort(), then
jtl [Fri, 6 Apr 2018 17:20:37 +0000 (17:20 +0000)]
If a user closes the socket before we call tcp_usr_abort(), then
tcp_drop() may unlock the INP.  Currently, tcp_usr_abort() does not
check for this case, which results in a panic while trying to unlock
the already-unlocked INP (not to mention, a use-after-free violation).

Make tcp_usr_abort() check the return value of tcp_drop(). In the case
where tcp_drop() returns NULL, tcp_usr_abort() can skip further steps
to abort the connection and simply unlock the INP_INFO lock prior to
returning.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Netflix, Inc.

6 years agoRemove caching from getlogin(2).
brooks [Fri, 6 Apr 2018 17:17:34 +0000 (17:17 +0000)]
Remove caching from getlogin(2).

This caching has existed since the CSRG import, but serves no obvious
purpose. Sure, setlogin() is called rarely, but calls to getlogin()
should also be infrequent. The required invalidation was not
implemented on aarch64, arm, mips, amd riscv so updates would never
occur if getlogin() was called before setlogin().

Reported by: Ali Mashtizadeh <ali@mashtizadeh.com>
Reviewed by: kib
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14965

6 years agoPush RFC 5424 message format from logmsg() into fprintlog().
ed [Fri, 6 Apr 2018 17:16:50 +0000 (17:16 +0000)]
Push RFC 5424 message format from logmsg() into fprintlog().

Now that all of parsemsg() parses both RFC 3164 and 5424 messages and
hands them to logmsg(), alter the latter to properly forward all RFC
5424 message attributes to fprintlog(). While there, make some minor
cleanups to this code:

- Instead of extending the existing code that compares hostnames and
  message bodies for deduplication, print all of the relevant message
  fields into a single string that we can compare ('saved').

- No longer let the behaviour of fprintflog() depend on whether
  'msg == NULL' to print repetition messages, Simply decompose this
  function into fprintlog_first() and fprintlog_successive(). This
  makes the interpretation of function arguments less magical and also
  allows us to get consistent behaviour across RFC 3164 and 5424 when
  adding support for the RFC 5424 output format.

- As RFC 5424 syslog messages have a dedicated application name field,
  alter the repetition messages to be printed on behalf of syslogd on
  the current system. Change these messages to use the local hostname,
  so that it's obvious which syslogd instance detected the repetition.
  Remove f_prevhost, as it has now become unnecessary.

- Remove a useless strdup(). Deconsting the message string is safe in
  this specific case.

6 years agoPat the watchdog less while producing a coredump. Prior to this change,
jtl [Fri, 6 Apr 2018 17:06:22 +0000 (17:06 +0000)]
Pat the watchdog less while producing a coredump.  Prior to this change,
we patted the watchdog approximately once per 4KB page of memory.  After
this change, we pat the watchdog approximately once per 128MB of memory.
On a sample machine, this translated to patting the watchdog approximately
every 5.4 seconds, which "seems reasonable". We can choose a different
value in the future, if warranted.

This has extensive field experience. It is a performance improvement, and
has not caused any known problems.

Reviewed by: imp, kib
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D14988

6 years agoCheck that in_pcbfree() is only called once for each PCB. If that
jtl [Fri, 6 Apr 2018 16:48:11 +0000 (16:48 +0000)]
Check that in_pcbfree() is only called once for each PCB.  If that
assumption is violated, "bad things" could follow.

I believe such an assert would have detected some of the problems jch@
was chasing in PR 203175 (see r307551).  We also use it in our internal
TCP development efforts.  And, in case a bug does slip through to
released code, this change silently ignores subsequent calls to
in_pcbfree().

Reviewed by: rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D14990

6 years agoRemove some places where error messages are prefixed with "syslogd".
ed [Fri, 6 Apr 2018 16:26:46 +0000 (16:26 +0000)]
Remove some places where error messages are prefixed with "syslogd".

Due to using RFC 5424, the application name is stored in a dedicated
field. It can simply be passed as an argument to logmsg() now.

6 years agoProperly respect the passed in hostname for RFC 5424 messages.
ed [Fri, 6 Apr 2018 16:24:03 +0000 (16:24 +0000)]
Properly respect the passed in hostname for RFC 5424 messages.

Only override the hostname in case none is provided or when remote
hostnames should be ignored.

6 years agox86: fix trampoline memory allocation after r332073
royger [Fri, 6 Apr 2018 16:22:14 +0000 (16:22 +0000)]
x86: fix trampoline memory allocation after r332073

Add the missing breaks in the for loops, in order to exit the loop
when a suitable entry is found.

Also switch amd64 native_start_all_aps to use PHYS_TO_DMAP in order to
find the virtual address of the boot_trampoline and the initial page
tables.

Reported and tested by: pho
Sponsored by: Citrix Systems R&D

6 years agopf tests: Basic ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS...
kp [Fri, 6 Apr 2018 15:57:20 +0000 (15:57 +0000)]
pf tests: Basic ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS

Validate the DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and
DIOCRSETTFLAGS ioctls with invalid values. These may succeed (because
the kernel uses the minimally required size, not the specified size),
but should not trigger kernel panics.

MFC after: 1 week

6 years agopf: Improve ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and...
kp [Fri, 6 Apr 2018 15:54:30 +0000 (15:54 +0000)]
pf: Improve ioctl validation for DIOCRGETTABLES, DIOCRGETTSTATS, DIOCRCLRTSTATS and DIOCRSETTFLAGS

These ioctls can process a number of items at a time, which puts us at
risk of overflow in mallocarray() and of impossibly large allocations
even if we don't overflow.

Limit the allocation to required size (or the user allocation, if that's
smaller). That does mean we need to do the allocation with the rules
lock held (so the number doesn't change while we're doing this), so it
can't M_WAITOK.

MFC after: 1 week

6 years agolualoader: Fix menu skipping with loader.conf(5) vars
kevans [Fri, 6 Apr 2018 15:19:48 +0000 (15:19 +0000)]
lualoader: Fix menu skipping with loader.conf(5) vars

Earlier efforts to stop loading the menu broke the ability to skip the menu
with, e.g., beastie_disable in loader.conf(5) as it was decided before
configuration was read.

Defer bringing in the menu module until we've loaded configuration so that
we can make a more informed decision on whether the menu should be skipped
or not.

6 years agoaw_sid(4): Use prctl read for all reads when it's required
kevans [Fri, 6 Apr 2018 15:17:09 +0000 (15:17 +0000)]
aw_sid(4): Use prctl read for all reads when it's required

It was later found that some operation on the OrangePi one will cause
direct accesses to the eeprom to return wrong data again, so reading it all
once via prctl at attach time is no longer sufficient.

6 years agoIn cases where an application issues certain IPMI commands at a high
jtl [Fri, 6 Apr 2018 15:15:21 +0000 (15:15 +0000)]
In cases where an application issues certain IPMI commands at a high
enough rate, the IPMI code can print large numbers of messages to the
console, such as:
  ipmi0: KCS: Failed to read completion code
  ipmi0: KCS error: ff
  ipmi0: KCS: Failed to read completion code
  ipmi0: KCS error: ff

These seem to be innocuous from a system standpoint, and the user-
space code can deal with the failures. Therefore, suppress printing
these messages to the console unless bootverbose is enabled.

Obtained from: Netflix, Inc.

6 years agopf tests: Basic ioctl validation tests
kp [Fri, 6 Apr 2018 15:03:48 +0000 (15:03 +0000)]
pf tests: Basic ioctl validation tests

Validate the DIOCRADDTABLES and DIOCRDELTABLES ioctls with invalid size
values. All of these requests should fail.

MFC after: 1 week

6 years agopf: Improve ioctl validation for DIOCRADDTABLES and DIOCRDELTABLES
kp [Fri, 6 Apr 2018 15:01:45 +0000 (15:01 +0000)]
pf: Improve ioctl validation for DIOCRADDTABLES and DIOCRDELTABLES

The DIOCRADDTABLES and DIOCRDELTABLES ioctls can process a number of
tables at a time, and as such try to allocate <number of tables> *
sizeof(struct pfr_table). This multiplication can overflow. Thanks to
mallocarray() this is not exploitable, but an overflow does panic the
system.

Arbitrarily limit this to 65535 tables. pfctl only ever processes one
table at a time, so it presents no issues there.

MFC after: 1 week

6 years agoLet syslog(3) use RFC 5424.
ed [Fri, 6 Apr 2018 13:00:45 +0000 (13:00 +0000)]
Let syslog(3) use RFC 5424.

With r332099 changing syslogd(8) to parse RFC 5424 formatted syslog
messages, go ahead and also change the syslog(3) libc function to
generate them. Compared to RFC 3164, RFC 5424 has various advantages,
such as sub-second precision for log entry timestamps.

As this change could have adverse effects when not updating syslogd(8)
or using a different system logging daemon, add a notice to UPDATING and
increase __FreeBSD_version.

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

6 years agoAdd RFC 5424 syslog message parsing to syslogd.
ed [Fri, 6 Apr 2018 12:57:01 +0000 (12:57 +0000)]
Add RFC 5424 syslog message parsing to syslogd.

Syslogd currently uses the RFC 3164 format for its log messages.One
limitation of RFC 3164 is that it cannot be used to log entries with
sub-second precision timestamps. One of our users has expressed a desire
for doing this for doing some basic performance measurements.

This change attempts to make a first cut at switching to RFC 5424 based
logging. The first step is to alter syslogd's input path to properly
parse such messages. It alters the logmsg() prototype to match the
fields of RFC 5424. The parsemsg() function is extended to parse both
RFC 3164 and 5424 messages and call into logmsg() accordingly.

Additional changes include:

- Introducing proper parsing of timestamps, so that they can be printed
  in any desired output format. This means we need to infer the year and
  timezone for RFC 3164 timestamps.
- Removing ISKERNEL. This can now be realised by simply providing an
  APP-NAME (== "kernel").
- Extending RFC 3164 parsing to trim off the TAG prefix and using that
  to derive APP-NAME and PROCID.
- Increase MAXLINE. RFC 5424 mentions we should support 2k messages.

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

6 years agoremove GiB/MiB macros from param.h
royger [Fri, 6 Apr 2018 11:20:06 +0000 (11:20 +0000)]
remove GiB/MiB macros from param.h

And instead define them in the files where they are used.

Requested by: bde

6 years agostand: pass --no-rosegment for i386 bits when linking with lld
emaste [Fri, 6 Apr 2018 02:57:58 +0000 (02:57 +0000)]
stand: pass --no-rosegment for i386 bits when linking with lld

btxld does not correctly handle input with other than 2 PT_LOAD
segments.  Passing --no-rosegment lets lld produce output eqivalent to
ld.bfd: 2 PT_LOAD segments and no PT_GNU_RELRO.

PR: 225775
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14956

6 years agoAdd 32-bit compat for ioctls that take struct ifgroupreq.
brooks [Thu, 5 Apr 2018 22:14:55 +0000 (22:14 +0000)]
Add 32-bit compat for ioctls that take struct ifgroupreq.

Use an accessor to access ifgr_group and ifgr_groups.

Use an macro CASE_IOC_IFGROUPREQ(cmd) in place of case statements such
as "case SIOCAIFGROUP:". This avoids poluting the switch statements
with large numbers of #ifdefs.

Reviewed by: kib
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14960