]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agolib: further adoption of SPDX licensing ID tags.
pfg [Sun, 26 Nov 2017 02:00:33 +0000 (02:00 +0000)]
lib: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

6 years agoRemove some, but not all, assumptions that the BSP is CPU 0 and that CPUs
nwhitehorn [Sat, 25 Nov 2017 23:41:05 +0000 (23:41 +0000)]
Remove some, but not all, assumptions that the BSP is CPU 0 and that CPUs
are numbered densely from there to n_cpus.

MFC after: 1 month

6 years agoAvoid assumptions about the BSP being CPU 0.
nwhitehorn [Sat, 25 Nov 2017 23:23:24 +0000 (23:23 +0000)]
Avoid assumptions about the BSP being CPU 0.

MFC after: 3 weeks

6 years agoOn AIM systems, it is not actually possible to stop the CPU timer, so we
nwhitehorn [Sat, 25 Nov 2017 22:43:52 +0000 (22:43 +0000)]
On AIM systems, it is not actually possible to stop the CPU timer, so we
just set it to a large default value (and inherit any previously existing
value), hoping it never turns over. Instead, silently allow spurious
one-shots from rollovers.

MFC after: 10 days

6 years agoReturn base IRQ of PIC when added and massively increase the number of
nwhitehorn [Sat, 25 Nov 2017 22:42:05 +0000 (22:42 +0000)]
Return base IRQ of PIC when added and massively increase the number of
available IRQs per PIC for large systems.

MFC after: 3 weeks

6 years agoMissed gate on __powerpc64__ for setting LPCR in r326207.
nwhitehorn [Sat, 25 Nov 2017 22:15:56 +0000 (22:15 +0000)]
Missed gate on __powerpc64__ for setting LPCR in r326207.

MFC after: 3 weeks
X-MFC-with: r326207

6 years agoWhen booting from an FDT, make sure the FDT itself isn't included the range
nwhitehorn [Sat, 25 Nov 2017 22:14:30 +0000 (22:14 +0000)]
When booting from an FDT, make sure the FDT itself isn't included the range
of available memory. Boot loaders are supposed to add a reserved entry for
it, but not all do.

MFC after: 2 weeks

6 years agoAllow platform modules to set the size of large pizes, as potentially
nwhitehorn [Sat, 25 Nov 2017 22:13:19 +0000 (22:13 +0000)]
Allow platform modules to set the size of large pizes, as potentially
discovered from firmware, and better handle highly-discontiguous memory
and CPU maps.

MFC after: 3 weeks

6 years agoInvalidate TLB at boot using the correct IS settings on newer-than-POWER5
nwhitehorn [Sat, 25 Nov 2017 22:10:10 +0000 (22:10 +0000)]
Invalidate TLB at boot using the correct IS settings on newer-than-POWER5
CPUs.

MFC after: 3 weeks

6 years agoDefinitions for registers and trap types found on new POWER CPUs.
nwhitehorn [Sat, 25 Nov 2017 22:08:40 +0000 (22:08 +0000)]
Definitions for registers and trap types found on new POWER CPUs.

MFC after: 3 weeks

6 years agoMissed platform_smp_timebase_sync() in r326205.
nwhitehorn [Sat, 25 Nov 2017 22:06:40 +0000 (22:06 +0000)]
Missed platform_smp_timebase_sync() in r326205.

MFC after: 3 weeks
X-MFC-With: r326205

