]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agosfxge(4): fix warnings from VS2015 C compiler (C4245)
Andrew Rybchenko [Sat, 24 Nov 2018 16:29:58 +0000 (16:29 +0000)]
sfxge(4): fix warnings from VS2015 C compiler (C4245)

Fix level 4 warning
"C4245: 'initializing': conversion from 'int' to 'uint32_t',
signed/unsigned mismatch" warning; no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18121

5 years agosfxge(4): fix warnings from VS2015 C compiler (C4244)
Andrew Rybchenko [Sat, 24 Nov 2018 16:29:46 +0000 (16:29 +0000)]
sfxge(4): fix warnings from VS2015 C compiler (C4244)

Fix level 4 warning
"C4244: '+=': conversion from 'unsigned int' to 'uint16_t', possible loss
of data"; no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18120

5 years agosfxge(4): fix warnings from VS2015 C compiler (C4310)
Andrew Rybchenko [Sat, 24 Nov 2018 16:29:35 +0000 (16:29 +0000)]
sfxge(4): fix warnings from VS2015 C compiler (C4310)

Fix level 4 warning
"C4310: cast truncates constant value";
no functional changes.

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18119

5 years agosfxge(4): fix probes in licensing support
Andrew Rybchenko [Sat, 24 Nov 2018 16:29:23 +0000 (16:29 +0000)]
sfxge(4): fix probes in licensing support

EFSYS_PROBE1 takes one typed value (in addition to the probe name),
whereas EFSYS_PROBE has just the probe name.

Which to use is determined by the probe name - "fail1" probes are
expected to include the function result.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18118

5 years agosfxge(4): fix diagnostics support build without Siena
Andrew Rybchenko [Sat, 24 Nov 2018 16:29:11 +0000 (16:29 +0000)]
sfxge(4): fix diagnostics support build without Siena

The compilation failed because __efx_sram_pattern_fns was used in
efx_nic.c, but defined in efx_sram.c which is only needed when
supporting Siena.

To fix it move all the code using __efx_sram_pattern_fns into
Siena-specific files (except for the definition in efx_sram.c itself,
as that file only needs to be included in Siena-supporting builds
anyway).

The functions to test registers and tables are unlikely to apply to any
new hardware and so can be moved into Siena files. Since Huntington
such tests have been implemented in firmware.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18117

5 years agosfxge(4): allow to use PHY stats on Huntington/Medford
Andrew Rybchenko [Sat, 24 Nov 2018 16:28:58 +0000 (16:28 +0000)]
sfxge(4): allow to use PHY stats on Huntington/Medford

EFSYS_OPT_PHY_STATS can be used with Huntington or Medford, not just Siena.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18116

5 years agoDisable the dynamiclib test until a failure can be debugged
Andrew Turner [Sat, 24 Nov 2018 16:05:40 +0000 (16:05 +0000)]
Disable the dynamiclib test until a failure can be debugged

5 years agosfxge(4): fix coding style
Andrew Rybchenko [Sat, 24 Nov 2018 15:24:47 +0000 (15:24 +0000)]
sfxge(4): fix coding style

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18115

5 years agosfxge(4): remove unused defined for WPTR alignment
Andrew Rybchenko [Sat, 24 Nov 2018 15:24:35 +0000 (15:24 +0000)]
sfxge(4): remove unused defined for WPTR alignment

MEDFORD_RX_WPTR_ALIGN is not used.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18114

5 years agosfxge(4): support new sensors
Andrew Rybchenko [Sat, 24 Nov 2018 15:24:23 +0000 (15:24 +0000)]
sfxge(4): support new sensors

Submitted by:   Andrew Jackson <ajackson at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18113

5 years agosfxge(4): add new sensors
Andrew Rybchenko [Sat, 24 Nov 2018 15:24:12 +0000 (15:24 +0000)]
sfxge(4): add new sensors

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18112

5 years agosfxge(4): move Siena-specific defs to right header
Andrew Rybchenko [Sat, 24 Nov 2018 15:23:58 +0000 (15:23 +0000)]
sfxge(4): move Siena-specific defs to right header

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18111

5 years agosfxge(4): fix build issue with PHY LED control enabled
Andrew Rybchenko [Sat, 24 Nov 2018 15:23:46 +0000 (15:23 +0000)]
sfxge(4): fix build issue with PHY LED control enabled

Fixed build issue with the EFSYS_OPT_PHY_LED_CONTROL for Huntigton and
Medford.

Submitted by:   Vijay Srivastava <vijays at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18110

5 years agosfxge(4): improve names for TXQ descriptor counts
Andrew Rybchenko [Sat, 24 Nov 2018 15:23:34 +0000 (15:23 +0000)]
sfxge(4): improve names for TXQ descriptor counts

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18109

