]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r349285
Eric van Gyzen [Wed, 3 Jul 2019 19:52:24 +0000 (19:52 +0000)]
MFC r349285

VirtIO SCSI:  validate seg_max on attach

Until head r349278 (stable/12 r349690), bhyve presented a seg_max
to the guest that was too large.  Detect this case and clamp it to
the virtqueue size.  Otherwise, we would fail the "too many segments
to enqueue" assertion in virtqueue_enqueue().

I hit this by running a guest with a MAXPHYS of 256 KB.

Reviewed by: bryanv cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20703

5 years agoMFC r349278
Eric van Gyzen [Wed, 3 Jul 2019 19:50:22 +0000 (19:50 +0000)]
MFC r349278

bhyve: Fix vtscsi maximum segment config

The seg_max value reported to the guest should be two less than the
host's maximum, in order to leave room for the request and the
response.  This is analogous to r347033 for virtio_block.

We hit the "too many segments to enqueue" assertion on OneFS because
we increase MAXPHYS to 256 KB.

Reviewed by: bryanv
Discussed with: cem jhb rgrimes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20529

5 years agoMFC r349320, r349324:
Konstantin Belousov [Wed, 3 Jul 2019 19:34:17 +0000 (19:34 +0000)]
MFC r349320, r349324:
coredump: avoid writing to core files not owned by the effective user.

PR: 68905
admbugs: 358

5 years agoMFC r346777:
Justin Hibbits [Wed, 3 Jul 2019 19:32:25 +0000 (19:32 +0000)]
MFC r346777:

powerpc: Add POWER8NVL definition

The POWER8NVL (POWER8 NVLink) architecturally behaves identically to the
POWER8, with a different PVR identifier.  Mark it as such, so it shows up
appropriately to the user.

Reported by: Alexey Kardashevskiy

5 years agoMFC r349519:
Konstantin Belousov [Wed, 3 Jul 2019 19:31:11 +0000 (19:31 +0000)]
MFC r349519:
Style.

5 years agoMFC r349512:
Konstantin Belousov [Wed, 3 Jul 2019 19:29:53 +0000 (19:29 +0000)]
MFC r349512:
Mention proccontrol(1) -m kpti.

5 years agoMFC r349511:
Konstantin Belousov [Wed, 3 Jul 2019 19:28:47 +0000 (19:28 +0000)]
MFC r349511:
Typo.

5 years agoMFC r349427:
Konstantin Belousov [Wed, 3 Jul 2019 19:27:34 +0000 (19:27 +0000)]
MFC r349427:
amd64 pmap: Fix pkru handling in pmap_remove().

5 years agoMFC r347167,r348079
Justin Hibbits [Wed, 3 Jul 2019 19:25:57 +0000 (19:25 +0000)]
MFC r347167,r348079

Book-E pmap

r347167: powerpc/booke: Use #ifdef __powerpc64__ instead of hw_direct_map in
places
r348079: powerpc/booke: Use wrtee instead of msr to restore EE bit

5 years agoMFC r349299:
Konstantin Belousov [Wed, 3 Jul 2019 19:24:50 +0000 (19:24 +0000)]
MFC r349299:
Add libc stub for pthread_getthreadid_np(3).

PR: 238650

5 years agoMFC r349297:
Konstantin Belousov [Wed, 3 Jul 2019 19:22:25 +0000 (19:22 +0000)]
MFC r349297:
Remove redundand 'else' and 'return'.

5 years agoMFC r346173,r347943
Justin Hibbits [Wed, 3 Jul 2019 19:21:03 +0000 (19:21 +0000)]
MFC r346173,r347943

r346173: powerpc/dtrace: Fix dtrace powerpc asm, and simplify stack walking
r347943: powerpc/dtrace: Actually fix stack traces

5 years agoMFC r344915:
Justin Hibbits [Wed, 3 Jul 2019 19:07:42 +0000 (19:07 +0000)]
MFC r344915:

powerpc: Fix cpufreq statement scoping

