]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoCorrect definitions in sys.opencrypto.runtests.main for 32bit platform
lwhsu [Wed, 10 Jul 2019 01:08:08 +0000 (01:08 +0000)]
Correct definitions in sys.opencrypto.runtests.main for 32bit platform

Reviewed by: cem, jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20894

4 years agoUse 'retval' label for first error in syscallenter().
jhb [Tue, 9 Jul 2019 23:58:12 +0000 (23:58 +0000)]
Use 'retval' label for first error in syscallenter().

This is more consistent with the rest of the function and lets us
unindent most of the function.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20897

4 years agocxgbe(4): Clear the freelist statistics in the clearstats ioctl.
np [Tue, 9 Jul 2019 22:24:22 +0000 (22:24 +0000)]
cxgbe(4): Clear the freelist statistics in the clearstats ioctl.

Move all clearstats code into its own function while here.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoupdate calendar.freebsd
vmaffione [Tue, 9 Jul 2019 22:11:15 +0000 (22:11 +0000)]
update calendar.freebsd

MFC after: 1 week

4 years agobhyve: net_backends.c: add missing __FBSDID
vmaffione [Tue, 9 Jul 2019 22:05:58 +0000 (22:05 +0000)]
bhyve: net_backends.c: add missing __FBSDID

Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20883

4 years agobhyve: add missing license identifiers in net_utils and net_backend
vmaffione [Tue, 9 Jul 2019 22:04:33 +0000 (22:04 +0000)]
bhyve: add missing license identifiers in net_utils and net_backend

Reviewed by: jhb, markj, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20874

4 years agoIntroduce pmap_clear(), which zeroes a page table entry, and use it, instead
alc [Tue, 9 Jul 2019 20:28:53 +0000 (20:28 +0000)]
Introduce pmap_clear(), which zeroes a page table entry, and use it, instead
of pmap_load_clear(), in places where we don't care about the page table
entry's prior contents.

Eliminate an unnecessary pmap_load() from pmap_remove_all().  Instead, use
the value returned by the pmap_load_clear() on the very next line.  (In the
future, when we support "hardware dirty bit management", using the value
from the pmap_load() rather than the pmap_load_clear() would have actually
been an error because the dirty bit could potentially change between the
pmap_load() and the pmap_load_clear().)

A KASSERT() in pmap_enter(), which originated in the amd64 pmap, was meant
to check the value returned by the pmap_load_clear() on the previous line.
However, we were ignoring the value returned by the pmap_load_clear(), and
so the KASSERT() was not serving its intended purpose.  Use the value
returned by the pmap_load_clear() in the KASSERT().

MFC after: 2 weeks

4 years agocxgbe(4): Use the simplest configuration possible when falling back from
np [Tue, 9 Jul 2019 19:32:31 +0000 (19:32 +0000)]
cxgbe(4): Use the simplest configuration possible when falling back from
the default configuration.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoMFV: r349861
jkim [Tue, 9 Jul 2019 18:02:36 +0000 (18:02 +0000)]
MFV: r349861

Import ACPICA 20190703.

4 years agohyperv/vmbus: Fix the wrong size in ndis_offload structure
whu [Tue, 9 Jul 2019 08:21:14 +0000 (08:21 +0000)]
hyperv/vmbus: Fix the wrong size in ndis_offload structure

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

4 years agohyperv/vmbus: Update VMBus version 4.0 and 5.0 support.
whu [Tue, 9 Jul 2019 07:24:18 +0000 (07:24 +0000)]
hyperv/vmbus: Update VMBus version 4.0 and 5.0 support.

Add VMBus protocol version 4.0. and 5.0 to support Windows 10 and newer HyperV hosts.

For VMBus 4.0 and newer HyperV, the netvsc gpadl teardown must be done after vmbus close.

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

4 years agomld6query: Fix typo s/linkocal/linklocal/
meta [Mon, 8 Jul 2019 22:20:25 +0000 (22:20 +0000)]
mld6query: Fix typo s/linkocal/linklocal/

PR: 239039
Approved by: markj

4 years agoPut USB ACPI code into own module, uacpi.ko.
hselasky [Mon, 8 Jul 2019 20:53:25 +0000 (20:53 +0000)]
Put USB ACPI code into own module, uacpi.ko.
The code needs more testing before being enabled by default.

Sponsored by: Mellanox Technologies

4 years agoRestore the ability for i2c slave devices to do IO from their probe method.
ian [Mon, 8 Jul 2019 20:26:56 +0000 (20:26 +0000)]
Restore the ability for i2c slave devices to do IO from their probe method.

r348164 added code to iicbus_request_bus/iicbus_release_bus to automatically
call device_busy()/device_unbusy() as part of aquiring exclusive use of the
bus (so modules can't be unloaded while the bus is exclusively owned and/or
IO is in progress).  That broke the ability to do i2c IO from a slave device
probe method, because the slave isn't attached yet, so calling device_busy()
triggers a sanity-check panic for trying to busy a non-attached device.

Now we check whether the device status is < DS_ATTACHING, and if so we busy
the iicbus rather than the slave device.  I think this leaves a small window
where a module could be unloaded while probing is in progress.  But I think
that's true of all devices, and probably should be fixed by introducing a
DS_PROBING state for devices, and handling that at various points in the
newbus code.

