Commit Graph

116527 Commits

Author SHA1 Message Date
Adrian Chadd
779da5cfb3 [mbufq] add a concat method.
Reviewed by:	gnn, ae, glebius
Approved by:	ae, glebius
Differential Revision:	https://reviews.freebsd.org/D10158
2017-03-30 02:34:21 +00:00
Robert Watson
b783025921 When handling msgsys(2), semsys(2), and shmsys(2) multiplex system calls,
map the 'which' argument into a suitable audit event identifier for the
specific operation requested.

Obtained from:	TrustedBSD Project
MFC after:	3 weeks
Sponsored by:	DARPA, AFRL
2017-03-29 23:31:35 +00:00
Gavin Atkinson
255bba06cf ichsmb: switch device_probe() from a large case statement to a lookup table.
The case statement was getting unmanageably large, and I'm about to add
several more devices to it.

MFC after:	2 weeks
2017-03-29 23:13:04 +00:00
David C Somayajulu
9986117559 Upgrade firmware and other related files to version 5.4.64 2017-03-29 23:00:07 +00:00
Robert Watson
d8ca0a2b70 Hook up new audit event identifiers for various non-Orange Book/CAPP
system calls supported by OpenBSM 1.2-alpha5.

Obtained from:	TrustedBSD Project
MFC after:	3 weeks
Sponsored by:	DARPA, AFRL
2017-03-29 22:33:56 +00:00
Robert Watson
1811d6bf7f Add an experimental DTrace audit provider, which allows users of DTrace to
instrument security event auditing rather than relying on conventional BSM
trail files or audit pipes:

- Add a set of per-event 'commit' probes, which provide access to
  particular auditable events at the time of commit in system-call return.
  These probes gain access to audit data via the in-kernel audit_record
  data structure, providing convenient access to system-call arguments and
  return values in a single probe.

- Add a set of per-event 'bsm' probes, which provide access to particular
  auditable events at the time of BSM record generation in the audit
  worker thread. These probes have access to the in-kernel audit_record
  data structure and BSM representation as would be written to a trail
  file or audit pipe -- i.e., asynchronously in the audit worker thread.

DTrace probe arguments consist of the name of the audit event (to support
future mechanisms of instrumenting multiple events via a single probe --
e.g., using classes), a pointer to the in-kernel audit record, and an
optional pointer to the BSM data and its length. For human convenience,
upper-case audit event names (AUE_...) are converted to lower case in
DTrace.

DTrace scripts can now cause additional audit-based data to be collected
on system calls, and inspect internal and BSM representations of the data.
They do not affect data captured in the audit trail or audit pipes
configured in the system. auditd(8) must be configured and running in
order to provide a database of event information, as well as other audit
configuration parameters (e.g., to capture command-line arguments or
environmental variables) for the provider to operate.

Reviewed by:	gnn, jonathan, markj
Sponsored by:	DARPA, AFRL
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D10149
2017-03-29 19:58:00 +00:00
Mark Johnston
0d75d0dfbc Avoid sleeping when the mirror I/O queue is non-empty.
A request may be queued while the queue lock is dropped when the mirror is
being destroyed. The corresponding wakeup would be lost, possibly resulting
in an apparent hang of the mirror worker thread.

Tested by:	pho (part of a larger patch)
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-29 19:39:07 +00:00
Mark Johnston
c1ab409cba Remove an unneeded g_mirror_destroy_provider() call.
The worker thread will destroy the mirror provider as part of its teardown
sequence. The call made sense in the initial revision of gmirror, but
became unnecessary in r137248.

Tested by:	pho (part of a larger diff)
MFC afteR:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-03-29 19:30:22 +00:00
Navdeep Parhar
a6bef5c275 cxgbe: Don't call t4_edc_err_read for errors not related to the EDCs.
MFC after:	3 days
Sponsored by:	Chelsio Communications
2017-03-29 19:25:31 +00:00
Warner Losh
0deb09e26d xfsread inlined uses more space, so remove the inline tag. This
doesn't help clang, but buys us another 32 bytes for gcc 4.2.1. It
also eliminates a warning from gcc 6.3.0 that says inlining this would
be unhelpful.
2017-03-29 18:35:20 +00:00
Bruce Evans
912da69951 The switch to kernel terminal context needs to update more than the cursor
position.  Especially the screen size, and potentially everything except
the input state and attributes.  Do this by changing the cursor position
setting method to a general syncing method.

Use proper constructors instead of copying to create kernel terminal
contexts.  We really want clones and not new instances, but there is
no method for cloning and there is nothing in the active instance that
needs to be cloned exactly.

Add proper destructors for kernel terminal contexts.  I doubt that the
destructor code has every been reached, but if it was then it leaked the
memory of the clones.

Remove freeing of statically allocated memory for the non-kernel terminal
context for the same terminal as the kernel.  This is in the nearly
unreachable code.  This used to not happen because delicate context
swapping made the user context use the dynamic memory and kernel
context the static memory.  I didn't restore this swapping since it
would have been unnatural to have all kernel contexts except 1 dynamic.

The constructor for terminal context has bad layering for reasons
related to the bug.  It has to return static memory early before
malloc() works.  Callers also can't allocate memory until after the
first constructor selects an emulator and tells upper layers the size
of its context.  After that, the cloning hack required the cloning
code to allocate the memory, but for all other constructors it would
be better for the terminal layer to allocate and deallocate the
memory in all cases.

Zero the memory when allocating terminal contexts dynamically.
2017-03-29 14:46:26 +00:00
Andrey V. Elsukov
8291fb89cf Fix bug in r308972 that leads to panic when non-compressed IPComp
packet is received.

Reported by:	Denis Ahrens <denis h3q com>
MFC after:	3 days
2017-03-29 10:24:48 +00:00
Enji Cooper
94697f90d6 Parameterize out 7680 (15 * 512) as BOOT2SIZE, similar to sys/boot/i386/zfsboot/...
This is being done to make it easier to change in the future--this action might be
needed sooner rather than later because of gcc 6.3.0 bailing, stating that there
is negative free space left (deficit) in the boot2 bootloader.

MFC after:	2 months
Sponsored by:	Dell EMC Isilon
2017-03-29 09:30:03 +00:00
Enji Cooper
ca8478f6a9 self_reloc.c: Pass -Wno-error=maybe-uninitialized to gcc versions greater than 4.2.1
self_reloc.c doesn't initialize `rel` in all cases in the C code, however, the value
might be initialized properly on the stack in the assembly code.

For right now (because this doesn't seem to be breaking anything and my initializing
the stack value could break something since it's called from assembly code) disable
the warning for self_reloc.c. More investigation should be done to determine the
appropriate response to this warning (either intialize the value or find a smarter
way to deal with the warning).

A long MFC timeout is being set for this change to allow a better solution for the
issue to be developed in that time period.

MFC after:	2 months
Reported by:	Jenkins (FreeBSD-head-amd64-gcc job)
Tested with:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 23:56:02 +00:00
Navdeep Parhar
ce22fbcf83 cxgbe/iw_cxgbe: T6 has no limit on the amount of memory that can be
registered in one ib_reg_phys_mr.
2017-03-28 23:39:11 +00:00
Michael Gmelin
9fc511b8a5 In r289137 the legacy_aliases compatibility shims for ata were removed,
also remove a leftover define used for implementing them.

Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D6726
2017-03-28 23:02:41 +00:00
Andriy Voskoboinyk
350086f249 iwn: remove unneeded cast. 2017-03-28 22:40:51 +00:00
Andriy Voskoboinyk
50e04f492d iwn: drop duplicate synchronization requests.
Rx descriptor / payload is already synchronized in iwn_notif_intr()
(before accessing desc->type / desc->qid fields).

Tested with Intel 6205, STA mode.
2017-03-28 22:31:48 +00:00
Gavin Atkinson
44f3702036 Remove #define PCIS_SERIALBUS_SMBUS_PROGIF, unused since r200091 2017-03-28 21:54:36 +00:00
Toomas Soome
9dbf6249dc loader: ls command should display file types properly
With some file system the ls is unable to display file types.

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10066
2017-03-28 21:50:11 +00:00
Toomas Soome
b1740d31c8 loader: move bios getsecs into time.c
Move the time related function into time.c, keep the same logic as libefi.

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10058
2017-03-28 21:47:12 +00:00
Enji Cooper
21f6d18b26 Use -Wno-missing-declarations with CWARNFLAGS for skein.c
`-Wno-missing-variable-declarations` is a clang-specific flag,
so gcc (not 4.2.1, in particular 6.3.0 in my case) dies when
it's passed the flag.

X-MFC with:	r304321
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 21:39:24 +00:00
Enji Cooper
c20d3baeb0 Don't hardcode input files for stage 1/2 bootloaders; use .ALLSRC instead
This is a better pattern to follow when creating the bootloaders and doing
the relevant space checks to make sure that the sizes aren't exceeded (and
thus, copy-pasting is a bit less error prone).

MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-03-28 21:35:18 +00:00
Enji Cooper
e5daf958c1 Remove -Wunused-but-set variable, tail in ls_getdir(..)
This variable has been unused since its inception in r40106.

MFC after:	3 days
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 21:16:11 +00:00
Enji Cooper
e468767c4b Remove redundant declaration for zfs_crc64_table
zfssubr.c already defines this statically. Besides, zfsimpl.c defined it, but
didn't use it.

This fixes a -Wredundant-decls warning.

MFC after:	3 days
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 20:52:59 +00:00
Enji Cooper
5b594b7f21 Don't shadow read(2) definition with read argument in vdev_{create,probe}
This fixes several -Wshadow warnings introduced in r192194, but now errors
with gcc 6.3.0.

MFC after:	3 days
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 20:39:24 +00:00
Enji Cooper
1020003cc6 Use NO_WCAST_ALIGN instead of spelling it out as -Wno-cast-align in CFLAGS
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
2017-03-28 20:30:33 +00:00
Enji Cooper
901f8af05e Remove redundant declarations
They're already defined in libstand.h

MFC after:	1 week
Reported by:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 20:26:04 +00:00
Enji Cooper
f13f3bfaa3 Wrap bootcamp DEBUG statement with curly braces
This fixes a -Wempty-body warning with gcc 6.3.0 when PART_DEBUG is undefined.

MFC after:	3 days
Reported by:	Jenkins (FreeBSD-head-amd64-gcc job)
Tested with:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:	Dell EMC Isilon
2017-03-28 20:22:44 +00:00
Warner Losh
df4fcca522 Remove -fno-guess-branch-probability and -fno-unit-at-a-time.
bde enabled -fno-guess-branch-probability in 2003, well before our
current compiler was imported. At the time it produced weirdly orded
code. It no longer does that. It also saves 0-4 bytes depending on
other options.

kan disabled unit-at-a-time in 2004 because it badly mangled boot2 so
it wouldn't work. That too was before the 4.2.1 compiler, where it no
longer does that. This saves 44 bytes.

I had planned to document why they were needed, but when I discovered
their antiquity, I removed them and boot2 still works and is
smaller. In qemu, the old and new boot2's behaved identically.

These are gcc specific hacks, and won't affect clang-built boot2
at all.
2017-03-28 18:09:01 +00:00
Warner Losh
f2d4cc2f5f Simply retire the sedification of the boot2.s file. It's been obsolete
for years.

clang before 96 free after 100 (+4)
gcc before 163 free after 156 (-7)

Suggested by: bde@
Sponsored by: Netflix
2017-03-28 07:58:27 +00:00
Enji Cooper
156715d048 gpt*boot: Save a bit more memory when LOADER_NO_GELI_SUPPORT is specified
Don't compile geliargs into the image and don't pass geliargs to the respective
bootloader code via __exec(..).

This saves a negligible amount of memory/disk space.

X-MFC with:	r296963
Obtained from:	Isilon OneFS
Sponsored by:	Dell EMC Isilon
2017-03-28 07:10:35 +00:00
Enji Cooper
fa7083e0a0 Unbreak compilation with gcc 4.2.1
-Wtentative-definition-incomplete-type isn't implemented for 4.2.1

X-MFC with:	r304321
Sponsored by:	Dell EMC Isilon
2017-03-28 07:01:40 +00:00
Enji Cooper
75cc519f34 sys/boot/common: Make geli(4) support optional in MI sources
This saves a negligible amount of memory for non-geli enabled
bootloaders.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-28 06:39:54 +00:00
Ed Maste
a3cfc94601 Remove usfs(4) from arm kernel configs
cfumass(4) is not usable if usfs(4) is loaded or compiled into the
kernel. Remove usfs so that the user may kldload the USB mass storage
target they prefer.

