]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoreadelf: Add RISC-V DWARF register aliases
mhorne [Sun, 30 Jun 2019 19:47:15 +0000 (19:47 +0000)]
readelf: Add RISC-V DWARF register aliases

This allows DWARF debugging output to use the common register
mneumonics, such as ra, sp, or t0.

DWARF registers 0-31 are mapped to the 32 general purpose registers,
which are then followed by the 32 floating point registers.

Reviewed by: markj
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20779

4 years agoelftoolchain: fix an incorrect e_flags description
mhorne [Sun, 30 Jun 2019 19:43:13 +0000 (19:43 +0000)]
elftoolchain: fix an incorrect e_flags description

r349482 introduced the definitions and descriptions of the RISC-V
specific e_flags values to elftoolchain. However, the description for
the EF_RISCV_RVE flag was incorrectly duplicated from EF_RISCV_RVC. Fix
this by providing the proper description for this flag.

Reported by: jhb
Approved by: markj (mentor)

4 years agoFix CROSS_TOOLCHAIN=amd64-gcc build after r349554
arichardson [Sun, 30 Jun 2019 17:03:14 +0000 (17:03 +0000)]
Fix CROSS_TOOLCHAIN=amd64-gcc build after r349554

Apparently clang can remove the reference to __umoddi3 but GCC keeps it.

Reported by: lwhsu

4 years agoChanges to the expose_password functionality:
des [Sun, 30 Jun 2019 14:46:15 +0000 (14:46 +0000)]
Changes to the expose_password functionality:

 - Implement use_first_pass, allowing expose_password to be used by other
   service functions than pam_auth() without prompting a second time.

 - Don't prompt for a password during pam_setcred().

PR: 238041
MFC after: 3 weeks

4 years agoFix my name in license header
arichardson [Sun, 30 Jun 2019 14:04:30 +0000 (14:04 +0000)]
Fix my name in license header

Reported by: trasz

4 years agoReduce size of rtld by 22% by pulling in less code from libc
arichardson [Sun, 30 Jun 2019 11:49:58 +0000 (11:49 +0000)]
Reduce size of rtld by 22% by pulling in less code from libc

Currently RTLD is linked against libc_nossp_pic which means that any libc
symbol used in rtld can pull in a lot of depedencies. This was causing
symbol such as __libc_interposing and all the pthread stubs to be included
in RTLD even though they are not required. It turns out most of these
dependencies can easily be avoided by providing overrides inside of rtld.

This change is motivated by CHERI, where we have an experimental ABI that
requires additional relocation processing to allow the use of function
pointers inside of rtld. Instead of adding this self-relocation code to
RTLD I attempted to remove most function pointers from RTLD and discovered
that most of them came from the libc dependencies instead of being actually
used inside rtld.

A nice side-effect of this change is that rtld is now 22% smaller on amd64.

   text    data     bss     dec     hex filename
0x21eb6   0xce0   0xe60  145910   239f6 /home/alr48/ld-elf-x86.before.so.1
0x1a6ed   0x728   0xdd8  113645   1bbed /home/alr48/ld-elf-x86.after.so.1

The number of R_X86_64_RELATIVE relocations that need to be processed on
startup has also gone down from 368 to 187 (almost 50% less).

Reviewed By: kib
Differential Revision: https://reviews.freebsd.org/D20663

4 years agoDisplay the approximate space needed when a minidump fails due to lack
np [Sun, 30 Jun 2019 03:14:04 +0000 (03:14 +0000)]
Display the approximate space needed when a minidump fails due to lack
of space.

Reviewed by: kib@
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20801

4 years agoAdd support for Python 3 and make it the default.
marcel [Sun, 30 Jun 2019 02:29:12 +0000 (02:29 +0000)]
Add support for Python 3 and make it the default.

Python 2.7 will retire on Januari 1, 2020.

4 years agoRemove a call to vm_map_simplify_entry from _vm_map_clip_start.
dougm [Sun, 30 Jun 2019 02:08:13 +0000 (02:08 +0000)]
Remove a call to vm_map_simplify_entry from _vm_map_clip_start.
Recent changes to vm_map_protect have made it unnecessary.

Reviewed by: alc
Approved by: kib (mentor)
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D20633

4 years agoMFV r349535: less v551.
delphij [Sat, 29 Jun 2019 18:41:40 +0000 (18:41 +0000)]
MFV r349535: less v551.

MFC after: 2 weeks
Relnotes: yes

4 years agoBuild lib32 libl. The library is built from usr.bin/lex/lib. It would be
tijl [Sat, 29 Jun 2019 17:01:56 +0000 (17:01 +0000)]
Build lib32 libl.  The library is built from usr.bin/lex/lib.  It would be
better to move this directory to lib/libl, but this requires more extensive
changes to Makefile.inc1.  This simple fix can be MFCed quickly.

PR: 238874
Reviewed by: imp
MFC after: 3 days

4 years agoUse a consistent snapshot of the fd's rights in fget_mmap().
markj [Sat, 29 Jun 2019 16:11:09 +0000 (16:11 +0000)]
Use a consistent snapshot of the fd's rights in fget_mmap().

fget_mmap() translates rights on the descriptor to a VM protection
mask.  It was doing so without holding any locks on the descriptor
table, so a writer could simultaneously be modifying those rights.
Such a situation would be detected using a sequence counter, but
not before an inconsistency could trigger assertion failures in
the capability code.