4 years agoFix bugs in recovery path and improve cm tracking
imp [Mon, 8 Jul 2019 20:20:01 +0000 (20:20 +0000)]
Fix bugs in recovery path and improve cm tracking

Eliminate the TIMEDOUT state. This state really conveyed two different
concepts: I timed out during recovery (and my command got put on the
recovery queue), and I timed out diring discovery (which doesn't).
Separate those two concepts into two flags. Use the TIMEDOUT flag to
fail requests as timed out. Use the on queue flag to remove them from
the queue.

In mps_intr_locked for MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY message
type, when completing commands, ignore the ones that are not in state
INQUEUE. They were already completed as part of the recovery
process. When we complete them twice, we wind up with entries on the
free queue that are marked as busy, trigging asserts.

Reviewed by: scottl (earlier version, just for mpr)
Differential Revision: https://reviews.freebsd.org/D20785

4 years ago- Fix gcc build for superio(4)
lwhsu [Mon, 8 Jul 2019 20:01:28 +0000 (20:01 +0000)]
- Fix gcc build for superio(4)
- Change string mapping of SUPERIO_DEV_NONE to distinguish from SUPERIO_DEV_MAX

Reviewed by: imp
Discussed with: avg, imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20880

4 years agoFix gcc build for cxgbe(4)
lwhsu [Mon, 8 Jul 2019 19:59:15 +0000 (19:59 +0000)]
Fix gcc build for cxgbe(4)

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20879

4 years agoMerge the vm_page hold and wire mechanisms.
markj [Mon, 8 Jul 2019 19:46:20 +0000 (19:46 +0000)]
Merge the vm_page hold and wire mechanisms.

The hold_count and wire_count fields of struct vm_page are separate
reference counters with similar semantics.  The remaining essential
differences are that holds are not counted as a reference with respect
to LRU, and holds have an implicit free-on-last unhold semantic whereas
vm_page_unwire() callers must explicitly determine whether to free the
page once the last reference to the page is released.

This change removes the KPIs which directly manipulate hold_count.
Functions such as vm_fault_quick_hold_pages() now return wired pages
instead.  Since r328977 the overhead of maintaining LRU for wired pages
is lower, and in many cases vm_fault_quick_hold_pages() callers would
swap holds for wirings on the returned pages anyway, so with this change
we remove a number of page lock acquisitions.

No functional change is intended.  __FreeBSD_version is bumped.

Reviewed by: alc, kib
Discussed with: jeff
Discussed with: jhb, np (cxgbe)
Tested by: pho (previous version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19247

4 years agoWork around devices which return all zeros for reads of existing MSI-X
imp [Mon, 8 Jul 2019 19:38:49 +0000 (19:38 +0000)]
Work around devices which return all zeros for reads of existing MSI-X
table VCTRL registers.

Unconditionally program the MSI-X vector control Mask field for MSI-X
table entries without regarud for Mask's previous value. Some devices
return all zeros on reads of the VCTRL registers, which would cause us
to skip disabling interrupts. This fixes the Samsung SM961/PM961 SSDs
which are return zero starting from offset 0x3084 within the memory
region specified by BAR0, even when they are active MSI-X vectors.

The Illumos kernel writes these unconditionally to 0 or 1. However,
section 6.8.2.9 of the PCI Local Bus 3.0 spec (dated Feb 3, 2004)
states for bits 31::01:
After reset, the state of these bits must be 0. However, for
potential future use, software must preserve the value of
these reserved bits when modifying the value of other Vector
Control bits. If software modifies the value of these reserved
bits, the result is undefined."
so we always set or clear the Mask bit, but otherwise preserves the
old value.

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211713
Reviewed By: imp, jhb
Submitted by: Ka Ho Ng
MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D20873

4 years agoMinor code cleanup of USB ACPI code after r349161.
hselasky [Mon, 8 Jul 2019 19:26:05 +0000 (19:26 +0000)]
Minor code cleanup of USB ACPI code after r349161.

While at it fix an invalid memory access issue when attaching external
USB HUBs, which are not mapped by ACPI, due to missing status check
when calling AcpiGetObjectInfo() from acpi_usb_hub_port_probe_cb().

Sponsored by: Mellanox Technologies

4 years agoUpdate frtuc struct comments. It not only defines TCP things we are
cy [Mon, 8 Jul 2019 19:11:49 +0000 (19:11 +0000)]
Update frtuc struct comments. It not only defines TCP things we are
interested in but also UDP.

While at it document the source and destination port variables.

MFC after: 3 days

4 years agoCorrect the description for the low port in the port compare struct.
cy [Mon, 8 Jul 2019 19:11:35 +0000 (19:11 +0000)]
Correct the description for the low port in the port compare struct.

Adjust the high port description to match that of the low port
description.

MFC after: 3 days

4 years agoElide the vm_reserv_free_page() call when PG_PCPU_CACHE is set.
markj [Mon, 8 Jul 2019 19:02:40 +0000 (19:02 +0000)]
Elide the vm_reserv_free_page() call when PG_PCPU_CACHE is set.

Pages with PG_PCPU_CACHE set cannot have been allocated from a
reservation, so as an optimization, skip the call to
vm_reserv_free_page() in this case.  Otherwise, the access of
the corresponding reservation structure often results in a cache
miss.

Reviewed by: alc, kib
Discussed with: jeff
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20859

4 years agoAdd a per-CPU page cache per VM free pool.
markj [Mon, 8 Jul 2019 18:56:30 +0000 (18:56 +0000)]
Add a per-CPU page cache per VM free pool.

Some workloads benefit from having a per-CPU cache for
VM_FREEPOOL_DIRECT pages.

Reviewed by: dougm, kib
Discussed with: alc, jeff
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20858

4 years agoCall device_unbusy() on the error exit path, because if iicbus_request_bus()
ian [Mon, 8 Jul 2019 18:29:37 +0000 (18:29 +0000)]
Call device_unbusy() on the error exit path, because if iicbus_request_bus()
returns an error, iicbus_release_bus() is not going to be called.

4 years agoIgnore kern.vt.splash_cpu without graphics
vangyzen [Mon, 8 Jul 2019 13:46:26 +0000 (13:46 +0000)]
Ignore kern.vt.splash_cpu without graphics

When the system has no graphical console, such as bhyve in common
configurations, ignore kern.vt.splash_cpu, instead of panicking
on INVARIANTS kernels.

Reviewed by: cem dumbbell
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20877

4 years ago[PPC] Add missing SLB allocation KASSERT
luporl [Mon, 8 Jul 2019 13:01:54 +0000 (13:01 +0000)]
[PPC] Add missing SLB allocation KASSERT

Although PPC SLB code doesn't handle allocation failures,
which are rare, in most places it asserts that the pointer
returned by uma_zalloc() is not NULL, making it easier to
identify the failure and avoiding an invalid pointer dereference.

This change simply adds a missing KASSERT in SLB code.

4 years agoEliminate spurious periodic.daily error message for rotating accounting log.
ian [Sun, 7 Jul 2019 17:15:45 +0000 (17:15 +0000)]
Eliminate spurious periodic.daily error message for rotating accounting log.

In 2011, r218961 removed local code for rotating logs in favor of using the
rotate_log command in etc/rc.d/accounting.  If the accounting service is
activated then subsequently de-activated in rc.conf but still remains active
in periodic.conf, then you get an error message every day in the periodic
jobs about being unable to rotate the logs.

With this change to use "onerotate_log", the log rotation will happen the
first time periodic daily runs after accounting was disabled but periodic
accounting was left enabled.  After that happens once, the /var/account/acct
will no longer exist, which results in a different path through the periodic
code and no more error messages will appear (unless daily_show_badconfig is
set, in which case the admin will be told that periodic security processing
is enabled but the accounting file is not present).

This is only a partial fix for the problems reported in PR 202203.

PR: 202203

4 years agobhyve: abstraction for network backends
vmaffione [Sun, 7 Jul 2019 12:15:24 +0000 (12:15 +0000)]
bhyve: abstraction for network backends

Bhyve can currently emulate two virtual NICs, namely virtio-net and e1000,
and connect to the host network through two backends, namely tap and netmap.
However, there is no interface between virtual NIC functionalities and
backend functionalities. As a result, the backend code is duplicated between
the two virtual NIC implementations and also within the same virtual NIC.
Also, e1000 cannot currently use netmap as a backend.
This patch introduces a network backend API between virtio-net/e1000 and
tap/netmap, to improve code reuse and add missing functionalities.
Virtual NICs and backends can negotiate virtio-net features, such as checksum
offload and TSO. If the backend supports the features, it will propagate this
information to the guest, so that the latter can make use of them. Currently,
only netmap VALE ports support the features, but support should be added to
tap in the future.

Reviewed by: jhb, bryanv
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20659

4 years agoAdd additional check for 'blocks per group' and 'fragments per group' superblock...
fsu [Sun, 7 Jul 2019 08:58:02 +0000 (08:58 +0000)]
Add additional check for 'blocks per group' and 'fragments per group' superblock fields.

These fields will not be equal only in case if bigalloc filesystem feature is turned on.
This feature is not supported for now.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct)

MFC after: 2 weeks

4 years agoRemove ufs fragments logic.
fsu [Sun, 7 Jul 2019 08:56:13 +0000 (08:56 +0000)]
Remove ufs fragments logic.

The ext2fs fragments are different from ufs fragments.
In case of ext2fs the fragment should be equal or more then block size.
The values more than block size are used only in case of bigalloc feature, which is does not supported for now.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc)