6 years agoMake n_slbs public in a more straightforward way. Some platforms (like
nwhitehorn [Sat, 25 Nov 2017 22:05:05 +0000 (22:05 +0000)]
Make n_slbs public in a more straightforward way. Some platforms (like
PowerNV) use firmware-assisted mechanisms to discover it and need access
to the variable.

MFC after: 3 weeks

6 years agoPreserve the LPCR on new-ish (POWER7 and POWER8) CPUs, preventing exceptions
nwhitehorn [Sat, 25 Nov 2017 22:03:25 +0000 (22:03 +0000)]
Preserve the LPCR on new-ish (POWER7 and POWER8) CPUs, preventing exceptions
and such from ending on the wrong CPU on SMP systems. It would be good to
have this be more generic somehow as POWER9s appear, but PPC does not
have features bits, unfortunately.

MFC after: 3 weeks

6 years agoYield while spinning on APs and avoid announcing all CPUs unless bootverbose
nwhitehorn [Sat, 25 Nov 2017 22:01:55 +0000 (22:01 +0000)]
Yield while spinning on APs and avoid announcing all CPUs unless bootverbose
is set. These improve startup performance on massively multithreaded systems
with 8-way SMT and dozens to hundreds of CPUs.

MFC after: 3 weeks

6 years agoWhether you can use mttb() or not is more complicated than whether PSL_HV
nwhitehorn [Sat, 25 Nov 2017 21:59:59 +0000 (21:59 +0000)]
Whether you can use mttb() or not is more complicated than whether PSL_HV
is set and the right thing to do may be platform-dependent (it requires
firmware on PowerNV, for instance). Make it a new platform method called
platform_smp_timebase_sync().

MFC after: 3 weeks

6 years agoDo not bind to CPUs with SMT, which use a different CPU numbering convention
nwhitehorn [Sat, 25 Nov 2017 21:46:51 +0000 (21:46 +0000)]
Do not bind to CPUs with SMT, which use a different CPU numbering convention
that does not play well with this driver.

MFC after: 2 weeks

6 years agoAvoid emitting a PT_INTERP section for powerpc64 kernels and arrange for
nwhitehorn [Sat, 25 Nov 2017 21:45:51 +0000 (21:45 +0000)]
Avoid emitting a PT_INTERP section for powerpc64 kernels and arrange for
the first instruction to be at the start of the text segment. This allows
the kernel to be booted correctly by stock kexec-lite.

MFC after: 2 weeks

6 years agoAutomatically use the ELFv2 ABI on powerpc64 if supported by the compiler.
nwhitehorn [Sat, 25 Nov 2017 21:44:23 +0000 (21:44 +0000)]
Automatically use the ELFv2 ABI on powerpc64 if supported by the compiler.
This has the same effects on DDB working as -mcall=aixdesc, but also is
supported by clang and marginally improves kernel performance.

MFC after: 2 weeks

6 years agoAdd the missing lockstat check for thread lock.
mjg [Sat, 25 Nov 2017 20:49:27 +0000 (20:49 +0000)]
Add the missing lockstat check for thread lock.

6 years agoConvert in-kernel thread_lock_flags calls to thread_lock when debug is disabled
mjg [Sat, 25 Nov 2017 20:37:13 +0000 (20:37 +0000)]
Convert in-kernel thread_lock_flags calls to thread_lock when debug is disabled

The flags argument is not used in this case.

6 years agorwlock: fix up compilation of the previous change
mjg [Sat, 25 Nov 2017 20:25:45 +0000 (20:25 +0000)]
rwlock: fix up compilation of the previous change

commmitted wrong version of the patch

6 years agorwlock: add __rw_try_{r,w}lock_int
mjg [Sat, 25 Nov 2017 20:22:51 +0000 (20:22 +0000)]
rwlock: add __rw_try_{r,w}lock_int

6 years agosx: change sunlock to wake waiters up if it locked sleepq
mjg [Sat, 25 Nov 2017 20:13:50 +0000 (20:13 +0000)]
sx: change sunlock to wake waiters up if it locked sleepq

sleepq is only locked if the curhtread is the last reader. By the time
the lock gets acquired new ones could have arrived. The previous code
would unlock and loop back. This results spurious relocking of sleepq.

This is a step towards xadd-based unlock routine.

6 years agolocks: retry turnstile/sleepq loops on failed cmpset
mjg [Sat, 25 Nov 2017 20:10:33 +0000 (20:10 +0000)]
locks: retry turnstile/sleepq loops on failed cmpset

In order to go to sleep threads set waiter flags, but that can spuriously
fail e.g. when a new reader arrives. Instead of unlocking everything and
looping back, re-evaluate the new state while still holding the lock necessary
to go to sleep.

6 years agorwlock: stop re-reading the owner when going to sleep
mjg [Sat, 25 Nov 2017 20:08:11 +0000 (20:08 +0000)]
rwlock: stop re-reading the owner when going to sleep

6 years agolibc: further adoption of SPDX licensing ID tags.
pfg [Sat, 25 Nov 2017 17:12:48 +0000 (17:12 +0000)]
libc: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

6 years agoinclude: General further adoption of SPDX licensing ID tags.
pfg [Sat, 25 Nov 2017 17:09:43 +0000 (17:09 +0000)]
include: General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

6 years agoAllwinner a83t: enable USB support
kevans [Sat, 25 Nov 2017 16:46:35 +0000 (16:46 +0000)]
Allwinner a83t: enable USB support

Originally a patch by Mark Millard, augmented with information from work
done on NetBSD by jmcneill@.

Submitted by: Mark Millard (markmi@dsl-only.net)
Reviewed by: emaste, manu
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D13240

6 years agoAdd r-ccu support for the Allwinner a83t
kevans [Sat, 25 Nov 2017 15:14:40 +0000 (15:14 +0000)]
Add r-ccu support for the Allwinner a83t

The r-ccu on the a83t differs from the others only by what it names the
ar100 parents. Export the _CCU macros (now converted to an enu) so that
ccu_sun8i_r can differentiate between a83t r-ccu and the others, then add
the compat string for the a83t r-ccu.

Reviewed by: manu
Approved by: emaste (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D13206

6 years agozdb: follow-up to r326150, check if malloc succeeded
avg [Sat, 25 Nov 2017 09:47:31 +0000 (09:47 +0000)]
zdb: follow-up to r326150, check if malloc succeeded

Reported by: rpokala
MFC after: 1 week
X-MFC with: r326150

6 years agoSlightly fix bidirectional stream number allocation.
mav [Sat, 25 Nov 2017 09:42:14 +0000 (09:42 +0000)]
Slightly fix bidirectional stream number allocation.

This logic is still imperfect, since it allows at most 15 bidirectional
streams out of 30 allowed by specification, but at least now those should
work better.  On the other side I don't remember I ever saw controller
supporting the bidirectional streams, so this is likely a nop change.

MFC after: 1 month

6 years agoSet errno to EFTYPE instead of EINVAL to be more consistent with the
delphij [Sat, 25 Nov 2017 09:03:38 +0000 (09:03 +0000)]
Set errno to EFTYPE instead of EINVAL to be more consistent with the
rest of code.

MFC after: 1 month

6 years agoDecode kevent structures logged via ktrace(2) in kdump.
jhb [Sat, 25 Nov 2017 04:49:12 +0000 (04:49 +0000)]
Decode kevent structures logged via ktrace(2) in kdump.

- Add a new KTR_STRUCT_ARRAY ktrace record type which dumps an array of
  structures.

  The structure name in the record payload is preceded by a size_t
  containing the size of the individual structures.  Use this to
  replace the previous code that dumped the kevent arrays dumped for
  kevent().  kdump is now able to decode the kevent structures rather
  than dumping their contents via a hexdump.

  One change from before is that the 'changes' and 'events' arrays are
  not marked with separate 'read' and 'write' annotations in kdump
  output.  Instead, the first array is the 'changes' array, and the
  second array (only present if kevent doesn't fail with an error) is
  the 'events' array.  For kevent(), empty arrays are denoted by an
  entry with an array containing zero entries rather than no record.

- Move kevent decoding tables from truss to libsysdecode.

  This adds three new functions to decode members of struct kevent:
  sysdecode_kevent_filter, sysdecode_kevent_flags, and
  sysdecode_kevent_fflags.

  kdump uses these helper functions to pretty-print kevent fields.

- Move structure definitions for freebsd11 and freebsd32 kevent
  structures to <sys/event.h> so that they can be shared with userland.
  The 32-bit structures are only exposed if _WANT_KEVENT32 is defined.
  The freebsd11 structures are only exposed if _WANT_FREEBSD11_KEVENT is
  defined.  The 32-bit freebsd11 structure requires both.

- Decode freebsd11 kevent structures in truss for the compat11.kevent()
  system call.

- Log 32-bit kevent structures via ktrace for 32-bit compat kevent()
  system calls.

- While here, constify the 'void *data' argument to ktrstruct().

Reviewed by: kib (earlier version)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D12470

6 years agoAdd stdio.h to the synopsis for sysdecode functions that take a FILE *.
jhb [Sat, 25 Nov 2017 03:59:36 +0000 (03:59 +0000)]
Add stdio.h to the synopsis for sysdecode functions that take a FILE *.

6 years agoModify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems to pass a
nwhitehorn [Fri, 24 Nov 2017 23:41:04 +0000 (23:41 +0000)]
Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems to pass a
magic number to the kernel in r7 rather than the (currently unused and
irrelevant) width of the metadata pointer, which I believe was intended
for a never-used approach to the 64-bit port. This enables the kernel,
in a future commit, to switch on the cookie to distinguish a real
metadata pointer from loader(8) from garbage left in r6 by some other
boot loader.

MFC after: 3 weeks

6 years agoCompile one of the uctf test programs with -m32.
markj [Fri, 24 Nov 2017 19:57:13 +0000 (19:57 +0000)]
Compile one of the uctf test programs with -m32.

The err.user64mode.ksh test expects it to run as a 32-bit process.

MFC after: 1 week

6 years agoFix SPDX line as suggested by pfg
tuexen [Fri, 24 Nov 2017 19:38:59 +0000 (19:38 +0000)]
Fix SPDX line as suggested by pfg

6 years agoTemporarily disable VIMAGE on arm64
emaste [Fri, 24 Nov 2017 19:21:21 +0000 (19:21 +0000)]
Temporarily disable VIMAGE on arm64

Loading a kernel module with a static VNET_DEFINE'd variable (e.g.
if_lagg) currently results in a kernel panic.

PR: 223670

6 years agoDon't redefine _KERNEL.
markj [Fri, 24 Nov 2017 19:08:54 +0000 (19:08 +0000)]
Don't redefine _KERNEL.

MFC after: 1 week

6 years agoFix the type signature for sx(9) DTrace subroutines.
markj [Fri, 24 Nov 2017 19:05:45 +0000 (19:05 +0000)]
Fix the type signature for sx(9) DTrace subroutines.

MFC after: 1 week

6 years agoHave lockstat:::sx-release fire only after the lock state has changed.
markj [Fri, 24 Nov 2017 19:04:31 +0000 (19:04 +0000)]
Have lockstat:::sx-release fire only after the lock state has changed.

MFC after: 1 week

6 years agoAdd a missing lockstat:::sx-downgrade probe.
markj [Fri, 24 Nov 2017 19:02:06 +0000 (19:02 +0000)]
Add a missing lockstat:::sx-downgrade probe.

We were returning without firing the probe when the lock had no shared
waiters.

MFC after: 1 week

6 years agobhnd(4): Add missing dependency on ofw_bus_if.h
landonf [Fri, 24 Nov 2017 19:01:14 +0000 (19:01 +0000)]
bhnd(4): Add missing dependency on ofw_bus_if.h

Reported by: wma
Approved by: adrian (mentor, implicit)

6 years agoFix typos.
markj [Fri, 24 Nov 2017 17:57:00 +0000 (17:57 +0000)]
Fix typos.

MFC after: 3 days

6 years agoAdd new ports committer jwb
jwb [Fri, 24 Nov 2017 16:54:25 +0000 (16:54 +0000)]
Add new ports committer jwb

Approved by:    jrm

6 years agoSwitch the default firmware for npe(4) from the QOS_VLAN one to the
nwhitehorn [Fri, 24 Nov 2017 15:48:17 +0000 (15:48 +0000)]
Switch the default firmware for npe(4) from the QOS_VLAN one to the
plain-vanilla ETH microcode. The QOS_VLAN firmware added support in microcode
for handling IEEE 802.1q tags, but the npe(4) driver did not actually
support the relevant signalling. As a result, it was impossible to use
VLANs with npe(4). Switching to the more basic microcode (same license)
removes the on-NIC promisisng and makes vlan(4) work on both NPE interfaces.

Ref: https://lists.freebsd.org/pipermail/freebsd-arm/2012-August/003826.html

6 years agoRoCE/infiniband upgrade to Linux v4.9 for kernel and userspace.
hselasky [Fri, 24 Nov 2017 14:50:28 +0000 (14:50 +0000)]
RoCE/infiniband upgrade to Linux v4.9 for kernel and userspace.

This commit merges projects/bsd_rdma_4_9 to head.

List of kernel sources used:
============================

1) kernel sources were cloned from git://github.com/torvalds/linux.git
Top commit 69973b830859bc6529a7a0468ba0d80ee5117826 - tag: v4.9, linux-4.9

2) krping was cloned from https://github.com/larrystevenwise/krping
Top commit 292a2f1abf0348285e678a82264740d52e4dcfe4