5 years agosfxge(4): improve names for RXQ descriptor counts
Andrew Rybchenko [Sat, 24 Nov 2018 15:23:22 +0000 (15:23 +0000)]
sfxge(4): improve names for RXQ descriptor counts

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18108

5 years agosfxge(4): improve names for EVQ descriptor counts
Andrew Rybchenko [Sat, 24 Nov 2018 15:23:09 +0000 (15:23 +0000)]
sfxge(4): improve names for EVQ descriptor counts

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18107

5 years agosfxge(4): remove assertion on no longer used define
Andrew Rybchenko [Sat, 24 Nov 2018 15:22:57 +0000 (15:22 +0000)]
sfxge(4): remove assertion on no longer used define

MC_CMD_INIT_RXQ_OUT_LEN is not used any more.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18106

5 years agoAn OSF/1 ifdef makes absolutley no sense in a FreeBSD specific source
Cy Schubert [Sat, 24 Nov 2018 07:16:44 +0000 (07:16 +0000)]
An OSF/1 ifdef makes absolutley no sense in a FreeBSD specific source
file.
MFC after: 1 week

5 years agoFreeBSD 7 has been history for many moons. Remove some dead code.
Cy Schubert [Sat, 24 Nov 2018 06:49:41 +0000 (06:49 +0000)]
FreeBSD 7 has been history for many moons. Remove some dead code.

MFC after: 1 week

5 years agoMFV r340865:
Martin Matuska [Sat, 24 Nov 2018 01:25:45 +0000 (01:25 +0000)]
MFV r340865:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1080: Spelling fixes
  PR #1084: RAR5 reader bugfixes
  PR #1091: fix use-after-free in delayed newc link processing
  PR #1092: Fix a few obvious resource leaks and strcpy() misuses

MFC after: 1 week

5 years agoUpdate vendor/libarchive/dist to git 0e416f2fe757ad6841dbb3386a17d88b5c9f5533
Martin Matuska [Sat, 24 Nov 2018 01:15:08 +0000 (01:15 +0000)]
Update vendor/libarchive/dist to git 0e416f2fe757ad6841dbb3386a17d88b5c9f5533
Relevant vendor changes:
  PR #1080: Spelling fixes
  PR #1084: RAR5 reader bugfixes
  PR #1091: fix use-after-free in delayed newc link processing
  PR #1092: Fix a few obvious resource leaks and strcpy() misuses

5 years agoParse FreeBSD Feature Control note on the ELF image activation.
Konstantin Belousov [Fri, 23 Nov 2018 23:33:55 +0000 (23:33 +0000)]
Parse FreeBSD Feature Control note on the ELF image activation.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoGeneralize ELF parse_notes().
Konstantin Belousov [Fri, 23 Nov 2018 23:29:14 +0000 (23:29 +0000)]
Generalize ELF parse_notes().

Remove the knowledge of the ABI note type and brandnote from it,
instead provide it with a callback to do note-specific matching and
data fetching.  Implement callback to match against ELF brand.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoTrivial reduction of the code duplication, reuse the return FALSE code.
Konstantin Belousov [Fri, 23 Nov 2018 23:16:01 +0000 (23:16 +0000)]
Trivial reduction of the code duplication, reuse the return FALSE code.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoHonour the waitok parameter in kevent_expand().
Mark Johnston [Fri, 23 Nov 2018 23:10:03 +0000 (23:10 +0000)]
Honour the waitok parameter in kevent_expand().

Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18316

5 years agoProvide storage for the process feature control flags in struct proc.
Konstantin Belousov [Fri, 23 Nov 2018 23:07:57 +0000 (23:07 +0000)]
Provide storage for the process feature control flags in struct proc.

The flags are cleared on exec, it is up to the image activator to set
them.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoEnsure the dirent remains initialized when dirent.d_fileno is unset.
Mark Johnston [Fri, 23 Nov 2018 23:07:49 +0000 (23:07 +0000)]
Ensure the dirent remains initialized when dirent.d_fileno is unset.

Reported by: rmacklem
MFC with: r340856
Sponsored by: The FreeBSD Foundation

5 years agortld: parse FreeBSD Feature Control note on the object load.
Konstantin Belousov [Fri, 23 Nov 2018 22:37:35 +0000 (22:37 +0000)]
rtld: parse FreeBSD Feature Control note on the object load.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

5 years agoNuke out buffer overflow safety marker code, it duplicates similar code in
Maxim Sobolev [Fri, 23 Nov 2018 22:36:56 +0000 (22:36 +0000)]
Nuke out buffer overflow safety marker code, it duplicates similar code in
the malloc()/free() as well as having potential of softening the handling
in case error is detected down to a mere warning as compared to hard panic
in free().

