freebsd.git
9 years agoValidate the schema that the PF driver passed to us
rstone [Sun, 1 Mar 2015 00:59:28 +0000 (00:59 +0000)]
Validate the schema that the PF driver passed to us

Differential Revision: https://reviews.freebsd.org/D90
Reviewed by: emaste
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoDocument the interface for defining a configuration schema
rstone [Sun, 1 Mar 2015 00:59:21 +0000 (00:59 +0000)]
Document the interface for defining a configuration schema

Differential Revision: https://reviews.freebsd.org/D89
Reviewed by: wblock, emaste, allanjude
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd an rc.d script to invoke iovctl(8) during boot
rstone [Sun, 1 Mar 2015 00:58:23 +0000 (00:58 +0000)]
Add an rc.d script to invoke iovctl(8) during boot

Differential Revision: https://reviews.freebsd.org/D88
Reviewed by: wblock, emaste, allanjude
MFC after: 1 month
Relnotes: yes
Sponsored by: Sandvine Inc.

9 years agoAdd main() for iovctl and hook iovctl into build
rstone [Sun, 1 Mar 2015 00:52:41 +0000 (00:52 +0000)]
Add main() for iovctl and hook iovctl into build

Differential Revision: https://reviews.freebsd.org/D87
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd functions for parsing the iovctl config file
rstone [Sun, 1 Mar 2015 00:52:34 +0000 (00:52 +0000)]
Add functions for parsing the iovctl config file

Add two functions for parsing the iovctl config file.  The config
file is parsed using libucl[1], which accepts most YAML files and
a superset of JSON.  The first function is an ad-hoc parser that
searches the file for the PF.DEVICE configuration value.  We need
to know that value in order to fetch the schema from the kernel,
and we need the schema in order to be able to fully parse the file.

The second function parses the config file and validates it
against a schema.  This function will exit with an error message
if any validation error occurs.  If it succeeds, the configuration
is returned as an nvlist suitable for passing to the kernel.

[1] https://github.com/vstakhov/libucl

Differential Revision: https://reviews.freebsd.org/D86
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd iovctl functions for validating config
rstone [Sun, 1 Mar 2015 00:52:28 +0000 (00:52 +0000)]
Add iovctl functions for validating config

Add an function to iovctl that validates the configuration against
a schema.  This function is able to assume that the parser has
done most of the validation already and it's only responsible for
applying default VF values specified in the config file, confirming
that all required parameters have been set and that no invalid VF
numbers have been specified.

Differential Revision: https://reviews.freebsd.org/D85
Reviewed by: bcr
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd manpage documenting iovctl config file format.
rstone [Sun, 1 Mar 2015 00:52:21 +0000 (00:52 +0000)]
Add manpage documenting iovctl config file format.

Differential Revision: https://reviews.freebsd.org/D84
Reviewed by: emaste, bcr, wblock
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd a manpage for iovctl(8)
rstone [Sun, 1 Mar 2015 00:52:15 +0000 (00:52 +0000)]
Add a manpage for iovctl(8)

Differential Revision: https://reviews.freebsd.org/D83
Reviewed by: wblock
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoRevert r279454. The new directory didn't get added to svn properly.
rstone [Sun, 1 Mar 2015 00:44:15 +0000 (00:44 +0000)]
Revert r279454.  The new directory didn't get added to svn properly.

Pointy hat to: rstone

9 years agoAdd main() for iovctl and hook iovctl into build
rstone [Sun, 1 Mar 2015 00:41:17 +0000 (00:41 +0000)]
Add main() for iovctl and hook iovctl into build

Differential Revision: https://reviews.freebsd.org/D87
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoPass SR-IOV configuration to kernel using an nvlist
rstone [Sun, 1 Mar 2015 00:40:57 +0000 (00:40 +0000)]
Pass SR-IOV configuration to kernel using an nvlist

Pass all SR-IOV configuration to the kernel using an nvlist.  The
main benefit that this offers is flexibility.  It allows a driver
to accept any number of parameters of any type supported by the
SR-IOV configuration infrastructure with having to make any
changes outside of the driver.

It also offers the user very fine-grained control over the
configuration of the VFs -- if they want, they can have different
configuration applied to every VF.

Differential Revision: https://reviews.freebsd.org/D82
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd function to validate the consistency of SR-IOV config
rstone [Sun, 1 Mar 2015 00:40:51 +0000 (00:40 +0000)]
Add function to validate the consistency of SR-IOV config

Add a function that validates that the user-provided SR-IOV
configuration is valid.  This includes basic checks that the
structure of the configuration is correct (e.g. all required
configuration nodes are present) as well as validating against
a configuration schema.

The schema validation consists of:
 - Ensuring that all required config parameters are present.
 - If the schema defines a default value for a parameter,
   adding the default value if the parameter is not set.
 - Ensuring that no parameters are specified in the config
   that are not defined in the schema.
 - Ensuring that have the correct type defined in the schema.
 - Ensuring that no configuration nodes are present for devices
   that do not exist.  For example, if 2 VFs are configured,
   then we validate that a node called VF-5 does not exist.