List of userspace sources used:
===============================

1) rdma-core was cloned from https://github.com/linux-rdma/rdma-core.git
Top commit d65138ef93af30b3ea249f3a84aa6a24ba7f8a75

2) OpenSM was cloned from git://git.openfabrics.org/~halr/opensm.git
Top commit 85f841cf209f791c89a075048a907020e924528d

3) libibmad was cloned from git://git.openfabrics.org/~iraweiny/libibmad.git
Tag 1.3.13 with some additional patches from Mellanox.

4) infiniband-diags was cloned from git://git.openfabrics.org/~iraweiny/infiniband-diags.git
Tag 1.6.7 with some additional patches from Mellanox.

NOTES:
======

1) The mthca driver has been removed in kernel and in userspace.
2) All GPLv2 only sources have been removed and where applicable
   rewritten from scratch under a BSD license.
3) List of fully supported drivers in userspace and kernel:
   a) iw_cxgbe (Chelsio)
   b) mlx4ib (Mellanox)
   c) mlx5ib (Mellanox)
4) WITH_OFED=YES is still required by make in order to build
   OFED userspace and kernel code.
5) Full support has been added for routable RoCE, RoCE v2.

Sponsored by: Mellanox Technologies

6 years agoFix for multi-threaded lib32 compat build on amd64.
hselasky [Fri, 24 Nov 2017 14:29:32 +0000 (14:29 +0000)]
Fix for multi-threaded lib32 compat build on amd64.