Submitted by: tsoome
Differential Revision: https://reviews.freebsd.org/D18299

5 years agoEnsure that directory entry padding bytes are zeroed.
Mark Johnston [Fri, 23 Nov 2018 22:24:59 +0000 (22:24 +0000)]
Ensure that directory entry padding bytes are zeroed.

Directory entries must be padded to maintain alignment; in many
filesystems the padding was not initialized, resulting in stack
memory being copied out to userspace.  With the ino64 work there
are also some explicit pad fields in struct dirent.  Add a subroutine
to clear these bytes and use it in the in-tree filesystems.  The
NFS client is omitted for now as it was fixed separately in r340787.

Reported by: Thomas Barabosch, Fraunhofer FKIE
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoaxp8xx: Rework the enable part and add the GPIOXLDO regulators
Emmanuel Vadot [Fri, 23 Nov 2018 19:45:57 +0000 (19:45 +0000)]
axp8xx: Rework the enable part and add the GPIOXLDO regulators

MFC after: 1 month

5 years agoa10_ehci: Always set the phy to host mode
Emmanuel Vadot [Fri, 23 Nov 2018 19:45:11 +0000 (19:45 +0000)]
a10_ehci: Always set the phy to host mode

MFC after: 1 month

5 years agoaw_usbphy: Convert to usbphy subclass
Emmanuel Vadot [Fri, 23 Nov 2018 19:44:26 +0000 (19:44 +0000)]
aw_usbphy: Convert to usbphy subclass

Instead of routing the phy when enabling it, do the configuration
and routing in the phynode_usb_set_mode function.
While here, if we don't have a vbus detection method, enable the phy
if requested.

MFC after: 1 month

5 years agoDerive PHY class to new one specialized for USB PHY functions.
Emmanuel Vadot [Fri, 23 Nov 2018 19:43:18 +0000 (19:43 +0000)]
Derive PHY class to new one specialized for USB PHY functions.

Submitted by: mmel

5 years agoRevert r340843 - addressed independently in r340842!
Conrad Meyer [Fri, 23 Nov 2018 18:27:16 +0000 (18:27 +0000)]
Revert r340843 - addressed independently in r340842!

5 years agortld: Silence a false positive GCC 6.4.0 warning
Conrad Meyer [Fri, 23 Nov 2018 18:23:29 +0000 (18:23 +0000)]
rtld: Silence a false positive GCC 6.4.0 warning

The function reloc_non_plt has complicated variable lifetimes that GCC 6.4.0
(the version currently used by amd64-xtoolchain-gcc) misunderstands and
produces an erroneous warning about.  Silence it to allow the -Werror build
to proceed.

Reviewed by: emaste

5 years agoSilence gcc warnings.
Konstantin Belousov [Fri, 23 Nov 2018 18:15:23 +0000 (18:15 +0000)]
Silence gcc warnings.

Reported by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

5 years agoEnable the BSD crtbegin/crtend by default.
Andrew Turner [Fri, 23 Nov 2018 16:45:07 +0000 (16:45 +0000)]
Enable the BSD crtbegin/crtend by default.

It has passed an exp run on amd64 and i386, and has testing on arm64. On
other architectures it is expected to run, however it can be disabled by
building world with -DWITHOUT_BSD_CRTBEGIN.

Sponsored by: DARPA, AFRL

5 years agoMark the function called by the MIPS .init/.fini sequence with .local.
Andrew Turner [Fri, 23 Nov 2018 16:33:03 +0000 (16:33 +0000)]
Mark the function called by the MIPS .init/.fini sequence with .local.

As with r328939 we need to mark local symbols as such. Without this the
assembly parser treats the symbols as global and created relocations
against these private symbols.

MFC with: r339738
Sponsored by: DARPA, AFRL

5 years agosfxge(4): request info about outer frame in Rx events
Andrew Rybchenko [Fri, 23 Nov 2018 16:18:36 +0000 (16:18 +0000)]
sfxge(4): request info about outer frame in Rx events

For encapsulated packets, the firmware gives info about the inner frame
fields by default. When not using encapsulation offload, ask for info
about the outer frame instead.

On SFN8xxx with firmware version before v6.4.2.1007 driver reload is
needed after switching from full-feature to low-latency firmware
variant since the driver still thinks that firmware supports
encapsulation, but firmware does not tolerate request to provide info
about outer frame in Rx events.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18105

5 years agosfxge(4): ignore error in completion event on MCDIv2 HW
Andrew Rybchenko [Fri, 23 Nov 2018 15:59:49 +0000 (15:59 +0000)]
sfxge(4): ignore error in completion event on MCDIv2 HW