PR:		218169
Reviewed by:	trasz, hselasky (no objection)
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10153
2017-03-28 00:57:33 +00:00
Bryan Drewery
9ff3cdff12 Release ccb if mode_buffer allocation fails.
MFC after:	2 weeks
Obtained from:	OneFS
Sponsored by:	Dell EMC Isilon
2017-03-28 00:39:41 +00:00
Mike Karels
4a5c6c6ab0 Enable route and LLE (ndp) caching in TCP/IPv6
tcp_output.c was using a route on the stack for IPv6, which does not
allow route caching or LLE/ndp caching. Switch to using the route
(v6 flavor) in the in_pcb, which was already present, which caches
both L3 and L2 lookups.

Reviewed by:	gnn hiren
MFC after:	2 weeks
2017-03-27 23:48:36 +00:00
Warner Losh
fa370b1a25 Fix build with path names with 'align' or 'nop' in them.
clang is now inserting .file directives with the entire path in
them. This is fine, except that our sed peephole optimizer removes
them if ${SRCTOP} or ${OBJTOP} contains 'align' or 'nop', leading to
build failures. The sed peephole optimizer removes useful things for
boot2 when used with clang, so restrict its use to gcc. Also, gcc no
longer generates nops to pad things, so there's no point in removing
it. Specialize the optimization to just removing the .align 4 lines to
preclude inadvertant path matching.

Sponsored by: Netflix
Commit brought to you the path: /home/xxx/NCD-3592-logsynopts/FreeBSD
2017-03-27 22:53:36 +00:00
Navdeep Parhar
74308c6816 cxgbe/iw_cxgbe: Defer the handling of error CQEs and RDMA_TERMINATE to
the thread that deals with socket state changes.  This eliminates
various bad races with the ithread.

Submitted by:	KrishnamRaju ErapaRaju @ Chelsio (original version)
MFC after:	3 days
Sponsored by:	Chelsio Communications
2017-03-27 22:00:03 +00:00
Michael Zhilin
cb99e844b4 [etherswitch] simplify kernconf for recently added etherswitch drivers
This simple patch adds e6060sw, adm6996fc and ksz8995ma into conf/files.

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	adrian, mizhka
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9255
2017-03-27 19:26:09 +00:00
Michael Zhilin
bf73b5a299 [etherswitch] add support for Marvell 88E6065 ethernet switch incl. 802.1q
This patch brings 802.1q support for Marvell 88E606x ethernet switches.
Test is done on 88E6065 chip (Aterm WR1200).

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	mizhka
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10144
2017-03-27 19:06:29 +00:00
Michael Tuexen
4222f9685c Tweak the Makefiles a bit to allow using "tcp" in MODULES_OVERRIDE
to build the tcp modules.

Sponsored by:	Netflix, Inc.
2017-03-27 18:20:32 +00:00
Josh Paetzel
e106234416 MFV: 315989
7603 xuio_stat_wbuf_* should be declared (void)

illumos/illumos-gate@99aa8b5505
99aa8b5505

https://www.illumos.org/issues/7603

  The funcs are declared k&r style, where the args are not specified:

  void xuio_stat_wbuf_copied();
  They should be declared to take no arguments:

  void xuio_stat_wbuf_copied(void);
  Need to change both .c and .h.

Author: Prashanth Sreenivasa <pks@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
2017-03-27 17:27:46 +00:00
Hans Petter Selasky
0a475c59a9 Implement vmalloc_32() in the LinuxKPI.
Obtained from:		kmacy @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-27 17:18:04 +00:00
Hans Petter Selasky
0791730913 Add more platforms supporting the direct map feature in the LinuxKPI.
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-27 17:09:11 +00:00
Hans Petter Selasky
8186b52744 Implement a series of physical page management related functions in
the LinuxKPI for accessing user-space memory in the kernel.

Add functions to hold and wire physical page(s) based on a given range
of user-space virtual addresses.

Add functions to get and put a reference on, wire, hold, mark
accessed, copy and dirty a physical page.

Add new VM related structures and defines as a preparation step for
advancing the memory map capabilities of the LinuxKPI.

Add function to figure out if a virtual address was allocated using
malloc().

Add function to convert a virtual kernel address into its physical
page pointer.

Obtained from:		kmacy @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-27 17:04:11 +00:00
Mark Johnston
819cd913f4 Refine r301173 a bit.
- Don't execute any of g_mirror_shutdown_post_sync() when panicking. We
  cannot safely idle the mirror or stop synchronization in that state, and
  the current attempts to do so complicate debugging of gmirror itself.
- Check for a non-NULL panicstr instead of using SCHEDULER_STOPPED(). The
  latter was added for use in the locking primitives.

Reviewed by:	mav, pjd
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-03-27 16:25:58 +00:00
Mark Johnston
5788c2bde1 Adjust the constraint for "src" in atomic_(f)cmpset_8.
"r" is not sufficient to prevent the use of invalid byte-width registers
with at least gcc.

Reported and reviewed by:	bde
X-MFC-With:	r315718
2017-03-27 16:18:19 +00:00
Sean Bruno
935ca1ae7c Access *correct* ifp data structure when debug sysctl is invoked.
Submitted by:	Kevin Bowling <kevin.bowling@kev009.com>
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D10126
2017-03-27 15:08:02 +00:00
Sean Bruno
a066d74b07 Change the default rss_type to M_HASHTYPE_OPAQUE_HASH.
Submitted by:	Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9905
2017-03-27 14:55:23 +00:00
Andriy Gapon
978f3da16f revert r315959 because it causes build problems
The change introduced a dependency between genassym.c and header files
generated from .m files, but that dependency is not specified in the
make files.

Also, the change could be not as useful as I thought it was.

Reported by:	dchagin, Manfred Antar <null@pozo.com>, and many others
2017-03-27 12:34:29 +00:00
Andriy Gapon
80b9074a51 update comment describing topo_probe_amd()
MFC after:	2 weeks
MFC with:	r316017
2017-03-27 11:04:57 +00:00
Bruce Evans
1370fa3380 Oops, my fix for bright colors broke bright black some more (in cases
that used to work via the bold hack).

Fix the table entry for bright black.  Fix spelling of plain black in
nearby table entries (use the macro for black everywhere everywhere).
Fix the currently-unused non-bright color table to not have bright
colors in entries 9-15.

Improve nearby comments.  Start converting to the xterm terminology
and default rendering of "bright" instead of "light" for bright
colors.

Syscons wasn't affected by the bug since I optimized it a little by
converting colors 0-15 directly.  This also fixes the layering of
the conversion for these colors.

Apply the same optimization to vt (actually the layer above it).  This
also moves the conversion 1 closer to the correct layer for colors
0-15.

The optimization of just avoiding 2 calls to a trivial function is worth
about 10% for simple output to the virtual buffer with occasional
rendering.  The optimization is so large because the 2 calls are done
on every character, so although there are too many other calls and
other instructions per character, there are only about 10 times as
many.  Old versions of syscons were about 10 times faster for simple
output, by using a fast path with about 12 instructions per character.
Rendering to even slow hardware takes relatively little time provided
it is rarely actually done.
2017-03-27 10:48:28 +00:00
Robert Watson
759c8caa5a Introduce an audit event identifier -> audit event name mapping
database in the kernel audit implementation, similar the exist
class mapping database.  This will be used by the DTrace audit
provider to map audit event identifiers originating in the
system-call table back into strings for the purposes of setting
probe names.  The database is initialised and maintained by
auditd(8), which reads values in from the audit_events
configuration file, and then manages them using the A_GETEVENT
and A_SETEVENT auditon(2) operations.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, AFRL
MFC after:	3 weeks
2017-03-27 10:38:53 +00:00
Andriy Gapon
d9da46bf1c add SMT detection for newer AMD processors
The change seems to be more in the nomenclature than in the way the
topology is advertised by the hardware.

Tested by:	truckman (earlier version of the change)
MFC after:	2 weeks
2017-03-27 09:45:27 +00:00
Robert Watson
d422682f67 Extend comment describing path canonicalisation in audit.
Sponsored by:	DARPA, AFRL
Obtained from:	TrustedBSD Project
MFC after:	3 days
2017-03-27 08:29:17 +00:00
Andrey V. Elsukov
af48c203d6 ake pfil's locking macros private.
Obtained from:	Yandex LLC
MFC after:	1 week
2017-03-27 08:18:13 +00:00
Andrey V. Elsukov
52b8eb0b31 Declare module version.
MFC after:	1 week
2017-03-27 07:56:41 +00:00
Konstantin Belousov
476358b30f Timeout DMAR commands.
Implement timeouts for register-based DMAR commands.  Tunable/sysctl
hw.dmar.timeout specifies the timeout in nanoseconds, set it to zero
to allow infinite wait.  Default is 1ms.

Runtime modification of the sysctl is not safe, it is allowed for
debugging.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-27 07:06:45 +00:00
Andriy Voskoboinyk
7beeab43a1 iwm: fix build without IWM_DEBUG.
Reported by:	O. Hartmann <ohartmann@walstatt.org>
Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D10146
2017-03-27 07:02:27 +00:00
Konstantin Belousov
97222e17ab Fix TUNABLE_UINT64() on 32bit architectures.
The macro is not used in the tree.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-27 06:37:03 +00:00
Navdeep Parhar
dee33b4bd5 cxgbe/iw_cxgbe: Remove unused code.
MFC after:	3 days
2017-03-27 03:11:51 +00:00
Robert Watson
5e386598a6 Merge OpenBSM 1.2-alpha5 from vendor branch to FreeBSD -CURRENT:
- Add a new "qsize" parameter in audit_control and the getacqsize(3) API to
  query it, allowing to set the kernel's maximum audit queue length.
- Add support to push a mapping between audit event names and event numbers
  into the kernel (where supported) using new A_GETEVENT and A_SETEVENT
  auditon(2) operations.
- Add audit event identifiers for a number of new (and not-so-new) FreeBSD
  system calls including those for asynchronous I/O, thread management, SCTP,
  jails, multi-FIB support, and misc. POSIX interfaces such as
  posix_fallocate(2) and posix_fadvise(2).
- On operating systems supporting Capsicum, auditreduce(1) and praudit(1) now
  run sandboxed.
- Empty "flags" and "naflags" fields are now permitted in audit_control(5).

Many thanks to Christian Brueffer for producing the OpenBSM release and
importing/tagging it in the vendor branch.  This release will allow improved
auditing of a range of new FreeBSD functionality, as well as non-traditional
events (e.g., fine-grained I/O auditing) not required by the Orange Book or
Common Criteria.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, AFRL
MFC after:	3 weeks
2017-03-26 21:14:49 +00:00
Bruce Evans
f434f3515b Fix printing of negative offsets (typically from frame pointers) again.
I fixed this in 1997, but the fix was over-engineered and fragile and
was broken in 2003 if not before.  i386 parameters were copied to 8
other arches verbatim, mostly after they stopped working on i386, and
mostly without the large comment saying how the values were chosen on
i386.  powerpc has a non-verbatim copy which just changes the uncritical
parameter and seems to add a sign extension bug to it.

Just treat negative offsets as offsets if they are no more negative than
-db_offset_max (default -64K), and remove all the broken parameters.

-64K is not very negative, but it is enough for frame and stack pointer
offsets since kernel stacks are small.

The over-engineering was mainly to go more negative than -64K for the
negative offset format, without affecting printing for more than a
single address.

Addresses in the top 64K of a (full 32-bit or 64-bit) address space
are now printed less well, but there aren't many interesting ones.
For arches that have many interesting ones very near the top (e.g.,
68k has interrupt vectors there), there would be no good limit for
the negative offset format and -64K is a good as anything.
2017-03-26 18:46:35 +00:00
Andriy Voskoboinyk
53d5e4e71c iwn: fix debug message 2017-03-26 18:06:51 +00:00
Andriy Voskoboinyk
60ff4558ee iwn: fix error handling for one well-known corner case. 2017-03-26 17:59:51 +00:00
Andriy Voskoboinyk
d25646a482 iwn: drop unneeded bus_dmamap_sync() calls.
1) They are using wrong tag (Tx) + map (Rx) combination.
2) Rx descriptor is already synchronized in iwn_notif_intr()
3) It's not needed for transmitted data since device does not change
mbuf contents.