Sponsored by: Mellanox Technologies

6 years agoPick the right vDSO file/linker flags when building cloudabi32.ko on ARM64.
ed [Fri, 24 Nov 2017 14:02:32 +0000 (14:02 +0000)]
Pick the right vDSO file/linker flags when building cloudabi32.ko on ARM64.

The recently imported cloudabi_vdso_armv6_on_64bit.S should be the vDSO
for 32-bit processes when being run on FreeBSD/arm64. This vDSO ensures
that all system call arguments are padded to 64 bits, so that they can
be used by the kernel to call into most of the native implementations
directly.

6 years agoSet CP15BEN in SCTLR to make memory barriers work in 32-bit mode.
ed [Fri, 24 Nov 2017 13:51:59 +0000 (13:51 +0000)]
Set CP15BEN in SCTLR to make memory barriers work in 32-bit mode.

Binaries generated by Clang for ARMv6 may contain these instructions:

  MCR p15, 0, <Rd>, c7, c10, 5

These instructions are deprecated as of ARMv7, which is why modern
processors have a way of toggling support for them. On FreeBSD/arm64 we
currently disable support for these instructions, meaning that if 32-bit
executables with these instructions are run, they would crash with
SIGILL. This is likely not what we want.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D13145

6 years agoAdd rudimentary support for building FreeBSD/arm64 with COMPAT_FREEBSD32.
ed [Fri, 24 Nov 2017 13:50:53 +0000 (13:50 +0000)]
Add rudimentary support for building FreeBSD/arm64 with COMPAT_FREEBSD32.