With MCDIv2, the reponse length can be to big to fit into the
CMDDONE_DATALEN field in the MCDI completion event. But rather that
the length being truncated, it can overflow into the CMDDONE_ERRNO
field (this is a longstanding firmware bug). Hence the CMDDONE_ERRNO
field may not be valid.

It isn't necessary to use the value in the CMDDONE_ERRNO field though,
so it can be ignored. The actual error code is already read from the
response header on MCDIv2 capable hardware and stored in emr_rc, so
that can be used instead.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18104

5 years agosfxge(4): use MCDIv2 for requests with too long response
Andrew Rybchenko [Fri, 23 Nov 2018 15:59:37 +0000 (15:59 +0000)]
sfxge(4): use MCDIv2 for requests with too long response

Use MCDIv2 for requests with a response size too long for MCDIv1.

Required for MC_CMD_MAC_STATS to reports the stats without using DMA.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18103

5 years agoregexec: fix processing multibyte strings.
Yuri Pankov [Fri, 23 Nov 2018 15:49:18 +0000 (15:49 +0000)]
regexec: fix processing multibyte strings.

Matcher function incorrectly assumed that moffset that we get from
findmust is in bytes. Fix this by introducing a stepback function,
taking short path if MB_CUR_MAX is 1, and going back byte-by-byte,
checking if we have a legal character sequence otherwise.

PR: 153502
Reviewed by: pfg, kevans
Approved by: kib (mentor, implicit)
Differential revision: https://reviews.freebsd.org/D18297

5 years agoDisable build-id in i386 binary boot components
Ed Maste [Fri, 23 Nov 2018 13:50:18 +0000 (13:50 +0000)]
Disable build-id in i386 binary boot components

A user may enable build-id for all builds by adding
LDFLAGS=-Wl,--build-id=sha1 to /etc/make.conf.  In this case the build-id
note ends added up to mbr and pmbr's .text, which makes it too large (it
ends up being 532 bytes). To avoid this explicitly turn off build-id for
these components.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15470

5 years agosfxge(4): support inner checksum offload on transmit
Andrew Rybchenko [Fri, 23 Nov 2018 13:12:04 +0000 (13:12 +0000)]
sfxge(4): support inner checksum offload on transmit

Inner checksum offloads may be used only if firmware supports
these tunnels.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18102

5 years agoAdd support for none ACPI battery method batteries
Tom Jones [Fri, 23 Nov 2018 12:03:01 +0000 (12:03 +0000)]
Add support for none ACPI battery method batteries

Remove the requirement that a device be a ACPI method battery to be supported
as a battery.

Require now that the device be in the battery devclass and implement the
get_status and get_info functions. This allows batteries which are not ACPI
method batteries to be supported.

Reviewed by: jtl
Approved by: jtl (mentor)
MFC after: 1 Month
Differential Revision: https://reviews.freebsd.org/D17434

5 years agosfxge(4): make MAC naming consistent with other modules
Andrew Rybchenko [Fri, 23 Nov 2018 11:39:24 +0000 (11:39 +0000)]
sfxge(4): make MAC naming consistent with other modules

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18101

5 years agosfxge(4): enforce packed stream fake buffer size
Andrew Rybchenko [Fri, 23 Nov 2018 11:39:13 +0000 (11:39 +0000)]
sfxge(4): enforce packed stream fake buffer size

In the case of packed stream real size of the buffer does not fit in
Rx descriptor byte count. Real size is specified on Rx queue setup.
Non-zero fake should be used to bypass hardware checks.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18100

5 years agosfxge(4): provide simple access to RxQ state in EvQ
Andrew Rybchenko [Fri, 23 Nov 2018 11:39:02 +0000 (11:39 +0000)]
sfxge(4): provide simple access to RxQ state in EvQ

Packed stream Rx datapath requires access to packed stream state
stored in event queue. Number of credits is upstead in event handler
on a new buffer, packets parsing on 64k boundary crossing and
Rx doorbell push to give credits back.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18099

5 years agosfxge(4): improve RxQ label init prototype
Andrew Rybchenko [Fri, 23 Nov 2018 11:38:50 +0000 (11:38 +0000)]
sfxge(4): improve RxQ label init prototype

RxQ type provides more information which may be useful to
setup event queue appropriately.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18098

5 years agosfxge(4): support MUM/SUC firmware partitions
Andrew Rybchenko [Fri, 23 Nov 2018 11:31:57 +0000 (11:31 +0000)]
sfxge(4): support MUM/SUC firmware partitions

Submitted by:   Andrew Lee <alee at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18097

5 years agosfxge(4): fix ignoring function return value
Andrew Rybchenko [Fri, 23 Nov 2018 11:31:45 +0000 (11:31 +0000)]
sfxge(4): fix ignoring function return value

fix PreFAST issue, add missing annotation that function return value
should not be ignored. Fix alignment.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18096