MFC after: 2 weeks

4 years agoRemove unneeded mount point unlock call.
fsu [Sun, 7 Jul 2019 08:53:52 +0000 (08:53 +0000)]
Remove unneeded mount point unlock call.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc)

MFC after: 2 weeks

4 years agoA style-related change, r349791, made unclear the meaning of a
dougm [Sun, 7 Jul 2019 06:57:04 +0000 (06:57 +0000)]
A style-related change, r349791, made unclear the meaning of a
comment. Rewrite that comment to improve its clarity.

Reported by: cem
Reviewed by: alc, cem
Approved by: kib, markj (mentors, implicit)
Differential Revision: https://reviews.freebsd.org/D20871

4 years agoThree changes to pmap_enter():
alc [Sun, 7 Jul 2019 06:06:48 +0000 (06:06 +0000)]
Three changes to pmap_enter():

1. Use _pmap_alloc_l3() instead of pmap_alloc_l3() in order to handle the
possibility that a superpage mapping for "va" was created while we slept.
(This is derived from the amd64 version.)

2. Eliminate code for allocating kernel page table pages.  Kernel page
table pages are preallocated by pmap_growkernel().

3. Eliminate duplicated unlock operations when KERN_RESOURCE_SHORTAGE is
returned.

MFC after: 2 weeks