Fix the problem by copying the fd's rights to a structure on the stack,
and perform the translation only once we know that that snapshot is
consistent.

Reported by: syzbot+ae359438769fda1840f8@syzkaller.appspotmail.com
Reviewed by: brooks, mjg
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20800

4 years agoFix mutual exclusion in pipe_direct_write().
markj [Sat, 29 Jun 2019 16:05:52 +0000 (16:05 +0000)]
Fix mutual exclusion in pipe_direct_write().

We use PIPE_DIRECTW as a semaphore for direct writes to a pipe, where
the reader copies data directly from pages mapped into the writer.
However, when a reader finishes such a copy, it previously cleared
PIPE_DIRECTW, allowing multiple writers to race and corrupt the state
used to track wired pages belonging to the writer.

Fix this by having the writer clear PIPE_DIRECTW and instead use the
count of unread bytes to determine whether a write is finished.

Reported by: syzbot+21811cc0a89b2a87a9e7@syzkaller.appspotmail.com
Reviewed by: kib, mjg
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20784

4 years agoFix VOP_PUTPAGES(9) in regards to the use of VM_PAGER_CLUSTER_OK
lwhsu [Sat, 29 Jun 2019 14:55:53 +0000 (14:55 +0000)]
Fix VOP_PUTPAGES(9) in regards to the use of VM_PAGER_CLUSTER_OK

Submitted by: Ka Ho Ng <khng300 at gmail.com>
Reviewed by: mckusick
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20695

4 years agoSkip sys.netpfil.pf.names.names and sys.netpfil.pf.synproxy.synproxy
lwhsu [Sat, 29 Jun 2019 12:19:57 +0000 (12:19 +0000)]
Skip sys.netpfil.pf.names.names and sys.netpfil.pf.synproxy.synproxy
temporarily because kernel panics when flushing epair queue.

PR: 238870
Sponsored by: The FreeBSD Foundation

4 years agoInstall missing test data file
lwhsu [Sat, 29 Jun 2019 10:58:31 +0000 (10:58 +0000)]
Install missing test data file

MFC with: r349527
Sponsored by: The FreeBSD Foundation

4 years agoAdd support for IFCAP_NOMAP to mlx5(4).
jhb [Sat, 29 Jun 2019 00:53:07 +0000 (00:53 +0000)]
Add support for IFCAP_NOMAP to mlx5(4).

Since mlx5 uses bus_dma, this only required adding the capability
flag.

Submitted by: gallatin
Reviewed by: gallatin, hselasky, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoAdd support for IFCAP_NOMAP to cxgbe(4).
jhb [Sat, 29 Jun 2019 00:52:21 +0000 (00:52 +0000)]
Add support for IFCAP_NOMAP to cxgbe(4).

Since cxgbe(4) uses sglist instead of bus_dma, this required updates
to the code that generates scatter/gather lists for packets.  Also,
unmapped mbufs are always sent via DMA and never as immediate data in
the payload of a work request.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Discussed with: np
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoSupport IFCAP_NOMAP in vlan(4).
jhb [Sat, 29 Jun 2019 00:51:38 +0000 (00:51 +0000)]
Support IFCAP_NOMAP in vlan(4).

Enable IFCAP_NOMAP for a vlan interface if it is supported by the
underlying trunk device.

Reviewed by: gallatin, hselasky, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoCompress pending socket buffer data once it is marked ready.
jhb [Sat, 29 Jun 2019 00:50:25 +0000 (00:50 +0000)]
Compress pending socket buffer data once it is marked ready.

Apply similar logic from sbcompress to pending data in the socket
buffer once it is marked ready via sbready.  Normally sbcompress
merges small mbufs to reduce the length of mbuf chains in the socket
buffer.  However, sbcompress cannot do this for mbufs marked
M_NOTREADY.  sbcompress_ready is now called from sbready when mbufs
are marked ready to merge small mbuf chains once the data is available
to copy.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoAdd support for using unmapped mbufs with sendfile(2).
jhb [Sat, 29 Jun 2019 00:49:35 +0000 (00:49 +0000)]
Add support for using unmapped mbufs with sendfile(2).

This can be enabled at runtime via the kern.ipc.mb_use_ext_pgs sysctl.
It is disabled by default.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoAdd an external mbuf buffer type that holds multiple unmapped pages.
jhb [Sat, 29 Jun 2019 00:48:33 +0000 (00:48 +0000)]
Add an external mbuf buffer type that holds multiple unmapped pages.

Unmapped mbufs allow sendfile to carry multiple pages of data in a
single mbuf, without mapping those pages.  It is a requirement for
Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web
serving workloads when used by sendfile, due to effectively
compressing socket buffers by an order of magnitude, and hence
reducing cache misses.

For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer
now points to a struct mbuf_ext_pgs structure instead of a data
buffer.  This structure contains an array of physical addresses (this
reduces cache misses compared to an earlier version that stored an
array of vm_page_t pointers).  It also stores additional fields needed
for in-kernel TLS such as the TLS header and trailer data that are
currently unused.  To more easily detect these mbufs, the M_NOMAP flag
is set in m_flags in addition to M_EXT.

Various functions like m_copydata() have been updated to safely access
packet contents (using uiomove_fromphys()), to make things like BPF
safe.