5 years agosfxge(4): quieten get version methods
Andrew Rybchenko [Fri, 23 Nov 2018 10:22:01 +0000 (10:22 +0000)]
sfxge(4): quieten get version methods

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18095

5 years agosfxge(4): remove duplicate NVRAM asserts
Andrew Rybchenko [Fri, 23 Nov 2018 10:21:50 +0000 (10:21 +0000)]
sfxge(4): remove duplicate NVRAM asserts

The checking performed in the ->envo_type_to_partn
internal method make these assertions unnecessary.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18094

5 years agosfxge(4): precheck and verify flash writes
Andrew Rybchenko [Fri, 23 Nov 2018 10:21:36 +0000 (10:21 +0000)]
sfxge(4): precheck and verify flash writes

Read existing flash content before writing, so the flash write can be
avoided if the existing partition content matches the new image. This
avoids unnecessary write cycles for the flash device, and may also be
faster. If the flash does need to be updated, verify the content after
writing.

Note that reading the flash content after writing but before calling
efx_nvram-rw_finish() avoids firmware bug68170, which can lead to
signed image updates failing on Medford.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18093

5 years agosfxge(4): fix check in NVRAM validate
Andrew Rybchenko [Fri, 23 Nov 2018 10:21:28 +0000 (10:21 +0000)]
sfxge(4): fix check in NVRAM validate

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18092

5 years agosfxge(4): report correct partition write chunk size
Andrew Rybchenko [Fri, 23 Nov 2018 10:21:17 +0000 (10:21 +0000)]
sfxge(4): report correct partition write chunk size

If the firmware reports a non-zero write chunk size then nvram writes
may fail if a different granularity is used (e.g. for MUM firmware on
Sorrento).

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18091

5 years agosfxge(4): check NVRAM locking by partition ID
Andrew Rybchenko [Fri, 23 Nov 2018 10:21:06 +0000 (10:21 +0000)]
sfxge(4): check NVRAM locking by partition ID

Tracking which partition is locked avoids being overly conservative
when EFX_NVRAM_xxx maps to more than one partition (depnding on the
current port number).

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18090

5 years agosfxge(4): simplify NVRAM type to partition mappings
Andrew Rybchenko [Fri, 23 Nov 2018 10:20:55 +0000 (10:20 +0000)]
sfxge(4): simplify NVRAM type to partition mappings

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18089

5 years agosfxge(4): rename firmware update verify result cap field
Andrew Rybchenko [Fri, 23 Nov 2018 10:20:44 +0000 (10:20 +0000)]
sfxge(4): rename firmware update verify result cap field

The existing name confuses support for secure boot with
support for reporting a verify result after an NVRAM update.

As the capability only reports support for returning a verify
result, change the name to be less confusing.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18088

5 years agosfxge(4): extend NVRAM RW finish to return verify result
Andrew Rybchenko [Fri, 23 Nov 2018 10:20:32 +0000 (10:20 +0000)]
sfxge(4): extend NVRAM RW finish to return verify result

Extend efx_nvram_rw_finish() to return firmware verify result code.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18087

5 years agosfxge(4): report verify result from RW finish callback
Andrew Rybchenko [Fri, 23 Nov 2018 10:20:20 +0000 (10:20 +0000)]
sfxge(4): report verify result from RW finish callback

This makes the verify result visible to efx_nvram_rw_finish(), which
can be extended to report it in a later patch.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18086

5 years agosfxge(4): simplify verify result handling
Andrew Rybchenko [Fri, 23 Nov 2018 10:20:08 +0000 (10:20 +0000)]
sfxge(4): simplify verify result handling

Simplify verify result handling in NVRAM update finish

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18085

5 years agosfxge(4): fix result code in MCDI NVRAM update finish
Andrew Rybchenko [Fri, 23 Nov 2018 10:19:57 +0000 (10:19 +0000)]
sfxge(4): fix result code in MCDI NVRAM update finish

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18084

5 years agosfxge(4): copy new header from firmware src
Andrew Rybchenko [Fri, 23 Nov 2018 10:19:46 +0000 (10:19 +0000)]
sfxge(4): copy new header from firmware src

Submitted by:   Andrew Jackson <ajackson at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18083

5 years agosfxge(4): add RSS key size define
Andrew Rybchenko [Fri, 23 Nov 2018 09:16:07 +0000 (09:16 +0000)]
sfxge(4): add RSS key size define

Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18082

5 years agosfxge(4): add API to set an RSS context for a filter
Andrew Rybchenko [Fri, 23 Nov 2018 09:15:56 +0000 (09:15 +0000)]
sfxge(4): add API to set an RSS context for a filter

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18081