4 years agoDocument atomicity for read(2) and write(2).
kib [Sat, 6 Jul 2019 20:31:37 +0000 (20:31 +0000)]
Document atomicity for read(2) and write(2).

Take part of the text from POSIX 2018 edition and describe the
atomicity requirements for read and write syscalls.  See p1003.1-2018,
Vol.2, 2.9.7 Threads interaction with Regular File Operations.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D20867

4 years agoUpgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
dim [Sat, 6 Jul 2019 18:02:29 +0000 (18:02 +0000)]
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3).  The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004

4 years agoFix style(9) violations involving division by PAGE_SIZE.
dougm [Sat, 6 Jul 2019 15:55:16 +0000 (15:55 +0000)]
Fix style(9) violations involving division by PAGE_SIZE.

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

4 years agoChange blist_next_leaf_alloc so that it can examine more than one leaf
dougm [Sat, 6 Jul 2019 06:15:03 +0000 (06:15 +0000)]
Change blist_next_leaf_alloc so that it can examine more than one leaf
after the one where the possible block allocation begins, and allocate
a larger number of blocks than the current limit. This does not affect
the limit on minimum allocation size, which still cannot exceed
BLIST_MAX_ALLOC.

Use this change to modify swp_pager_getswapspace and its callers, so
that they can allocate more than BLIST_MAX_ALLOC blocks if they are
available.

Tested by: pho
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20579

4 years agoRestructure cache_handle_range to avoid repeated barriers. Specifically,
alc [Fri, 5 Jul 2019 20:01:06 +0000 (20:01 +0000)]
Restructure cache_handle_range to avoid repeated barriers.  Specifically,
restructure cache_handle_range so that all of the data cache operations are
performed before any instruction cache operations.  Then, we only need one
barrier between the data and instruction cache operations and one barrier
after the instruction cache operations.

On an Amazon EC2 a1.2xlarge instance, this simple change reduces the time
for a "make -j8 buildworld" by 9%.

Reviewed by: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20848

4 years agoBased on work posted at https://reviews.freebsd.org/D13484, change
dougm [Fri, 5 Jul 2019 16:49:34 +0000 (16:49 +0000)]
Based on work posted at https://reviews.freebsd.org/D13484, change
swap_pager_swapoff_object and swp_pager_force_pagein so that they can
page in multiple pages at a time to a swap device, rather than doing
one I/O operation for each page.

Tested by: pho
Submitted by: ota_j.email.ne.jp (Yoshihiro Ota)
Reviewed by: alc, markj, kib
Approved by: kib, markj (mentors)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20635

4 years agoMerge r349526 from amd64. When we protect an L3 entry, we only call
alc [Fri, 5 Jul 2019 05:23:23 +0000 (05:23 +0000)]
Merge r349526 from amd64.  When we protect an L3 entry, we only call
vm_page_dirty() when, in fact, we are write protecting the page and the L3
entry has PTE_D set.  However, pmap_protect() was always calling
vm_page_dirty() when an L2 entry has PTE_D set.  Handle L2 entries the
same as L3 entries so that we won't perform unnecessary calls to
vm_page_dirty().

Simplify the loop calling vm_page_dirty() on L2 entries.

4 years agonetmap: Remove pointer leakage in netmap_mem2.c
vmaffione [Thu, 4 Jul 2019 21:31:49 +0000 (21:31 +0000)]
netmap: Remove pointer leakage in netmap_mem2.c

PR: 238641
Submitted by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed by: vmaffione
MFC after: 1 week

4 years agonetmap: fix kernel pointer printing in netmap_generic.c
vmaffione [Thu, 4 Jul 2019 21:11:45 +0000 (21:11 +0000)]
netmap: fix kernel pointer printing in netmap_generic.c

Print the adapter name rather than the address of the adapter
to avoid kernel address leakage.

PR: Bug 238642
Submitted by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed by: vmaffione
MFC after: 1 week

4 years agoUpdate Linux compat version to 2.6.36
emaste [Thu, 4 Jul 2019 20:42:08 +0000 (20:42 +0000)]
Update Linux compat version to 2.6.36

New system calls between 2.6.32 and 2.6.26 are already implemented.

This should be mostly NFC as far as contemporary Linux applications are
concerned though, as Linux kernel 3.2 is the oldest supported by a
number of popular distros today; work is in progress by others to enable
support for those applications.

Discussed with: trasz
MFC after: 1 month

4 years agoReturn ENOTSUP for Linux FS_IOC_FIEMAP ioctl.
trasz [Thu, 4 Jul 2019 20:16:04 +0000 (20:16 +0000)]
Return ENOTSUP for Linux FS_IOC_FIEMAP ioctl.