The second statements on the lines are not guarded by the `if' condition.
This triggers a warning with newer gcc.  It's relatively harmless given the
usage, but incorrect.  Instead, wrap the statements so they're properly
guarded.

5 years agoMFC r345829,345831,349402
Justin Hibbits [Wed, 3 Jul 2019 19:01:41 +0000 (19:01 +0000)]
MFC r345829,345831,349402

r345829: powerpc: Apply r178139 from sparc64 to powerpc's fpu_sqrt
r345831: powerpc: Allow emulating optional FPU instructions on CPUs with an FPU
r349402: powerpc/booke: Handle misaligned floating point loads/stores as on AIM

5 years agoMFC r344958,r344960,r344961
Justin Hibbits [Wed, 3 Jul 2019 18:53:04 +0000 (18:53 +0000)]
MFC r344958,r344960,r344961

r344958: powerpc: Print data address register on alignment exceptions
r344960: powerpc: Print trap frame address for fatal traps
r344961: powerpc: Print trap frame address in ddb backtraces

5 years agoMFC r349522:
Hans Petter Selasky [Wed, 3 Jul 2019 18:29:18 +0000 (18:29 +0000)]
MFC r349522:
Need to apply the PCIM_BAR_MEM_BASE mask to the physical memory
address before returning it to the user. Some of the least significant
bits have special meaning and should be masked away.

Discussed with: kib@
Sponsored by: Mellanox Technologies

5 years agoMFC r349409 and r349410:
Hans Petter Selasky [Wed, 3 Jul 2019 18:23:36 +0000 (18:23 +0000)]
MFC r349409 and r349410:
Fix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
devices are enumerated regardless of of the LIBUSB_HOTPLUG_ENUMERATE
flag. Make sure when the flag is not specified no arrival events are
generated for currently enumerated devices.

Sponsored by: Mellanox Technologies

5 years agoMFC r349370:
Hans Petter Selasky [Wed, 3 Jul 2019 18:18:05 +0000 (18:18 +0000)]
MFC r349370:
Fix parsing of corrupt data in usbdump(8). Check that the transfer
type array lookup is within bounds to avoid segfault.

PR: 238801
Sponsored by: Mellanox Technologies

5 years agoMFC r349368:
Hans Petter Selasky [Wed, 3 Jul 2019 18:16:10 +0000 (18:16 +0000)]
MFC r349368:
Free all allocated unit IDs in cuse(3) after the client character
devices have been destroyed to avoid creating character devices with
identical name.

Sponsored by: Mellanox Technologies

5 years agoMFC r349367:
Hans Petter Selasky [Wed, 3 Jul 2019 18:14:00 +0000 (18:14 +0000)]
MFC r349367:
Fix for deadlock situation in cuse(3)

The final server unref should be done by the server thread to prevent
deadlock in the client cdevpriv destructor, which cannot destroy
itself.

Sponsored by: Mellanox Technologies

5 years agoMFC r349448:
Cy Schubert [Wed, 3 Jul 2019 18:11:22 +0000 (18:11 +0000)]
MFC r349448:

Fix a typo.

PR/238816 initially addressed updates to usage() however it has now
become a shopping list of fixes to ipmon man pages and usage().

PR: 238816

5 years agoMFC r349268: nandsim: correct test to avoid out-of-bounds access
Ed Maste [Wed, 3 Jul 2019 17:34:26 +0000 (17:34 +0000)]
MFC r349268: nandsim: correct test to avoid out-of-bounds access

Previously nandsim_chip_status returned EINVAL iff both of user-provided
chip->ctrl_num and chip->num were out of bounds.  If only one failed the
bounds check arbitrary memory would be read and returned.

The NAND framework is not built by default, nandsim is not intended for
production use (it is a simulator), and the nandsim device has root-only
permissions.

admbugs: 827
Reported by: Daniel Hodson of elttam
Security: kernel information leak or DoS
Sponsored by: The FreeBSD Foundation

5 years agoMFC r349401:
Cy Schubert [Wed, 3 Jul 2019 17:09:41 +0000 (17:09 +0000)]
MFC r349401:

While working on PR/238796 I discovered an unused variable in frdest,
the next hop structure. It is likely this contributes to PR/238796
though other factors remain to be investigated.

PR: 238796

5 years agoMFC r349399-349400,349567-349568:
Cy Schubert [Wed, 3 Jul 2019 17:04:44 +0000 (17:04 +0000)]
MFC r349399-349400,349567-349568:

Prompted by r349366, ipfilter is also does not conform to RFC 3128
by dropping TCP fragments with offset = 1.

In addition to dropping these fragments, add a DTrace probe to allow
for more detailed monitoring and diagnosis if required.

5 years agoMFC r349362:
Cy Schubert [Wed, 3 Jul 2019 16:53:59 +0000 (16:53 +0000)]
MFC r349362:

The definition of icmptypes in ip_compt.h is dead code as it already
use the icmptypes in ip_icmp.h.

5 years agoMFC r349331:
Cy Schubert [Wed, 3 Jul 2019 16:48:46 +0000 (16:48 +0000)]
MFC r349331:

Clean out duplicate definitions of TCP macros also found in netinet/tcp.h.

5 years agoMFC r349153:
Cy Schubert [Wed, 3 Jul 2019 16:43:40 +0000 (16:43 +0000)]
MFC r349153:

Allow the hostapd program to be specified. This allows users to use
hostapd from ports instead of the one in base. The default is the hostapd
in base.

PR: 238571

5 years agoMFC r342972:
Cy Schubert [Wed, 3 Jul 2019 16:23:06 +0000 (16:23 +0000)]
MFC r342972:

Disable FTS3, FTS4, and RTREE in bundled and private sqlite3.

Suggested by: delphij@
Reviewed by: delphij@ (for secteam@)
Differential Revision: https://reviews.freebsd.org/D18786

5 years agoMFC r349366:
Andrey V. Elsukov [Wed, 3 Jul 2019 09:46:30 +0000 (09:46 +0000)]
MFC r349366:
  Follow the RFC 3128 and drop short TCP fragments with offset = 1.

5 years agoMFC r349365:
Andrey V. Elsukov [Wed, 3 Jul 2019 09:45:02 +0000 (09:45 +0000)]
MFC r349365:
  Mark default rule with IPFW_RULE_NOOPT flag, so it can be showed in
  compact form.

5 years agoMFC r349364:
Andrey V. Elsukov [Wed, 3 Jul 2019 09:43:26 +0000 (09:43 +0000)]
MFC r349364:
  Restore ipfw(8)'s compact output support broken after r331668.

  Also modify it a bit. Now -c option omits only 'from any to any' part
  and works for different protocols (not just for ip).

  Reported by: Dmitry Selivanov <dseliv at gmail>

5 years agoMFC r349439:
Mark Johnston [Wed, 3 Jul 2019 00:36:00 +0000 (00:36 +0000)]
MFC r349439:
Free DHCP options with length zero.

5 years agoMFC r349438:
Mark Johnston [Wed, 3 Jul 2019 00:32:42 +0000 (00:32 +0000)]
MFC r349438:
Avoid a divide-by-zero when bad checksum counters overflow.

5 years agoMFC r349627:
Mark Johnston [Wed, 3 Jul 2019 00:11:31 +0000 (00:11 +0000)]
MFC r349627:
Remove the CDIOCREADSUBCHANNEL_SYSSPACE ioctl.

admbugs: 768
Reported by: Alex Fortune
Approved by: so
Security: CVE-2019-5602
Security: FreeBSD-SA-19:11.cd_ioctl

5 years agoMFC r349619: libc: correct iconv buffer overflow
Ed Maste [Wed, 3 Jul 2019 00:01:38 +0000 (00:01 +0000)]
MFC r349619: libc: correct iconv buffer overflow

admbugs: 920
Submitted by: Andrea Venturoli, gabor
Reported by: Andrea Venturoli <security@netfence.it>, NetFence
Approved by: so
Security: CVE-2019-5600
Security: FreeBSD-SA-19:09.iconv

5 years agoMFC 349133 349146 349150: document PCIOCATTACHED
Niclas Zeising [Tue, 2 Jul 2019 17:23:37 +0000 (17:23 +0000)]
MFC 349133 349146 349150: document PCIOCATTACHED

r349133:

pci(4): Document PCIOCATTACHED

Document the PCIOCATTACHED ioctl(2) in the pci(4) manual.
PCIOCATTACHED is used to query if a driver has attached to a PCI.

Reviewed by: bcr, imp
Differential Revision: https://reviews.freebsd.org/D20652

r349146:

pci.4: wordsmith and add missing words

Add missing words after PCI in the description of the PCIOCWRITE and
PCIOCATTACHED ioctls.
Use singular in PCIOCREAD, we only read one register at the time.

Reviewed by: bcr, bjk, rgrimes, cem
Differential Revision: https://reviews.freebsd.org/D20671

r349150:

pci.4: Use plural configuration registers

It is customary to use plural when talking about PCI configure registers.

Reported by: scottl

5 years agoMFC r349600.
Warren Block [Tue, 2 Jul 2019 16:54:46 +0000 (16:54 +0000)]
MFC r349600.

Correct name of vmm(4) pptdevs variable.

5 years agoMFC r349592: Import tzdata 2019b
Philip Paeps [Tue, 2 Jul 2019 12:22:27 +0000 (12:22 +0000)]
MFC r349592: Import tzdata 2019b

5 years agoMFC r349267:
Andrey V. Elsukov [Mon, 1 Jul 2019 10:01:08 +0000 (10:01 +0000)]
MFC r349267:
  Add "tcpmss" opcode to match the TCP MSS value.

  With this opcode it is possible to match TCP packets with specified
  MSS option, whose value corresponds to configured in opcode value.
  It is allowed to specify single value, range of values, or array of
  specific values or ranges. E.g.

   # ipfw add deny log tcp from any to any tcpmss 0-500

5 years agoMFC r346455-r346458, r348520, r348529, r348817, r348818
Vladimir Kondratyev [Sat, 29 Jun 2019 12:49:52 +0000 (12:49 +0000)]
MFC r346455-r346458, r348520, r348529, r348817, r348818

r346455:
psm(4): Add support for 4 and 5 finger touches in synaptics driver

While 4-th and 5-th finger positions are not exported through PS/2
interface, total number of touches is reported by MT trackpads.

r346456:
psm(4): do not process gestures when palm is present

Ignoring of gesture processing when the palm is detected helps to reduce
some of the erratic pointer behavior.

This fixes regression introduced in r317814

Reported by: Ben LeMasurier <ben@crypt.ly>

r346457:
psm(4): respect tap_disabled configuration with enabled Extended support

This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
were processed.
tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
To respect PR kern/139272, taps are ignored only when explicity disabled.

Submitted by: Ben LeMasurier <ben@crypt.ly> (initial version)

r346458:
psm(4): give names to synaptics commands

Submitted by: Ben LeMasurier <ben@crypt.ly>

r348520:
psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

PR: 238291
Submitted by: Andrey Kosachenko <andrey.kosachenko@gmail.com>

r348529:
psm(4): Add natural scrolling support to sysmouse protocol

This change enables natural scrolling with two finger scroll enabled
and when user is using a trackpad (mouse and trackpoint are not affected).
Depending on trackpad model it can be activated with setting of
hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
values to 1.

Evdev protocol is not affected by this change too. Tune userland client
e.g. libinput to enable natural scrolling in that case.

Submitted by: nyan_myuji.xyz
Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D20447

r348817:
psm(4): Fix Elantech trackpoint support.

Sign bits for X and Y motion data were taken from wrong places.

PR: 238291
Reported by: Andrey Kosachenko <andrey.kosachenko@gmail.com>
Tested by: Andrey Kosachenko <andrey.kosachenko@gmail.com>

r348818:
psm(4): Add extra sanity checks to Elantech trackpoint packet parser.

Add strict checks for unused bit states in Elantech trackpoint packet
parser to filter out spurious events produces by some hardware which
are detected as trackpoint packets. See comment on r328191 for example.

Tested by: Andrey Kosachenko <andrey.kosachenko@gmail.com>

5 years agoMFC r348993,349135:
Martin Matuska [Fri, 28 Jun 2019 22:31:53 +0000 (22:31 +0000)]
MFC r348993,349135:
Sync libarchive with vendor including security fixes

r348993:
  - version bumped to 3.4.0
  - check_symlinks_fsobj() without chdir() and fchdir()
  - bsdtar.1 manpage fixes
  - patches from OpenBSD to libarchive_fe/passphrase.c

r349135:
  PR #1212: RAR5 reader - window_mask was not updated correctly
            (OSS-Fuzz 15278)
  OSS-Fuzz 15120: RAR reader - extend use after free bugfix

5 years agoMFC r349372:
Glen Barber [Fri, 28 Jun 2019 20:28:20 +0000 (20:28 +0000)]
MFC r349372:
 Include files containing metadata specific to the branch in the
 directory where the individual distribution sets exist.

 The new metadata files include the build date, svn branch, and
 revision of the build.

Sponsored by: Rubicon Communications, LLC (Netgate)

5 years agoMFC r348887:
Mitchell Horne [Fri, 28 Jun 2019 01:03:55 +0000 (01:03 +0000)]
MFC r348887:
procstat: Recognize HWCAP and HWCAP2 with auxv command

Approved by: markj (mentor, implicit)

5 years agoMFC r348886:
Mitchell Horne [Fri, 28 Jun 2019 01:01:54 +0000 (01:01 +0000)]
MFC r348886:
RISC-V: expose extension bits in AT_HWCAP

Approved by: markj (mentor, implicit)

5 years agoMFC r348840:
Mitchell Horne [Fri, 28 Jun 2019 00:58:54 +0000 (00:58 +0000)]
MFC r348840:
Remove unused mcall_trap() function

Approved by: markj (mentor, implicit)

5 years agoMFC r348839:
Mitchell Horne [Fri, 28 Jun 2019 00:56:26 +0000 (00:56 +0000)]
MFC r348839:
Clean up some GENERIC options

Approved by: markj (mentor)

5 years agoMFC r348838:
Mitchell Horne [Fri, 28 Jun 2019 00:53:27 +0000 (00:53 +0000)]
MFC r348838:
Announce real and available memory at boot

Approved by: markj (mentor, implicit)

5 years agoMFC r348837:
Mitchell Horne [Fri, 28 Jun 2019 00:50:00 +0000 (00:50 +0000)]
MFC r348837:
Add TSLOG events to initriscv()

Approved by: markj (mentor, implicit)

5 years agoMFC 348835-348836:
Mitchell Horne [Fri, 28 Jun 2019 00:43:38 +0000 (00:43 +0000)]
MFC 348835-348836:
Fix global pointer relaxations in the RISC-V kernel

The gp register is intended to used by the linker as another means of
performing relaxations, and should point to the small data section (.sdata).

Currently gp is being used as the pcpu pointer within the kernel, but the more
appropriate choice for this is the tp register, which is unused.

Swap existing usage of gp with tp within the kernel, and set up gp properly
at boot with the value of __global_pointer$ for all harts.

Approved by: markj (mentor, implicit)

5 years agoMFC r346021:
Mitchell Horne [Fri, 28 Jun 2019 00:36:26 +0000 (00:36 +0000)]
MFC r346021:
RISC-V: initialize pcpu slightly earlier

In certain scenarios, it is possible for PCPU data to be
accessed before it has been initialized (e.g. during printf
if the kernel was built with the TSLOG option).

Initialize the PCPU pointer for hart 0 at the beginning of
initriscv() rather than near the end.

Approved by: markj (mentor)

5 years agoMFC r344827-344830, r344845:
Mark Johnston [Thu, 27 Jun 2019 16:48:24 +0000 (16:48 +0000)]
MFC r344827-344830, r344845:
Implement minidump support for RISC-V.

5 years agoMFC r349376: Fix strsep_quote() on strings without quotes.
Alexander Motin [Thu, 27 Jun 2019 14:10:58 +0000 (14:10 +0000)]
MFC r349376: Fix strsep_quote() on strings without quotes.

For strings without quotes and escapes dstptr and srcptr are equal, so
zeroing *dstptr before checking *srcptr is not a good idea.  In practice
it means that in -maproot=65534:65533 everything after the colon is lost.

The problem was there since r293305, but before r346976 it was covered by
improper strsep_quote() usage.

PR: 238725

5 years agoMFC: r347065 (by jhb) Emulate the "ADD reg, r/m" instruction (opcode 03H).
Rodney W. Grimes [Wed, 26 Jun 2019 21:59:43 +0000 (21:59 +0000)]
MFC: r347065 (by jhb) Emulate the "ADD reg, r/m" instruction (opcode 03H).

OVMF's flash variable storage is using add instructions when indexing
the variable store bootrom location.

5 years agoMFC r349196:
Mark Johnston [Wed, 26 Jun 2019 17:41:38 +0000 (17:41 +0000)]
MFC r349196:
Make zlib encoding messages idempotent.

PR: 238333

5 years agoMFC r343826, r346698, r349057-r349060, r349073-r349077, r349080-r349086, r349088,
Ian Lepore [Wed, 26 Jun 2019 17:28:55 +0000 (17:28 +0000)]
MFC r343826, r346698, r349057-r349060, r349073-r349077, r349080-r349086, r349088,
    r349091-r349097, r349115, r349119, r349130-r349132, r349143-r349145,
    r349164-r349168, r349174, r349269-r349273

r343826 by yuripv:
pwm.8: fix markup in synopsis, add -f description

r346698 by manu:
arm: allwinner: aw_pwm: compile it as module too

r349057:
Allow pwm(9) components to be selected individually, while 'device pwm'
still includes it all.

r349058:
In detach(), check for failure of bus_generic_detach(), only release
resources if they got allocated (because detach() gets called from attach()
to handle various failures), and delete the pwmbus child if it got created.

r349059:
Don't call pwmbus_attach_bus(), because it may not be present if this
driver is compiled into the kernel but pwmbus will be loaded as a module
when needed (and because of that, pwmbus_attach_bus() is going away in
the near future).  Instead, just directly do what that function did:
register the fdt xfef handle, and attach the pwmbus.

r349060:
Handle failure to enable the clock or obtain its frequency.

r349073:
Do not include pwm.h here, it is purely a userland interface file containing
ioctl defintions for the pwmc driver. It is not part of the pwmbus interface.

r349074:
Move/rename the sys/pwm.h header file to dev/pwm/pwmc.h.  The file contains
ioctl definitions and related datatypes that allow userland control of pwm
hardware via the pwmc device.  The new name and location better reflects its
assocation with a single device driver.

r349075:
Remove pwmbus_attach_bus(), it no longer has any callers.  Also remove a
couple prototypes for functions that never existed (and never will).

r349076:
Use device_delete_children() instead of a locally-rolled copy of it that
leaks the device-list memory.

r349077:
Add a missing #include.  I suspect this used to get included via some header
pollution that was cleaned up recently, and this file got missed in the
cleanup because it's not attached to the build unless you specifically
request this device in a custom kernel config.

r349080:
Make pwmbus driver and devclass vars static; they're not mentioned in any
header file, so they can't be used outside this file anyway.

r349081:
Unwrap prototype lines so that return type and function name are on the
same line.  No functional changes.

r349082:
Spell unsigned int as u_int and channel as chan; eliminates the need to wrap
some long lines.

r349083:
Give the aw_pwm driver a module version.

r349084:
Rename the channel_max method to channel_count, because that's what it's
returning.  (If the channel count is 2, then the max channel number is 1.)

r349085:
Destroy the cdev on device detach.  Also, make the driver and devclass
static, because nothing outside this file needs them.

r349086:
Restructure the pwm device hirearchy and interfaces.

The pwm and pwmbus interfaces were nearly identical, this merges them into a
single pwmbus interface.  The pwmbus driver now implements the pwmbus
interface by simply passing all calls through to its parent (the hardware
driver).  The channel_count method moves from pwm to pwmbus, and the
get_bus method is deleted (just no longer needed).

The net effect is that the interface for doing pwm stuff is now the same
regardless of whether you're a child of pwmbus, or some random driver
elsewhere in the hierarchy that is bypassing the pwmbus layer and is talking
directly to the hardware driver via cross-hierarchy connections established
using fdt data.

The pwmc driver is now a child of pwmbus, instead of being its sibling
(that's why the get_bus method is no longer needed; pwmc now gets the
device_t of the bus using device_get_parent()).

r349088:
Make pwm channel numbers unsigned.

r349091:
The pwm interface was replaced with pwmbus, include the right header file.

r349092:
Make channel number unsigned, and spell unsigned int u_int.  This should
have been part of r349088.

r349093:
This code no longer uses fdt/ofw stuff, no need to include ofw headers.

r349094:
Add module makefiles for pwm.

r349095:
Split the dtb MODULES_EXTRA line to a series of += lines, making it easier
to maintain and keep in alphabetical order, and paving the way for adding
some other modules that aren't dtb-related.

r349096:
Add module makefiles for Texas Instruments ARM SoCs.

The natural place to look for them based on how other SoCs are organized
would be sys/modules/ti, but that's already taken.  Drop a clue into
modules/ti/Makefile directing people to modules/arm_ti if they're looking
for ARM modules.

r349097:
Build SoC-specific modules with GENERIC for the SoCs that have them.

r349115:
Rename pwmbus.h to ofw_pwm.h, because after all the recent changes, there
is nothing left in the file that related to pwmbus at all.  It just contains
prototypes for the functions implemented in dev/pwm.ofw_pwm.c, so name it
accordingly and fix the include protect wrappers to match.

A new pwmbus.h will be coming along in a future commit.

r349119:
Rework pwmbus and pwmc so that each child will handle a single PWM channel.

Previously, there was a pwmc instance for each instance of pwm hardware
regardless of how many pwm channels that hardware supported.  Now there
will be a pwmc instance for each channel when the hardware supports
multiple channels.  With a separate instance for each channel, we can have
"named channels" in userland by making devfs alias entries in /dev/pwm.

These changes add support for ivars to pwmbus, and use an ivar to track the
channel number for each child.  It also adds support for hinted children.

In pwmc, the driver checks for a label hint, and if present, it's used to
create an alias for the cdev in /dev/pwm.  It's not anticipated that hints
will be heavily used, but it's easy to do and allows quick ad-hoc creation
of named channels from userland by using kenv to create hint.pwmc.N.label=
hints.  Upcoming changes will add FDT support, and most labels will
probably be specified that way.

r349130:
Add ofw_pwmbus to enumerate pwmbus devices on systems configured with fdt
data.  Also, add fdt support to pwmc.

r349131:
Implement the ofw_bus_get_node method in aw_pwm(4) so that ofw_pwmbus can
find its metadata for instantiating children.

r349132:
Add back a const qualifier I somehow fumbled away between test-building
and committing recent changes.

r349143:
Put the pwmc cdev filenames under the pwm directory along with any label
names.  I.e., everything related to pwm now goes in /dev/pwm.  This will
make it easier for userland tools to turn an unqualified name into a fully
qualified pathname, whether it's the base pwmcX.Y name or a label name.

r349144:
Follow changes in the pwmc(4) driver in relation to device filenames.

The driver now names its cdev nodes pwmcX.Y where X is unit number and
Y is the channel within that unit.  Change the default device name from
pwmc0 to pwmc0.0.  The driver now puts cdev files and label aliases in
the /dev/pwm directory, so allow the user to provide unqualified names
with -f and automatically prepend the /dev/pwm part for them.

Update the examples in the manpage to show the new device name format
and location within /dev/pwm.

r349145:
Put periods at the ends of argument descriptions.  Explain the relationship
between the period and duty arguments.

r349164:
Remove everything related to channels from the pwmc public interface, now
that there is a pwmc(4) instance per channel and the channel number is
maintained as a driver ivar rather than being passed in from userland.

r349165:
Explain the relationship between PWM hardware channels being controlled and
pwmc(4) device filenames.  Also, use uppercase PWM when the term is being
used as an acronym, and expand the acronym where it's first used.

r349166:
Rearrange the argument checking and processing so that enable and disable
can be combined with configuring the period and duty cycle (the same ioctl
sets all 3 values at once, so there's no reason to require the user to run
the program twice to get all 3 things set).

r349167:
Oops, it seems I left out the word 'cycle', fix it.

r349168:
Add a pwmc(4) manpage.

r349174:
Handle labels specified with hints even on FDT systems.  Hints are the
easiest thing for a user to control (via loader.conf or kenv+kldload), so
handle them in addition to any label specified via the FDT data.

r349269:
Some mundane tweaks and cleanups to help de-clutter the diffs of some
upcoming functional changes.

Add an ofw_compat_data table for probing compat strings, and use it to add
PNP data.  Remove some stray semicolons at the end of macro definitions,
and add a PWM_LOCK_ASSERT macro to round out the usual suite.  Move the
device_t and driver_methods structs to the end of the file.  Tweak comments.

r349270:
Add support for the PWM(9) API.  This allows configuring the pwm output using
pwm(9), but also maintains the historical sysctl config interface for
compatiblity with existing apps.  The two config systems are not compatible
with each other; if you use both interfaces to change configurations you're
likely to end up with incorrect output or none at all.

r349271:
Catch up with recent changes in pwmbus(9).  The pwm(9) and pwmbus(9)
interfaces were unified into pwmbus(9), and the PWMBUS_CHANNEL_MAX method
was renamed PWMBUS_CHANNEL_COUNT.  The pwmbus_attach_bus() function just
went away completely.  Also, fix a few typos such as s/is/if/.

r349272:
Do some general cleanup and light wordsmithing.

Sort methods alphabetically.  Wrap long lines.  Start sentences on a new
line.  Remove contractions (not because it's a good idea, just to silence
igor).  Add some explanation of the units for the period and duty arguments
and the convention for channel numbers.

r349273:
Add pwm to the armv7 GENERIC kernel, it's now used by TI and Allwinner.

5 years agoMFC r340130, r340134:
Ian Lepore [Wed, 26 Jun 2019 16:38:46 +0000 (16:38 +0000)]
MFC r340130, r340134:

r340130: (by oshogbo)

libcapsicum: Introduce caph_{rights,ioctls,fcntls}_limit

The idea behind those functions is not to force consumers to remember that there
is a need to check errno on failure. We already have a caph_enter(3) function
which does the same for cap_enter(2).

r340134: (by oshogbo)

Fix a recusive call introduce in the r340130.

5 years agoMFC r341268, r342003-r342007, r342087-r342088, r342091
Ian Lepore [Wed, 26 Jun 2019 15:34:35 +0000 (15:34 +0000)]
MFC r341268, r342003-r342007, r342087-r342088, r342091

r341268 by manu:
arm64: allwinner: Add a dtbo to have cpu operating points

This enables cpufreq on A64 boards.

r342003 by manu:
Add a pwm subsystem so we can configure pwm controller from kernel and userland.

The pwm subsystem consist of API for PWM controllers, pwmbus to register them
and a pwm(8) utility to talk to them from userland.

Reviewed by: oshgobo (capsicum), bcr (manpage), 0mp (manpage)
Differential Revision: https://reviews.freebsd.org/D17938

r342004 by manu:
arm64: allwinner: Add pwm driver

Add a pwm driver for Allwinner PWM
Add pwm and aw_pwm to the GENERIC kernel

r342005 by manu:
arm64: allwinner: Add DTSO for pwm and r_pwm

Those are both dtso (overlays) for the two pwm controllers found on the A64.

r342006 by manu:
arm64: allwinner: Fix pwm dtso

Double patched files ended up in the tree

Reported by: kevans

r342007 by manu:
pwm: Fix some arches by using %ju and casting to uintmax_t

Reported by: ci.freebsd.org

r342087 by manu:
pwm: Convert period and duty to unsigned int

We don't need a 64 bits value to store nanoseconds

Discused with: ian, jhibbits

r342088 by manu:
pwm(8): Add percentage value support for duty cycle

r342091 by manu:
allwinner: aw_pwm: Read value at attach

The booloaded might have configured the pwm controller so read the values.

5 years agoMFC r348740-r348741, r348995
Ian Lepore [Sun, 23 Jun 2019 16:59:06 +0000 (16:59 +0000)]
MFC r348740-r348741, r348995

r348740:
Don't refer to the cpu variable in a KASSERT before initializing it.

r348741:
For armv6 and armv7, build hwpmc_armv7.c as well as the base hwpmc_arm.c.

Submitted by: Arnaud YSMAL <arnaud.ysmal@stormshield.eu>

r348995:
Don't attempt to include hwpmc support for armv6, we're missing some of the
necessary support functions in cpu-v6.h, and it may be that the only armv6
platform we support (RPi, the bcm2835 SOC) is incapable of supporting hwpmc.

Reported by: dim@

5 years agoMFC r348169-r348170, r348172-r348173, r348183-r348184
Ian Lepore [Sun, 23 Jun 2019 16:16:55 +0000 (16:16 +0000)]
MFC r348169-r348170, r348172-r348173, r348183-r348184

r348169:
Define macros making it easier to define bus-specific pnpinfo for FDT systems.

Pnpinfo is bus-specific and requires the bus name. The FDTCOMPAT_PNP_INFO()
macro makes it easier to define new FDT-based pnpinfo for busses other than
simplebus.

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

r348170:
Add pnpinfo for icee(4) on fdt systems.

r348172:
Use the new FDTCOMPAT_PNP_INFO() macro to define SPIBUS_FDT_PNP_INFO().
Also rename SPIBUS_PNP_INFO -> SPIBUS_FDT_PNP_INFO because there could be
other kinds of pnpinfo for other (non-fdt) bus attachments.

r348173:
Rename IICBUS_FDT_PNPINFO -> IICBUS_FDT_PNP_INFO because all the other
existing pnpinfo-related macros right now use PNP_INFO, not PNPINFO.

r348183:
Add pnpinfo.

r348184:
Add pnpinfo to all i2c drivers that have FDT compat data.

5 years agoMFC r341386 (by manu):
Ian Lepore [Sun, 23 Jun 2019 16:05:53 +0000 (16:05 +0000)]
MFC r341386 (by manu):

Add Silergy SYR827 PMIC driver

SYR827 is a PMIC that can output a voltage from 0.7125V to 1.5V in 12.5mV steps
It's controlled via I2C.

5 years agoMFC r348141, r348143
Ian Lepore [Sun, 23 Jun 2019 16:00:29 +0000 (16:00 +0000)]
MFC r348141, r348143

r348141:
Handle the driftfile option correctly when ntpd_flags is empty.

The logic I originally wrote to detect whether a driftfile option was in the
set of flags was based on the result of removing the pattern *flag* being an
empty string.  That didn't handle the case where the string was empty to
begin with.  Doh!  So now it also specifically checks for an empty string.

The result of the bad check was that ntpd would run without a driftfile, but
it would do so only if it was running as root instead of the non-priveleged
ntpd user, which isn't a typical case.  Ntpd runs fine without a driftfile,
although it does take it longer to stabilize the clock frequency at startup.

Reported by: avg@
Pointy hat: ian@

r348143:
Remove accidentally-added blank line; the style throughout this file
is to use no whitespace between a comment block and the code it describes.

5 years agoMFC r348123, r348164, r348166
Ian Lepore [Sun, 23 Jun 2019 15:58:46 +0000 (15:58 +0000)]
MFC r348123, r348164, r348166

r348123:
Add pnp info to the imx_i2c driver.

r348164:
Mark i2c slave devices busy while they own the bus.

Many i2c slave drivers are in modules that can be unloaded.  If they detach
while IO is in progress the bus would be hung forever.  Conversely,
lower-layer drivers (iicbus and the hardware driver) also live in modules
and other kinds of bad things happen if they get detached while IO is in
progress.  Because device_busy() propagates up to parents, marking the slave
device busy while it owns the bus solves both kinds of problems that come
with detaching i2c devices while IO is in progress.

r348166:
Release the bus-recovery gpio pins in detach(), so that unload then
reload of the module works without "pin already allocated" errors.

5 years agoMFC r348120:
Ian Lepore [Sun, 23 Jun 2019 15:55:41 +0000 (15:55 +0000)]
MFC r348120:

Add a new 'tr' (transfer) mode to i2c(8) to support more i2c controllers.

Some i2c controller hardware does not provide a way to do individual START,
REPEAT-START and STOP actions on the i2c bus.  Instead, they can only do
a complete transfer as a single operation.  Typically they can do either
START-data-STOP or START-data-REPEATSTART-data-STOP.  In the i2c driver
framework, this corresponds to the iicbus_transfer method.  In the userland
interface they are initiated with the I2CRDWR ioctl command.

These changes add a new 'tr' mode which can be specified with the '-m'
command line option.  This mode should work on all hardware; when an i2c
controller driver doesn't directly support the iicbus_transfer method,
code in the i2c driver framework uses the lower-level START/REPEAT/STOP
methods to implement the transfer.  After this new mode has gotten some
testing on various hardware, the 'tr' mode should probably become the
new default mode.

PR: 189914

5 years agoMFC r348737:
Alan Somers [Sun, 23 Jun 2019 13:44:06 +0000 (13:44 +0000)]
MFC r348737:

Add a testing facility to manually reclaim a vnode

Add the debug.try_reclaim_vnode sysctl. When a pathname is written to it, it
will be reclaimed, as long as it isn't already or doomed. The purpose is to
gain test coverage for vnode reclamation, which is otherwise hard to
achieve.

Add the debug.ftry_reclaim_vnode sysctl.  It does the same thing, except
that its argument is a file descriptor instead of a pathname.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20519

5 years agoMFC r348316:
Alan Somers [Sun, 23 Jun 2019 13:40:56 +0000 (13:40 +0000)]
MFC r348316:

VOP_ADVLOCK.9: fix description of flags

* F_RDLCK, F_UNLCK, and F_WRLCK aren't flags.  They're stored in the
  fl.l_type field.
* Add F_REMOTE, added in r177633
* Add F_NOINTR, added in r180025

Sponsored by: The FreeBSD Foundation

5 years agoMFC r348251:
Alan Somers [Sun, 23 Jun 2019 13:35:01 +0000 (13:35 +0000)]
MFC r348251:

Remove "struct ucred*" argument from vtruncbuf

vtruncbuf takes a "struct ucred*" argument. AFAICT, it's been unused ever
since that function was first added in r34611. Remove it.  Also, remove some
"struct ucred" arguments from fuse and nfs functions that were only used by
vtruncbuf.

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20377

5 years agoMFC r348802:
Konstantin Belousov [Sun, 23 Jun 2019 11:09:08 +0000 (11:09 +0000)]
MFC r348802:
Remove lazy FPU switch support from amd64.

For the merge, the hw.lazy_fpu_switch sysctl was kept but made read-only
with the value of 0.

5 years agoMFC r348799:
Konstantin Belousov [Sun, 23 Jun 2019 11:02:31 +0000 (11:02 +0000)]
MFC r348799:
i386 trap.c: Remove unused MAX_TRAP_MSG define.

5 years agoMFC r348813:
Konstantin Belousov [Sun, 23 Jun 2019 11:01:09 +0000 (11:01 +0000)]
MFC r348813:
Make trap_msg array constant as well.

5 years agoMFC r348798:
Konstantin Belousov [Sun, 23 Jun 2019 10:59:53 +0000 (10:59 +0000)]
MFC r348798:
amd64 trap.c: Modernize syntax around trap_msg[].

5 years agoMFC r349160:
Glen Barber [Thu, 20 Jun 2019 14:34:45 +0000 (14:34 +0000)]
MFC r349160:
 Fix passing ${CONF_FILES} (which contains MAKE_CONF and
 SRC_CONF, __MAKE_CONF and SRCCONF, respectively) through
 to arm_install_base() and chroot_arm_build_release().
 This prevents failures when the target image is intended
 to be build with make.conf(5) and src.conf(5) overrides,
 which are correctly handled for non-embedded image builds.

PR: 238615
Sponsored by: The FreeBSD Foundation

5 years agoMFC r348728:
Michael Tuexen [Thu, 20 Jun 2019 07:50:38 +0000 (07:50 +0000)]
MFC r348728:

r347382 added receiver side DSACK support for the TCP base stack.
The corresponding changes for the RACK stack where missed and are added
by this commit.

5 years agodrm2/intel_iic: stop using iicbus_set_nostop
Andriy Gapon [Thu, 20 Jun 2019 06:53:59 +0000 (06:53 +0000)]
drm2/intel_iic: stop using iicbus_set_nostop

The desired mode of transmitting messages is implemented by subclassing
iicbb driver and overriding its iicbus_transfer method with an almost
identical copy that issues the stop condition only at the very end.

iicbus_set_nostop is very broken and is set to be removed from the KPI.

This is a direct commit as in head the drm drivers have been moved out
of the tree.
The same change has been committed to FreeBSDDesktop/drm-legacy.

5 years agoMFC r349152:
Cy Schubert [Thu, 20 Jun 2019 05:01:35 +0000 (05:01 +0000)]
MFC r349152:

Make ipf_objbytes a constant. ipf_objbytes is a table of internal data
structures that are saved across reboots by ipfs(8). The table is not
changed at runtime.

5 years agoMFC r348764: Allow UMA hash tables to expand faster then 2x in 20 seconds.
Alexander Motin [Thu, 20 Jun 2019 01:18:15 +0000 (01:18 +0000)]
MFC r348764: Allow UMA hash tables to expand faster then 2x in 20 seconds.

ZFS ABD allocates tons of 4KB chunks via UMA, requiring huge hash tables.
With initial hash table size of only 32 elements it takes ~20 expansions
or ~400 seconds to adapt to handling 220GB ZFS ARC.  During that time not
only the hash table is highly inefficient, but also each of those expan-
sions takes significant time with the lock held, blocking operation.

On my test system with 256GB of RAM and ZFS pool of 28 HDDs this change
reduces time needed to first time read 240GB from ~300-400s, during which
system is quite busy and unresponsive, to only ~150s with light CPU load
and just 5 sub-second CPU spikes to expand the hash table.

5 years agoMFC r349148:
Mark Johnston [Thu, 20 Jun 2019 00:23:51 +0000 (00:23 +0000)]
MFC r349148:
Add some missing MLINKs for tree(3).

5 years agoMFC r348772: Restore ARC MFU/MRU pressure
Andriy Gapon [Wed, 19 Jun 2019 20:27:31 +0000 (20:27 +0000)]
MFC r348772: Restore ARC MFU/MRU pressure

Submitted by: Slawa Olhovchenkov <slw@zxy.spb.ru>
Sponsored by: Integros [integros.com]

5 years agoMFC r348228: amdgpio: fix reading status of input pins
Andriy Gapon [Wed, 19 Jun 2019 20:20:02 +0000 (20:20 +0000)]
MFC r348228: amdgpio: fix reading status of input pins

5 years agoMFC r348227: amdgpio: remove new line symbols from pin names
Andriy Gapon [Wed, 19 Jun 2019 20:18:34 +0000 (20:18 +0000)]
MFC r348227: amdgpio: remove new line symbols from pin names

5 years agoMFC r348159: add mrsas_shutdown method
Andriy Gapon [Wed, 19 Jun 2019 20:15:53 +0000 (20:15 +0000)]
MFC r348159: add mrsas_shutdown method

Sponsored by: Panzura

5 years agoMFC r348152: Add USB ID for CP2112
Andriy Gapon [Wed, 19 Jun 2019 20:09:04 +0000 (20:09 +0000)]
MFC r348152: Add USB ID for CP2112

5 years agoMFC r349192:
Jonathan T. Looney [Wed, 19 Jun 2019 16:25:39 +0000 (16:25 +0000)]
MFC r349192:
  Add the ability to limit how much the code will fragment the RACK send map
  in response to SACKs. The default behavior is unchanged; however, the
  limit can be activated by changing the new net.inet.tcp.rack.split_limit
  sysctl.

Approved by: so (gordon)
Security: CVE-2019-5599

5 years agoMFC r347228: makesyscalls: use @generated tag in generated files
Ed Maste [Wed, 19 Jun 2019 14:57:51 +0000 (14:57 +0000)]
MFC r347228: makesyscalls: use @generated tag in generated files

Multiple tools use @generated to identify generated files (for example,
in a review Phabricator will by default hide diffs in generated files).
Use the @generated tag in makesyscalls.sh as we've done for other
generated files.

Sponsored by: The FreeBSD Foundation

5 years agovtfontcvt: whitespace and other cleanup
Ed Maste [Wed, 19 Jun 2019 13:19:36 +0000 (13:19 +0000)]
vtfontcvt: whitespace and other cleanup

MFC r343842: vtfontcvt: whitespace cleanup

MFC r348653: vtfontcvt: use VFNT_MAP_{NORMAL|BOL}_RH symbolic constants

MFC r348656: vtfontcvt: unwrap a line per style(9)

PR: 205707
Submitted by: Dmitry Wagin

5 years agoMFC r348985:
Cy Schubert [Wed, 19 Jun 2019 01:28:13 +0000 (01:28 +0000)]
MFC r348985:

Enclose a long multi-line single conditional statement in braces to
improve legibility and aesthetics.

5 years agoUnmount filesystems on jail removal with "-f", to get around a situation
Jamie Gritton [Tue, 18 Jun 2019 23:49:13 +0000 (23:49 +0000)]
Unmount filesystems on jail removal with "-f", to get around a situation
where the jail root vnode reference is stopping the filesystem from
unmounting, when the jail is removed by still exists in a dying state.

PR: 238517
Reported by: matthias at harz.de

5 years agoMFC r348657:
Mark Johnston [Tue, 18 Jun 2019 16:31:05 +0000 (16:31 +0000)]
MFC r348657:
elfcopy: Use libelftc's string table routines to build .shstrtab.

PR: 234949

5 years agoMFC r348654:
Mark Johnston [Tue, 18 Jun 2019 16:30:35 +0000 (16:30 +0000)]
MFC r348654:
elfcopy: Use elf_getscn() instead of iterating over all sections.

PR: 234949

5 years agoMFC r348652:
Mark Johnston [Tue, 18 Jun 2019 16:29:46 +0000 (16:29 +0000)]
MFC r348652:
libelf: Use a red-black tree to manage the section list.

PR: 234949

5 years agoMFC of 349032
Kirk McKusick [Mon, 17 Jun 2019 21:31:27 +0000 (21:31 +0000)]
MFC of 349032

Clarify -r and -R only usable for level 0 dumps.

5 years agoMFC r347950:
Mark Johnston [Mon, 17 Jun 2019 15:14:26 +0000 (15:14 +0000)]
MFC r347950:
Use M_NEXTFIT in memguard(9).

5 years agoMFC r347949, r347955:
Mark Johnston [Mon, 17 Jun 2019 15:13:15 +0000 (15:13 +0000)]
MFC r347949, r347955:
Implement the M_NEXTFIT allocation strategy for vmem(9).

5 years agoMFC r348459:
Mark Johnston [Mon, 17 Jun 2019 15:11:54 +0000 (15:11 +0000)]
MFC r348459:
acpi_dock(4): Notify devd(8) on dock status change.

PR: 238138

5 years agoMFC r348785:
Mark Johnston [Mon, 17 Jun 2019 15:11:04 +0000 (15:11 +0000)]
MFC r348785:
Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m).

5 years agoMFC: r347583
Rick Macklem [Mon, 17 Jun 2019 00:37:55 +0000 (00:37 +0000)]
MFC: r347583
Replace global list for grouplist with list(s) for each exportlist element.

In mountd.c, the grouplist structures are linked into a single global
linked list headed by "grphead". The only use of this linked list is
to free all list elements when the exportlist elements are also all being
free'd at the time the exports are being reloaded.
This patch replaces this one global linked list head with a list head in
each exportlist structure, where the grouplist elements for that exported
file system are linked.
The only change is that now the grouplist elements are free'd with the
associated exportlist element as they are free'd instead of all grouplist
elements being free'd after the exportlist elements are free'd. This
change should have no effect in practice.
This is being done, since a future patch that will add a "-I" option for
incrementally updating the exports in the kernel needs to know which
grouplist elements are associated with each exported file system and
having them linked into a list headed by the exportlist element does that.

PR: 237860

5 years agoMFC: r347498
Rick Macklem [Mon, 17 Jun 2019 00:20:39 +0000 (00:20 +0000)]
MFC: r347498
Factor code into two new functions in preparation for a future commit.

Factor code into two functions.
read_exportfile() a functon  which reads the exports file(s) and calls
get_exportlist_one() to process each of them.
delete_export() a function which deletes the exports in the kernel for a file
system.
The contents of these functions is just the same code as was used to do the
operations, moved into separate functions. As such, there is no semantic change.
This is being done in preparation for a future commit that will add an
option to do incremental changes of kernel exports upon receiving SIGHUP.

PR: 237860

5 years agoMFC: r347476
Rick Macklem [Mon, 17 Jun 2019 00:00:12 +0000 (00:00 +0000)]
MFC: r347476
Factor out some exportlist list operations into separate functions.

This patch moves the code that removes and frees all exportlist elements
out into a separate function called free_exports().
It does the same for the insertion of a new exportlist entry into a list.
It also adds a second argument to ex_search() for the list to use.
None of these changes have any semantic effect. They are being done to
prepare the code for future patches that convert the single linked list
for the exportlist to a hash table of lists and a patch that will do
incremental changes of exports in the kernel.
And it fixes the argument for SLIST_HEAD_INITIALIZER() to a pointer,
which doesn't really matter, since SLIST_HEAD_INITIALIZER() doesn't use
the argument.

PR: 237860

5 years agoMFC: r347390
Marius Strobl [Sun, 16 Jun 2019 15:34:10 +0000 (15:34 +0000)]
MFC: r347390

- Merge r338254 from cxgbe(4):
  Use fcmpset instead of cmpset when appropriate.
- Revert r277226 of cxgbe(4), obsolete since r334320.

5 years agoMFC: r347222
Marius Strobl [Sun, 16 Jun 2019 15:30:07 +0000 (15:30 +0000)]
MFC: r347222

o Avoid determining the MAC class (LEM/EM or IGB) - possibly even multiple
  times - on every interrupt by using an own set of device methods for the
  IGB class. This translates to introducing igb_if_intr_{disable,enable}()
  and igb_if_{rx,tx}_queue_intr_enable() with that IGB-specific code moved
  out of their EM counterparts and otherwise continuing to use the EM IFDI
  methods also for IGB.
  Note that igb_if_intr_{disable,enable}() also issue E1000_WRITE_FLUSH as
  lost with the conversion of igb(4) to iflib(4).
  Also note, that the em_if_{disable,enable}_intr() methods are renamed to
  em_if_intr_{disable,enable}() for consistency with the names used in the
  interface declaration.
o In em_intr():
  - Don't bother to bail out if the interrupt type is "legacy", i. e. INTx
    or MSI, as iflib(4) doesn't use ift_legacy_intr methods for MSI-X. All
    other iflib(4)-based drivers avoid this check, too.
  - Given that only the MSI-X interrupts have one-shot behavior (by taking
    advantage of the EIAC register), explicitly disable interrupts. Hence,
    em_intr() now matches what {em,igb}_irq_fast() previously did (in case
    of igb(4) supposedly also to work around MSI message reordering errata
    on certain systems).
o In em_if_intr_disable():
  - Clear the EIAC register unconditionally for 82574 and not just in case
    of MSI-X, matching em_if_intr_enable() and bringing back the last hunk
    of r206437 lost with the iflib(4) conversion.
  - Write to EM_EIAC for clearing said register instead of to the IGB-only
    E1000_EIAC used ever since the iflib(4) conversion.

Reviewed by: shurd
Differential Revision: https://reviews.freebsd.org/D20176

5 years agoMFC: r347221, r347245
Marius Strobl [Sun, 16 Jun 2019 15:25:46 +0000 (15:25 +0000)]
MFC: r347221, r347245

o Use iflib_fast_intr_rxtx() also for "legacy" interrupts, i. e. INTx and
  MSI. Unlike as with iflib_fast_intr_ctx(), the former will also enqueue
  _task_fn_tx() in addition to _task_fn_rx() if appropriate, bringing TCP
  TX throughput of EM-class devices on par with the MSI-X case and, thus,
  close to wirespeed/pre-iflib(4) times again. [1]
  Note that independently of the interrupt type, the UDP performance with
  these MACs still is abysmal and nowhere near to where it was before the
  conversion of em(4) to iflib(4).
o In iflib_init_locked(), announce which free list failed to set up.
o In _task_fn_tx() when running netmap(4), issue ifdi_intr_enable instead
  of the ifdi_tx_queue_intr_enable method in case of a "legacy" interrupt
  as the latter is valid with MSI-X only.
o Instead of adding the missing - and apparently convoluted enough that a
  DBG_COUNTER_INC was put into a wrong spot in _task_fn_rx() - checks for
  ifdi_{r,t}x_queue_intr_enable being available in the MSI-X case also to
  iflib_fast_intr_rxtx(), factor these out to iflib_device_register() and
  make the checks fail gracefully rather than panic. This avoids invoking
  the checks at runtime over and over again in iflib_fast_intr_rxtx() and
  _task_fn_{r,t}x() - even if it's just in case of INVARIANTS - and makes
  these functions more readable.
o In iflib_rx_structures_setup(), only initialize LRO resources if device
  and driver have LRO capability in order to not waste memory. Also, free
  the LRO resources again if setting them up fails for one of the queues.
  However, don't bother invoking iflib_rx_sds_free() in that case because
  iflib_rx_structures_setup() doesn't call iflib_rxsd_alloc() either (and
  iflib_{device,pseudo}_register() will issue iflib_rx_sds_free() in case
  of failure via iflib_rx_structures_free(), but there definitely is some
  asymmetry left to be fixed, though).
o Similarly, free LRO resources again in iflib_rx_structures_free().
o In iflib_irq_set_affinity(), handle get_core_offset() errors gracefully
  instead of panicing (but only in case of INVARIANTS). This is a follow-
  up to r344132 (MFCed to stable/12 in r344163) as such bugs shouldn't be
  fatal.
o Likewise, handle unknown iflib_intr_type_t in iflib_irq_alloc_generic()
  gracefully, too.
o Bring yet more sanity to iflib_msix_init():
  - If the device doesn't provide enough MSI-X vectors or not all vectors
    can be allocate so the expected number of queues in addition to admin
    interrupts can't be supported, try MSI next (and then INTx) as proper
    MSI-X vector distribution can't be assured in such cases. In essence,
    this change brings r254008 forward to iflib(4). Also, this is the fix
    alluded to in the commit message of r343934.
  - If the MSI-X allocation has failed, don't prematurely announce MSI is
    going to be used as the latter in fact may not be available either.
  - When falling back to MSI, only release the MSI-X table resource again
    if it was allocated in iflib_msix_init(), i. e. isn't supplied by the
    driver, in the first place.
o In mp_ndesc_handler(), handle unknown type arguments gracefully, too.

PR: 235031 (likely) [1]
Reviewed by: shurd
Differential Revision: https://reviews.freebsd.org/D20175