NIC drivers advertise support for unmapped mbufs on transmit via a new
IFCAP_NOMAP capability.  This capability can be toggled via the new
'nomap' and '-nomap' ifconfig(8) commands.  For NIC drivers that only
transmit packet contents via DMA and use bus_dma, adding the
capability to if_capabilities and if_capenable should be all that is
required.

If a NIC does not support unmapped mbufs, they are converted to a
chain of mapped mbufs (using sf_bufs to provide the mapping) in
ip_output or ip6_output.  If an unmapped mbuf requires software
checksums, it is also converted to a chain of mapped mbufs before
computing the checksum.

Submitted by: gallatin (earlier version)
Reviewed by: gallatin, hselasky, rrs
Discussed with: ae, kp (firewalls)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20616

4 years agoMFV r349454:
mm [Fri, 28 Jun 2019 22:41:17 +0000 (22:41 +0000)]
MFV r349454:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1217: RAR5 reader - fix ARM filter going beyond window buffer boundary
            (OSS-Fuzz 15431)
  PR #1218: Fixes to sparse file handling

MFC after: 1 week

4 years agoWhen we protect PTEs (as opposed to PDEs), we only call vm_page_dirty()
alc [Fri, 28 Jun 2019 22:40:34 +0000 (22:40 +0000)]
When we protect PTEs (as opposed to PDEs), we only call vm_page_dirty()
when, in fact, we are write protecting the page and the PTE has PG_M set.
However, pmap_protect_pde() was always calling vm_page_dirty() when the PDE
has PG_M set.  So, adding PG_NX to a writeable PDE could result in
unnecessary (but harmless) calls to vm_page_dirty().

Simplify the loop calling vm_page_dirty() in pmap_protect_pde().

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20793

4 years agoNeed to apply the PCIM_BAR_MEM_BASE mask to the physical memory
hselasky [Fri, 28 Jun 2019 22:28:51 +0000 (22:28 +0000)]
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@
MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoAdd the 802.1q support for the Marvell e6000 series of ethernet switches.
loos [Fri, 28 Jun 2019 22:19:50 +0000 (22:19 +0000)]
Add the 802.1q support for the Marvell e6000 series of ethernet switches.

Tested on: espressobin, Clearfog, SG-3100 and others
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoAdd the 'drop tagged' flag support for ethernet switch ports.
loos [Fri, 28 Jun 2019 22:12:43 +0000 (22:12 +0000)]
Add the 'drop tagged' flag support for ethernet switch ports.

This is intended to drop all 802.1q tagged packets on a port.

Sponsored by:  Rubicon Communications, LLC (Netgate)

4 years agoStyle.
kib [Fri, 28 Jun 2019 20:40:54 +0000 (20:40 +0000)]
Style.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agocxgbe/t4_tom: Tweaks to some of the AIO related CTRs.
np [Fri, 28 Jun 2019 19:57:42 +0000 (19:57 +0000)]
cxgbe/t4_tom: Tweaks to some of the AIO related CTRs.

Reviewed by: jhb@
MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoSync mbuf flags, types, and external buffer types with <sys/mbuf.h>.
jhb [Fri, 28 Jun 2019 19:49:47 +0000 (19:49 +0000)]
Sync mbuf flags, types, and external buffer types with <sys/mbuf.h>.

Sponsored by: Netflix

4 years agoUse a tab after #define for EXT_* constants.
jhb [Fri, 28 Jun 2019 19:37:48 +0000 (19:37 +0000)]
Use a tab after #define for EXT_* constants.

This matches other #define's in this manpage as well as <sys/mbuf.h>.

Sponsored by: Netflix

4 years agocxgbe/t4_tom: the AIO tx job queue must be empty by the time the driver
np [Fri, 28 Jun 2019 19:27:45 +0000 (19:27 +0000)]
cxgbe/t4_tom: the AIO tx job queue must be empty by the time the driver
releases the offload resources associated with the tid.

Reviewed by: jhb@
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20798

4 years agoMention proccontrol(1) -m kpti.
kib [Fri, 28 Jun 2019 18:03:13 +0000 (18:03 +0000)]
Mention proccontrol(1) -m kpti.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoTypo.
kib [Fri, 28 Jun 2019 16:42:44 +0000 (16:42 +0000)]
Typo.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years ago[PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)
luporl [Fri, 28 Jun 2019 16:00:55 +0000 (16:00 +0000)]
[PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)

This prints out description text with the meaning of 'Flags' value in PowerPC64.

Example:

$ readelf -h ~/tmp/t1-Flag2
ELF Header:

Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
Class:                             ELF64
Data:                              2's complement, big endian
Version:                           1 (current)
OS/ABI:                            FreeBSD
ABI Version:                       0
Type:                              EXEC (Executable file)
Machine:                           PowerPC 64-bit
Version:                           0x1
Entry point address:               0x10010000
Start of program headers:          64 (bytes into file)
Start of section headers:          209368 (bytes into file)
Flags:                             0x2, OpenPOWER ELF V2 ABI
Size of this header:               64 (bytes)
Size of program headers:           56 (bytes)
Number of program headers:         10
Size of section headers:           64 (bytes)
Number of section headers:         34
Section header string table index: 31

Submitted by:  alfredo.junior_eldorado.org.br
Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D20782