5 years agosfxge(4): update RSS API to take RSS context parameter
Andrew Rybchenko [Fri, 23 Nov 2018 09:15:44 +0000 (09:15 +0000)]
sfxge(4): update RSS API to take RSS context parameter

Update efx_rx_scale_mode_set(), efx_rx_scale_key_set()
and efx_rx_scale_tbl_set().

Submitted by:   Mark Spender <mspender at solarflare.com>
Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18080

5 years agosfxge(4): add API to allocate and free RSS contexts
Andrew Rybchenko [Fri, 23 Nov 2018 09:15:32 +0000 (09:15 +0000)]
sfxge(4): add API to allocate and free RSS contexts

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18079

5 years agosfxge(4): rename API to check Rx scale and hash support
Andrew Rybchenko [Fri, 23 Nov 2018 09:15:20 +0000 (09:15 +0000)]
sfxge(4): rename API to check Rx scale and hash support

Rename efx_rx_scale_support_get() to efx_rx_scale_default_support_get(),
and efx_rx_hash_support_get() to efx_rx_hash_default_support_get().

All these really report is whether an exclusive RSS context was
successfully acquired at efx_rx_init().

efx_rx_scale_support_get() sounds like it reports whether the device
supports RSS, and whether exclusive or shared contexts are supported,
but it doesn't do that. Renaming it to
efx_rx_scale_default_support_get() helps to reflect that it reports
what RSS support the client gets without trying to allocate RSS
contexts itself.

Also rename efx_rx_scale_support_t to efx_rx_scale_context_type_t, to
make the enum more suitable for specifying the type of an RSS context
to be allocated.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18078

5 years agosfxge(4): add the max number of RSS exclusive contexts
Andrew Rybchenko [Fri, 23 Nov 2018 09:15:08 +0000 (09:15 +0000)]
sfxge(4): add the max number of RSS exclusive contexts

The patch adds enc_rx_scale_max_exclusive_contexts member
to nic_cfg_t structure and sets the corresponding values
for Siena, Huntington and Medford

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18077

5 years agosfxge(4): fix default RSS context check on Siena
Andrew Rybchenko [Fri, 23 Nov 2018 09:14:57 +0000 (09:14 +0000)]
sfxge(4): fix default RSS context check on Siena

Default RSS context check is carried out during filter
insertion on Siena and it needs to be fixed

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18076

5 years agosfxge(4): define a handle to denote default RSS context
Andrew Rybchenko [Fri, 23 Nov 2018 09:14:45 +0000 (09:14 +0000)]
sfxge(4): define a handle to denote default RSS context

Make the existing filter-specific define more general.
This is the same as MC_CMD_RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID_INVALID.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18075

5 years agosfxge(4): insert filters for encapsulated packets
Andrew Rybchenko [Fri, 23 Nov 2018 09:03:32 +0000 (09:03 +0000)]
sfxge(4): insert filters for encapsulated packets

On Medford, with full-featured firmware running, encapsulated
packets may not be delivered unless filters are inserted for
them, as ordinary filters are not applied to encapsulated
packets. So filters for encapsulated packets need to be
inserted for each class of encapsulated packet. For simplicity,
catch-all filters are always inserted. These may match more
packets than the OS has asked for, but trying to insert more
precise filters increases complexity for little gain.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18074

5 years agosfxge(4): support filters for encapsulated packets
Andrew Rybchenko [Fri, 23 Nov 2018 09:03:20 +0000 (09:03 +0000)]
sfxge(4): support filters for encapsulated packets

This supports filters which match all unicast or multicast
inner frames in VXLAN, GENEVE, or NVGRE packets.
(Additional fields to match on can be added easily.)

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18073

5 years agosfxge(4): use proper MCDI command for encap filters
Andrew Rybchenko [Fri, 23 Nov 2018 09:03:09 +0000 (09:03 +0000)]
sfxge(4): use proper MCDI command for encap filters

MC_CMD_FILTER_OP_IN_EXT is needed to set filters for encapsulated
packets.

Submitted by:   Mark Spender <mspender at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18072

5 years agosfxge(4): provide information about supported tunnels
Andrew Rybchenko [Fri, 23 Nov 2018 09:02:58 +0000 (09:02 +0000)]
sfxge(4): provide information about supported tunnels

VXLAN/NVGRE (and Geneve) support is available on SFN8xxx with
full-feature firmware variant running.

Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18071

5 years agosfxge(4): let caller know that queue is already flushed
Andrew Rybchenko [Fri, 23 Nov 2018 07:50:56 +0000 (07:50 +0000)]
sfxge(4): let caller know that queue is already flushed

Tx/Rx queue may be already flushed due to Tx/Rx error on the queue or
MC reboot. Caller needs to know that the queue is already flushed to
avoid waiting for flush done event.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18070