Differential Revision: https://reviews.freebsd.org/D81
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd infrastructure for exporting config schema from PF drivers
rstone [Sun, 1 Mar 2015 00:40:42 +0000 (00:40 +0000)]
Add infrastructure for exporting config schema from PF drivers

Differential Revision: https://reviews.freebsd.org/D80
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd interface to destroy SR-IOV VFs
rstone [Sun, 1 Mar 2015 00:40:34 +0000 (00:40 +0000)]
Add interface to destroy SR-IOV VFs

Differential Revision: https://reviews.freebsd.org/D79
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAllocate PCI I/O memory spaces for VFs
rstone [Sun, 1 Mar 2015 00:40:26 +0000 (00:40 +0000)]
Allocate PCI I/O memory spaces for VFs

When creating VFs, we must size each SR-IOV BAR on the PF and
allocate a configuous I/O memory window large enough for every VF.
However, the window only needs to be aligned to a boundary equal
to the size of the window for a single VF.

When a VF attempts to allocate an I/O memory resource, we must
intercept the request in the pci driver and pass it off to the
SR-IOV code, which will allocate the correct window from the
pre-allocated memory space for the PF.

Inform the pci driver about the size and address of the BARs on
the VF when the VF is created.  This is required by pciconf -b and
bhyve.

Differential Revision: https://reviews.freebsd.org/D78
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoEmulate the Device ID and Vendor ID registers for VFs
rstone [Sun, 1 Mar 2015 00:40:19 +0000 (00:40 +0000)]
Emulate the Device ID and Vendor ID registers for VFs

The SR-IOV standard requires VFs to read all-ones when the VID
and DID registers are read.  The VMM (hypervisor) is required to
emulate them instead.  Make pci_read_config() do this emulation.

Change pci_user.c to use pci_read_config() to read config space
registers instead of going directly to the pcib so that the
emulated VID/DID registers work correctly on VFs.  This is
required both for pciconf and bhyve PCI passthrough.

Differential Revision: https://reviews.freebsd.org/D77
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoImplement interface to create SR-IOV Virtual Functions
rstone [Sun, 1 Mar 2015 00:40:09 +0000 (00:40 +0000)]
Implement interface to create SR-IOV Virtual Functions

Implement the interace to create SR-IOV Virtual Functions (VFs).
When a driver registers that they support SR-IOV by calling
pci_setup_iov(), the SR-IOV code creates a new node in /dev/iov
for that device.  An ioctl can be invoked on that device to
create VFs and have the driver initialize them.

At this point, allocating memory I/O windows (BARs) is not
supported.

Differential Revision: https://reviews.freebsd.org/D76
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd manpages for SR-IOV enable/disable driver interface
rstone [Sun, 1 Mar 2015 00:40:01 +0000 (00:40 +0000)]
Add manpages for SR-IOV enable/disable driver interface

Differential Revision: https://reviews.freebsd.org/D75
Reviewed by: wblock
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoDocument pci_iov_attach/detach in pci.9
rstone [Sun, 1 Mar 2015 00:39:55 +0000 (00:39 +0000)]
Document pci_iov_attach/detach in pci.9

Differential Revision: https://reviews.freebsd.org/D74
Reviewed by: bcr, wblock, emaste
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAllow passthrough devices to be hinted.
rstone [Sun, 1 Mar 2015 00:39:48 +0000 (00:39 +0000)]
Allow passthrough devices to be hinted.

Allow the ppt driver to attach to devices that were hinted to be
passthrough devices by the PCI code creating them with a driver
name of "ppt".

Add a tunable that allows the IOMMU to be forced to be used.  With
SR-IOV passthrough devices the VFs may be created after vmm.ko is
loaded.  The current code will not initialize the IOMMU in that
case, meaning that the passthrough devices can't actually be used.

Differential Revision: https://reviews.freebsd.org/D73
Reviewed by: neel
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoAdd some pcib methods to get ARI-related information
rstone [Sun, 1 Mar 2015 00:39:40 +0000 (00:39 +0000)]
Add some pcib methods to get ARI-related information

Differential Revision: https://reviews.freebsd.org/D72
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoRefactor PCI resource allocation
rstone [Sun, 1 Mar 2015 00:39:33 +0000 (00:39 +0000)]
Refactor PCI resource allocation

Refactor PCI resource allocation code to allow a request for a
memory-mapped I/O window that is a multiple of a requested size.
This is needed by the SR-IOV code because the VF BARs are all
allocated contiguously.  We can't just allocate a resource that is
a multiple of a single VF BAR because the size of an allocation
implies its alignment requirement.

Differential Revision: https://reviews.freebsd.org/D71
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoRefactor PCI device creation
rstone [Sun, 1 Mar 2015 00:39:26 +0000 (00:39 +0000)]
Refactor PCI device creation

Refactor creation of PCI devices into helper methods that can be
used by the VF creation code.