4 years ago[PowerPC64] Add ABI flags to 'file' magic
luporl [Fri, 28 Jun 2019 15:52:40 +0000 (15:52 +0000)]
[PowerPC64] Add ABI flags to 'file' magic

The distinction between ELF header version and OpenPOWER ELF ABI version is
confusing for most of people, so this adds text to "file" output to make it
clear about which OpenPOWER ELF ABI version binary was built for.

The strings used in this change are based on "64-Bit ELF V2 ABI
Specification/3.1. ELF Header" document available at
http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655241_97607.html

Example:

$ file t1-Flag2 -m -m contrib/file/magic/Magdir/elf t1-Flag2: ELF 64-bit MSB
executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1
(FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD
13.0 (1300033), FreeBSD-style, not stripped

Submitted by: alfredo.junior_eldorado.org.br
Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D20771

4 years agoFix missing powerpc64 in _LLVM_TARGET_FILT
luporl [Fri, 28 Jun 2019 15:49:14 +0000 (15:49 +0000)]
Fix missing powerpc64 in _LLVM_TARGET_FILT

This change was originally in D20378. Making it in a new diff since it's a
bugfix.

Submitted by: alfredo.junior_eldorado.org.br
Reviewed by: emaste, luporl
Differential Revision: https://reviews.freebsd.org/D20756

4 years agoNeed to wait for epoch callbacks to complete before detaching a
hselasky [Fri, 28 Jun 2019 10:49:04 +0000 (10:49 +0000)]
Need to wait for epoch callbacks to complete before detaching a
network interface.

This particularly manifests itself when an INP has multicast options
attached during a network interface detach. Then the IPv4 and IPv6
leave group call which results from freeing the multicast address, may
access a freed ifnet structure. These are the steps to reproduce:

service mdnsd onestart # installed from ports

ifconfig epair create
ifconfig epair0a 0/24 up
ifconfig epair0a destroy

Tested by: pho @
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoImplement API for draining EPOCH(9) callbacks.
hselasky [Fri, 28 Jun 2019 10:38:56 +0000 (10:38 +0000)]
Implement API for draining EPOCH(9) callbacks.

The epoch_drain_callbacks() function is used to drain all pending
callbacks which have been invoked by prior epoch_call() function calls
on the same epoch. This function is useful when there are shared
memory structure(s) referred to by the epoch callback(s) which are not
refcounted and are rarely freed. The typical place for calling this
function is right before freeing or invalidating the shared
resource(s) used by the epoch callback(s). This function can sleep and
is not optimized for performance.

Differential Revision: https://reviews.freebsd.org/D20109
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoUpgrade to Bzip2 version 1.0.7.
delphij [Fri, 28 Jun 2019 05:11:02 +0000 (05:11 +0000)]
Upgrade to Bzip2 version 1.0.7.

MFC after: 3 days

4 years agoFix a typo.
cy [Fri, 28 Jun 2019 04:52:24 +0000 (04:52 +0000)]
Fix a typo.

PR: 238816
MFC after: 1 week
X-MFC with: r349503

4 years agoDocument the -B, binary logfile, and the -C config file options.
cy [Fri, 28 Jun 2019 04:28:32 +0000 (04:28 +0000)]
Document the -B, binary logfile, and the -C config file options.
Reference the ipmon.5 man page and ipmon.conf.

PR: 238816
MFC after: 1 week

4 years agocxgbe/t4_tom: Mark the socket's receive as done before calling
np [Fri, 28 Jun 2019 04:02:56 +0000 (04:02 +0000)]
cxgbe/t4_tom: Mark the socket's receive as done before calling
handle_ddp_close.

This eliminates a bad race where an aio_ddp_requeue that happened to run
after handle_ddp_close could bump up the active count.

Discussed with: jhb@
MFC after: 3 days
Sponsored by: Chelsio Communications

4 years agocxgbe/t4_tom: Fix regression in t_maxseg usage within t4_tom.
np [Fri, 28 Jun 2019 02:41:17 +0000 (02:41 +0000)]
cxgbe/t4_tom: Fix regression in t_maxseg usage within t4_tom.

t_maxseg was changed in r293284 to not have any adjustment for TCP
timestamps.  t4_tom inadvertently went back to pre-r293284 semantics
in r332506.

Sponsored by: Chelsio Communications

4 years agocxgbe/iw_cxgbe: Remove unused field from the endpoint structure.
np [Fri, 28 Jun 2019 02:21:42 +0000 (02:21 +0000)]
cxgbe/iw_cxgbe: Remove unused field from the endpoint structure.

MFC after: 3 days

4 years agoIf vm_map_protect fails with KERN_RESOURCE_SHORTAGE, be sure to
dougm [Fri, 28 Jun 2019 02:14:54 +0000 (02:14 +0000)]
If vm_map_protect fails with KERN_RESOURCE_SHORTAGE, be sure to
simplify modified entries before returning.

Reviewed by: alc, markj (earlier version), kib (earlier version)
Approved by: kib, markj (mentors, implicit)
Differential Revision: https://reviews.freebsd.org/D20753

4 years agoAdd ACPI entries for Synopsys Designware UARTs used on ARM platforms
bcran [Fri, 28 Jun 2019 01:19:08 +0000 (01:19 +0000)]
Add ACPI entries for Synopsys Designware UARTs used on ARM platforms

This fixes (userspace) console on the Marvell MACCHIATObin in ACPI mode with
latest TianoCore EDK2 firmware.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: mw, bcran
Differential Revision: https://reviews.freebsd.org/D20765

4 years agoAdd missing ACPI GICv2 MSI/MSI-X attachment
bcran [Fri, 28 Jun 2019 01:17:33 +0000 (01:17 +0000)]
Add missing ACPI GICv2 MSI/MSI-X attachment

This lets PCIe MSI-X device interrupts work on the MACCHIATObin
(Marvell Armada 8k), which allows e.g. the Intel igb NIC to fully work.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: mw, bcran
Differential Revision: https://reviews.freebsd.org/D20775

4 years agolibelftc: add RISC-V bfd targets
mhorne [Fri, 28 Jun 2019 00:14:12 +0000 (00:14 +0000)]
libelftc: add RISC-V bfd targets

This adds the following targets: elf32-riscv, elf64-riscv, elf64-riscv-freebsd

Reviewed by: emaste, markj, jkoshy@users.sourceforge.net
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20768

4 years agoreadelf: Add support for RISC-V specific e_flags
mhorne [Fri, 28 Jun 2019 00:10:26 +0000 (00:10 +0000)]
readelf: Add support for RISC-V specific e_flags

Reviewed by: markj
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20767

4 years agoAdd some missing RISC-V ELF defines
mhorne [Fri, 28 Jun 2019 00:03:29 +0000 (00:03 +0000)]
Add some missing RISC-V ELF defines

This adds defines for the RISC-V specific e_flags values, and some of
the missing static relocations.

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20766

4 years agoFIOBMAP2: inline vn_ioc_bmap2
asomers [Thu, 27 Jun 2019 23:39:06 +0000 (23:39 +0000)]
FIOBMAP2: inline vn_ioc_bmap2

Reported by: kib
Reviewed by: kib
MFC after: 2 weeks
MFC-With: 349238
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20783

4 years ago[skip ci] VOP_BMAP.9: fix diction in copyright header
asomers [Thu, 27 Jun 2019 23:37:09 +0000 (23:37 +0000)]
[skip ci] VOP_BMAP.9: fix diction in copyright header

MFC after: 2 weeks
MFC-With: r349230
Sponsored by: The FreeBSD Foundation

4 years agoAdd non-blocking trylock variants for the rangelock functions.
rmacklem [Thu, 27 Jun 2019 23:10:40 +0000 (23:10 +0000)]
Add non-blocking trylock variants for the rangelock functions.

A future patch that will add a Linux compatible copy_file_range(2) syscall
needs to be able to lock the byte ranges of two files concurrently.
To do this without a risk of deadlock, a non-blocking variant of
vn_rangelock_rlock() called vn_rangelock_tryrlock() was needed.
This patch adds this, along with vn_rangelock_trywlock(), in order to
do this.
The patch also adds a couple of comments, that I hope clarify how the
algorithm used in kern_rangelock.c works.

Reviewed by: kib, asomers (previous version)
Differential Revision: https://reviews.freebsd.org/D20645

4 years agoFix comment in sofree() to reference sbdestroy().
jhb [Thu, 27 Jun 2019 22:50:11 +0000 (22:50 +0000)]
Fix comment in sofree() to reference sbdestroy().

r160875 added sbdestroy() as a wrapper around sbrelease_internal to be
called from sofree(), yet the comment added in the same revision to
sofree() still mentions sbrelease_internal().

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20488

4 years agoReject attempts to register a TCP stack being unloaded.
jhb [Thu, 27 Jun 2019 22:34:05 +0000 (22:34 +0000)]
Reject attempts to register a TCP stack being unloaded.

Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20617

4 years agoFollow r349460 to complete removing "flags" in struct gpiobus_ivar
lwhsu [Thu, 27 Jun 2019 22:18:21 +0000 (22:18 +0000)]
Follow r349460 to complete removing "flags" in struct gpiobus_ivar

MFC with: r349460
Sponsored by: The FreeBSD Foundation

4 years agoIncrease EFI_STAGING_SIZE to 100MB on x64
bcran [Thu, 27 Jun 2019 22:06:41 +0000 (22:06 +0000)]
Increase EFI_STAGING_SIZE to 100MB on x64

To avoid failures when the large 18MB nvidia.ko module is being loaded,
increase EFI_STAGING_SIZE from 64MB to 100MB on x64 systems.
Leave the other platforms at 64MB.

4 years agoUse __FBSDID() and sort #includes.
jhb [Thu, 27 Jun 2019 21:45:40 +0000 (21:45 +0000)]
Use __FBSDID() and sort #includes.

No functional change.

4 years agoExpose the kernel's build-ID through `uname -b`
emaste [Thu, 27 Jun 2019 20:34:50 +0000 (20:34 +0000)]
Expose the kernel's build-ID through `uname -b`

After r348611 the kernel's build-ID is available via sysctl.  Add a -b flag
to uname to report it.

Submitted by: Ali Mashtizadeh <ali_mashtizadeh.com>
Reviewed by: markj, imp
Relnotes: Yes
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D20511

4 years agoHold an explicit reference on the socket for the aiotx task.
jhb [Thu, 27 Jun 2019 19:36:30 +0000 (19:36 +0000)]
Hold an explicit reference on the socket for the aiotx task.

Previously, the aiotx task relied on the aio jobs in the queue to hold
a reference on the socket.  However, when the last job is completed,
there is nothing left to hold a reference to the socket buffer lock
used to check if the queue is empty.  In addition, if the last job on
the queue is cancelled, the task can run with no queued jobs holding a
reference to the socket buffer lock the task uses to notice the queue
is empty.

Fix these races by holding an explicit reference on the socket when
the task is queued and dropping that reference when the task
completes.

Reviewed by: np
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20539

4 years agoAdd support for extended descriptor format to Altera mSGDMA driver.
br [Thu, 27 Jun 2019 18:08:18 +0000 (18:08 +0000)]
Add support for extended descriptor format to Altera mSGDMA driver.

The format to use depends on hardware configuration (synthesis-time),
so make it compile-time kernel option.

Extended format allows DMA engine to operate with 64-bit memory addresses.

Sponsored by: DARPA, AFRL

4 years agorevert r349460, printf -> KASSERT in bus.h, until I can fix it
avg [Thu, 27 Jun 2019 15:51:50 +0000 (15:51 +0000)]
revert r349460, printf -> KASSERT in bus.h, until I can fix it

I tested only kernel builds naively assuming that sys/bus.h cannot
affect userland builds.

Pointyhat to: me

4 years agogpiobus: provide a new hint, pin_list
avg [Thu, 27 Jun 2019 15:46:06 +0000 (15:46 +0000)]
gpiobus: provide a new hint, pin_list

"pin_list" allows to specify child pins as a list of pin numbers.
Existing hint "pins" serves the same purpose but with a 32-bit wide bit
mask.  One problem with that is that a controller can have more than 32
pins.  One example is amdgpio.  Also, a list of numbers is a little bit
more human friendly than a matching bit mask.  As a side note, it seems
that in FDT pins are typically specified by their numbers as well.

This commit also adds accessors for instance variables (IVARs) that
define the child pins.  My primary goal is to allow a child to be
configured programmatically rather than via hints (assuming that FDT is
not supported on a platform).  Also, while a child should not care about
specific pin numbers that are allocated to it, it could be interested in
how many were actually assigned to it.

While there, I removed "flags" instance variable.  It was unused.

Reviewed by: mizhka
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20459

4 years agoupgrade the warning printf-s in bus accessors to KASSERT-s
avg [Thu, 27 Jun 2019 15:07:06 +0000 (15:07 +0000)]
upgrade the warning printf-s in bus accessors to KASSERT-s

After this change sys/bus.h includes sys/systm.h.

Discussed with: cem, imp
MFC after: 2 weeks

4 years agobectl(8): create non-recursive boot environments
kevans [Thu, 27 Jun 2019 14:03:32 +0000 (14:03 +0000)]
bectl(8): create non-recursive boot environments

bectl advertises that it has the ability to create recursive and
non-recursive boot environments. This patch implements that functionality
using the be_create_depth API provided by libbe. With this patch, bectl now
works as bectl(8) describes in regards to creating recursive/non-recursive
boot environments.

Submitted by: Rob Fairbanks <rob.fx907 gmail com> (with minor changes)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20240

4 years agoUpdate vendor/libarchive/dist to git d6d3799d6b309593f271c4c319dfba92efc95772
mm [Thu, 27 Jun 2019 13:37:34 +0000 (13:37 +0000)]
Update vendor/libarchive/dist to git d6d3799d6b309593f271c4c319dfba92efc95772

Relevant vendor changes:
  PR #1217: RAR5 reader - fix ARM filter going beyond window buffer boundary
            (OSS-Fuzz 15431)
  PR #1218: Fixes to sparse file handling

4 years agopicobsd: also exclude .git where we exclude .svn today
emaste [Thu, 27 Jun 2019 13:31:55 +0000 (13:31 +0000)]
picobsd: also exclude .git where we exclude .svn today

Sponsored by: The FreeBSD Foundation

4 years agoCreate a link to the ipmon.conf.5 man page as documented in ipmon.5.
cy [Thu, 27 Jun 2019 12:37:44 +0000 (12:37 +0000)]
Create a link to the ipmon.conf.5 man page as documented in ipmon.5.
Add its corresponding optional removal entry.

PR: 238816
MFC after: 1 week

4 years agoReturn a return code scripts might expect. I missed this while
cy [Thu, 27 Jun 2019 03:50:13 +0000 (03:50 +0000)]
Return a return code scripts might expect. I missed this while
reviewing and rewriting a patch in PR/238816.

PR: 238816
Reported by: rgrimes@
Pointy hat to: cy@
MFC after: 1 week
X-MFC with: r349450

4 years agoUpdate usage() to refect the current state of ipmon.
cy [Thu, 27 Jun 2019 02:43:30 +0000 (02:43 +0000)]
Update usage() to refect the current state of ipmon.

PR: 238816
MFC after: 1 week

4 years agoAdd the ipmon.5 man page.
cy [Thu, 27 Jun 2019 02:43:26 +0000 (02:43 +0000)]
Add the ipmon.5 man page.

PR/238816 initially addressed updates to usage() however the PR has
morphed into a shopping list of updates to usage() and man pages.

PR: 238816 (I added to the list during discussion)
MFC after: 1 week

4 years agoFix a typo.
cy [Thu, 27 Jun 2019 02:42:56 +0000 (02:42 +0000)]
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
MFC after: 3 days

4 years agolibsecureboot: allow OpenPGP support to be dormant
sjg [Wed, 26 Jun 2019 23:33:32 +0000 (23:33 +0000)]
libsecureboot: allow OpenPGP support to be dormant

Since we can now add OpenPGP trust anchors at runtime,
ensure the latent support is available.

Ensure we do not add duplicate keys to trust store.

Also allow reporting names of trust anchors added/revoked

We only do this for loader and only after initializing trust store.
Thus only changes to initial trust store will be logged.

Reviewed by: stevek
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20700

4 years agoIn get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to
cognet [Wed, 26 Jun 2019 22:06:40 +0000 (22:06 +0000)]
In get_fpcontext32() and set_fpcontext32(), we can't just use memcpy() to
copy the VFP registers.
arvm7 VFP uses 32 64bits fp registers (but those could be used in pairs to
make 16 128bits registers), while aarch64 uses 32 128bits fp registers, so
we have to copy the value of each register.

4 years agoRevert one of the changes from r349323. Specifically, undo the change
alc [Wed, 26 Jun 2019 21:43:41 +0000 (21:43 +0000)]
Revert one of the changes from r349323.  Specifically, undo the change
that replaced a pmap_invalidate_page() with a dsb(ishst) in
pmap_enter_quick_locked().  Even though this change is in principle
correct, I am seeing occasional, spurious bus errors that are only
reproducible without this pmap_invalidate_page().  (None of adding an
isb, "upgrading" the dsb to wait on loads as well as stores, or
disabling superpage mappings eliminates the bus errors.)  Add an XXX
comment explaining why the pmap_invalidate_page() is being performed.

Discussed with:      andrew, markj

4 years agoEmulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).
rgrimes [Wed, 26 Jun 2019 21:19:43 +0000 (21:19 +0000)]
Emulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).