Right now I'm using two Raspberry Pi's (2 and 3) to test CloudABI
support for armv6, armv7 and aarch64. It would be nice if I could
restrict this to just a single instance when testing smaller changes.
This is why I'd like to get COMPAT_CLOUDABI32 to work on arm64.

As COMPAT_CLOUDABI32 depends on COMPAT_FREEBSD32, at least for the ELF
loading, this change adds all of the bits necessary to at least build a
kernel with COMPAT_FREEBSD32. All of the machine dependent system calls
are still stubbed out, for the reason that implementations for these are
only useful if actual support for running FreeBSD binaries is added.
This is outside the scope of this work.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D13144

6 years agoUnbreak compilation when using SCTP_DETAILED_STR_STATS option.
tuexen [Fri, 24 Nov 2017 12:18:48 +0000 (12:18 +0000)]
Unbreak compilation when using SCTP_DETAILED_STR_STATS option.

MFC after: 1 week

6 years agoMerge ^/head r326132 through r326161.
hselasky [Fri, 24 Nov 2017 12:13:27 +0000 (12:13 +0000)]
Merge ^/head r326132 through r326161.

6 years agoImplement atomic_fetchadd_64() for i386. This function is needed by the
hselasky [Fri, 24 Nov 2017 12:10:42 +0000 (12:10 +0000)]
Implement atomic_fetchadd_64() for i386. This function is needed by the
atomic64 header file in the LinuxKPI for i386.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoCompile fixes for 32-bit architectures.
hselasky [Fri, 24 Nov 2017 12:08:50 +0000 (12:08 +0000)]
Compile fixes for 32-bit architectures.

Sponsored by: Mellanox Technologies

6 years agoCompile fix for LINT-NOIP kernel target.
hselasky [Fri, 24 Nov 2017 12:05:49 +0000 (12:05 +0000)]
Compile fix for LINT-NOIP kernel target.

Sponsored by: Mellanox Technologies

6 years agoamd-vi: a small whitespace cleanup
avg [Fri, 24 Nov 2017 11:37:41 +0000 (11:37 +0000)]
amd-vi: a small whitespace cleanup

Reviewed by: anish

6 years agoamd-vi: use correct type for pci_rid, start_dev_rid, end_dev_rid sysctls
avg [Fri, 24 Nov 2017 11:36:35 +0000 (11:36 +0000)]
amd-vi: use correct type for pci_rid, start_dev_rid, end_dev_rid sysctls

Previously, the values could look confusing because of unrelated bits from
adjacent memory.

Reviewed by: anish

6 years agoamd-vi: small improvements to event printing
avg [Fri, 24 Nov 2017 11:35:43 +0000 (11:35 +0000)]
amd-vi: small improvements to event printing

Ensure that an opening bracket always has a matching closing one.
Ensure that there is always a new-line at the end of a report line.
Also, add a space before the printed event flag.

Reviewed by: anish

6 years agoamd-vi: print some additional details for INVALID_DEVICE_REQUEST event
avg [Fri, 24 Nov 2017 11:34:46 +0000 (11:34 +0000)]
amd-vi: print some additional details for INVALID_DEVICE_REQUEST event

Namely, the type of the hardware event and whether the transaction
was a translation request.

Reviewed by: anish

6 years agoAdd SPDX line.
tuexen [Fri, 24 Nov 2017 11:25:53 +0000 (11:25 +0000)]
Add SPDX line.

6 years agoamd-vi: fix up r326152, the new width requires a wider type
avg [Fri, 24 Nov 2017 11:25:06 +0000 (11:25 +0000)]
amd-vi: fix up r326152, the new width requires a wider type

This is my brain-o from extending the width at the last moment.

6 years agoamd-vi: fix and extend definition of Command and Event Status Register (0x2020)
avg [Fri, 24 Nov 2017 11:20:10 +0000 (11:20 +0000)]
amd-vi: fix and extend definition of Command and Event Status Register (0x2020)

The defined bits are the lower bits, not the higher ones.

Also, the specification has been extended to define bits 0:18 and they
all could potentially be interesting to us, so extend the width of the
field accordingly.

Reviewed by: anish

6 years agovmm/amd: improve iteration over IVHD (type 10h) entries in IVRS table
avg [Fri, 24 Nov 2017 11:10:36 +0000 (11:10 +0000)]
vmm/amd: improve iteration over IVHD (type 10h) entries in IVRS table

Many 8-byte entries have zero at byte 4, so the second 4-byte part is
skipped as a 4-byte padding entry.  But not all 8-byte entries have that
property and they get misinterpreted.

A real example:
    48 00 00 00 ff 01 00 01
This an 8-byte ACPI_IVRS_TYPE_SPECIAL entry for IOAPIC with ID 255 (bogus).
It is reported as:
    ivhd0: Unknown dev entry:0xff