Differential Revision: https://reviews.freebsd.org/D67
Reviewed by: jhb
MFC after:  1 month
Sponsored by: Sandvine Inc.

9 years agoFix build of nv_tests.cc
rstone [Sun, 1 Mar 2015 00:37:23 +0000 (00:37 +0000)]
Fix build of nv_tests.cc

nv_tests.cc managed to get two copies of several functions due to me
applying a patch in an unclean working tree.  My kingdom for an
"svn clean" command.

MFC after: 1 month
X-MFC-With: r279424

9 years agoMove libnv into the kernel and hook it into the kernel build
rstone [Sun, 1 Mar 2015 00:34:27 +0000 (00:34 +0000)]
Move libnv into the kernel and hook it into the kernel build

Differential Revision: https://reviews.freebsd.org/D1883
Reviewed by: jfv
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd macros to make code compile in kernel
rstone [Sun, 1 Mar 2015 00:22:53 +0000 (00:22 +0000)]
Add macros to make code compile in kernel

Make it possible to compile libnv in the kernel.  Mostly this
involves wrapping functions that have a different signature in
the kernel and in userland (e.g. malloc()) in a macro that will
conditionally expand to the right API depending on whether the
code is being compiled for the kernel or not.

I have also #ifdef'ed out all of file descriptor-handling code,
as well as the unsafe varargs functions.

Differential Revision: https://reviews.freebsd.org/D1882
Reviewed by: jfv
MFC after: 1 month
Sponsored by: Sandvine Inc

9 years agoAllow Illumos code to co-exist with nv(9)
rstone [Sun, 1 Mar 2015 00:22:45 +0000 (00:22 +0000)]
Allow Illumos code to co-exist with nv(9)

Differential Revision: https://reviews.freebsd.org/D1881
Reviewed by: jfv, will
Suggested by: pjd
MFC after: 1 month
Sponsored by: Sandvine Inc

9 years agoPrevent creation of an invalid nvlist
rstone [Sun, 1 Mar 2015 00:22:38 +0000 (00:22 +0000)]
Prevent creation of an invalid nvlist

If an nvlist is set as a child of another nvlist with
nvlist_move_nvlist then fail the operation and set the parent
nvlist to the error state.

Differential Revision: https://reviews.freebsd.org/D1880
Reviewers: jfv
MFC after: 1 month
Sponsored by: Sandvine Inc

9 years agoDon't allocate memory for operations that do not insert
rstone [Sun, 1 Mar 2015 00:22:31 +0000 (00:22 +0000)]
Don't allocate memory for operations that do not insert

Almost every operation performed on an nvlist was allocating a
new string to hold the key name.  The nvlist_exists* family of
functions would always return false if they failed to allocate
the string.  The rest of the functions would outright abort().
Fix the non-varargs variants of the functions to perform the
requested operations directly and the varargs versions to
allocate the string and call into the non-varargs versions.
The varargs versions are still broken and really can't be fixed,
so we might consider axing them entirely.  However, now the non-
varargs functions are always safe to call.

Differential Revision: https://reviews.freebsd.org/D1879
Reviewed by: pjd, jfv
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd function to force an nvlist into the error state
rstone [Sun, 1 Mar 2015 00:22:23 +0000 (00:22 +0000)]
Add function to force an nvlist into the error state

Add an nvlist_set_error() function that can be used to force an
nvlist into the error state.  This is useful both for writing
tests and for writing APIs that use nvlists internally.

Differential Revision: https://reviews.freebsd.org/D1878
Reviewed by: pjd, jfv
MFC After: 1 month
Sponsored by: Sandvine Inc.

9 years agoImplement asprintf in libkern
rstone [Sun, 1 Mar 2015 00:22:16 +0000 (00:22 +0000)]
Implement asprintf in libkern

Differential Revision: https://reviews.freebsd.org/D1877
Reviewed by: pjd, jfv
MFC After: 1 month
Sponsored by: Sandvine Inc.

9 years agoExtend the unit test to fix the bug caught in r277925
rstone [Sun, 1 Mar 2015 00:22:09 +0000 (00:22 +0000)]
Extend the unit test to fix the bug caught in r277925

Differential Revision: https://reviews.freebsd.org/D1888
MFC After: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for dnvlist_take_*
rstone [Sun, 1 Mar 2015 00:22:03 +0000 (00:22 +0000)]
Add tests for dnvlist_take_*

Differential Revision: https://reviews.freebsd.org/D1876
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for dnv_get_*
rstone [Sun, 1 Mar 2015 00:21:56 +0000 (00:21 +0000)]
Add tests for dnv_get_*

Differential Revision: https://reviews.freebsd.org/D1875
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for nvlist_free* functions
rstone [Sun, 1 Mar 2015 00:21:50 +0000 (00:21 +0000)]
Add tests for nvlist_free* functions

Differential Revision: https://reviews.freebsd.org/D1874
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for nvlist_take_*
rstone [Sun, 1 Mar 2015 00:21:43 +0000 (00:21 +0000)]
Add tests for nvlist_take_*