5 years agosfxge(4): fix error code usage
Andrew Rybchenko [Fri, 23 Nov 2018 07:50:45 +0000 (07:50 +0000)]
sfxge(4): fix error code usage

MCDI results returned in req.emr_rc have already been translated
from MC_CMD_ERR_* to errno names, so using an MC_CMD_ERR_* value
is incorrect.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18069

5 years agosfxge(4): fix out of bounds read in VIs allocation
Andrew Rybchenko [Fri, 23 Nov 2018 07:50:34 +0000 (07:50 +0000)]
sfxge(4): fix out of bounds read in VIs allocation

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18068

5 years agosfxge(4): fix potential buffer overflow in Tx queue init
Andrew Rybchenko [Fri, 23 Nov 2018 07:50:22 +0000 (07:50 +0000)]
sfxge(4): fix potential buffer overflow in Tx queue init

Improve error checking to avoid a caller overflowing the MCDI
request buffer if the requested TXQ size was excessively large.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18067

5 years agosfxge(4): fix failure path in EF10 Tx queue PIO enable
Andrew Rybchenko [Fri, 23 Nov 2018 07:43:44 +0000 (07:43 +0000)]
sfxge(4): fix failure path in EF10 Tx queue PIO enable

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18066

5 years agosfxge(4): add advanced function to extract FW version
Andrew Rybchenko [Fri, 23 Nov 2018 07:38:59 +0000 (07:38 +0000)]
sfxge(4): add advanced function to extract FW version

Some libefx-based drivers might need this functionality to
indicate DPCPU FW IDs as part of FW version info to assist
experienced users.

Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18065

5 years agosfxge(4): add MCDI agnostic wrapper for MAC stats clear
Andrew Rybchenko [Fri, 23 Nov 2018 07:26:37 +0000 (07:26 +0000)]
sfxge(4): add MCDI agnostic wrapper for MAC stats clear

If a libefx-based driver needs some way to clear port statistics,
then an MCDI agnostic method is required.

Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18064

5 years agoRevert "fork: fix use-after-free with vfork"
Mateusz Guzik [Fri, 23 Nov 2018 04:38:50 +0000 (04:38 +0000)]
Revert "fork: fix use-after-free with vfork"

This unreliably breaks libc handling of vfork where forking succeded,
but execve did not.

vfork code in libc performs waitpid with WNOHANG in case of failed exec.
With the fix exit codepath was waking up the parent before the child
fully transitioned to a zombie. Woken up parent would waitpid, which
could find a not-yet-zombie child and fail to reap it due to the WNOHANG
flag.

While removing the flag fixes the problem, it is not an option due to older
releases which would still suffer from the kernel change.

Revert the fix until a solution can be worked out.

Note that while use-after-free which gets back due to the revert is a real
bug, it's side-effects are limited due to the fact that struct proc memory
is never released by UMA.

5 years agoFix a minor typo in ipfw(8) manual page.
Guangyuan Yang [Fri, 23 Nov 2018 03:42:05 +0000 (03:42 +0000)]
Fix a minor typo in ipfw(8) manual page.

PR: 230747
Submitted by: f.toscan@hotmail.it
MFC after: 1 week

5 years agoMake sure the NFS readdir client fills in all "struct dirent" data.
Rick Macklem [Fri, 23 Nov 2018 00:17:47 +0000 (00:17 +0000)]
Make sure the NFS readdir client fills in all "struct dirent" data.

The NFS client code (nfsrpc_readdir() and nfsrpc_readdirplus()) wasn't
filling in parts of the readdir reply, such as d_pad[01] and the bytes
at the end of d_name within d_reclen. As such, data left in a buffer cache
block could be leaked to userland in the readdir reply.
This patch makes sure all of the data is filled in.

Reported by: Thomas Barabosch, Fraunhofer FKIE
Reviewed by: kib, markj
MFC after: 2 weeks

5 years agoAnnotate TDP_RFPPWAIT as unlikely.
Mateusz Guzik [Thu, 22 Nov 2018 21:38:24 +0000 (21:38 +0000)]
Annotate TDP_RFPPWAIT as unlikely.

The flag is only set on vfork, but is tested for *all* syscalls.
On amd64 this shortens common-case (not vfork) code.

5 years agofork: remove avoidable proc lock/unlock pair
Mateusz Guzik [Thu, 22 Nov 2018 21:29:36 +0000 (21:29 +0000)]
fork: remove avoidable proc lock/unlock pair

We don't have to access the process after making it runnable, so there
is no need to hold it either.

Sponsored by: The FreeBSD Foundation

5 years agofork: fix use-after-free with vfork
Mateusz Guzik [Thu, 22 Nov 2018 21:08:37 +0000 (21:08 +0000)]
fork: fix use-after-free with vfork