Fortunately, it was completely harmless.

Also, bail out early if we encounter an entry of a variable length type.
We do not have proper handling for those yet.

Reviewed by: anish

6 years agozdb: use a heap allocation instead of a huge array on stack
avg [Fri, 24 Nov 2017 10:45:33 +0000 (10:45 +0000)]
zdb: use a heap allocation instead of a huge array on stack

SPA_MAXBLOCKSIZE is 16 MB and having such a large object on the stack is
not nice in general and it could cause some confusing failures in the
single-user mode where the default stack size of 8 MB is used.

I expect that the upstream would make the same change.

MFC after: 1 week

6 years agoMake sure all tasks are cancelled synchronously in ipoib to avoid
hselasky [Fri, 24 Nov 2017 09:55:20 +0000 (09:55 +0000)]
Make sure all tasks are cancelled synchronously in ipoib to avoid
use after free.

Sponsored by: Mellanox Technologies

6 years agoBuild fix for ipoib when CONFIG_INFINIBAND_IPOIB_CM is defined.
hselasky [Fri, 24 Nov 2017 09:52:56 +0000 (09:52 +0000)]
Build fix for ipoib when CONFIG_INFINIBAND_IPOIB_CM is defined.

Sponsored by: Mellanox Technologies

6 years agoBuild fix for kernel LINT target.
hselasky [Fri, 24 Nov 2017 09:12:13 +0000 (09:12 +0000)]
Build fix for kernel LINT target.

Sponsored by: Mellanox Technologies

6 years agoSimplify the build dependencies when building the OFED libraries.
hselasky [Fri, 24 Nov 2017 09:01:08 +0000 (09:01 +0000)]
Simplify the build dependencies when building the OFED libraries.

Suggested by: bdrewery@
Sponsored by: Mellanox Technologies

6 years agoDon't let cpu_set_syscall_retval() clobber exec_setregs().
ed [Fri, 24 Nov 2017 07:35:08 +0000 (07:35 +0000)]
Don't let cpu_set_syscall_retval() clobber exec_setregs().

Upon successful completion, the execve() system call invokes
exec_setregs() to initialize the registers of the initial thread of the
newly executed process. What is weird is that when execve() returns, it
still goes through the normal system call return path, clobbering the
registers with the system call's return value (td->td_retval).

Though this doesn't seem to be problematic for x86 most of the times (as
the value of eax/rax doesn't matter upon startup), this can be pretty
frustrating for architectures where function argument and return
registers overlap (e.g., ARM). On these systems, exec_setregs() also
needs to initialize td_retval.

Even worse are architectures where cpu_set_syscall_retval() sets
registers to values not derived from td_retval. On these architectures,
there is no way cpu_set_syscall_retval() can set registers to the way it
wants them to be upon the start of execution.

To get rid of this madness, let sys_execve() return EJUSTRETURN. This
will cause cpu_set_syscall_retval() to leave registers intact. This
makes process execution easier to understand. It also eliminates the
difference between execution of the initial process and successive ones.
The initial call to sys_execve() is not performed through a system call
context.

Reviewed by: kib, jhibbits
Differential Revision: https://reviews.freebsd.org/D13180

6 years agoMark the func pointer as __dead2. It looks up loader_main, which
imp [Fri, 24 Nov 2017 05:01:00 +0000 (05:01 +0000)]
Mark the func pointer as __dead2. It looks up loader_main, which
either aborts or exits, but never returns. Tag it as a non-returning
function rather than supply a bogus return(0) at the end of main.

CID: 1382885
Sponsored by: Netflix

6 years agoFix theoretical integer overflow issues. If the product here is
imp [Fri, 24 Nov 2017 05:00:25 +0000 (05:00 +0000)]
Fix theoretical integer overflow issues. If the product here is
greater than 2^31-1, then the result will be huge. This is unlikely,
as we don't support that many sections, but out of an abundace of
caution cast to size_t so the multiplication won't overflow
mysteriously when size_t is larger than 32-bits. The resulting code
may be a smidge larger, but this isn't super-space critical code.

CID: 119421611942171194222119422312650181265019,1265020,
     1265021
Sponsored by: Netflix

6 years agoAdd ccu compat string for Allwinner a83t
kevans [Fri, 24 Nov 2017 02:39:38 +0000 (02:39 +0000)]
Add ccu compat string for Allwinner a83t

A ccu driver was added for the a83t in r326114. Add compat string to
aw_ccung and register the clocks for the a83t upon attach.