This adds emulation for:
test r/m16, imm16
test r/m32, imm32
test r/m64, imm32 sign-extended to 64

OpenBSD guests compiled with clang 8.0.0 use TEST directly against a
Local APIC register instead of separate read via MOV followed by a
TEST against the register.

PR: 238794
Submitted by: jhb
Reported by: Jason Tubnor jason@tubnor.net
Tested by: Jason Tubnor jason@tubnor.net
Reviewed by: markj, Patrick Mooney patrick.mooney@joyent.com
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20755

4 years agoFree DHCP options with length zero.
markj [Wed, 26 Jun 2019 20:19:48 +0000 (20:19 +0000)]
Free DHCP options with length zero.

Otherwise they are leaked, allowing an attacker to trigger memory
exhaustion.

This is options.c rev. 1.70 from OpenBSD.

admbugs: 552
Obtained from: OpenBSD
MFC after: 3 days

4 years agoAvoid a divide-by-zero when bad checksum counters overflow.
markj [Wed, 26 Jun 2019 20:11:52 +0000 (20:11 +0000)]
Avoid a divide-by-zero when bad checksum counters overflow.

A mixture of IP or UDP packets with valid and invalid checksum could
cause {ip,udp}_packets_bad_checksum to wrap around to 0, resulting
in a division by zero.