Differential Revision: https://reviews.freebsd.org/D1873
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd test cases for nvlist_move_*
rstone [Sun, 1 Mar 2015 00:21:37 +0000 (00:21 +0000)]
Add test cases for nvlist_move_*

Differential Revision: https://reviews.freebsd.org/D1872
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for nvlist_pack/unpack
rstone [Sun, 1 Mar 2015 00:21:30 +0000 (00:21 +0000)]
Add tests for nvlist_pack/unpack

Differential Revision: https://reviews.freebsd.org/D1871
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd tests for nvlist_clone
rstone [Sun, 1 Mar 2015 00:21:24 +0000 (00:21 +0000)]
Add tests for nvlist_clone

Differential Revision: https://reviews.freebsd.org/D1870
Reviewed by: pjd, jfv
MFC after: 1 month
Sponsored by: Sandvine Inc

9 years agoTests of basic nvlist add functions
rstone [Sun, 1 Mar 2015 00:20:57 +0000 (00:20 +0000)]
Tests of basic nvlist add functions

Differential Revision: https://reviews.freebsd.org/D1869
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoRevert r279422. My "apply patch and commit" script wasn't adding
rstone [Sun, 1 Mar 2015 00:05:45 +0000 (00:05 +0000)]
Revert r279422.  My "apply patch and commit" script wasn't adding
new files properly.

Pointy hat to: rstone

9 years agoTests of basic nvlist add functions
rstone [Sun, 1 Mar 2015 00:01:44 +0000 (00:01 +0000)]
Tests of basic nvlist add functions

Differential Revision: https://reviews.freebsd.org/D1869
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoMake libnv headers includable from C++
rstone [Sun, 1 Mar 2015 00:01:36 +0000 (00:01 +0000)]
Make libnv headers includable from C++

Differential Revision: https://reviews.freebsd.org/D1868
Reviewed by: jfv, pjd
MFC after: 1 month
Sponsored by: Sandvine Inc.

9 years agoAdd another register definition for the AR8327.
adrian [Sat, 28 Feb 2015 23:59:29 +0000 (23:59 +0000)]
Add another register definition for the AR8327.

Obtained from: OpenWRT

9 years agoRemove the old DTrace test suite makefile - it was somewhat primitive and
markj [Sat, 28 Feb 2015 23:35:29 +0000 (23:35 +0000)]
Remove the old DTrace test suite makefile - it was somewhat primitive and
mostly unmaintained, and it has been superseded by the infrastructure added
in r279418.

Reviewed by: ngie
Sponsored by: EMC / Isilon Storage Divison

9 years agoAdd infrastructure to integrate the DTrace test suite with Kyua.
markj [Sat, 28 Feb 2015 23:30:06 +0000 (23:30 +0000)]
Add infrastructure to integrate the DTrace test suite with Kyua.

For each test category, we generate a script containing ATF test cases for
the tests under that category. Each test case simply runs dtest.pl (the
upstream test harness) with the corresponding test files. The exclude.sh
script is used to record info about tests which should be skipped or are
expected to fail; it is used to generate atf_skip and atf_expect_fail calls.
The genmakefiles.sh script can be used to regenerate the test makefiles when
new tests are brought it from upstream.

The test suite is currently not connected to the build as there is a small
number of lingering test issues which still need to be worked out. In the
meantime however, the test suite can be easily built and installed
manually from cddl/usr.sbin/dtrace/tests.

Reviewed by: ngie
Sponsored by: EMC / Isilon Storage Division

9 years agoUse the -shared option to create a shared library.
markj [Sat, 28 Feb 2015 23:14:35 +0000 (23:14 +0000)]
Use the -shared option to create a shared library.

MFC after: 1 week

9 years agoRemove a leading tab that causes a make(1) error when running the test.
markj [Sat, 28 Feb 2015 23:11:18 +0000 (23:11 +0000)]
Remove a leading tab that causes a make(1) error when running the test.

MFC after: 1 week

9 years agoOnly kill sleep processes that were forked from the test script.
markj [Sat, 28 Feb 2015 23:10:26 +0000 (23:10 +0000)]
Only kill sleep processes that were forked from the test script.

MFC after: 1 week

9 years agoStop hard-coding an incorrect path to rm(1).
markj [Sat, 28 Feb 2015 23:09:01 +0000 (23:09 +0000)]
Stop hard-coding an incorrect path to rm(1).

MFC after: 1 week

9 years agoAdd a missing include of an options header.
rstone [Sat, 28 Feb 2015 22:37:48 +0000 (22:37 +0000)]
Add a missing include of an options header.

watchdog.c does an #ifdef DDB but does not #include "opt_ddb.h".
Fixing this turned up a missing include file.

MFC after: 1 week
X-MFC-With: r261495, r279410

9 years agoDo not leak 'copy' buffer if bmap_truncate_indirect fails.
kan [Sat, 28 Feb 2015 22:24:45 +0000 (22:24 +0000)]
Do not leak 'copy' buffer if bmap_truncate_indirect fails.