The pointer to the child is stored without any reference held. Then it is
blindly used to wait until P_PPWAIT is cleared. However, if the child is
autoreaped it could have exited and get freed before the parent started
waiting.

Use the existing hold mechanism to mitigate the problem. Most common case
of doing exec remains unchanged. The corner case of doing exit performs
wake up before waiting for holds to clear.

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

5 years agoPlug some networking sysctl leaks.
Mark Johnston [Thu, 22 Nov 2018 20:49:41 +0000 (20:49 +0000)]
Plug some networking sysctl leaks.

Various network protocol sysctl handlers were not zero-filling their
output buffers and thus would export uninitialized stack memory to
userland.  Fix a number of such handlers.

Reported by: Thomas Barabosch, Fraunhofer FKIE
Reviewed by: tuexen
MFC after: 3 days
Security: kernel memory disclosure
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18301

5 years agoA TCP stack is required to check SEG.ACK first, when processing a
Michael Tuexen [Thu, 22 Nov 2018 20:05:57 +0000 (20:05 +0000)]
A TCP stack is required to check SEG.ACK first, when processing a
segment in the SYN-SENT state as stated in Section 3.9 of RFC 793,
page 66. Ensure this is also done by the TCP RACK stack.

Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18034

5 years agoEnsure that the TCP RACK stack honours the setting of the
Michael Tuexen [Thu, 22 Nov 2018 20:02:39 +0000 (20:02 +0000)]
Ensure that the TCP RACK stack honours the setting of the
net.inet.tcp.drop_synfin sysctl-variable.

Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18033

5 years agoEnsure that the default RTT stack can make an RTT measurement if
Michael Tuexen [Thu, 22 Nov 2018 19:56:52 +0000 (19:56 +0000)]
Ensure that the default RTT stack can make an RTT measurement if
the TCP connection was initiated using the RACK stack, but the
peer does not support the TCP RACK extension.

This ensures that the TCP behaviour on the wire is the same if
the TCP connection is initated using the RACK stack or the default
stack.

Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D18032

5 years agoEnsure that TCP RST-segments announce consistently a receiver window of
Michael Tuexen [Thu, 22 Nov 2018 19:49:52 +0000 (19:49 +0000)]
Ensure that TCP RST-segments announce consistently a receiver window of
zero. This was already done when sending them via tcp_respond().

Reviewed by: rrs@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D17949

5 years agoClear unused bytes in ia32_osendsig().
Mark Johnston [Thu, 22 Nov 2018 17:51:19 +0000 (17:51 +0000)]
Clear unused bytes in ia32_osendsig().

Mirror the fix for the native i386 implementation from r218327.  This
code is compiled only when the non-default COMPAT_43 option is
configured.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18298

5 years agoproto: change device permissions to 0600
Ed Maste [Thu, 22 Nov 2018 16:55:09 +0000 (16:55 +0000)]
proto: change device permissions to 0600

C Turt reports that the driver is not thread safe and may have
exploitable races.

Note that the proto device is intended for prototyping and development,
and is not for use on production systems.  From the man page:

SECURITY CONSIDERATIONS
     Because programs have direct access to the hardware, the proto
     driver is inherently insecure.  It is not advisable to use this
     driver on a production machine.

The proto device is not included in any of FreeBSD's kernel config files
(although the module is built).

The issues in the proto device still need to be fixed, and the device is
inherently (and intentionally) insecure, but it might as well be limited
to root only.

admbugs: 782
Reported by: C Turt <ecturt@gmail.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agosfxge(4): limit max TXQ size on Medford to 2048
Andrew Rybchenko [Thu, 22 Nov 2018 16:15:24 +0000 (16:15 +0000)]
sfxge(4): limit max TXQ size on Medford to 2048

Queues with 4096 descriptors are not supported as the top bit is used for vfifo
stuffing.

Submitted by:   Mark Spender <mspender at solarflare.com>
Reviewed by:    gnn
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision:  https://reviews.freebsd.org/D8948

5 years agosfxge(4): support packed stream Rx mode in libefx
Andrew Rybchenko [Thu, 22 Nov 2018 14:31:35 +0000 (14:31 +0000)]
sfxge(4): support packed stream Rx mode in libefx

Submitted by:   Artem V. Andreev <Artem.Andreev@oktetlabs.ru>
Sponsored by:   Solarflare Communications, Inc.
Differential Revision:  https://reviews.freebsd.org/D18022

5 years agosfxge(4): cleanup: move into right place
Andrew Rybchenko [Thu, 22 Nov 2018 14:10:46 +0000 (14:10 +0000)]
sfxge(4): cleanup: move into right place

Due to incorrect merge the piece of code was put in incorrect
place and diverge from libefx in other locations.

Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D18024