This is packet.c rev. 1.27 from OpenBSD.

admbugs: 552
Obtained from: OpenBSD
MFC after: 3 days

4 years agofix up r349428, fix a typo made during "fdt" removal
avg [Wed, 26 Jun 2019 17:38:38 +0000 (17:38 +0000)]
fix up r349428, fix a typo made during "fdt" removal

Reported by: ian
MFC after: 11 days

4 years agoAdd a return value to vm_page_remove().
markj [Wed, 26 Jun 2019 17:37:51 +0000 (17:37 +0000)]
Add a return value to vm_page_remove().

Use it to indicate whether the page may be safely freed following
its removal from the object.  Also change vm_page_remove() to assume
that the page's object pointer is non-NULL, and have callers perform
this check instead.

This is a step towards an implementation of an atomic reference counter
for each physical page structure.

Reviewed by: alc, dougm, kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20758

4 years agoowc_gpiobus: clean / fix up the driver module things
avg [Wed, 26 Jun 2019 17:17:33 +0000 (17:17 +0000)]
owc_gpiobus: clean / fix up the driver module things

"fdt" is removed from the driver module name as the driver does not
require FDT and can work very well on hints based systems.

A module dependency is added for gpiobus.  Without that owc cannot
resolve symbols in gpiobus if both are loaded as kernel modules.