Reported by: Brainy Code Scanner, by Maxime Villard.
MFC after: 2 weeks

9 years agoUnbreak 'make depend' with sfxge by removing debugging code activated in the
ngie [Sat, 28 Feb 2015 21:50:04 +0000 (21:50 +0000)]
Unbreak 'make depend' with sfxge by removing debugging code activated in the
INET || INET6 case

X-MFC with: r279398
Pointyhat to: arybchik

9 years agoCorrect the use of an unitialized variable in sendfind_getobj()
rstone [Sat, 28 Feb 2015 21:49:59 +0000 (21:49 +0000)]
Correct the use of an unitialized variable in sendfind_getobj()

When sendfile_getobj() is called on a DTYPE_SHM file, it never
initializes error, which is eventually returned to the caller.

Differential Revision: https://reviews.freebsd.org/D1989
Reviewed by: kib
Reported by:  Brainy Code Scanner, by Maxime Villard.

9 years agoAdd ofw_gpiobus_parse_gpios(), a new public function, to parse the gpios
loos [Sat, 28 Feb 2015 21:01:01 +0000 (21:01 +0000)]
Add ofw_gpiobus_parse_gpios(), a new public function, to parse the gpios
property for devices that doesn't descend directly from gpiobus.

The parser supports multiple pins, different GPIO controllers and can use
arbitrary names for the property (to match the many linux variants:
cd-gpios, power-gpios, wp-gpios, etc.).

Pass the driver name on ofw_gpiobus_add_fdt_child().  Update gpioled to
match.

An usage example of ofw_gpiobus_parse_gpios() will follow soon.

9 years agoSupposed fix for some SandyBridge mobile CPUs hang on AP startup when
kib [Sat, 28 Feb 2015 20:37:38 +0000 (20:37 +0000)]
Supposed fix for some SandyBridge mobile CPUs hang on AP startup when
x2APIC mode is detected and enabled.  Current theory is that switching
the APIC mode while an IPI is in flight might be the issue.

Postpone switching to x2APIC mode until we are guaranteed that all
starting IPIs are already send and aknowledged.  Use aps_ready signal
as an indication that the BSP is done with us.

Tested by: adrian
Sponsored by: The FreeBSD Foundation
MFC after: 2 months

9 years agoAvoid closing unallocated socket in case socreate fails.
kan [Sat, 28 Feb 2015 20:30:29 +0000 (20:30 +0000)]
Avoid closing unallocated socket in case socreate fails.

Found by: Brainy Code Scanner
Reported by: Maxime Villard <max@M00nBSD.net>
MFC after: 2 weeks

9 years agoAvoid lookup of CODESET aliases using uninitialized path
kan [Sat, 28 Feb 2015 20:30:25 +0000 (20:30 +0000)]
Avoid lookup of CODESET aliases using uninitialized path

We do not use iconv.alias file, so avoid using the vestiges
of the code that do.

Differential Revision: https://reviews.freebsd.org/D1729
Reviewed by: emaste
MFC after: 2 weeks

9 years agoRename and move gpiobus_alloc_ivars() and gpiobus_free_ivars() so they can
loos [Sat, 28 Feb 2015 20:02:41 +0000 (20:02 +0000)]
Rename and move gpiobus_alloc_ivars() and gpiobus_free_ivars() so they can
be used on non FDT systems.

This prevents access to uninitialized memory on drivers that try to access
pin flags on non FDT systems.

9 years agoSome fixes for fdescfs lookup code.
kib [Sat, 28 Feb 2015 19:57:22 +0000 (19:57 +0000)]
Some fixes for fdescfs lookup code.

Do not ever return doomed vnode from lookup.  This could happen, if
not checked, since dvp is relocked in the 'looking up ourselves' case.

In the other case, since dvp is relocked, mount point might go away
while fdesc_allocvp() is called.  Prevent the situation by doing
vfs_busy() before unlocking dvp.  Reuse the vn_vget_ino_gen() helper.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

9 years agoEliminate a variable that became unused when VFS_LOCK_GIANT() was
alc [Sat, 28 Feb 2015 19:11:37 +0000 (19:11 +0000)]
Eliminate a variable that became unused when VFS_LOCK_GIANT() was
eliminated.

MFC after: 3 days

9 years agoAdd a driver for the Maxim DS3231 a low-cost, extremely accurate (+-2PPM)
loos [Sat, 28 Feb 2015 19:02:44 +0000 (19:02 +0000)]
Add a driver for the Maxim DS3231 a low-cost, extremely accurate (+-2PPM)
I2C real-time clock (RTC).

The DS3231 has an integrated temperature-compensated crystal oscillator
(TXCO) and crystal.

DS3231 has a temperature sensor, an independent 32kHz output (which can be
turned on and off by the driver) and another output that can be used as
interrupt for alarms or as a second square-wave output, which frequency and
operation mode can be set by driver sysctl(8) knobs.

Differential Revision: https://reviews.freebsd.org/D1016
Reviewed by: ian, rpaulo
Tested on: Raspberry pi model B