Linux man(1) calls it for no good reason; this avoids the console spam
(eg '(man): ioctl fd=4, cmd=0x660b ('f',11) is not implemented').

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20690

4 years agoAdd support for PTRACE_O_TRACEEXIT to linuxulator ptrace(2).
trasz [Thu, 4 Jul 2019 19:46:58 +0000 (19:46 +0000)]
Add support for PTRACE_O_TRACEEXIT to linuxulator ptrace(2).
This fixes strace 4.25 from Ubuntu 19.04.

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20689

4 years agoImplement PTRACE_GETSIGINFO. This makes Linux strace(1) quieter
trasz [Thu, 4 Jul 2019 19:44:13 +0000 (19:44 +0000)]
Implement PTRACE_GETSIGINFO.  This makes Linux strace(1) quieter
in some cases (strace -f man id > /dev/null).

Reviewed by: dchagin
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20691

4 years agoFix linuxulator prlimit64(2) with pid == 0. This makes 'ulimit -a'
trasz [Thu, 4 Jul 2019 19:40:01 +0000 (19:40 +0000)]
Fix linuxulator prlimit64(2) with pid == 0.  This makes 'ulimit -a'
return something reasonable, and helps linux binaries which attempt
to close all the files, eg apt(8).

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20692

4 years agoMove an assignment, drop a label, and change gotos to break statements
dougm [Thu, 4 Jul 2019 19:25:30 +0000 (19:25 +0000)]
Move an assignment, drop a label, and change gotos to break statements
in vm_map_unwire. The code generated on amd86 is unchanged.

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

4 years agoReplace a 'goto' with an 'else' in vm_map_wire_locked.
dougm [Thu, 4 Jul 2019 19:17:55 +0000 (19:17 +0000)]
Replace a 'goto' with an 'else' in vm_map_wire_locked.

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

4 years agoChange boolean_t variables in vm_map_unwire and vm_map_wire_locked to
dougm [Thu, 4 Jul 2019 19:12:13 +0000 (19:12 +0000)]
Change boolean_t variables in vm_map_unwire and vm_map_wire_locked to
bool. Drop result variable. Add holes_ok bool to replace repeated
masking of flags parameter.

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

4 years agoDrop a temp variable from vm_map_insert, with no effect on the
dougm [Thu, 4 Jul 2019 18:28:49 +0000 (18:28 +0000)]
Drop a temp variable from vm_map_insert, with no effect on the
resulting amd64 machine code.

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

4 years agoDefer funsetown() calls for a TTY to tty_rel_free().
markj [Thu, 4 Jul 2019 15:42:02 +0000 (15:42 +0000)]
Defer funsetown() calls for a TTY to tty_rel_free().

We were otherwise failing to call funsetown() for some descriptors
associated with a tty, such as pts descriptors.  Then, if the
descriptor is closed before the owner exits, we may get memory
corruption.

Reported by: syzbot+c9b6206303bf47bac87e@syzkaller.appspotmail.com
Reviewed by: ed
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoFix transfers that don't use busdma or bounce buffer (e.g. software dmas).
br [Thu, 4 Jul 2019 15:26:02 +0000 (15:26 +0000)]
Fix transfers that don't use busdma or bounce buffer (e.g. software dmas).
Busdma data loaded by different function (the bug introduced in r349727).

Sponsored by: DARPA, AFRL

4 years agoFix cut-and-pasto that slipped through my testing.
imp [Thu, 4 Jul 2019 15:09:58 +0000 (15:09 +0000)]
Fix cut-and-pasto that slipped through my testing.

4 years agoelfcopy: Clear errors after fetching the shstrtab index.
markj [Thu, 4 Jul 2019 15:07:19 +0000 (15:07 +0000)]
elfcopy: Clear errors after fetching the shstrtab index.

Otherwise a future call to elf_errno() will return a non-zero value.
update_shdr(), for example, treats any errors associated with the ELF
descriptor as fatal.  Clear the error per the first example in
elf_errmsg.3.

Convert to elf_getshdrstrndx() while here since elf_getshstrndx() is
apparently deprecated.

Reported by: royger
Reviewed by: emaste
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20852

4 years agoConsider *clean targets as non-build targets as well.
bdrewery [Thu, 4 Jul 2019 14:51:44 +0000 (14:51 +0000)]
Consider *clean targets as non-build targets as well.

MFC after: 2 weeks
Sponsored by: DellEMC

4 years agoImplement missing MMCBR ivars
imp [Thu, 4 Jul 2019 14:15:04 +0000 (14:15 +0000)]
Implement missing MMCBR ivars

All MMCBR bridges have to implement all the MMCBR variables. This
implements them for everybody that currently doesn't.

A common routine for this should be written.

4 years agoNegate the logic of XCHAN_CAP_NOBUFS macro and rename it to
br [Thu, 4 Jul 2019 14:04:08 +0000 (14:04 +0000)]
Negate the logic of XCHAN_CAP_NOBUFS macro and rename it to
XCHAN_CAP_BOUNCE.

The only application that uses bounce buffering for now is the Government
Furnished Equipment (GFE) P2's dma core (AXIDMA) with its own dedicated
cacheless bounce buffer.

Sponsored by: DARPA, AFRL

4 years ago[PPC64] pseries llan: fix MAC address
luporl [Thu, 4 Jul 2019 12:31:24 +0000 (12:31 +0000)]
[PPC64] pseries llan: fix MAC address