Tested with Intel 6205 (amd64), STA mode.
2017-03-26 16:46:39 +00:00
Bruce Evans
89a1e6c3eb Fix 3 entries in mode tables related to mono and 90-column text modes.
Newer VGAs don't support any mono modes, but bugs in the tables created
2 virtual mono modes (#45 90x43 and #112 80x43) that behaved more
strangely than crashing.  90-column modes are tweaked 80-column ones
and also fail to work on newer VGAs.  #45 did crash (hang) on some
hardware.
2017-03-26 14:31:29 +00:00
Bruce Evans
d91400bf98 Restore switching to a separate kernel terminal "input" state and extend
it to a separate state for each CPU.

Terminal "input" is user or kernel output.  Its state includes the current
parser state for escape sequences and multi-byte characters, and some
results of previous parsing (mainly attributes), and in teken the cursor
position, but not completed output.  This state must be switched for kernel
output since the kernel can preempt anything, including itself, and this
must not affect the preempted state more than necessary.  Since vty0 is
shared, it is necessary to affect the frame buffer and cursor position and
history, but escape sequences must not be affected and attributes for
further output must not be affected.

This used to work.  The syscons terminal state contained mainly the parser
state for escape sequences and attributes, but not the cursor position,
and was switched.  This was first broken by SMP and/or preemptive kernels.
Then there should really be a separate state for each thread, and one more
for ddb, or locking to prevent preemption.  Serialization of printf() helps.
But it is arcane that full syscons escape sequences mostly work in kernel
printf(), and I have never seen them used except by me to test this fix.
They worked perfectly except for the races, since "input" from the kernel
was not special in any way.

This was broken to use teken.  The general switch was removed, and the
kernel normal attribute was switched specially.  The kernel reverse
attribute (config option SC_CONS_REVERSE_ATTR) became unused, and is
still unusable because teken doesn't support default reverse attributes
(it used to only be used via the ANSI escape sequence to set reverse
video).

The only new difficulty for using teken seems to be that the cursor
position is in the "input" state, so it must be updated in the active
input state for each half of the switch.  Do this to complete the
restoration.

The per-CPU state is mainly to make per-CPU coloring work cleanly, at
a cost of some space.  Each CPU gets its own full set of attribute
(not just the current attribute) maintained in the usual way.  This
also reduces races from unserialized printf()s.  However, this gives
races for serialized printf()s that otherwise have none.  Nothing
prevents the CPU doing the a printf() changing in the middle of an
escape sequence.
2017-03-26 13:03:16 +00:00
Bruce Evans
864c28cf81 Use inline asm instead of unportable intrinsics for the SSE4 crc32
optimization.

This fixes building with gcc-4.2.1 (it doesn't support SSE4).
gas-2.17.50 [FreeBSD] supports SSE4 instructions, so this doesn't
need using .byte directives.

This fixes depending on host user headers in the kernel.

Fix user includes (don't depend on namespace pollution in <nmmintrin.h>
that is not included now).

The instrinsics had no advantages except to sometimes avoid compiler
pessimixations.  clang understands them a bit better than inline asm,
and generates better looking code which also runs better for cem, but
for me it just at the same speed or slower by doing excessive
unrollowing in all the wrong places.  gcc-4.2.1 also doesn't understand
what it is doing with unrolling, but with -O3 somehow it does more
unrolling that helps.

Reduce 1 of the the compiler pessimizations (copying a variable which
already satisfies an "rm" constraint in a good way by being in memory
and not used again, to different memory and accessing it there.  Force
copying it to a register instead).

Try to optimize the inner loops significantly, so as to run at full
speed on smaller inputs.  The algorithm is already very MD, and was
tuned for the throughput of 3 crc32 instructions per cycle found on
at least Sandybridge through Haswell.  Now it is even more tuned for
this, so depends more on the compiler not rearranging or unrolling
things too much.  The main inner loop for should have no difficulty
runing at full speed on these CPUs unless the compiler unrolls it too
much.  However, the main inner loop wasn't even used for buffers smaller
than 24K.  Now it is used for buffers larger than 384 bytes.  Now it
is not so long, and the main outer loop is used more.  The new
optimization is to try to arrange that the outer loop runs in parallel
with the next inner loop except for the final iteration; then reduce
the loop sizes significantly to take advantage of this.

Approved by:	cem
Not tested in production by:	bde
2017-03-26 10:31:48 +00:00
Andriy Voskoboinyk
15044a59f3 iwn: deduplicate code in iwn_tx_data() and iwn_tx_data_raw().
Some code was additionally moved for (future) lock splitting.

Tested with Intel 6205, STA mode.

Differential Revision:	https://reviews.freebsd.org/D10106
2017-03-26 09:41:08 +00:00
Andriy Voskoboinyk
b4750b8855 iwn: omit unneeded bus_dmamap_sync() calls when compiled without
'options IWN_DEBUG'
2017-03-26 09:10:01 +00:00
Michal Meloun
6fc9f4dbc8 Preserve VFP state across signal delivery.
We don't have enouch space to store full VFP context within mcontext
stucture. Due to this:
 - follow i386/amd64 way and store VFP state outside of the mcontext_t
   but point to it. Use the size of VFP state structure as an 'magic'
   indicator of the saved VFP state presence.
 - teach set_mcontext() about this external storage.
 - for signal delivery, store VFP state to expanded 'struct sigframe'.

Submited by:	Andrew Gierth (initial version)
PR:		217611
MFC after:	2 weeks
2017-03-26 08:36:56 +00:00
Michal Meloun
d9d7354968 Save VFP state on fork().
Update the copy of VFP state in PCB before it is cloned for new process.

MFC after:	2 weeks
2017-03-26 08:36:20 +00:00
Konstantin Belousov
70fd237c5d Provide less laborius way to enable busdma DMAR to only short list of devices.
Kernel environment variable hw.busdma.default can take values 'bounce'
and 'dmar' and selects corresponding busdma backend as default.
Per-device environment variable hw.busdma.pci<domain>.<bus>.<slot>.<func>
takes the same values and overrides hw.busdma.default for the given device.

Note that even with hw.busdma.default=bounce, DMA translation engines
are still started if DMARs are enabled, to disable them use
hw.dmar.dma tunable, as before.

Sponsored by:	The FreeBSD Foundation
MFC after: 1 week
2017-03-26 00:40:35 +00:00
Oleksandr Tymoshenko
e9804ab2bd [rpi] Use compatibility string from upstream DTB for I2C controller
FreeBSD uses upstream DTB for RPi3 build and compatibility string for
i2c device is different there. Add this new string to compatibility data.

Reported by:	Karl Denninger
MFC after:	3 days
2017-03-25 22:58:37 +00:00
Andriy Voskoboinyk
7d6a0b8e00 iwn: fix return code conflict in iwn_init_locked()
Do not try to use errno(2) codes here; instead, just return unique
value (1) when radio is disabled via hardware switch and another
one (-1) for any other error in initialization path.

Tested with Intel 6205, STA mode.
2017-03-25 22:07:21 +00:00
Sean Bruno
e407efca16 Add ids for ALC233 found on Intel Skull Mountain NUC. 2017-03-25 19:12:09 +00:00
Andriy Gapon
20c69e76b4 dtrace sched:::preempt should fire only when there is preemption
The probe fire on any thread switch before.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Panzura
2017-03-25 19:08:51 +00:00
Andriy Gapon
a7b4c009e1 specific end of interrupt implementation for AMD Local APIC
The change is more intrusive than I would like because the feature
requires that a vector number is written to a special register.
Thus, now the vector number has to be provided to lapic_eoi().
It was readily available in the IO-APIC and MSI cases, but the IPI
handlers required more work.
Also, we now store the VMM IPI number in a global variable, so that it
is available to the justreturn handler for the same reason.

Reviewed by:	kib
MFC after:	6 weeks
Differential Revision: https://reviews.freebsd.org/D9880
2017-03-25 18:45:09 +00:00
Andriy Voskoboinyk
64b92f2691 iwn: do not try to update node configuration when the node does not exist.
Firmware will just respond with status '0x8' (node does not exist) or
will hang -> cause 'device timeout's (sometimes).
2017-03-25 15:57:47 +00:00
Dmitry Chagin
6c2a934b79 Implement Linux mincore() system call.
This is necessary for the upcoming drm-next.

Suggested by:	hselasky@
MFC after:	1 month
2017-03-25 15:47:29 +00:00
Mike Karels
8c1960d506 Fix reference count leak with L2 caching.
ip_forward, TCP/IPv6, and probably SCTP leaked references to L2 cache
entry because they used their own routes on the stack, not in_pcb routes.
The original model for route caching was callers that provided a route
structure to ip{,6}input() would keep the route, and this model was used
for L2 caching as well. Instead, change L2 caching to be done by default
only when using a route structure in the in_pcb; the pcb deallocation
code frees L2 as well as L3 cacches. A separate change will add route
caching to TCP/IPv6.

Another suggestion was to have the transport protocols indicate willingness
to use L2 caching, but this approach keeps the changes in the network
level

Reviewed by:    ae gnn
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D10059
2017-03-25 15:06:28 +00:00
Andriy Voskoboinyk
8972534f35 iwn: add few missing notification types into iwn_intr_str() 2017-03-25 13:15:43 +00:00
Konstantin Belousov
3d47c58b98 Avoid leaking allocated but unused context after creation race.
As noted in the comment, nothing special needs to be done to destroy
the unneeded context after the allocation race, but the context memory
itself still should to be freed.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-25 10:47:35 +00:00
Konstantin Belousov
5f8e5c7fa2 Do not create RMRR entries for identity-mapped domains.
It does not make sense since identity mapping already provides the
required mapping for RMRR ranges.  More, since identity page tables do
not reflect content of map entries for id domains, creating RMRR
entries makes domain data inconsistent.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-25 10:45:16 +00:00
Konstantin Belousov
ad969cb1cd Slight cleanup of the comment.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-25 10:42:10 +00:00
Ganbold Tsagaankhuu
c8c3a33403 Fix and add comments to match selected frequency sample.
Add debug printfs when bootverbose is used.
No functional changes.
2017-03-25 10:39:24 +00:00
Adrian Chadd
6c3c52590e [iwm] Add the BSS's basic rates to iwm's LQ command, not all the rates.
Makes the firmware use appropriate Tx rates for ACKs.

Obtained from: dragonflybsd.git ab1d3efc208e797c1e09759cd506c95c0aeaa06e
2017-03-25 02:55:13 +00:00
Adrian Chadd
cd20383e4a [iwm] Enable Energy Based Scan (EBS).
This can significantly reduce scan duration thus saving time and power.
EBS failure reported by FW disables EBS for current connection. It is
re-enabled upon new connection attempt on any WLAN interface.

Obtained from:	dragonflybsd.git 89f579e9823a5c446ca172cf82bbc210d6a054a4
2017-03-25 02:49:20 +00:00
Adrian Chadd
5f00681c7d [iwm] GC unused code from if_iwm_scan.c, copyied from iwn or iwlwifi/dvm.
Obtained from:	dragonflybsd.git 10881df269b93c26e5ee6af629c36db5672e6e52
2017-03-25 02:44:25 +00:00
Adrian Chadd
8d3bbea007 [iwm] Tiny cleanup in iwm_rx_addbuf().
Obtained from:	dragonflybsd.git 3370bc5504ebb3c1b9bb960a185cd0c8052a2845
2017-03-25 02:42:52 +00:00
Navdeep Parhar
4aff1c38d1 cxgbe/iw_cxgbe: allocations that use GFP_KERNEL (which is M_WAITOK on
FreeBSD) cannot fail.

MFC after:	3 days
2017-03-25 02:28:21 +00:00
Navdeep Parhar
d4ce83cd36 cxgbe/iw_cxgbe: alloc_ep expects a gfp_t, and it's always ok to sleep during
alloc_ep.
2017-03-25 01:45:04 +00:00
Navdeep Parhar
a8d61a0a7b cxgbe/iw_cxgbe: c4iw_connect should always returns a -ve errno on failure.
MFC after:	3 days
2017-03-25 01:38:17 +00:00
Warner Losh
480c955cee Add 'device iic' to bring in userland I2C driver.
Submitted by: karl@
2017-03-24 22:33:03 +00:00
Andriy Voskoboinyk
e2db307ebc net80211: fix possible panic when wlan(4) interface is destroyed.
If this is the last running vap wait until device will be powered off
(fixes panic when 'ifconfig wlan0 destroy' is executed for running iwn(4)
interface).

Tested with:
 - Intel 6205, STA mode.
 - RTL8188EU, STA / IBSS modes.
 - RTL8821AU, STA / HOSTAP modes.
2017-03-24 22:29:51 +00:00
Bruce Evans
4e501eb7cc Remove buggy adjustment of page tables in db_write_bytes().
Long ago, perhaps only on i386, kernel text was mapped read-only and
it was necessary to change the mapping to read-write to set breakpoints
in kernel text.  Other writes by ddb to kernel text were also allowed.
This write protection is harder to implement with 4MB pages, and was
lost even for 4K pages when 4MB pages were implemented.  So changing
the mapping became useless.  It was actually worse than useless since
it followed followed various null and otherwise garbage pointers to
not change random memory instead of the mapping.  (On i386s, the
pointers became good in pmap_bootstrap(), and on amd64 the pointers
became bad in pmap_bootstrap() if not before.)

Another bug broke detection of following of null pointers on i386,
except early in boot where not detecting this was a feature.  When
I fixed the bug, I accidentally broke the feature and soon got traps
in db_write_bytes().  Setting breakpoints early in ddb was broken.

kib pointed out that a clean way to do the adjustment would be to use
a special [sub]map giving a small window on the bytes to be written.

The trap handler didn't know how to fix up errors for pagefaults
accessing the map itself.  Such errors rarely need fixups, since most
traps for the map are for the first access which is a read.

Reviewed by:	kib
2017-03-24 17:34:55 +00:00
Alexander Motin
00be964c08 Add brackets to fix incorrect macro expansion.
Reported by:	Andreas Hollmann / PVS-Studio
MFC after:	2 weeks
2017-03-24 16:26:11 +00:00
Gavin Atkinson
cb8f312598 Improve grammar on a warning, and only use one line rather than two when
printing it.
2017-03-24 16:18:20 +00:00
Gleb Smirnoff
9e3c8bd3e2 Make sendfile(2) more robust against file change. This fixes a possible
crash when the file shrinks.  This also fixes sendfile(2) not sending more
data in a case when the file grows, and the request is open-ended or
specifies a size that is greater than old file size.

PR:		217789
Reviewed by:	gallatin
MFC after:	10 days
2017-03-24 16:01:19 +00:00
Alexander Motin
7e31684ea4 Unify initiator and target DMA setup and command sending.
The code is so alike that it is pointless to keep it separate.

MFC after:	2 weeks
2017-03-24 14:44:03 +00:00
Sean Bruno
cb101e1257 Add missing 'else' to conditional. This doesn't really affect the code
flow or configuration in any way.
2017-03-24 14:27:29 +00:00
Sean Bruno
fdb25f38cb Add missing 'else' to 3-state conditional during setup of interrupts.
We don't want to overwrite the 82574 interrupt setup with a different
configuration.

PR:		218041
Submitted by:	razmyslov@viva64.com
2017-03-24 14:25:56 +00:00
Michal Meloun
dfe5f22fd7 Cleanup structures related to VFP and/or mcontext_t.
- in mcontext_t, rename newer used 'union __vfp' to equaly sized 'mc_spare'.
  Space allocated by 'union __vfp' is too small and cannot hold full
  VFP context.
- move structures defined in fp.h to more appropriate headers.
- remove all unused VFP structures.

MFC after:	2 weeks
2017-03-24 11:46:49 +00:00
Alexander Motin
3aef5b286a MFV r315290, r315291: 7303 dynamic metaslab selection
illumos/illumos-gate@8363e80ae7
https://github.com/illumos/illumos-gate/commit/8363e80ae72609660f6090766ca8c2c18

https://www.illumos.org/issues/7303

  This change introduces a new weighting algorithm to improve metaslab selection.
  The new weighting algorithm relies on the SPACEMAP_HISTOGRAM feature. As a result,
  the metaslab weight now encodes the type of weighting algorithm used
  (size-based vs segment-based).

  This also introduce a new allocation tracing facility and two new dcmds to help
  debug allocation problems. Each zio now contains a zio_alloc_list_t structure
  that is populated as the zio goes through the allocations stage. Here's an
  example of how to use the tracing facility:

> c5ec000::print zio_t io_alloc_list | ::walk list | ::metaslab_trace
  MSID    DVA    ASIZE      WEIGHT             RESULT               VDEV
     -      0      400           0    NOT_ALLOCATABLE           ztest.0a
     -      0      400           0    NOT_ALLOCATABLE           ztest.0a
     -      0      400           0             ENOSPC           ztest.0a
     -      0      200           0    NOT_ALLOCATABLE           ztest.0a
     -      0      200           0    NOT_ALLOCATABLE           ztest.0a
     -      0      200           0             ENOSPC           ztest.0a
     1      0      400      1 x 8M            17b1a00           ztest.0a

> 1ff2400::print zio_t io_alloc_list | ::walk list | ::metaslab_trace
  MSID    DVA    ASIZE      WEIGHT             RESULT               VDEV
     -      0      200           0    NOT_ALLOCATABLE           mirror-2
     -      0      200           0    NOT_ALLOCATABLE           mirror-0
     1      0      200      1 x 4M            112ae00           mirror-1
     -      1      200           0    NOT_ALLOCATABLE           mirror-2
     -      1      200           0    NOT_ALLOCATABLE           mirror-0
     1      1      200      1 x 4M            112b000           mirror-1
     -      2      200           0    NOT_ALLOCATABLE           mirror-2

  If the metaslab is using segment-based weighting then the WEIGHT column will
  display the number of segments available in the bucket where the allocation
  attempt was made.

Author: George Wilson <george.wilson@delphix.com>
Reviewed by: Alex Reece <alex@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <paul.dagnelie@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Don Brady <don.brady@intel.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
2017-03-24 09:37:00 +00:00
Ed Schouten
eb29911a30 Include <sys/systm.h> to obtain the memcpy() prototype.
I got a report of this source file not building on Raspberry Pi. It's
interesting that this only fails for that target and not for others.
Again, that's no reason not to include the right headers.

PR:		217969
Reported by:	Johannes Jost Meixner
MFC after:	1 week
2017-03-24 07:09:33 +00:00
Justin Hibbits
457797001e Don't bother checking core version
We already constrain by SoC, so there's no need to check the core version, too.
2017-03-24 01:52:10 +00:00
Justin Hibbits
52f0686952 Switch qoriq_gpio over to using ofw_bus_search_compatible
This will make it easier to add more compatibility strings in the future, if
necessary.
2017-03-24 01:30:18 +00:00
Kevin Lo
dd4b1792c7 Don't initialize if_output to ether_output(), ether_ifattach() does it for
us already.  While here, remove NOTYET code since if_watchdog is no longer
used.

Reviewed by:	royger
MFC after:	3 days
2017-03-24 01:23:07 +00:00
Ermal Luçi
4e950412ff Correct handling of ALTQ with epair(4) interfaces but presenting that ALTQ(9) is supported.
Approved by:	ae
MFC after:	2 weeks
2017-03-24 00:55:16 +00:00
Landon J. Fuller
4cb7084e29 Add Northstar/BCM4706 core ID for ChipCommon.
Approved by:	adrian (mentor, implicit)
2017-03-23 22:14:08 +00:00
Landon J. Fuller
5658bc0a95 Add a workaround for the BCM4706's dangling core region EROM entries.
Approved by:	adrian (mentor, implicit)
2017-03-23 22:12:14 +00:00
Alexander Motin
961da6389a isp field in struct isp_pcmd is also unused.
MFC after:	2 weeks
2017-03-23 21:18:10 +00:00
Alexander Motin
96ae113f37 Remove write-only crn field from struct isp_pcmd.
MFC after:	2 weeks
2017-03-23 21:11:55 +00:00
Gleb Smirnoff
061f01b16e Remove Solaris 2.6 syscalls selector.
Discussed with:	kib
2017-03-23 19:54:41 +00:00
Landon J. Fuller
591e79bc76 [mips/broadcom]: Early boot NVRAM support
Add support for early boot access to NVRAM variables, using a new
bhnd_nvram_data_getvar_direct() API to support zero-allocation direct
reading of NVRAM variables from a bhnd_nvram_io instance backed by the
CFE NVRAM device.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D9913
2017-03-23 19:29:12 +00:00
Hans Petter Selasky
8f7eee5a63 Use ppsratecheck() for ratelimiting in the LinuxKPI.
Suggested by:		cem @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-23 16:23:55 +00:00
Hans Petter Selasky
d2f312e0e7 Add proper error checking for the string to number conversion
functions in the LinuxKPI.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-23 16:01:51 +00:00
Ed Schouten
ebfc28088b Stop providing the compat_3_brand.
As of r315860, the ELF image activator works fine for CloudABI without it.

Reviewed by:	kib
MFC after:	2 weeks
2017-03-23 14:12:21 +00:00
Ed Schouten
0fe9832013 Don't require the presence of the compat_3_brand.
The existing ELF image activator requires the brandinfo to provide such
a string unconditionally, even if the executable format in question
doesn't use this type of branding. Skip matching when it's a null
pointer.

Reviewed by:	kib
MFC after:	2 weeks
2017-03-23 14:09:45 +00:00
Hans Petter Selasky
8293738e64 Function macros are preferred in the LinuxKPI.
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-23 13:28:16 +00:00
Andriy Gapon
48ff53e324 aacraid: rework r315083 for a clean build with and without AACRAID_DEBUG
r315083 essentially reverted r263954 which was made for a good reason,
but didn't take into account AACRAID_DEBUG.
Now both types of build should be clean.

MFC after:	5 days
No MFC to:	stable/10
2017-03-23 11:59:17 +00:00
Alexander Motin
62df0949fd Remove "UNMAPPED" messages printed on da periph attach.
I think this message is not very useful for end user.  Also its formatting
does not match other messages printed at that time.  Those who really need
this information can always find it in `camcontrol negotiate daX -v`.

MFC after:	2 weeks
2017-03-23 10:50:45 +00:00
Hans Petter Selasky
e9db3df254 Add support for ratelimited printouts in the LinuxKPI.
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-23 10:48:10 +00:00
Andriy Gapon
16b46572fa zfs_putpages: use TXG_WAIT
Explicit looping using TXG_NOWAIT is more verbose and may harm performance
under heavy load because of multiple waits.

MFC after:	1 week
2017-03-23 09:13:21 +00:00
Andriy Gapon
3d775e193e zfs: add zio_buf_alloc_nowait and use it in vdev_queue_aggregate
This way we can avoid blocking the whole queue in the low memory
situations.  It's better to sacrifice some I/O performance by not doing
the aggregation than to add an indefinite wait for more memory.

Reviewed by:	smh
MFC after:	2 weeks
Sponsored by:	Panzura
Differential Revision: https://reviews.freebsd.org/D9999
2017-03-23 08:59:17 +00:00
Andriy Gapon
afa0a46cfd move thread switch tracing from mi_switch to sched_switch
This is done so that the thread state changes during the switch
are not confused with the thread state changes reported when the thread
spins on a lock.

Here is an example, three consecutive entries for the same thread (from top to
bottom):

  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"sleep", attributes: prio:84, wmesg:"-", lockname:"(null)"
  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"spinning", attributes: lockname:"sched lock 1"
  KTRGRAPH group:"thread", id:"zio_write_intr_3 tid 100260", state:"running", attributes: none

The above trace could leave an impression that the final state of
the thread was "running".
After this change the sleep state will be reported after the "spinning"
and "running" states reported for the sched lock.

Reviewed by:	jhb, markj
MFC after:	1 week
Sponsored by:	Panzura
Differential Revision: https://reviews.freebsd.org/D9961
2017-03-23 08:57:04 +00:00
Dag-Erling Smørgrav
396e94586a The original author abused Nd (one-line description, used by makewhatis)
for its side effect of producing an en-dash.  This broke whatis with
newer versions of mdocml.  Use \(en instead.

MFC after:	1 week
2017-03-23 08:34:30 +00:00
Michal Meloun
693f8b3673 Restore original (pre r315760) naming for Tegra SDHCI device.
Newbus handles multiple equally named device classes without problems,
so there is no reason to use slightly cryptic "<foo>_shdci" for them.
In contrast, the driver module name must be unique, so "<foo>_shdci"
is the right name for it.
2017-03-23 08:16:53 +00:00
Michal Meloun
12561ddddc Revert r315800, it was committed with invalid (unsaved) commit log. 2017-03-23 08:15:11 +00:00
Michal Meloun
67a50f6e6d Release all previously allocated resources. 2017-03-23 05:54:03 +00:00
Adrian Chadd
a00bfbb19d [iwm] Make ucode capabilities and api flags handling more like iwlwifi.
Obtained from:	dragonflybsd.git 757eecf0e6c92745aa2eee95811e573c8300850e
2017-03-23 04:50:38 +00:00
Adrian Chadd
d045c744f1 [iwm] Remove a couple of unneeded IWM_UCODE_TLV_FLAGS_* flags.
* All the supported firmwares have these flags set.

* This removes the following flags:
  IWM_UCODE_TLV_FLAGS_PM_CMD_SUPPORT,
  IWM_UCODE_TLV_FLAGS_NEWBT_COEX,
  IWM_UCODE_TLV_FLAGS_BF_UPDATED,
  IWM_UCODE_TLV_FLAGS_D3_CONTINUITY_API,
  IWM_UCODE_TLV_FLAGS_STA_KEY_CMD,
  IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD,
  IWM_UCODE_TLV_FLAGS_SCHED_SCAN,
  IWM_UCODE_TLV_FLAGS_RX_ENERGY_API,
  IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2

* Also remove definitions and code for dealing with the v1 time-event api.

* Remove unneeded calc_rssi() function.

Obtained from:	dragonflybsd.git d078c812418d0e2c3392e99fa25fc776d07bdfad
2017-03-23 04:43:04 +00:00
Adrian Chadd
51c2814518 [iwm] Move mbuf hacks after sanity checks in iwm_mvm_rx_rx_mpdu().
* This avoids leaving the mbuf in a weird state, when dropping a packet.

Obtained from:	dragonflybsd.git 96eaecf93d9f731459a0df8efc72cfad034320bd
2017-03-23 04:34:25 +00:00
Adrian Chadd
6d218ca4c9 [iwm] Get rid of struct iwm_rx_data argument for iwm_mvm_rx_rx_mpdu.
Obtained from:	dragonflybsd.git b5cdd8067951dc90271ab104ef555b3b5a4d5d5a
2017-03-23 04:33:15 +00:00
Marius Strobl
906eb24c6d Correct the dependency of mmc(4) on sdhci_tegra(4) after r314887. 2017-03-23 00:41:33 +00:00
Konstantin Belousov
2274ab3d7b Update r315753 with the proper flag name.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-22 22:28:13 +00:00
Konstantin Belousov
1438fe3cf2 Add a flag BI_BRAND_ONLY_STATIC to specify that the brand only
matches static binaries.

Interpretation of the 'static' there is that the binary must not
specify an interpreter.  In particular, shared objects are matched by
the brand if BI_CAN_EXEC_DYN is also set.

This improves precision of the brand matching, which should eliminate
surprises due to brand ordering.

Revert r315701.

Discussed with and tested by:	ed (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-22 22:23:01 +00:00
Konstantin Belousov
7aab7a80e2 Adjust r314851 to not require every brand to specify interpreter path.
Reported and tested by:	ed
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-22 22:06:48 +00:00
Kristof Provost
2f8fb3a868 pf: Fix possible shutdown race
Prevent possible races in the pf_unload() / pf_purge_thread() shutdown
code. Lock the pf_purge_thread() with the new pf_end_lock to prevent
these races.

Use a shared/exclusive lock, as we need to also acquire another sx lock
(VNET_LIST_RLOCK). It's fine for both pf_purge_thread() and pf_unload()
to sleep,

Pointed out by: eri, glebius, jhb
Differential Revision:	https://reviews.freebsd.org/D10026
2017-03-22 21:18:18 +00:00
Enji Cooper
05dad2b781 Garbage collect if_igb reference in loader.conf
if_igb was merged with if_em in r311849

X-MFC with:	r311849
Sponsored by:	Dell EMC Isilon
2017-03-22 20:06:29 +00:00
Enji Cooper
cf4097dfdf Document some more 10GbE+ network drivers in loader.conf
- if_cxgbe
- if_ixl
- if_ixlv
- sfxge

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-22 19:48:09 +00:00
Ed Schouten
75865d0d75 Make file descriptor passing for CloudABI's recvmsg() work.
Similar to the change for sendmsg(), create a pointer size independent
implementation of recvmsg() and let cloudabi32 and cloudabi64 call into
it. In case userspace requests one or more file descriptors, call
kern_recvit() in such a way that we get the control message headers in
an mbuf. Iterate over all of the headers and copy the file descriptors
to userspace.
2017-03-22 19:20:39 +00:00
Warner Losh
79d80af216 Implement moving SD.
From the paper "Incremental calculation of weighted mean and variance"
by Tony Finch Februrary 2009, retrieved from
http://people.ds.cam.ac.uk/fanf2/hermes/doc/antiforgery/stats.pdf
converted to use shifting.
2017-03-22 19:18:47 +00:00
Ed Schouten
8b36e24529 Add forward declaration for struct vnode.
The coredump() function provided by this header file has struct vnode *
as an argument.

MFC after:	1 week
2017-03-22 18:45:13 +00:00
Mark Johnston
e5fe3ae2b4 Extend cmpxchg() to support 8- and 16-bit values, and add xchg().
These are needed to support updated revisions of the DRM code.

Reviewed by:	hselasky (previous version)
MFC after:	2 weeks
2017-03-22 17:33:57 +00:00
Mark Johnston
3d6732549d Add support for 8- and 16-bit atomic_(f)cmpset to x86.
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10068
2017-03-22 17:29:04 +00:00
Peter Grehan
e9517d2481 Bring the handling of the y axis in the ums driver in-line with the other
axes.

No functional change.

Submitted by:	Vicki Pfau (vi AT endrift.com)
Approved by:	hps
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D9595
2017-03-22 17:06:57 +00:00
Hans Petter Selasky
82d0140707 Add full VNET support to the inet_get_local_port_range() function in
the LinuxKPI.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-22 15:46:31 +00:00
Hans Petter Selasky
303bd80ad5 Add support for more IPv4 and IPv6 related macros in the LinuxKPI.
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-22 15:44:00 +00:00
Andrew Turner
e336138c40 Add the early hypervisor code needed on 32-bit ARMv7. This will be used
when we bring in bhyve support.

Submitted by:	Mihai Carabas <mihai.carabas AT gmail.com>
Differential Revision:	https://reviews.freebsd.org/D10045
2017-03-22 14:30:02 +00:00
Alexander Motin
ea8e769e42 Switch from using periph_links to sim_links.
periph_links field belongs to periph drivers and must not be used here.

MFC after:	2 weeks
2017-03-22 11:06:33 +00:00
Alexander Motin
2d24b6af63 Cleanup response queue processing.
MFC after:	2 weeks
2017-03-22 08:56:03 +00:00
Ed Schouten
ae2373da91 Set the interpreter path to /nonexistent.
CloudABI executables are statically linked and don't have an
interpreter. Setting the interpreter path to NULL used to work
previously, but r314851 introduced code that checks the string
unconditionally. Running CloudABI executables now causes a null pointer
dereference.

Looking at the rest of imgact_elf.c, it seems various other codepaths
already leaned on the fact that the interpreter path is set. Let's just
go ahead and pick an obviously incorrect interpreter path to appease
imgact_elf.c.

MFC after:	1 week
2017-03-22 07:05:27 +00:00
Ed Schouten
36cc183884 Make file descriptor passing work for CloudABI's sendmsg().
Reduce the potential amount of code duplication between cloudabi32 and
cloudabi64 by creating a cloudabi_sock_recv() utility function. The
cloudabi32 and cloudabi64 modules will then only contain code to convert
the iovecs to the native pointer size.

In cloudabi_sock_recv(), we can now construct an SCM_RIGHTS cmsghdr in
an mbuf and pass that on to kern_sendit().
2017-03-22 06:43:10 +00:00
Enji Cooper
8b69c3e79f Print out name of non-dynamic sysctl in sysctl_remove_oid_locked
This will provide a slightly better smoking gun than just stating
"can't remove non-dynamic nodes!" when calling sysctl_ctx_free(9)
and sysctl_remove_{name,oid}(9) with a non-dynamic (likely
static) sysctl.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-22 05:27:20 +00:00
Conrad Meyer
5abb3b74d3 kern_fail: Allow sleeping for more than 2147483/hz seconds
Because of integer types, the timeout calculation result was limited to
INT_MAX / (1000 * hz) seconds.  For systems with hz=10000, this is only 215
seconds.  Perform the calculation with 64-bit math to allow sleeping for the
full INT_MAX / hz interval (215000 seconds on such hz=10000 systems).

Submitted by:	Scott Ferris <sferris at isilon.com>
Sponsored by:	Dell EMC Isilon
2017-03-21 22:41:37 +00:00
Ed Maste
26af611582 tighten buffer bounds in imgact_binmisc_populate_interp
We must ensure there's space for the terminating null in the temporary
buffer in imgact_binmisc_populate_interp().

Note that there's no buffer overflow here because xbe->xbe_interpreter's
length and null termination is checked in imgact_binmisc_add_entry()
before imgact_binmisc_populate_interp() is called. However, the latter
should correctly enforce its own bounds.

Reviewed by:	sbruno
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10042
2017-03-21 18:02:14 +00:00
Gleb Smirnoff
3ae4b0e7e8 Force same alignment on struct xinpgen as we have on struct xinpcb. This
fixes 32-bit builds.
2017-03-21 16:23:44 +00:00
Alexander Motin
cf8242898d Remove another remnants left after r246713.
MFC after:	2 weeks
2017-03-21 14:14:11 +00:00
Alexander Motin
97dfdd4efa Remove some dead code left after r246713.
MFC after:	2 weeks
2017-03-21 13:49:43 +00:00
Alexander Motin
31c161a615 Improve command timeout handling.
Let firmware do its best first, and if it can't, try software recovery.
I would remove software timeout handler completely, but found bunch of
complains on command timeout on sparc64 mailing list few years ago, so
better be safe in case of interrupt loss.

MFC after:	2 weeks
2017-03-21 13:10:37 +00:00
Alexander Motin
01728721bf Remove questionable reqp->req_time access.
MFC after:	2 weeks
2017-03-21 11:26:31 +00:00
Alexander Motin
13d9c92192 Clean/unify some macro usage.
MFC after:	2 weeks
2017-03-21 10:34:34 +00:00
Alexander Motin
331d00ba74 Minor cosmetic addition to r315673.
Now CAM_SIM_LOCK() macros are not used and may be removed later.

MFC after:	2 weeks
2017-03-21 09:24:07 +00:00
Alexander Motin
401ed17ad0 Make CAM SIM lock optional.
For three years now CAM does not use SIM lock, but still enforces SIM to
use it.  Remove this requirement, allowing SIMs to have any locking they
prefer, if they pass no mutex to cam_sim_alloc().

MFC after:	2 weeks
2017-03-21 09:12:41 +00:00
Gleb Smirnoff
817e1ad9d0 Make sdp compilable after r315662. 2017-03-21 09:07:05 +00:00
Alexander Motin
abdc2e314b Addition to r315579: drop the lock while allocating IRQs.
MFC after:	12 days
2017-03-21 08:56:13 +00:00
Gleb Smirnoff
cc65eb4e79 Hide struct inpcb, struct tcpcb from the userland.
This is a painful change, but it is needed.  On the one hand, we avoid
modifying them, and this slows down some ideas, on the other hand we still
eventually modify them and tools like netstat(1) never work on next version of
FreeBSD.  We maintain a ton of spares in them, and we already got some ifdef
hell at the end of tcpcb.

Details:
- Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO.
- Make struct xinpcb, struct xtcpcb pure API structures, not including
  kernel structures inpcb and tcpcb inside.  Export into these structures
  the fields from inpcb and tcpcb that are known to be used, and put there
  a ton of spare space.
- Make kernel and userland utilities compilable after these changes.
- Bump __FreeBSD_version.

Reviewed by:	rrs, gnn
Differential Revision:	D10018
2017-03-21 06:39:49 +00:00
Toomas Soome
c1e968fb62 loader: verify the value from dhcp.interface-mtu and use snprintf to set mtu
Since the uset can set dhcp.interface-mtu, we need to try to validate the
value. So we verify if the conversion to int is successful and we will not
allow to set value greater than max IPv4 packet size.

Also use snprintf for safety.

Reviewed by:	allanjude, bapt
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D8492
2017-03-20 22:20:17 +00:00
Alexander Motin
98339da12a Remove some more dead code.
MFC after:	2 weeks
2017-03-20 20:44:14 +00:00
Landon J. Fuller
a668f3d89e Integrate BCM4706 PMU (rev6) support, derived from the ISC-licensed Broadcom
sbchipc.h and hndpmu.c sources included in the RT-N16 and later firmware
source drops.

Approved by:	adrian (mentor, implicit)
2017-03-20 19:27:35 +00:00
Andrew Turner
b4fca5d4a7 Use tc_priv to find the softc in the i.MX timer driver.
Sponsored by:	ABT Systems Ltd
2017-03-20 19:25:42 +00:00
Toomas Soome
11e46b7133 loader: pxe.h constants have wrong values
FLTR_PRMSCS should be 0x4 and FLTR_SRC_RTG should be 0x8

PXE Specification 2.1 PXENV_UNDI_OPEN, page 59.

http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10056
2017-03-20 18:15:36 +00:00
Toomas Soome
1c36b15ace loader: disk_cleanup was left in userboot_disk.c
In r315408, disk_cleanup was removed, which is called at
sys/boot/userboot/userboot/userboot_disk.c:113.
This causes bhyveload to fail.

PR:		217935
Reported by:	Fabian Freyer
Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10060
2017-03-20 18:03:40 +00:00
Andriy Voskoboinyk
90589b904f rtwn: fix node id assignment.
Do not assign new id if node is reused.

Tested with RTL8821AU, HOSTAP mode + RTL8188EU, STA mode
(with inactivity timeout == 90)
2017-03-20 08:10:35 +00:00
Alan Cox
2a016de1a5 Use IDX_TO_OFF(), not ptoa(), when converting the difference between two
vm_pindex_t's into a vm_ooffset_t.

The length given to shm_dotruncate() must never be negative.  Assert this.

Tidy up a comment.

Reviewed by:	kib
MFC after:	1 week
2017-03-20 05:15:55 +00:00
Marius Strobl
0f34084f95 o Add support for eMMC DDR bus speed mode at 52 MHz to sdhci(4) and
mmc(4). For the most part, this consists of support for:
  - Switching the signal voltage (VCCQ) to 1.8 V or (if supported
    by the host controller) to 1.2 V,
  - setting the UHS mode as appropriate in the SDHCI_HOST_CONTROL2
    register,
  - setting the power class in the eMMC device according to the
    core supply voltage (VCC),
  - using different bits for enabling a bus width of 4 and 8 bits
    in the the eMMC device at DDR or higher timings respectively,
  - arbitrating timings faster than high speed if there actually
    are additional devices on the same MMC bus.

  Given that support for DDR52 is not denoted by SDHCI capability
  registers, availability of that timing is indicated by a new
  quirk SDHCI_QUIRK_MMC_DDR52 and only enabled for Intel SDHCI
  controllers so far. Generally, what it takes for a sdhci(4)
  front-end to enable support for DDR52 is to hook up the bridge
  method mmcbr_switch_vccq (which especially for 1.2 V signaling
  support is chip/board specific) and the sdhci_set_uhs_timing
  sdhci(4) method.

  As a side-effect, this change also fixes communication with
  some eMMC devices at SDR high speed mode with 52 MHz due to
  the signaling voltage and UHS bits in the SDHCI controller no
  longer being left in an inappropriate state.

  Compared to 52 MHz at SDR high speed which typically yields
  ~45 MB/s with the eMMC chips tested, throughput goes up to
  ~80 MB/s at DDR52.

  Additionally, this change already adds infrastructure and quite
  some code for modes up to HS400ES and SDR104 respectively (I did
  not want to add to much stuff at a time, though). Essentially,
  what is still missing in order to be able to activate support
  for these latter is is support for and handling of (re-)tuning.

o In sdhci(4), add two tunables hw.sdhci.quirk_clear as well as
  hw.sdhci.quirk_set, which (when hooked up in the front-end)
  allow to set/clear sdhci(4) quirks for debugging and testing
  purposes. However, especially for SDHCI controllers on the
  PCI bus which have no specific support code so far and, thus,
  are picked up as generic SDHCI controllers, hw.sdhci.quirk_set
  allows for setting the necessary quirks (if required).

o In mmc(4), check and handle the return values of some more
  function calls instead of assuming that everything went right.
  In case failures actually are not problematic, indicate that
  by casting the return value to void.

Reviewed by:	jmcneill
2017-03-19 23:27:17 +00:00
Alan Cox
ac46d38655 Style fixes. In particular, the variable "bogus" is used like a Boolean.
Define it as such.

Reviewed by:	kib
MFC after:	1 week
2017-03-19 23:06:11 +00:00
Andriy Voskoboinyk
dc33c66d2b net80211: reschedule tasks properly after r315594. 2017-03-19 23:05:03 +00:00
Andriy Voskoboinyk
e79ef94927 net80211: do not cancel callout when FF queue is empty.
This should reduce overhead for aggregates (since every second frame
clears the queue and reschedules the task there is no need to cancel
the callout here; let it just run once at the end - even if queue is
empty).

Reported by:	adrian
2017-03-19 22:18:44 +00:00
Ian Lepore
928e4f221d Replace the hard-coded way-too-small minimum event timer period with a value
calculated at runtime based on how long it takes to set up an event in
hardware.  This fixes the intermittant 1-minute hang at boot on imx5
systems, and also the occasional oversleeping while running.  It doesn't
affect imx6 systems, which use different hardware for eventtimers.

It turns out that it usually takes about 30 timer ticks to set up the timer
compare register, and the old hard-coded minimum period was 10 ticks.  On
the rare occasions when a timeout event that short was set up, we'd miss
the event and have to wait about 64 seconds for counter rollover before
the compare interrupt would fire.

Instead of just hardcoding a new bigger value, the code now measures the
time it takes to do the register read/write sequence to set up the compare
register, scales it up by 1.5x to be safe, and calculates the minimum event
period from the result.  In the real world, the minimum period works out to
about 750 nanoseconds on imx5 hardware.
2017-03-19 21:53:12 +00:00
Ian Lepore
5e52290fda Eliminate unnecessary read/modify/write sequences during eventtimer setup.
It turns out to be surprisingly expensive to access the gpt hardware (on the
order of 150ns per read/write).  To cut down on the overhead of setting up
each eventtimer event, eliminate read-modify-write sequences to manage the
compare interrupt enable, by keeping a shadow copy of the hardware register
and only writing to the hardware when the enable bits really change.
2017-03-19 21:28:37 +00:00
Konstantin Belousov
133cbe3b59 Update the list of cpudev ioctls which require write access.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-19 21:25:27 +00:00
Alexander Motin
9abc1e2b0c Remove some useless code.
MFC after:	2 weeks
2017-03-19 21:25:13 +00:00
Konstantin Belousov
3966c3803f Style.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-19 21:24:07 +00:00
Andriy Voskoboinyk
2e184b72c3 rtwn: drop unneeded (after r315583) code.
Tested with RTL8188EU, HOSTAP mode + RTL8821AU, STA mode
(fast-frames / A-MSDU).
2017-03-19 20:51:28 +00:00
Andriy Voskoboinyk
abb0adffde net80211: add a timer to flush fast-frames queues.
This should allow to drop 'ieee80211_ff_[age/flush]' calls from drivers
(an additional call can be made from ieee80211_tx_complete()
for non-default ieee80211_ffagemax values to prevent stalls -
but it will require an additional counter for transmitted frames).

Tested with RTL8821AU, STA mode (A-MSDU part only).

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D9984
2017-03-19 20:05:21 +00:00
Alan Cox
8956418832 Two changes to vm_fault_populate():
Simplify the logic for clipping the range returned by the pager to fit
within the map entry.

Use atop() rather than OFF_TO_IDX() on addresses.

Reviewed by:	kib
MFC after:	1 week
2017-03-19 19:52:47 +00:00
Alexander Motin
08826086fe Add initial support for multiple MSI-X vectors.
For 24xx and above use 2 vectors (default and response queue).
For 26xx and above use 3 vectors (default, response and ATIO queues).
Due to global lock interrupt hardlers never run simultaneously now, but
at least this allows to save one regitster read per interrupt.

MFC after:	2 weeks
2017-03-19 19:11:40 +00:00
Ian Lepore
e6f055f6b4 Add a module to build imx5 dtb files. 2017-03-19 19:10:23 +00:00
Ian Lepore
98641b99e3 Delete our local imx53-qsb.dts file; the code now runs fine using the
standard vendor-supplied file in sys/gnu/dts/arm.
2017-03-19 18:50:03 +00:00
Ian Lepore
d32c1ca43c Add INTRNG option to EFIKA_MX config, it is an imx5-based platform. 2017-03-19 18:38:08 +00:00
Ian Lepore
d32f00077b Remove kernel config for DIGI-CCWMX53 devel board. It was just standard
IMX53 with static dtb added, and now that imx53 can use vendor-supplied dts
files and ubldr, there is no need for a static-dtb variant.
2017-03-19 18:35:20 +00:00
Ian Lepore
cde8ef4d96 Convert the imx5 interrupt controller driver to INTRNG. 2017-03-19 18:30:38 +00:00
Ian Lepore
e04a4275b2 Add dtb/imx5 module build to the imx53 kernel config. 2017-03-19 18:28:38 +00:00
Ian Lepore
76fedc062f Remove kernel config for IMX53-QSB (quickstart board). It was just
standard IMX53 with static dtb added, and now that imx53 can use vendor-
supplied dts files and ubldr, there is no need for a static-dtb variant.
2017-03-19 18:26:52 +00:00
Konstantin Belousov
bc27810671 Fix off-by-one in the vm_fault_populate() code.
When re-calculating the last inclusive page index after the pager
call, -1 was erronously ommitted.  If the pager extended the run
(unlikely), the result would be insertion of the valid page mapping
outside the current map entry range.

Found by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-19 14:42:16 +00:00
Alexander Motin
9c81a61ee1 Remove hackish code delaying ATIOs to unknown virtual port.
Since we support RQSTYPE_RPT_ID_ACQ, that functionality is only useful
in loop mode, which probably doesn't worth having this hack in 2017.

MFC after:	2 weeks
2017-03-19 13:46:11 +00:00
Alexander Motin
e2a658cb0c Move <= 23xx PDB workaround to generic code.
It is chip-specific and has nothing to do with platform.

MFC after:	2 weeks
2017-03-19 10:28:04 +00:00
Alexander Motin
a41dd87f61 Remove some dead stuff.
MFC after:	2 weeks
2017-03-19 09:36:43 +00:00
Alexander Motin
5a5632c2de Move 24xx RQSTYPE_NOTIFY handling to generic code.
This code has nothing to do with specific platform.

MFC after:	2 weeks
2017-03-19 09:30:03 +00:00
Adrian Chadd
15e58d4d26 [ath] prepare for "correct" group (bcast/mcast) address frame handling and software/hardware queue TID mapping.
When I initially did this 11n TX work in days of yonder, my 802.11 standards
clue was ... not as finely tuned.  One of the things in 802.11-2012 (which
I guess technically was after I did this work, but I'm sure it was like this
in the previous rev?) is that among other traffic classes, three things are
important:

* group addressed frames should be default non-QoS, even if they're QoS frames, and
* group addressed frames should have a seqno out of a different space than the
  per-TID QoS one; and because of this
* group addressed frames, being non-QoS, should never be in the Block-ACK window
  for TX.

Now, net80211 and now this code cheats by using the non-QOS TID, but ideally
we'd introduce a separate seqno space just for multicast/group traffic for
TX and RX comparison.

Later extensions (eg reliable multicast / multimedia) express what one should do
when doing multicast traffic in a TID.  Now, technically we /could/ do group traffic
as QoS traffic and throw it into a per-TID seqno space, but this definitely
introduces ordering issues when you take into account things like CABQ behaviour.
(Ie, if some traffic in the TID goes into the CABQ and some doesn't, because
it's doing a split of multicast and non-multicast traffic, then you have
seqno ordering issues.)

So, until someone implements 802.11vv reliable multicast / multimedia extensions,
group traffic is non-QoS.

Next, software/hardware queue TID mapping.  In the past I believed the WME tagging
of frames because well, net80211 had a habit of tagging things like management
traffic with it.  But, then we also map QoS traffic categories to TIDs as well.
So, we should obey the TID!  But! then it put some management traffic into higher
WME categories too, as those frames don't have QoS TIDs.  But! It'd do things like
put things like QoS action frames into higher WME categories, when they should
be kept in-order with the rest of the traffic for that TID.  So! Given all of this,
the ath(4) driver does overrides to not trust the WME category.

I .. am undoing some of this.  Now, the TID has a 1:1 mapping to the hardware
queue.  The TID is the primary source of truth now for all QoS traffic.
The WME is only used for non-QoS traffic.  This now means that any TID traffic
queued should be consistently queued regardless of WME, so things like the
"TX finished, do more TX" that is occuring right now for transmit handling
should be "better".

The consistent {TID, WME} -> hardware queue mapping is important for
transmit completion.  It's used to schedule more traffic for that
particular TID, because that {many TID}:{1 TXQ} mapping in ath_tx_tid_sched()
is used for driving completion.  Ie, when the hardware queue completes,
it'll walk that list of scheduled TIDs attached to that TXQ.

The eventual aim is to get ready for some other features around putting
some data into other hardware queues (eg for better PS-POLL support,
uAPSD, support, correct-er TDMA support, etc) which requires that
I tidy all of this up in preparation for then introducing further
TID scheduling that isn't linked to a hardware TXQ (likely a per-WME, per-TID
driver queue, and a per-node driver queue) to enable that.

Tested:

* AR9380, STA mode
* AR9380, AR9580, AP mode
2017-03-19 05:00:14 +00:00
Ian Lepore
3d9df27601 Remove unreferenced global function imx_gpt_get_timerfreq() and do some
cleanups enabled by that:

 - The only thing left in imx_gptvar.h was the softc, which IMO never
   should have been in there at all.  Move it into the driver, and
   delete the header file.

 - Remove several unneeded #includes from the driver.

 - Change imx_gpt_softc from global to static (it's used by DELAY()), and
   don't redundantly static-initialize it to NULL.
2017-03-19 04:03:39 +00:00
Kristof Provost
08ef4ddb0f pf: Fix rule evaluation after inet6 route-to
In pf_route6() we re-run the ruleset with PF_FWD if the packet goes out
of a different interface. pf_test6() needs to know that the packet was
forwarded (in case it needs to refragment so it knows whether to call
ip6_output() or ip6_forward()).

This lead pf_test6() to try to evaluate rules against the PF_FWD
direction, which isn't supported, so it needs to treat PF_FWD as PF_OUT.
Once fwdir is set correctly the correct output/forward function will be
called.

PR:		217883
Submitted by:	Kajetan Staszkiewicz
MFC after:	1 week
Sponsored by:	InnoGames GmbH
2017-03-19 03:06:09 +00:00
Eric van Gyzen
26f86ab732 Regenerate syscall files for r315526
Sponsored by:	Dell EMC
2017-03-19 00:54:24 +00:00
Eric van Gyzen
3f8455b090 Add clock_nanosleep()
Add a clock_nanosleep() syscall, as specified by POSIX.
Make nanosleep() a wrapper around it.

Attach the clock_nanosleep test from NetBSD. Adjust it for the
FreeBSD behavior of updating rmtp only when interrupted by a signal.
I believe this to be POSIX-compliant, since POSIX mentions the rmtp
parameter only in the paragraph about EINTR. This is also what
Linux does. (NetBSD updates rmtp unconditionally.)

Copy the whole nanosleep.2 man page from NetBSD because it is complete
and closely resembles the POSIX description. Edit, polish, and reword it
a bit, being sure to keep any relevant text from the FreeBSD page.

Reviewed by:	kib, ngie, jilles
MFC after:	3 weeks
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10020
2017-03-19 00:51:12 +00:00
Ed Maste
bd4e40546c use INT3 instead of NOP for x86 binary padding
We should never end up executing the inter-function padding, so we
are better off faulting than silently carrying on to whatever function
happens to be next.

Note that LLD will soon do this by default (although it currently pads
with zeros).

Reviewed by:	dim, kib
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10047
2017-03-19 00:22:13 +00:00
Alan Cox
c547cbb49c Avoid unnecessary calls to vm_map_protect() in elf_load_section().
Typically, when elf_load_section() unconditionally passed VM_PROT_ALL to
elf_map_insert(), it was needlessly enabling execute access on the
mapping, and it would later have to call vm_map_protect() to correct the
mapping's access rights.  Now, instead, elf_load_section() always passes
its parameter "prot" to elf_map_insert().  So, elf_load_section() must
only call vm_map_protect() if it needs to remove the write access that
was temporarily granted to perform a copyout().

Reviewed by:	kib
MFC after:	1 week
2017-03-18 23:37:00 +00:00
Don Lewis
46c8aadb6f Change several constants used by the PIE algorithm from unsigned to signed.
- PIE_MAX_PROB is compared to variable of int64_t and the type promotion
   rules can cause the value of that variable to be treated as unsigned.
   If the value is actually negative, then the result of the comparsion
   is incorrect, causing the algorithm to perform poorly in some
   situations.  Changing the constant to be signed cause the comparision
   to work correctly.

 - PIE_SCALE is also compared to signed values.  Fortunately they are
   also compared to zero and negative values are discarded so this is
   more of a cosmetic fix.

 - PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
   enough that the automatic promotion to unsigned is harmless.

Submitted by:	Rasool Al-Saadi <ralsaadi@swin.edu.au>
MFC after:	1 week
2017-03-18 23:00:13 +00:00
Eric van Gyzen
4cf66812ea nanosleep: plug a kernel memory disclosure
nanosleep() updates rmtp on EINVAL.  In that case, kern_nanosleep()
has not updated rmt, so sys_nanosleep() updates the user-space rmtp
by copying garbage from its stack frame.  This is not only a kernel
memory disclosure, it's also not POSIX-compliant.  Fix it to update
rmtp only on EINTR.

Reviewed by:	jilles (via D10020), dchagin
MFC after:	3 days
Security:	possibly
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10044
2017-03-18 20:16:23 +00:00
Ian Lepore
6c23d3cf76 Remove hardcoded bootverbose=1; imx53 systems boot using loader(8) and
users can set verbose if they want to.
2017-03-18 19:54:58 +00:00
Alexander Motin
87b04de6cb Reorganize RQSTYPE_NOTIFY handling for chips <= 23xx.
There were two copies of the code: one in generic code was half-broken, and
another in platform code was never called.  Leave only one in generic code
and working.

MFC after:	2 weeks
2017-03-18 19:27:16 +00:00
Dmitry Chagin
039aba0861 Glibc get_nprocs() and get_nprocs_conf() uses the sysfs cpu infrastructure
to get number of processors. Implement /sys/devices/system/cpu/.

MFC after:	1 month
2017-03-18 18:38:12 +00:00
Dmitry Chagin
b1ba0846f1 Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.

MFC after:	1 month
2017-03-18 18:34:29 +00:00
Dmitry Chagin
cd92d27e16 As noted by Roel Bouwman Linux allows a large buffer size than the
struct ucred size. Fix this.

PR:		102956
Reported by:	Roel Bouwman <roel at qsp nl>
MFC after:	1 week
2017-03-18 18:31:04 +00:00
Dmitry Chagin
857129394d To reduce code duplication move socket defines to the MI path.
MFC after:	1 week
2017-03-18 18:23:30 +00:00
Dmitry Chagin
54ec725bf3 Remove superflous break statment.
MFC after:	1 week
2017-03-18 18:19:31 +00:00
Dmitry Chagin
bd597911b2 Check for negative nanoseconds.
Linux do that in timespec_valid().

Reported by:	vangyzen@
MFC after:	1 week
2017-03-18 18:14:17 +00:00
Ian Lepore
26c048c814 Make the imx5 clocks driver work with vendor-supplied dts (which does not
supply the addresses for the DPLL register blocks) by hard-coding the
addresses in the driver source code.  Yes, this is just as bad an idea as
it sounds, but we have no choice.

In the early days of using fdt data, when we were making up our own data
for each board, we defined 4 sets of memory mapped registers in the data.
The vendor-supplied data only provides the address of the CCM register
block, but not the 3 DPLL blocks.  The linux driver has the DPLL physical
addresses (which differ by SOC type) hard-coded in the driver, and we
have no choice but to do the same thing if we want to run with the vendor-
supplied fdt data.

So now we use bus_space_map() to make the DPLL blocks accessible, choosing
the set of fixed addresses to map based on the soc id.
2017-03-18 17:50:49 +00:00
Alexander Motin
981ffc4e21 Move RQSTYPE_ABTS_RCVD parsing into generic code.
MFC after:	2 weeks
2017-03-18 17:01:11 +00:00
Alexander Motin
15c62456d1 Extend nt_lun to full 8 byte.
MFC after:	2 weeks
2017-03-18 16:09:36 +00:00
Alexander Motin
98b08fbea5 Remove dead remnants of SPI target.
MFC after:	2 weeks
2017-03-18 15:42:22 +00:00
Alexander Motin
782a8e7ca3 Use isp_target_put_entry() in places where it can be.
This unifies the code and removes some duplication.

MFC after:	2 weeks
2017-03-18 13:42:08 +00:00
Bruce Evans
4eb235fb4f Fix bright colors for syscons, and make them work for the first time
for vt.  Restore syscons' rendering of background (bg) brightness as
foreground (fg) blinking and vice versa, and add rendering of blinking
as background brightness to vt.

Bright/saturated is conflated with light/white in the implementation
and in this description.

Bright colors were broken in all cases, but appeared to work in the
only case shown by "vidcontrol show".  A boldness hack was applied
only in 1 layering-violation place (for some syscons sequences) where
it made some cases seem to work but was undone by clearing bold using
ANSI sequences, and more seriously was not undone when setting
ANSI/xterm dark colors so left them bright.  Move this hack to drivers.

The boldness hack is only for fg brightness.  Restore/add a similar hack
for bg brightness rendered as fg blinking and vice versa.  This works
even better for vt, since vt changes the default text mode to give the
more useful bg brightness instead of fg blinking.

The brightness bit in colors was unnecessarily removed by the boldness
hack.  In other cases, it was lost later by teken_256to8().  Use
teken_256to16() to not lose it.  teken_256to8() was intended to be
used for bg colors to allow finer or bg-specific control for the more
difficult reduction to 8; however, since 16 bg colors actually work
on VGA except in syscons text mode and the conversion isn't subtle
enough to significantly in that mode, teken_256to8() is not used now.

There are still bugs, especially in vidcontrol, if bright/blinking
background colors are set.

Restore XOR logic for bold/bright fg in syscons (don't change OR
logic for vt).  Remove broken ifdef on FG_UNDERLINE and its wrong
or missing bit and restore the correct hard-coded bit.  FG_UNDERLINE
is only for mono mode which is not really supported.

Restore XOR logic for blinking/bright bg in syscons (in vt, add
OR logic and render as bright bg).  Remove related broken ifdef
on BG_BLINKING and its missing bit and restore the correct
hard-coded bit.  The same bit means blinking or bright bg depending
on the mode, and we want to ignore the difference everywhere.

Simplify conversions of attributes in syscons.  Don't pretend to
support bold fonts.  Don't support unusual encodings of brightness.
It is as good as possible to map 16 VGA colors to 16 xterm-16
colors.  E.g., VGA brown -> xterm-16 Olive will be converted back
to VGA brown, so we don't need to convert to xterm-256 Brown.  Teken
cons25 compatibility code already does the same, and duplicates some
small tables.  This is mostly for the sc -> te direction.  The other
direction uses teken_256to16() which is too generic.
2017-03-18 11:13:54 +00:00
Alexander Motin
44a2a27af5 Do some notify acks cleanup.
ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument.

MFC after:	2 weeks
2017-03-18 10:34:29 +00:00
Bruce Evans
82b93348db Fix right shifts on arches with db_expr_t larger than u_int (LP64 arches
in practice).

db_expr_t is a signed type, but right shifts are fudged to evaluate
them in an unsigned type, and the unsigned type was broken by hard-
coding it as 'unsigned', so casting to it lost the top bits on arches
with db_expr_t larger than u_int.

The unsigned type with the same size as db_expr_t is not declared;
assume that db_addr_t gives it.  Fixing this properly is less important
than using the correct type for db_expr_t (originally always long for
C90, but always intmax_t since C99).
2017-03-18 07:01:18 +00:00
Kristof Provost
5c172e7059 pf: Fix memory leak on vnet shutdown or unload
Rules are unlinked in shutdown_pf(), so we must call
pf_unload_vnet_purge(), which frees unlinked rules, after that, not
before.

Reviewed by:	eri, bz
Differential Revision:	https://reviews.freebsd.org/D10040
2017-03-18 01:37:20 +00:00
Marius Strobl
c11bbc7dab Again, fixes regarding style(4), to comments, includes and unused
parameters.
2017-03-17 22:57:37 +00:00
Landon J. Fuller
b86f80276b Add MIPS boot support for the BCM4706/Northstar ChipCommon core.
This adds support for matching against a core lookup table when performing
early boot core lookup, and includes the BCM4706/Northstar-specific
ChipCommon core ID in the set of supported ChipCommon cores.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D10033
2017-03-17 22:02:02 +00:00
Justin Hibbits
e683c328f8 Introduce 64-bit PowerPC Book-E support
Extend the Book-E pmap to support 64-bit operation.  Much of this was taken from
Juniper's Junos FreeBSD port.  It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index).  In practice this may not be a problem
given the expanded address space.  However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space.  Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.

This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
  kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
  (total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
  a 32-bit init with 64-bit children.

Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.

Reviewed by:	stevek
Obtained from:	Juniper (in part)
MFC after:	2 months
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D9433
2017-03-17 21:40:14 +00:00
Bryan Drewery
66f30c92ee kmod: Fix building assym.o not building missing dependencies.
For instance, in the dtrace/dtrace module, building dtrace_asm.o wants
to build genassym.o first, but it doesn't build the missing ilinks
and if_*.h headers which are part of the OBJS_DEPEND_GUESS list
of dependencies to build if a .depend file is missing.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2017-03-17 18:08:33 +00:00
Bryan Drewery
3063d216c1 kmod: Fix depending on ILINKS for tracked DEPENDOBJS.
The objects that may be in the dependency graph may not match
${OBJS}.  Ensure the ilink link is added as a dependency for
all of them when a .depend file is missing for that objfile.

MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2017-03-17 18:08:00 +00:00
Alan Somers
559b42968c Constrain IPv6 routes to single FIBs when net.add_addr_allfibs=0
sys/netinet6/icmp6.c
	Use the interface's FIB for source address selection in ICMPv6 error
	responses.

sys/netinet6/in6.c
	In in6_newaddrmsg, announce arrival of local addresses on the
	interface's FIB only.  In in6_lltable_rtcheck, use a per-fib ND6
	cache instead of a single cache.

sys/netinet6/in6_src.c
	In in6_selectsrc, use the caller's fib instead of the default fib.
	In in6_selectsrc_socket, remove a superfluous check.

sys/netinet6/nd6.c
	In nd6_lle_event, use the interface's fib for routing socket
	messages.  In nd6_is_new_addr_neighbor, check all FIBs when trying
	to determine whether an address is a neighbor.  Also, simplify the
	code for point to point interfaces.

sys/netinet6/nd6.h
sys/netinet6/nd6.c
sys/netinet6/nd6_rtr.c
	Make defrouter_select fib-aware, and make all of its callers pass in
	the interface fib.

sys/netinet6/nd6_nbr.c
	When inputting a Neighbor Solicitation packet, consider the
	interface fib instead of the default fib for DAD.  Output NS and
	Neighbor Advertisement packets on the correct fib.

sys/netinet6/nd6_rtr.c
	Allow installing the same host route on different interfaces in
	different FIBs.  If rt_add_addr_allfibs=0, only install or delete
	the prefix route on the interface fib.

tests/sys/netinet/fibs_test.sh
	Clear some expected failures, but add a skip for the newly revealed
	BUG217871.

PR:		196361
Submitted by:	Erick Turnquist <jhujhiti@adjectivism.org>
Reported by:	Jason Healy <jhealy@logn.net>
Reviewed by:	asomers
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D9451
2017-03-17 16:50:37 +00:00
Hans Petter Selasky
a0699ebf77 Implement get_pid_task(), pid_task() and some other PID helper
functions in the LinuxKPI. Add a usage atomic to the task_struct
structure to facilitate refcounting the task structure when returned
from get_pid_task(). The get_task_struct() and put_task_struct()
function is used to manage atomic refcounting. After this change the
task_struct should only be freed through put_task_struct().

Obtained from:		kmacy @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-17 15:40:24 +00:00
Bruce Evans
ff17a6773e Don't access the reserved registers %dr4 and %dr5 on i386.
On the original i386, %dr[4-5] were unimplemented but not very clearly
reserved, so debuggers read them to print them.  i386 was still doing
this.

On the original athlon64, %dr[4-5] are documented as reserved but are
aliased to %dr[6-7] unless CR4_DE is set, when accessing them traps.

On 2 of my systems, accessing %dr[4-5] trapped sometimes.  On my Haswell
system, the apparent randomness was because the boot CPU starts with
CR4_DE set while all other CPUs start with CR4_DE clear.  FreeBSD
doesn't support the data breakpoints enabled by CR4_DE and it never
changes this flag, so the flag remains different across CPUs and
the behaviour seemed inconsistent except while booting when the CPU
doesn't change.

The invalid accesses broke:
- read access for printing the registers in ddb "show watches" on CPUs
  with CR4_DE set
- read accesses in fill_dbregs() on CPUs with CR4_DE set.  This didn't
  implement panic(3) since the user case always skipped %dr[4-5].
- write accesses in set_dbregs().  This also didn't affect userland.
  When it didn't trap, the aliasing made it fragile.

Don't print the dummy (zero) values of %dr[4-5] in "show watches" for
i386 or amd64.  Fix style bugs near this printing.

amd64 also has space in the dbregs struct for the reserved %dr[8-15]
and already didn't print the dummy values for these, and never accessed
any of the 10 reserved debug registers.

Remove cpufuncs for making the invalid accesses.  Even amd64 had these.
2017-03-17 13:49:05 +00:00
Konstantin Belousov
469ec1eb6a When clearing altsigstack settings on exec, do it to the right thread.
Diagnosed by:	smh
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-03-17 13:37:37 +00:00
Andrew Turner
ffa237e24f Mark the EFI PE header as allocated. While ld.bfd doesn't seem to care
about not having this flag ld.lld fails to link without it.

Sponsored by:	DARPA, AFRL
2017-03-17 13:31:24 +00:00
Andrew Turner
1eff4c0c37 Remove code for Marvell SoCs that lack a kernel config.
It seems to be old code from the armv6 project branch that never had a
kernel config.

Reviewed by:	mmel
Sponsored by:	ABT Systems Lrd
Differential Revision:	https://reviews.freebsd.org/D7166
2017-03-17 12:59:16 +00:00
Andrew Turner
83d9fd40d5 Make the default FDT implementation of platform_mp_setmaxid use the cpu
nodes from the DTB by default. This will allow us to enumerate the CPUs
without hard coding the CPU count into code.

Reviewed by:	br
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D9827
2017-03-17 12:45:53 +00:00
Steven Hartland
c76da62acf Reduce ARC fragmentation threshold
As ZFS can request up to SPA_MAXBLOCKSIZE memory block e.g. during zfs recv,
update the threshold at which we start agressive reclamation to use
SPA_MAXBLOCKSIZE (16M) instead of the lower zfs_max_recordsize which
defaults to 1M.

PR:		194513
Reviewed by:	avg, mav
MFC after:	1 month
Sponsored by:	Multiplay
Differential Revision:	https://reviews.freebsd.org/D10012
2017-03-17 12:34:57 +00:00
Andrew Turner
0960989f8f Move the IMX6 kernels to use PLATFORM_SMP. This is the last SMP config to
be migrated to this and will allow the removal of this option.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D9907
2017-03-17 12:34:56 +00:00
Hans Petter Selasky
05d4f501dc Implement minimalistic memory mapping structure, struct mm_struct, and
some associated helper functions in the LinuxKPI. Let the existing
linux_alloc_current() function allocate and initialize the new
structure and let linux_free_current() drop the refcount on the memory
mapping structure. When the mm_struct's refcount reaches zero, the
structure is freed.

Obtained from:		kmacy @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-17 10:30:06 +00:00
Hans Petter Selasky
0a2f4606bb Add comment describing the use of pagefault_disable() and
pagefault_enable() in the LinuxKPI.

Suggested by:  		rpokala@
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-17 08:02:46 +00:00
Marius Strobl
9dbf8c467e - Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
registers.
- Add slot type capability bits. These bits should allow recognizing
  removable card slots, embedded cards and shared buses (shared bus
  supposedly is always comprised of non-removable cards).
- Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LO
  registers in sdhci_dumpregs().
- The drive type support flags in the CAPABILITIES2 register are for
  drive types A,C,D, drive type B is the default setting (value 0) of
  the drive strength field in the SDHCI_HOST_CONTROL2 register.

Obtained from:	DragonFlyBSD (9e3c8f63, 455bd1b1)
2017-03-16 22:42:17 +00:00
Marius Strobl
72dec0792a - Add support for eMMC "partitions". Besides the user data area, i. e.
the default partition, eMMC v4.41 and later devices can additionally
  provide up to:
  1 enhanced user data area partition
  2 boot partitions
  1 RPMB (Replay Protected Memory Block) partition
  4 general purpose partitions (optionally with a enhanced or extended
    attribute)

  Of these "partitions", only the enhanced user data area one actually
  slices the user data area partition and, thus, gets handled with the
  help of geom_flashmap(4). The other types of partitions have address
  space independent from the default partition and need to be switched
  to via CMD6 (SWITCH), i. e. constitute a set of additional "disks".

  The second kind of these "partitions" doesn't fit that well into the
  design of mmc(4) and mmcsd(4). I've decided to let mmcsd(4) hook all
  of these "partitions" up as disk(9)'s (except for the RPMB partition
  as it didn't seem to make much sense to be able to put a file-system
  there and may require authentication; therefore, RPMB partitions are
  solely accessible via the newly added IOCTL interface currently; see
  also below). This approach for one resulted in cleaner code. Second,
  it retains the notion of mmcsd(4) children corresponding to a single
  physical device each. With the addition of some layering violations,
  it also would have been possible for mmc(4) to add separate mmcsd(4)
  instances with one disk each for all of these "partitions", however.
  Still, both mmc(4) and mmcsd(4) share some common code now e. g. for
  issuing CMD6, which has been factored out into mmc_subr.c.

  Besides simply subdividing eMMC devices, some Intel NUCs having UEFI
  code in the boot partitions etc., another use case for the partition
  support is the activation of pseudo-SLC mode, which manufacturers of
  eMMC chips typically associate with the enhanced user data area and/
  or the enhanced attribute of general purpose partitions.

  CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation.

- Now that properly issuing CMD6 is crucial (so data isn't written to
  the wrong partition for example), make a step into the direction of
  correctly handling the timeout for these commands in the MMC layer.
  Also, do a SEND_STATUS when CMD6 is invoked with an R1B response as
  recommended by relevant specifications. However, quite some work is
  left to be done in this regard; all other R1B-type commands done by
  the MMC layer also should be followed by a SEND_STATUS (CMD13), the
  erase timeout calculations/handling as documented in specifications
  are entirely ignored so far, the MMC layer doesn't provide timeouts
  applicable up to the bridge drivers and at least sdhci(4) currently
  is hardcoding 1 s as timeout for all command types unconditionally.
  Let alone already available return codes often not being checked in
  the MMC layer ...

- Add an IOCTL interface to mmcsd(4); this is sufficiently compatible
  with Linux so that the GNU mmc-utils can be ported to and used with
  FreeBSD (note that due to the remaining deficiencies outlined above
  SANITIZE operations issued by/with `mmc` currently most likely will
  fail). These latter will be added to ports as sysutils/mmc-utils in
  a bit. Among others, the `mmc` tool of the GNU mmc-utils allows for
  partitioning eMMC devices (tested working).

- For devices following the eMMC specification v4.41 or later, year 0
  is 2013 rather than 1997; so correct this for assembling the device
  ID string properly.

- Let mmcsd.ko depend on mmc.ko. Additionally, bump MMC_VERSION as at
  least for some of the above a matching pair is required.

- In the ACPI front-end of sdhci(4) describe the Intel eMMC and SDXC
  controllers as such in order to match the PCI one.
  Additionally, in the entry for the 80860F14 SDXC controller remove
  the eMMC-only SDHCI_QUIRK_INTEL_POWER_UP_RESET.

OKed by:	imp
Submitted by:	ian (mmc_switch_status() implementation)
2017-03-16 22:23:04 +00:00
Toomas Soome
429528f376 loader: biosdisk should report IO error from INT13
We should be more verbose about read errors from biosdisk, except filter
out the floppy controller errors, which apparently are resulting from
read attempt from device without the media present.

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10032
2017-03-16 21:34:14 +00:00
Hans Petter Selasky
3803a97f84 Use __LP64__ to detect presence of suword64() to fix linking and
loading of the LinuxKPI on 32-bit platforms.

Reported by:		lwhsu @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-03-16 20:39:31 +00:00
Andrew Turner
86b5c43667 If ofw_bus_msimap fails don't try to use the invalid MSI/MSI-X parent node.
Sponsored by:	ABT Systems Ltd
2017-03-16 17:49:37 +00:00