9 years agosfxge: compile out LRO if kernel is compiled without IPv4 and IPv6
arybchik [Sat, 28 Feb 2015 19:01:43 +0000 (19:01 +0000)]
sfxge: compile out LRO if kernel is compiled without IPv4 and IPv6

Sponsored by:   Solarflare Communications, Inc.
Approved by:    gnn (mentor)

9 years agonice(): Put back old return value, keeping [EPERM] error.
jilles [Sat, 28 Feb 2015 18:22:10 +0000 (18:22 +0000)]
nice(): Put back old return value, keeping [EPERM] error.

Commit r279154 changed the API and ABI significantly, and {NZERO} is still
wrong.

Also, preserve errno on success instead of setting it to 0.

PR: 189821
Reported by: bde
Relnotes: yes

9 years agoFormat the line properly (wrap before column 80).
ian [Sat, 28 Feb 2015 17:44:31 +0000 (17:44 +0000)]
Format the line properly (wrap before column 80).

9 years agoExport the new osreldate and osrelease jail parms in jail_get(2).
ian [Sat, 28 Feb 2015 17:32:31 +0000 (17:32 +0000)]
Export the new osreldate and osrelease jail parms in jail_get(2).

9 years agonetback: disable GSO
royger [Sat, 28 Feb 2015 15:21:06 +0000 (15:21 +0000)]
netback: disable GSO

The current GSO implementation in netback is broken and causes errors on the
guest tx path. While this is fixed disable GSO in order to have a working
netback.

Sponsored by: Citrix Systems R&D
Discussed with: gibbs

9 years agoPad RX copy alignment calculation to avoid illegal memory accesses
ngie [Sat, 28 Feb 2015 14:57:57 +0000 (14:57 +0000)]
Pad RX copy alignment calculation to avoid illegal memory accesses

The optimization made in r239940 is valid for struct mbuf's current structure
and size in FreeBSD, but hardcodes assumptions about sizes of struct mbuf,
which are unfortunately broken if additional data is added to the beginning of
struct mbuf

X-MFC note (discussed with rwatson):

This change requires the MPKTHSIZE definition, which is only available after
head@r277203 and will not be MFCed as it breaks mbuf(9) KPI.

A direct commit to stable/10 and merges to other branches to add the necessary
definitions to work with the code as-is will be done to facilitate this MFC

PR: 194314
MFC after: 2 weeks
Approved/Reviewed by: erj, jfv
Sponsored by: EMC / Isilon Storage Division

9 years agoMove the "offload" clause from the target section to portal-group
trasz [Sat, 28 Feb 2015 12:02:32 +0000 (12:02 +0000)]
Move the "offload" clause from the target section to portal-group
section; it makes more sense there.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoFix typo (_DP_grom -> _DP_geom) so applications that need to link against
ngie [Sat, 28 Feb 2015 05:14:42 +0000 (05:14 +0000)]
Fix typo (_DP_grom -> _DP_geom) so applications that need to link against
libgeom do so successfully

Tested by running `geom part list` produced from a -DWITHOUT_DYNAMICROOT built
world

PR: 198078
Reported by: Eir Nym <eirnym@gmail.com>

9 years agoThe umtx_lock mutex is used by top-half of the kernel, but is
kib [Sat, 28 Feb 2015 04:19:02 +0000 (04:19 +0000)]
The umtx_lock mutex is used by top-half of the kernel, but is
currently a spin lock.  Apparently, the only reason for this is that
umtx_thread_exit() is called under the process spinlock, which put the
requirement on the umtx_lock.  Note that the witness static order list
is wrong for the umtx_lock, umtx_lock is explicitely before any thread
lock, so it is also before sleepq locks.

Change umtx_lock to be the sleepable mutex.  For the reason above, the
calls to umtx_thread_exit() are moved from thread_exit() earlier in
each caller, when the process spin lock is not yet taken.

Discussed with: jhb
Tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

9 years agoWhitespace fixes for sys/mips/nlm/dev
jchandra [Sat, 28 Feb 2015 00:22:10 +0000 (00:22 +0000)]
Whitespace fixes for sys/mips/nlm/dev

Clean up whitespace issues under sys/mips/nlm/dev. No functional
change in this commit.

9 years agoWhitespace fixes for files in sys/mips/nlm
jchandra [Sat, 28 Feb 2015 00:17:29 +0000 (00:17 +0000)]
Whitespace fixes for files in sys/mips/nlm

Clean up whitespace issues under sys/mips/nlm (except dev). No
functional change in this commit.

9 years agoMerge latest (commit c8c1b3a77934768c7f7a4a9c10140c8bec529059) files
imp [Sat, 28 Feb 2015 00:06:04 +0000 (00:06 +0000)]
Merge latest (commit c8c1b3a77934768c7f7a4a9c10140c8bec529059) files
from the git tree. This merges a lot that we're not using, but there's
too many files to be selective and have a hope of catching everything.
If there are conflicts with the rest of the tree, we'll resolve them
on a case by case basis.

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