There was an issue in pseries llan driver, that resulted in the first 2 bytes
of the MAC address getting stripped, and the last 2 being always 0.

In most cases the network interface still worked, despite the MAC being
different of what was specified to QEMU, but when some other host or DHCP
server expected a specific MAC, this would fail.

This change fixes this by shifting right by 2 the local-mac-address read from
device tree, if its length is 6 instead of 8, as observed in QEMU DT, that
always presents a 6 bytes value for this property.

PR: 237471
Reported by: Alfredo Dal'Ava Junior
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20843

4 years agoUpgrade Unbound to 1.9.2.
des [Thu, 4 Jul 2019 08:40:10 +0000 (08:40 +0000)]
Upgrade Unbound to 1.9.2.

4 years agoLock busdma operations and serialize detach against open/close
marcel [Thu, 4 Jul 2019 02:51:34 +0000 (02:51 +0000)]
Lock busdma operations and serialize detach against open/close

Use sx to allow M_WAITOK allocations (suggested by markj).

admbugs: 782
Reviewed by: markj

4 years agoEliminate a goto and a label in vm_map_wire_locked by inserting an 'else'.
dougm [Wed, 3 Jul 2019 22:41:54 +0000 (22:41 +0000)]
Eliminate a goto and a label in vm_map_wire_locked by inserting an 'else'.

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

4 years agoiwm: Drain callouts after stopping the device during detach.
markj [Wed, 3 Jul 2019 21:05:40 +0000 (21:05 +0000)]
iwm: Drain callouts after stopping the device during detach.

Otherwise there is a window where they may be rescheduled.  This
typically manifested as a page fault shortly after unloading if_iwm.ko.
Close the race by draining callouts after calling iwm_stop_device(),
which is also what Dragonfly does.

Change whitespace to reduce gratuitous diffs with Dragonfly.

Reported and tested by: seanc
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoFix path of lib32 libcasper.
tijl [Wed, 3 Jul 2019 20:52:10 +0000 (20:52 +0000)]
Fix path of lib32 libcasper.

Reported by: jhb
MFC after: 1 week

4 years agocorrect pmap_ts_referenced return type
emaste [Wed, 3 Jul 2019 19:59:56 +0000 (19:59 +0000)]
correct pmap_ts_referenced return type

pmap_ts_referenced returns a count, not a boolean, and is supposed to
have int as the return type not boolean_t.

This worked previously because boolean_t is an int typedef.

Discussed with: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoSave the last callout function executed on each CPU
vangyzen [Wed, 3 Jul 2019 19:22:44 +0000 (19:22 +0000)]
Save the last callout function executed on each CPU

Save the last callout function pointer (and its argument) executed
on each CPU for inspection by a debugger.  Add a ddb `show callout_last`
command to show these pointers.  Add a kernel module that I used
for testing that command.

Relocate `ce_migration_cpu` to reduce padding and therefore preserve
the size of `struct callout_cpu` (320 bytes on amd64) despite the
added members.

This should help diagnose reference-after-free bugs where the
callout's mutex has already been freed when `softclock_call_cc`
tries to unlock it.

You might hope that the pointer would still be available, but it
isn't.  The argument to that function is on the stack (because
`softclock_call_cc` uses it later), and that might be enough in
some cases, but even then, it's very laborious.  A pointer to the
callout is saved right before these newly added fields, but that
callout might have been freed.  We still have the pointer to its
associated mutex, and the name within might be enough, but it might
also have been freed.

Reviewed by: markj jhb
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20794

4 years agoCache the next queue element when traversing a page queue.
markj [Wed, 3 Jul 2019 18:46:39 +0000 (18:46 +0000)]
Cache the next queue element when traversing a page queue.

When QUEUE_MACRO_DEBUG_TRASH is configured, removing a queue element
invalidates its queue linkage pointers.  vm_pageout_collect_batch()
was relying on these pointers remaining valid after a removal, so
modify it to fetch the next queued page before dequeuing the current
page.

Submitted by: Don Morris <dgmorris@earthlink.net>
Reviewed by: cem, vangyzen
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20842

4 years agobhyve/audio: don't leak resources on failed initialization.
seanc [Wed, 3 Jul 2019 17:24:24 +0000 (17:24 +0000)]
bhyve/audio: don't leak resources on failed initialization.

Coverity CID: 1402793
Approved by: markj, jhb, bhyve
Differential Revision: https://reviews.freebsd.org/D20841

4 years agoUse unmapped (M_NOMAP) mbufs for zero-copy AIO writes via TOE.
jhb [Wed, 3 Jul 2019 16:06:11 +0000 (16:06 +0000)]
Use unmapped (M_NOMAP) mbufs for zero-copy AIO writes via TOE.

Previously the TOE code used its own custom unmapped mbufs via
EXT_FLAG_VENDOR1.  The old version always wired the entire AIO request
buffer first for the duration of the AIO operation and constructed
multiple mbufs which used the wired buffer as an external buffer.

The new version determines how much room is available in the socket
buffer and only wires the pages needed for the available room building
chains of M_NOMAP mbufs.  This means that a large AIO write will now
limit the amount of wired memory it uses to the size of the socket
buffer.