Reviewed by: manu
Approved by: emaste (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D13205

6 years agovmrun.sh: add -A option for AHCI emulation of disk devices
avg [Thu, 23 Nov 2017 22:10:12 +0000 (22:10 +0000)]
vmrun.sh: add -A option for AHCI emulation of disk devices

AHCI emulation is useful for testing scenarios closer to the real
hardware.  For example, it allows to exercise the CAM subsystem.
There could be other uses as well.

MFC after: 2 weeks

6 years agovmstat: use 64-bit counters from struct vmtotal.
kib [Thu, 23 Nov 2017 19:10:09 +0000 (19:10 +0000)]
vmstat: use 64-bit counters from struct vmtotal.

Consistently print counters using unsigned intmax type.

Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd.
Differential revision: https://reviews.freebsd.org/D13199

6 years agoUse C standard spelling uint64_t for u_int64_t.
kib [Thu, 23 Nov 2017 19:06:44 +0000 (19:06 +0000)]
Use C standard spelling uint64_t for u_int64_t.

Submitted by: Pawel Biernacki <pawel.biernacki@gmail.com>
Sponsored by: Mysterious Code Ltd.
X-Differential revision: https://reviews.freebsd.org/D13199

6 years agoEnsure we check the program state set in the trap frame on arm and arm64.
andrew [Thu, 23 Nov 2017 17:40:40 +0000 (17:40 +0000)]
Ensure we check the program state set in the trap frame on arm and arm64.
This value may be set by userspace so we need to check it before using it.
If this is not done correctly on exception return the kernel may continue
in kernel mode with all registers set to a userspace controlled value. Fix
this by moving the check into set_mcontext, and also add the missing
sanitisation from the arm64 set_regs.

Discussed with: security-officer@
MFC after: 3 days
Sponsored by: DARPA, AFRL

6 years agobfd: avoid crash on corrupt binaries
emaste [Thu, 23 Nov 2017 16:04:52 +0000 (16:04 +0000)]
bfd: avoid crash on corrupt binaries

From binutils commits 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 and
7e1e19887abd24aeb15066b141cdff5541e0ec8e, made available under GPLv2
by Nick Clifton.

PR: 198824
MFC after: 1 week
Security: CVE-2014-8501
Security: CVE-2014-8502

6 years agobfd: fix segfault in the ihex parser on malformed ihex file
emaste [Thu, 23 Nov 2017 14:30:41 +0000 (14:30 +0000)]
bfd: fix segfault in the ihex parser on malformed ihex file

From binutils commit 0102ea8cec5fc509bba6c91df61b7ce23a799d32, made
available under GPLv2 by Nick Clifton.

PR: 198824
MFC after: 1 week
Security: CVE-2014-8503

6 years agoDuplicate helpers after disabling inherited tracepoints during a fork.
markj [Thu, 23 Nov 2017 14:29:07 +0000 (14:29 +0000)]
Duplicate helpers after disabling inherited tracepoints during a fork.

We may create probes in the nascent child process, so we first need to
ensure that any inherited tracepoints are first removed. Otherwise the
probe sites will not be in the state expected by fasttrap, and it won't
be able to enable the probes.

MFC after: 2 weeks

6 years agoMerge ^/head r325999 through r326131.
hselasky [Thu, 23 Nov 2017 14:28:14 +0000 (14:28 +0000)]
Merge ^/head r325999 through r326131.

6 years agoAllow kern.geom.mirror.debug to be negative.
markj [Thu, 23 Nov 2017 14:07:52 +0000 (14:07 +0000)]
Allow kern.geom.mirror.debug to be negative.

A negative value can be used to suppress all prints from the gmirror
kernel code, which can be useful when attempting to trigger race
conditions using stress tests.

MFC after: 1 week

6 years agoMake sure the iSCSI I/O limits are set properly so that the ISCSIDSEND IOCTL
hselasky [Thu, 23 Nov 2017 13:57:44 +0000 (13:57 +0000)]
Make sure the iSCSI I/O limits are set properly so that the ISCSIDSEND IOCTL
can be used prior to the ISCSIDHANDOFF IOCTL which set the negotiated values.
Else the login PDU will fail when passing the "-r" option to "iscsictl" which
means iSCSI over RDMA instead of TCP/IP.

Discussed with: np@ and trasz@
Sponsored by: Mellanox Technologies
MFC after: 1 week

6 years agoMark kgmon(8) obsolete, redirecting users to pmcstat(8).
trasz [Thu, 23 Nov 2017 12:41:05 +0000 (12:41 +0000)]
Mark kgmon(8) obsolete, redirecting users to pmcstat(8).

MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D12574

6 years agoThe __internal_mr is freed as part of the protection domain, pd.
hselasky [Thu, 23 Nov 2017 12:25:11 +0000 (12:25 +0000)]
The __internal_mr is freed as part of the protection domain, pd.
There is no need to free this mr. This fixes an issue accessing
freed memory in ISER.

Sponsored by: Mellanox Technologies

6 years agoRemove lint support from system headers and MD x86 headers.
kib [Thu, 23 Nov 2017 11:40:16 +0000 (11:40 +0000)]
Remove lint support from system headers and MD x86 headers.

Reviewed by: dim, jhb
Discussed with: imp
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D13156

6 years agoKill all descendants of the reaper, even if they are descendants of a
kib [Thu, 23 Nov 2017 11:25:11 +0000 (11:25 +0000)]
Kill all descendants of the reaper, even if they are descendants of a
subordinate reaper.

Also, mark reapers when listing pids.

Reported by: Michael Zuo <muh.muhten@gmail.com>
PR: 223745
Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13183

6 years agoZero struct efi_tm before setting the needed values. We don't use the dst
andrew [Thu, 23 Nov 2017 10:34:38 +0000 (10:34 +0000)]
Zero struct efi_tm before setting the needed values. We don't use the dst
or timezone fields so ensure these are set.

Reported by: emaste
Sponsored by: DARPA, AFRL

6 years agoModify ipfw's dynamic states KPI.
ae [Thu, 23 Nov 2017 08:02:02 +0000 (08:02 +0000)]
Modify ipfw's dynamic states KPI.

Hide the locking logic used in the dynamic states implementation from
generic code. Rename ipfw_install_state() and ipfw_lookup_dyn_rule()
function to have similar names: ipfw_dyn_install_state() and
ipfw_dyn_lookup_state(). Move dynamic rule counters updating to the
ipfw_dyn_lookup_state() function. Now this function return NULL when
there is no state and pointer to the parent rule when state is found.
Thus now there is no need to return pointer to dynamic rule, and no need
to hold bucket lock for this state. Remove ipfw_dyn_unlock() function.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D11657

6 years agoCheck that address family of state matches address family of packet.
ae [Thu, 23 Nov 2017 07:05:25 +0000 (07:05 +0000)]
Check that address family of state matches address family of packet.

If it is not matched avoid comparing other state fields.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

6 years agoMove ipfw_send_pkt() from ip_fw_dynamic.c into ip_fw2.c.
ae [Thu, 23 Nov 2017 06:04:57 +0000 (06:04 +0000)]
Move ipfw_send_pkt() from ip_fw_dynamic.c into ip_fw2.c.
It is not specific for dynamic states function and called also from
generic code.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

6 years agoRework rule ranges matching. Use comparison rule id with UINT32_MAX to
ae [Thu, 23 Nov 2017 05:55:53 +0000 (05:55 +0000)]
Rework rule ranges matching. Use comparison rule id with UINT32_MAX to
match all rules with the same rule number.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

6 years agoAllwinner a83t: add ccung bits
kevans [Thu, 23 Nov 2017 05:54:04 +0000 (05:54 +0000)]
Allwinner a83t: add ccung bits

Upstream DTS has switched to using CCU rather than /clocks nodes. Add a CCU
driver for the a83t to bring us closer to upstream, but don't yet attach it
to ccu node.

Reviewed by: manu
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D12843

6 years agoaw_ccung: changes to accommodate upcoming a83t support
kevans [Thu, 23 Nov 2017 05:43:44 +0000 (05:43 +0000)]
aw_ccung: changes to accommodate upcoming a83t support

Add a means to specify mask/value for the prediv condition instead of
shift/width/value for clocks that have a more complex mux scenario.

Specifically, ahb1 on the a83t has the prediv applied if mux is either b10
or b11.

Reviewed by: manu
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D12851

6 years agosx: unbreak debug after r326107
mjg [Thu, 23 Nov 2017 03:40:51 +0000 (03:40 +0000)]
sx: unbreak debug after r326107

An assertion was modified to use the found value, but it was not updated to
handle a race where blocked threads appear after the entrance to the func.

Move the assertion down to the area protected with sleepq lock where the
lock is read anyway. This does not affect coverage of the assertion and
is consistent with what rw locks are doing.

Reported by: Shawn Webb

6 years agorwlock: unbreak WITNESS builds after r326110
mjg [Thu, 23 Nov 2017 03:20:12 +0000 (03:20 +0000)]
rwlock: unbreak WITNESS builds after r326110

Reported by: Shawn Webb

6 years agorwlock: don't check for curthread's read lock count in the fast path
mjg [Wed, 22 Nov 2017 23:52:05 +0000 (23:52 +0000)]
rwlock: don't check for curthread's read lock count in the fast path

6 years agobhnd(4): Add a basic ChipCommon GPIO driver sufficient to support bwn(4)
landonf [Wed, 22 Nov 2017 23:10:20 +0000 (23:10 +0000)]
bhnd(4): Add a basic ChipCommon GPIO driver sufficient to support bwn(4)

The driver is functional on both BHND Wi-Fi adapters and MIPS SoCs, but
does not currently include support for features not required by bwn(4),
including GPIO interrupt handling.

Approved by: adrian (mentor, implicit)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D12708

6 years agoOrder declarations alphabetically.
kib [Wed, 22 Nov 2017 22:04:27 +0000 (22:04 +0000)]
Order declarations alphabetically.
Match signess of the format and the value.

Noted by: bde
Sponsored by: The FreeBSD Foundation

6 years agolocks: pass the found lock value to unlock slow path
mjg [Wed, 22 Nov 2017 22:04:04 +0000 (22:04 +0000)]
locks: pass the found lock value to unlock slow path

This avoids an explicit read later.

While here whack the cheaply obtainable 'tid' argument.