9 years agoAdd subclass of simplebus for Broadcom XLP
jchandra [Fri, 27 Feb 2015 23:33:53 +0000 (23:33 +0000)]
Add subclass of simplebus for Broadcom XLP

This will override the resource allocation of simplebus, and also
merge the resource allocation code which was in xlp_pci.c.

With this change the SoC devices that does not have proper PCI
resources will be on the FDT simplebus. We can remove
sys/mips/nlm/dev/cfi_pci_xlp.c and sys/mips/nlm/dev/uart_pci_xlp.c

9 years agoPut back Andy's void for gcc happiness.
imp [Fri, 27 Feb 2015 23:14:08 +0000 (23:14 +0000)]
Put back Andy's void for gcc happiness.

Submitted by: jchandra@

9 years agosys/boot/userboot/libstand/libstand.a should also include strtoul.c;
obrien [Fri, 27 Feb 2015 22:23:35 +0000 (22:23 +0000)]
sys/boot/userboot/libstand/libstand.a should also include strtoul.c;
as lib/libstand/ and sys/boot/libstand32/ already does.

9 years agoUse sys/boot/userboot/libstand/ and not /usr/lib/libstand.a.
obrien [Fri, 27 Feb 2015 22:22:05 +0000 (22:22 +0000)]
Use sys/boot/userboot/libstand/ and not /usr/lib/libstand.a.

9 years agoRemove duplicated -I.
obrien [Fri, 27 Feb 2015 22:20:07 +0000 (22:20 +0000)]
Remove duplicated -I.

9 years agoUpdate r279018 so it only applies to Clang version 3.5+ and not 3.4.[1-9].
obrien [Fri, 27 Feb 2015 22:18:33 +0000 (22:18 +0000)]
Update r279018 so it only applies to Clang version 3.5+ and not 3.4.[1-9].

9 years agoImport from device-tree git://xenbits.xen.org/people/ianc/device-tree-rebasing.git...
imp [Fri, 27 Feb 2015 22:16:54 +0000 (22:16 +0000)]
Import from device-tree git://xenbits.xen.org/people/ianc/device-tree-rebasing.git @c8c1b3a77934768c7f7a4a9c10140c8bec529059

9 years agoThese CTF tools do not use anything from libctf, so no need to link with it.
obrien [Fri, 27 Feb 2015 22:10:31 +0000 (22:10 +0000)]
These CTF tools do not use anything from libctf, so no need to link with it.

9 years agoFix I/O size calculation for pass(4) driver requests and add latency
ken [Fri, 27 Feb 2015 21:35:36 +0000 (21:35 +0000)]
Fix I/O size calculation for pass(4) driver requests and add latency
tracking.

It is important to subtract the residual from the requested
transfer size to see how much data was actually transferred.  With
tape drives in particular, it is common to request more data than is
returned.

Also, add I/O latency tracking for CAM requests issued by
cam_periph_runccb().

If the caller supplies a struct devstat, and the I/O is a SCSI or
ATA I/O, we will track the elapsed time to provide I/O latency
statistics for the request.

sys/cam/scsi/cam_periph.c:
In cam_periph_runccb(), subtract the residual when reporting I/O
totals to devstat(9) for SCSI and ATA passthrough requests.

In cam_periph_runccb(), grab the I/O start time and supply
the start time to devstat_end_transaction() so that it can
calculate the elapsed I/O time.

Sponsored by: Spectra Logic
MFC after: 1 week

9 years agoMake sched_random() return an unsigned number, and use uint32_t
imp [Fri, 27 Feb 2015 21:15:12 +0000 (21:15 +0000)]
Make sched_random() return an unsigned number, and use uint32_t
consistently. This also matches the per-cpu pointer declaration
anyway.

This changes the tweak we give to the load from -32..31 to be 0..31
which seems more inline with the rest of the code (- rnd and the -=
64). It should also provide the randomness we need, and may fix a
signedness bug in the old code (it isn't clear that the effect was
intentional as opposed to sloppy, and the right shift of a signed
value is undefined to boot).

This stores sched_balance() behavior when it used random().

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

9 years agoUse appropriate alternative to -msoft-float for clang-built PowerPC kernels.
nwhitehorn [Fri, 27 Feb 2015 20:32:50 +0000 (20:32 +0000)]
Use appropriate alternative to -msoft-float for clang-built PowerPC kernels.

9 years agoFix unitialized variable.
nwhitehorn [Fri, 27 Feb 2015 20:32:09 +0000 (20:32 +0000)]
Fix unitialized variable.

9 years agoAllow creating subclass of FDT simplebus
jchandra [Fri, 27 Feb 2015 20:11:02 +0000 (20:11 +0000)]
Allow creating subclass of FDT simplebus

Provide sys/dev/fdt/simplebus.h with the class declaration so that it
is possible to subclass FDT simplebus.

Differential Revision: https://reviews.freebsd.org/D1886
Reviewed by: nwhitehorn, imp