Reviewed by: gallatin, np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20839

4 years agoRemove dead code added after r348743 in the LinuxKPI. The
hselasky [Wed, 3 Jul 2019 09:48:20 +0000 (09:48 +0000)]
Remove dead code added after r348743 in the LinuxKPI. The
LINUXKPI_VERSION macro is not defined for any compiled LinuxKPI code
which basically means __GFP_NOTWIRED is never checked when allocating
pages. This should work fine with the existing external DRM code as
long as the page wiring and unwiring is balanced.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoAlso remove lib32 versions of libradius.
tijl [Wed, 3 Jul 2019 09:14:39 +0000 (09:14 +0000)]
Also remove lib32 versions of libradius.

MFC after: 1 week

4 years agoAlso remove lib32 version of libcasper.so.0.
tijl [Wed, 3 Jul 2019 09:08:17 +0000 (09:08 +0000)]
Also remove lib32 version of libcasper.so.0.

4 years agoAlso remove lib32 version of libprivateifconfig after r344530.
tijl [Wed, 3 Jul 2019 09:06:39 +0000 (09:06 +0000)]
Also remove lib32 version of libprivateifconfig after r344530.

4 years agoSubclass Rockchip's General Register Files driver from Simple MFD driver.
ganbold [Wed, 3 Jul 2019 03:42:51 +0000 (03:42 +0000)]
Subclass Rockchip's General Register Files driver from Simple MFD driver.

4 years agoFix build error introduced by r349596.
ganbold [Wed, 3 Jul 2019 01:40:29 +0000 (01:40 +0000)]
Fix build error introduced by r349596.

4 years agoRemove the CDIOCREADSUBCHANNEL_SYSSPACE ioctl.
markj [Wed, 3 Jul 2019 00:10:01 +0000 (00:10 +0000)]
Remove the CDIOCREADSUBCHANNEL_SYSSPACE ioctl.

This was added for emulation of Linux's CDROMSUBCHNL, but allows
users with read access to a cd(4) device to overwrite kernel memory
provided that the driver detects some media present.

Reimplement CDROMSUBCHNL by bouncing the data from CDIOCREADSUBCHANNEL
through the linux_cdrom_subchnl structure passed from userspace.

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

4 years agolibc: correct iconv buffer overflow
emaste [Tue, 2 Jul 2019 23:56:37 +0000 (23:56 +0000)]
libc: correct iconv buffer overflow

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