Finally, a driver module module version is added.

Reviewed by: imp
MFC after: 11 days

4 years agoamd64 pmap: Fix pkru handling in pmap_remove().
kib [Wed, 26 Jun 2019 17:16:26 +0000 (17:16 +0000)]
amd64 pmap: Fix pkru handling in pmap_remove().

When pmap_pkru_on_remove() is called, the sva argument value was
advanced.  Clear PKRU earlier when sva still specifies the start of
the region.

Noted and reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoFix debugging of 32bits arm binaries on arm64.
cognet [Wed, 26 Jun 2019 16:56:56 +0000 (16:56 +0000)]
Fix debugging of 32bits arm binaries on arm64.

In set_regs32()/fill_regs32(), we have to get/set SP and LR from/to
tf_x[13] and tf_x[14].
set_regs() and fill_regs() may be called for a 32bits process, if the process
is ptrace'd from a 64bits debugger. So, in set_regs() and fill_regs(), get
or set PC and SPSR from where the debugger expects it, from tf_x[15] and
tf_x[16].

4 years agolibdwarf: Use the cached strtab pointer when reading string attributes.
markj [Wed, 26 Jun 2019 16:38:30 +0000 (16:38 +0000)]
libdwarf: Use the cached strtab pointer when reading string attributes.