9 years agoFix typo. Note that this is mostly innocent, since libthr no longer
kib [Fri, 27 Feb 2015 19:23:01 +0000 (19:23 +0000)]
Fix typo.  Note that this is mostly innocent, since libthr no longer
interposes the symbol.

Noted by: rpaulo
MFC after: 3 days

9 years agoSet altroot if the user have specified it via -o altroot.
delphij [Fri, 27 Feb 2015 19:13:13 +0000 (19:13 +0000)]
Set altroot if the user have specified it via -o altroot.

MFC after: 2 weeks

9 years agoUse m_getjcl() instead of old mbuf(9) KPIs.
glebius [Fri, 27 Feb 2015 19:12:35 +0000 (19:12 +0000)]
Use m_getjcl() instead of old mbuf(9) KPIs.

Tested by: royger

9 years agoWhen a file is executed and the path starts with `/', AT_EXECPATH is set
jkim [Fri, 27 Feb 2015 19:05:23 +0000 (19:05 +0000)]
When a file is executed and the path starts with `/', AT_EXECPATH is set
without any translation.  If the file is a symbolic link, $ORIGIN may not be
expanded to the actual origin.  Use realpath(3) to properly expand $ORIGIN
to its absolute path.

Reviewed by: kib
MFC after: 1 week

9 years agoeui64_line(): plug memory leak.
pfg [Fri, 27 Feb 2015 18:13:06 +0000 (18:13 +0000)]
eui64_line(): plug memory leak.

CID: 978412
Reviewed by: brooks, delphij
CodeReview: https://reviews.freebsd.org/D1976

9 years agoThe VNASSERT in vflush() FORCECLOSE case is trying to panic early to
kib [Fri, 27 Feb 2015 16:43:50 +0000 (16:43 +0000)]
The VNASSERT in vflush() FORCECLOSE case is trying to panic early to
prevent errors from yanking devices out from under filesystems.  Only
care about special vnodes on devfs, special nodes on other kinds of
filesystems do not have special properties.

Sponsored by:  EMC / Isilon Storage Division
Submitted by:   Conrad Meyer
MFC after: 1 week

9 years agoAllow the kern.osrelease and kern.osreldate sysctl values to be set in a
ian [Fri, 27 Feb 2015 16:28:55 +0000 (16:28 +0000)]
Allow the kern.osrelease and kern.osreldate sysctl values to be set in a
jail's creation parameters.  This allows the kernel version to be reliably
spoofed within the jail whether examined directly with sysctl or
indirectly with the uname -r and -K options.

The values can only be set at jail creation time, to eliminate the need
for any locking when accessing the values via sysctl.

The overridden values are inherited by nested jails (unless the config for
the nested jails also overrides the values).

There is no sanity or range checking, other than disallowing an empty
release string or a zero release date, by design.  The system
administrator is trusted to set sane values.  Setting values that are
newer than the actual running kernel will likely cause compatibility
problems.

Differential Revision: https://reviews.freebsd.org/D1948
Relnotes: yes

9 years agoDetect, report and use 8-bit bus if is available.
ian [Fri, 27 Feb 2015 15:47:30 +0000 (15:47 +0000)]
Detect, report and use 8-bit bus if is available.

Differential Revision: https://reviews.freebsd.org/D1921
Submitted by: Michal Meloun

9 years agoMMC: Signal HC capability to (e)MMC.
ian [Fri, 27 Feb 2015 15:14:25 +0000 (15:14 +0000)]
MMC: Signal HC capability to (e)MMC.

Summary:
For new eMMC chips, we must signal controller HC capability in OP_COND command.

Reviewers: imp, ian

Reviewed By: ian

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

9 years agoFix sched_ule on sparc64, gcc complains sched_random is not a correct
andrew [Fri, 27 Feb 2015 15:05:20 +0000 (15:05 +0000)]
Fix sched_ule on sparc64, gcc complains sched_random is not a correct
prototype.

Sponsored by: The FreeBSD Foundation

9 years agoRemove SMP support from the Wandboard-Solo and have it run as part of
andrew [Fri, 27 Feb 2015 12:40:44 +0000 (12:40 +0000)]
Remove SMP support from the Wandboard-Solo and have it run as part of
universe as a config with sched_ule but without SMP.

Sponsored by: The FreeBSD Foundation

9 years agosched_random is only called for SMP, only define it there.
andrew [Fri, 27 Feb 2015 12:38:24 +0000 (12:38 +0000)]
sched_random is only called for SMP, only define it there.

Sponsored by: The FreeBSD Foundation

9 years agoSince all generations of Intel CPUs have errata which causes hang on
kib [Fri, 27 Feb 2015 11:13:46 +0000 (11:13 +0000)]
Since all generations of Intel CPUs have errata which causes hang on
the cache line flush in the LAPIC page, keep direct map page covering
LAPIC mapped uncached.

To have the (incomplete) check for the LAPIC range in
pmap_invalidate_cache_range() working, lapic_paddr must be initialized
in x2APIC mode too.

Sponsored by: The FreeBSD Foundation
MFC after: 2 months