4 years agoImplement pmap_copy(). (This includes the changes applied to the amd64
alc [Tue, 2 Jul 2019 23:02:52 +0000 (23:02 +0000)]
Implement pmap_copy().  (This includes the changes applied to the amd64
pmap_copy() in r349585.)

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D20790

4 years agoInvoke ext_free function when freeing an unmapped mbuf.
jhb [Tue, 2 Jul 2019 22:58:21 +0000 (22:58 +0000)]
Invoke ext_free function when freeing an unmapped mbuf.

Fix a mis-merge when extracting the unmapped mbuf changes from
Netflix's in-kernel TLS changes where the call to the function that
freed the backing pages from an unmapped mbuf was missed.

Sponsored by: Chelsio Communications

4 years agoFix description of debug.obsolete_panic.
jhb [Tue, 2 Jul 2019 22:57:24 +0000 (22:57 +0000)]
Fix description of debug.obsolete_panic.

MFC after: 1 week

4 years agoFix build race when building rtld
arichardson [Tue, 2 Jul 2019 22:11:07 +0000 (22:11 +0000)]
Fix build race when building rtld

I found this on one of the CheriBSD Jenkins builders. Using
beforelinking instead of ${PROG} should fix the dependency for the
DEBUG_FILES case.

Reviewed by: brooks

4 years agoMore style.
kib [Tue, 2 Jul 2019 21:03:06 +0000 (21:03 +0000)]
More style.

Re-wrap long lines, reformat comments, remove excessive blank line.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoefihttp: mac and err can be used uninitialized
tsoome [Tue, 2 Jul 2019 20:32:35 +0000 (20:32 +0000)]
efihttp: mac and err can be used uninitialized

While there, also check if mac != NULL, and use pointer compare for ipv4
and dns.

4 years agoMark pages allocated from the per-CPU cache.
markj [Tue, 2 Jul 2019 19:51:40 +0000 (19:51 +0000)]
Mark pages allocated from the per-CPU cache.

Only free pages to the cache when they were allocated from that cache.
This mitigates rapid fragmentation of physical memory seen during
poudriere's dependency calculation phase.  In particular, pages
belonging to broken reservations are no longer freed to the per-CPU
cache, so they get a chance to coalesce with freed pages during the
break.  Otherwise, the optimized CoW handler may create object
chains in which multiple objects contain pages from the same
reservation, and the order in which we do object termination means
that the reservation is broken before all of those pages are freed,
so some of them end up in the per-CPU cache and thus permanently
fragment physical memory.

The flag may also be useful for eliding calls to vm_reserv_free_page(),
thus avoiding memory accesses for data that is likely not present
in the CPU caches.

Reviewed by: alc
Discussed with: jeff
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20763

4 years agoStyle.
kib [Tue, 2 Jul 2019 19:32:48 +0000 (19:32 +0000)]
Style.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoAdd implicit PROT_MAX() knob to proccontrol(1).
kib [Tue, 2 Jul 2019 19:12:02 +0000 (19:12 +0000)]
Add implicit PROT_MAX() knob to proccontrol(1).

Reviewed by: emaste, markj (previous version)
Discussed with: brooks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D20795

4 years agoControl implicit PROT_MAX() using procctl(2) and the FreeBSD note
kib [Tue, 2 Jul 2019 19:07:17 +0000 (19:07 +0000)]
Control implicit PROT_MAX() using procctl(2) and the FreeBSD note
feature bit.

In particular, allocate the bit to opt-out the image from implicit
PROTMAX enablement.  Provide procctl(2) verbs to set and query
implicit PROTMAX handling.  The knobs mimic the same per-image flag
and per-process controls for ASLR.

Reviewed by: emaste, markj (previous version)
Discussed with: brooks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D20795

4 years agoUse traditional 'p' local to designate td->td_proc in kern_mmap.
kib [Tue, 2 Jul 2019 19:01:14 +0000 (19:01 +0000)]
Use traditional 'p' local to designate td->td_proc in kern_mmap.

Reviewed by: emaste, markj
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D20795

4 years agopci(4): Use plural configuration registers
zeising [Tue, 2 Jul 2019 17:48:27 +0000 (17:48 +0000)]
pci(4): Use plural configuration registers

Change to use registers instead of register, as it is customary to use
plural when talking about PCI registers.

This was missed in r349150.

MFC after: 3 days

4 years agoif_muge: set IFCAP_VLAN_MTU to maintain 1500 MTU with vlan use
emaste [Tue, 2 Jul 2019 16:44:04 +0000 (16:44 +0000)]
if_muge: set IFCAP_VLAN_MTU to maintain 1500 MTU with vlan use

PR: 238665
Submitted by: Ralf <iz-rpi03@hs-karlsruhe.de>
MFC after: 1 week

4 years agoInclude sys/lock.h, as told by man page.
mav [Tue, 2 Jul 2019 15:01:54 +0000 (15:01 +0000)]
Include sys/lock.h, as told by man page.

MFC after: 1 week

4 years agoCorrect name of vmm(4) pptdevs variable.
wblock [Tue, 2 Jul 2019 14:53:51 +0000 (14:53 +0000)]
Correct name of vmm(4) pptdevs variable.

Reported by: nwolff@ixsystems.com

4 years agoFix handling of errors from sblock() in soreceive_stream().
markj [Tue, 2 Jul 2019 14:24:42 +0000 (14:24 +0000)]
Fix handling of errors from sblock() in soreceive_stream().

Previously we would attempt to unlock the socket buffer despite having
failed to lock it.  Simply return an error instead: no resources need
to be released at this point, and doing so is consistent with
soreceive_generic().

PR: 238789
Submitted by: Greg Becker <greg@codeconcepts.com>
MFC after: 1 week

4 years agoExtend simple_mfd driver to expose a syscon interface if
ganbold [Tue, 2 Jul 2019 08:47:18 +0000 (08:47 +0000)]
Extend simple_mfd driver to expose a syscon interface if
that node is also compatible with syscon. For instance,
Rockchip RK3399's GRF (General Register Files) is compatible
with simple-mfd as well as syscon and has devices like
usb2-phy, emmc-phy and pcie-phy etc. under it.

Reviewed by: manu

4 years agoFix i386 LINT after r349594.
mav [Tue, 2 Jul 2019 07:47:11 +0000 (07:47 +0000)]
Fix i386 LINT after r349594.

MFC after: 1 month

4 years agoAdd driver for NTB in AMD SoC.
mav [Tue, 2 Jul 2019 05:25:18 +0000 (05:25 +0000)]
Add driver for NTB in AMD SoC.

This patch is the driver for NTB hardware in AMD SoCs (ported from Linux)
and enables the NTB infrastructure like Doorbells, Scratchpads and Memory
window in AMD SoC. This driver has been validated using ntb_transport and
if_ntb driver already available in FreeBSD.

Submitted by: Rajesh Kumar <rajesh1.kumar@amd.com>
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D18774

4 years agobwn(4): Include SROM revision when printing device identification.
landonf [Tue, 2 Jul 2019 02:52:05 +0000 (02:52 +0000)]
bwn(4): Include SROM revision when printing device identification.

4 years agoImport tzdata 2019b
philip [Tue, 2 Jul 2019 01:12:23 +0000 (01:12 +0000)]
Import tzdata 2019b

Changes: https://github.com/eggert/tz/blob/2019b/NEWS

MFC after: 1 day

4 years agoAdd a new "untrusted" option to the mount command. Its purpose
mckusick [Mon, 1 Jul 2019 23:22:26 +0000 (23:22 +0000)]
Add a new "untrusted" option to the mount command. Its purpose
is to notify the kernel that the file system is untrusted and it
should use more extensive checks on the file-system's metadata
before using it. This option is intended to be used when mounting
file systems from untrusted media such as USB memory sticks or other
externally-provided media.

It will initially be used by the UFS/FFS file system, but should
likely be expanded to be used by other file systems that may appear
on external media like msdosfs, exfat, and ext2fs.

Reviewed by:  kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20786