Previously we would perform a linear search of the DWARF section
list for ".debug_str".  However, libdwarf always caches a pointer to
the strtab image in its debug descriptor.  Using it gives a modest
performance improvement when iterating over the attributes of each
DIE.

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

4 years agoelfcopy: Provide a size hint when creating the section string table.
markj [Wed, 26 Jun 2019 16:35:37 +0000 (16:35 +0000)]
elfcopy: Provide a size hint when creating the section string table.

Use the input file's .shstrtab size as the hint if it exists.  This
gives a small performance improvement when processing files with
many sections.

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

4 years agolibelftc: Fix the documented prototype for elftc_string_table_destroy().
markj [Wed, 26 Jun 2019 16:32:41 +0000 (16:32 +0000)]
libelftc: Fix the documented prototype for elftc_string_table_destroy().

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Consistently use size_t for string table offsets and sizes.
markj [Wed, 26 Jun 2019 16:31:50 +0000 (16:31 +0000)]
libelftc: Consistently use size_t for string table offsets and sizes.

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

4 years agolibelftc: Micro-optimize string table insertion.
markj [Wed, 26 Jun 2019 16:30:14 +0000 (16:30 +0000)]
libelftc: Micro-optimize string table insertion.

The string's length is already known, so use memcpy() instead of
strcpy() to add it to the string table image.

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

4 years agoRemove references to splbio in ffs_softdep.c.
markj [Wed, 26 Jun 2019 16:28:42 +0000 (16:28 +0000)]
Remove references to splbio in ffs_softdep.c.

Assert that the per-mountpoint softdep mutex is held in modified
functions that do not already have this assertion.  No functional
change intended.

Reviewed by: kib, mckusick (previous version)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20741

4 years agoFix qlxgbe(4) static build.
mav [Wed, 26 Jun 2019 16:23:24 +0000 (16:23 +0000)]
Fix qlxgbe(4) static build.

MFC after: 2 weeks

4 years agoUse rtld_putstr() instead of write() for the rtld msg() macro
arichardson [Wed, 26 Jun 2019 15:43:26 +0000 (15:43 +0000)]
Use rtld_putstr() instead of write() for the rtld msg() macro

This removes an unnecessary libc dependency from rtld.
See https://reviews.freebsd.org/D20663 for more details.

4 years agoFix -Wsign-compare warnings in realpath.c
arichardson [Wed, 26 Jun 2019 15:43:20 +0000 (15:43 +0000)]
Fix -Wsign-compare warnings in realpath.c

This is needed in order to build realpath.c as part of rtld.

4 years agoo In iflib_txq_drain():
marius [Wed, 26 Jun 2019 15:28:21 +0000 (15:28 +0000)]
o In iflib_txq_drain():
  - Remove desc_used, which is only ever written to.
  - Remove a dead store to reclaimed.
  - Don't recycle avail.
  - Sort variables according to style(9).
  These changes will make a subsequent commit easier to read.
o In iflib_tx_credits_update(), don't bother checking whether the
  ift_txd_credits_update method pointer is NULL; _iflib_pre_assert()
  asserts upfront that this method has been assigned and functions
  like iflib_{fast_intr_rxtx,netmap_timer_adjust,txq_can_drain}()
  and _task_fn_tx() were already unconditionally relying on the
  method being callable.

4 years agoOnly call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
hselasky [Wed, 26 Jun 2019 12:04:54 +0000 (12:04 +0000)]
Only call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
Else when registering multiple filters the same USB device may appear twice in
the list.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoFix support for LIBUSB_HOTPLUG_ENUMERATE in libusb. Currently all
hselasky [Wed, 26 Jun 2019 11:28:08 +0000 (11:28 +0000)]
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.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agogpio.4: document device hints common to all devices on gpiobus
avg [Wed, 26 Jun 2019 07:38:31 +0000 (07:38 +0000)]
gpio.4: document device hints common to all devices on gpiobus

"at" keyword is documented in device.hints(5) for all buses, but it does
hurt to add another reference to it.
"pins" keyword is specific to gpiobus.
At least these two hints should be configured for any gpiobus device on
a hints based system.

MFC after: 10 days

4 years agofix up r349406, add missing .El
avg [Wed, 26 Jun 2019 07:08:51 +0000 (07:08 +0000)]
fix up r349406, add missing .El

MFC after: 1 week

4 years agoowc.4: document how to set up the 1-wire bus on a device.hints system
avg [Wed, 26 Jun 2019 06:40:30 +0000 (06:40 +0000)]
owc.4: document how to set up the 1-wire bus on a device.hints system

MFC after: 1 week

4 years agoRevert r349393, which leads to an assertion failure on bootup, in vm_map_stack_locked.
dougm [Wed, 26 Jun 2019 03:12:57 +0000 (03:12 +0000)]
Revert r349393, which leads to an assertion failure on bootup, in vm_map_stack_locked.

Reported by: ler@lerctr.org
Approved by: kib, markj (mentors, implicit)