]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r349539
Li-Wen Hsu [Tue, 9 Jul 2019 09:09:51 +0000 (09:09 +0000)]
MFC r349539

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 agoMFC r349794:
Konstantin Belousov [Tue, 9 Jul 2019 07:19:36 +0000 (07:19 +0000)]
MFC r349794:
Document atomicity for read(2) and write(2).

4 years agoRestore binary compatibility for epoch(9) API.
Hans Petter Selasky [Mon, 8 Jul 2019 21:33:14 +0000 (21:33 +0000)]
Restore binary compatibility for epoch(9) API.
This is a direct commit.

Discussed with: jhb@
Sponsored by: Mellanox Technologies

4 years agoMFC r349321: Improve AHCI Enclosure Management and SES interoperation.
Alexander Motin [Mon, 8 Jul 2019 10:21:38 +0000 (10:21 +0000)]
MFC r349321: Improve AHCI Enclosure Management and SES interoperation.

Since SES specs do not define mechanism to map enclosure slots to SATA
disks, AHCI EM code I written many years ago appeared quite useless,
that always bugged me.  I was thinking whether it was a good idea, but
if LSI HBAs do that, why I shouldn't?

This change introduces simple non-standard mechanism for the mapping
into both AHCI EM and SES code, that makes AHCI EM on capable controllers
(most of Intel's) a first-class SES citizen, allowing it to report disk
physical path to GEOM, show devices inserted into each enclosure slot in
`sesutil map` and `getencstat`, control locate and fault LEDs for specific
devices with `sesutil locate adaX on` and `sesutil fault adaX on`, etc.

I've successfully tested this on Supermicro X10DRH-i motherboard connected
with sideband cable of its S-SATA Mini-SAS connector to SAS815TQ backplane.
It can indicate with LEDs Locate, Fault and Rebuild/Remap SES statuses for
each disk identical to real SES of Supermicro SAS2 backplanes.

Relnotes: yes

4 years agoMFC r341811 (by delphij):
Alexander Motin [Mon, 8 Jul 2019 10:19:49 +0000 (10:19 +0000)]
MFC r341811 (by delphij):
Remove questionable initialization for ICH8M, rely on BIOS to properly
initialize the controller.

According to the datasheet, the old code checks if port 2 (P2E, 0x4) was
the only enabled port (except port 0, which was ignored by mask 0xfe),
and issue a write to the PCS register to disable all but port 0, right
before ahci_ctlr_reset.

Some other operating systems would issue a port enable to all ports, but
since the current code only does the special initialization for ICH8M,
it entirely and rely on BIOS to do the right thing (the alternative
would be https://reviews.freebsd.org/D18300?id=50922 , should we see
reports that we really need to do it).

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

4 years agoMFC r340092 (by imp): Implement ability to turn on/off PHYs for AHCI devices.
Alexander Motin [Mon, 8 Jul 2019 10:18:11 +0000 (10:18 +0000)]
MFC r340092 (by imp): Implement ability to turn on/off PHYs for AHCI devices.

As part of Chuck's work on fixing kernel crashes caused by disk I/O
errors, it is useful to be able to trigger various kinds of
errors. This patch allows causing an AHCI-attached disk to disappear,
by having the driver keep the PHY disabled when the driver would
otherwise enable the PHY. It also allows making the disk reappear by
having the driver go back to setting the PHY enable/disable state as
it normal would and simulating the hardware event that causes a bus
rescan.

Submitted by: Chuck Silvers
Differential Revision: https://reviews.freebsd.org/D16043

4 years agoMFC r340041 (by miwi): - Add quirk for Samsung on Mac Mini 7,1
Alexander Motin [Mon, 8 Jul 2019 10:17:00 +0000 (10:17 +0000)]
MFC r340041 (by miwi): - Add quirk for Samsung on Mac Mini 7,1

PR: 201676
Submitted by: Ruben Kerkhof

4 years agoMFC r349246: SPC-3 and up require some UAs to be returned as fixed.
Alexander Motin [Sun, 7 Jul 2019 18:51:01 +0000 (18:51 +0000)]
MFC r349246: SPC-3 and up require some UAs to be returned as fixed.

4 years agoMFC r349243: Optimize xpt_getattr().
Alexander Motin [Sun, 7 Jul 2019 18:50:23 +0000 (18:50 +0000)]
MFC r349243: Optimize xpt_getattr().

Do not allocate temporary buffer for attributes we are going to return
as-is, just make sure to NUL-terminate them.  Do not zero temporary 64KB
buffer for CDAI_TYPE_SCSI_DEVID, XPT tells us how much data it filled
and there are also length fields inside the returned data also.

4 years agoMFC r349220: Add wakeup_any(), cheaper wakeup_one() for taskqueue(9).
Alexander Motin [Sun, 7 Jul 2019 18:49:39 +0000 (18:49 +0000)]
MFC r349220: Add wakeup_any(), cheaper wakeup_one() for taskqueue(9).

wakeup_one() and underlying sleepq_signal() spend additional time trying
to be fair, waking thread with highest priority, sleeping longest time.
But in case of taskqueue there are many absolutely identical threads, and
any fairness between them is quite pointless.  It makes even worse, since
round-robin wakeups not only make previous CPU affinity in scheduler quite
useless, but also hide from user chance to see CPU bottlenecks, when
sequential workload with one request at a time looks evenly distributed
between multiple threads.

This change adds new SLEEPQ_UNFAIR flag to sleepq_signal(), making it wakeup
thread that went to sleep last, but no longer in context switch (to avoid
immediate spinning on the thread lock).  On top of that new wakeup_any()
function is added, equivalent to wakeup_one(), but setting the flag.
On top of that taskqueue(9) is switchied to wakeup_any() to wakeup its
threads.

As result, on 72-core Xeon v4 machine sequential ZFS write to 12 ZVOLs
with 16KB block size spend 34% less time in wakeup_any() and descendants
then it was spending in wakeup_one(), and total write throughput increased
by ~10% with the same as before CPU usage.

4 years agoMFC r349195: Use sbuf_cat() in GEOM confxml generation.
Alexander Motin [Sun, 7 Jul 2019 18:47:01 +0000 (18:47 +0000)]
MFC r349195: Use sbuf_cat() in GEOM confxml generation.

When it comes to megabytes of text, difference between sbuf_printf() and
sbuf_cat() becomes substantial.

4 years agoMFC r349190: Fix typo in r349178.
Alexander Motin [Sun, 7 Jul 2019 18:45:57 +0000 (18:45 +0000)]
MFC r349190: Fix typo in r349178.

4 years agoMFC r349178: Optimize kern.geom.conf* sysctls.
Alexander Motin [Sun, 7 Jul 2019 18:44:51 +0000 (18:44 +0000)]
MFC r349178: Optimize kern.geom.conf* sysctls.

On large systems those sysctls may generate megabytes of output.  Before
this change sbuf(9) code was resizing buffer by 4KB each time many times,
generating tons of TLB shootdowns.  Unfortunately in this case existing
sbuf_new_for_sysctl() mechanism, supposed to help with this issue, is not
applicable, since all the sbuf writes are done in different kernel thread.

This change improves situation in two ways:
 - on first sysctl call, not providing any output buffer, it sets special
sbuf drain function, just counting the data and so not needing big buffer;
 - on second sysctl call it uses as initial buffer size value saved on
previous call, so that in most cases there will be no reallocation, unless
GEOM topology changed significantly.

4 years agoMFC r349040: Minimize aggsum_compare(&arc_size, arc_c) calls.
Alexander Motin [Sun, 7 Jul 2019 18:42:25 +0000 (18:42 +0000)]
MFC r349040: Minimize aggsum_compare(&arc_size, arc_c) calls.

For busy ARC situation when arc_size close to arc_c is desired.  But
then it is quite likely that aggsum_compare(&arc_size, arc_c) will need
to flush per-CPU buckets to find exact comparison result.  Doing that
often in a hot path penalizes whole idea of aggsum usage there, since it
replaces few simple atomic additions with dozens of lock acquisitions.

Replacing aggsum_compare() with aggsum_upper_bound() in code increasing
arc_p when ARC is growing (arc_size < arc_c) according to PMC profiles
allows to save ~5% of CPU time in aggsum code during sequential write
to 12 ZVOLs with 16KB block size on large dual-socket system.

I suppose there some minor arc_p behavior change due to lower precision
of the new code, but I don't think it is a big deal, since it should
affect only very small window in time (aggsum buckets are flushed every
second) and in ARC size (buckets are limited to 10 average ARC blocks
per CPU).

4 years agoMFC r349039: Alike to ZoL disable metaslab allocation tracing code.
Alexander Motin [Sun, 7 Jul 2019 18:40:35 +0000 (18:40 +0000)]
MFC r349039: Alike to ZoL disable metaslab allocation tracing code.

It is too generous to collect in production debug traces that can only
be read with kernel debugger.  Illumos includes special code in their
mdb debugger to read it, we don't.

4 years agoMFC r349035: Properly align struct multilist_sublist to cache line.
Alexander Motin [Sun, 7 Jul 2019 18:39:32 +0000 (18:39 +0000)]
MFC r349035: Properly align struct multilist_sublist to cache line.

Manual Illumos alignment does not fit us due to different kmutex_t size.

4 years agoMFC r349029: Update td_runtime of running thread on each statclock().
Alexander Motin [Sun, 7 Jul 2019 18:38:40 +0000 (18:38 +0000)]
MFC r349029: Update td_runtime of running thread on each statclock().

Normally td_runtime is updated on context switch, but there are some kernel
threads that due to high absolute priority may run for many seconds without
context switches (yes, that is bad, but that is true), which means their
td_runtime was not updated all that time, that made them invisible for top
other then as some general CPU usage.

4 years agoMFC r349006: Move write aggregation memory copy out of vq_lock.
Alexander Motin [Sun, 7 Jul 2019 18:37:46 +0000 (18:37 +0000)]
MFC r349006: Move write aggregation memory copy out of vq_lock.

Memory copy is too heavy operation to do under the congested lock.
Moving it out reduces congestion by many times to almost invisible.
Since the original zio removed from the queue, and the child zio is
not executed yet, I don't see why would the copy need protection.
My guess it just remained like this from the time when lock was not
dropped here, which was added later to fix lock ordering issue.

Multi-threaded sequential write tests with both HDD and SSD pools
with ZVOL block sizes of 4KB, 16KB, 64KB and 128KB all show major
reduction of lock congestion, saving from 15% to 35% of CPU time
and increasing throughput from 10% to 40%.

4 years agoMFC r349292: Decouple enc/ses verbosity from bootverbose.
Alexander Motin [Sun, 7 Jul 2019 18:33:21 +0000 (18:33 +0000)]
MFC r349292: Decouple enc/ses verbosity from bootverbose.

I don't want to be regularly notified that my enclosure violates standards
until there is some real problem I want to debug.

4 years agoMFC r349287: Remove ancient SCSI-2/3 mentioning.
Alexander Motin [Sun, 7 Jul 2019 18:32:34 +0000 (18:32 +0000)]
MFC r349287: Remove ancient SCSI-2/3 mentioning.

4 years agoMFC r349284: Make ELEMENT INDEX validation more strict.
Alexander Motin [Sun, 7 Jul 2019 18:31:53 +0000 (18:31 +0000)]
MFC r349284: Make ELEMENT INDEX validation more strict.

SES specifications tell: "The Additional Element Status descriptors shall
be in the same order as the status elements in the Enclosure Status
diagnostic page".  It allows us to question ELEMENT INDEX that is lower
then values we already processed.  There are many SAS2 enclosures with
this kind of problem.

While there, add more specific error messages for cases when ELEMENT INDEX
is obviously wrong.  Also skip elements with INVALID bit set.

4 years agoMFC r349281: Fix individual_element_index when some type has 0 elements.
Alexander Motin [Sun, 7 Jul 2019 18:29:10 +0000 (18:29 +0000)]
MFC r349281: Fix individual_element_index when some type has 0 elements.

When some type has 0 elements, saved_individual_element_index was set
to -1 on second type bump, since individual_element_index was not
restored after the first.  To me it looks easier just to increment
saved_individual_element_index separately than think when to save it.

4 years agoMFC r349671:
Mark Johnston [Sun, 7 Jul 2019 17:45:17 +0000 (17:45 +0000)]
MFC r349671:
Cache the next queue element when traversing a page queue.

4 years agoMFC r349599:
Mark Johnston [Sun, 7 Jul 2019 17:43:15 +0000 (17:43 +0000)]
MFC r349599:
Fix handling of errors from sblock() in soreceive_stream().

PR: 238789

4 years agoMFC r349441 (by rgrimes):
Mark Johnston [Sun, 7 Jul 2019 17:30:23 +0000 (17:30 +0000)]
MFC r349441 (by rgrimes):
Emulate the "TEST r/m{16,32,64}, imm{16,32,32}" instructions (opcode F7H).

PR: 238794

4 years agoMFC r349733:
Mark Johnston [Sun, 7 Jul 2019 14:19:46 +0000 (14:19 +0000)]
MFC r349733:
Defer funsetown() calls for a TTY to tty_rel_free().

4 years agoMFC r349730:
Mark Johnston [Sun, 7 Jul 2019 14:19:19 +0000 (14:19 +0000)]
MFC r349730:
elfcopy: Clear errors after fetching the shstrtab index.

4 years agoMFC r349500:
Navdeep Parhar [Sun, 7 Jul 2019 05:30:07 +0000 (05:30 +0000)]
MFC r349500:

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 agoMFC r349499:
Navdeep Parhar [Sun, 7 Jul 2019 00:43:38 +0000 (00:43 +0000)]
MFC r349499:

cxgbe/iw_cxgbe: Remove unused field from the endpoint structure.

4 years agoMFC r349242, r349501, r349514, and r349517.
Navdeep Parhar [Sun, 7 Jul 2019 00:30:20 +0000 (00:30 +0000)]
MFC r349242, r349501, r349514, and r349517.

r349242:
cxgbe/t4_tom: DDP_DEAD is a ddp flag and not a toepcb flag.

The driver was in effect setting TPF_ABORT_SHUTDOWN on the toepcb
instead of what was intended.

Sponsored by: Chelsio Communications

r349501:
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@
Sponsored by: Chelsio Communications

r349514:
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@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D20798

r349517:
cxgbe/t4_tom: Tweaks to some of the AIO related CTRs.

Reviewed by: jhb@
Sponsored by: Chelsio Communications

4 years agoMFC r349608:
Konstantin Belousov [Sat, 6 Jul 2019 16:19:04 +0000 (16:19 +0000)]
MFC r349608:
Use traditional 'p' local to designate td->td_proc in kern_mmap.

4 years agoMFC r349547:
Mark Johnston [Sat, 6 Jul 2019 01:00:11 +0000 (01:00 +0000)]
MFC r349547:
Use a consistent snapshot of the fd's rights in fget_mmap().

4 years agoMFC r349546:
Mark Johnston [Sat, 6 Jul 2019 00:59:11 +0000 (00:59 +0000)]
MFC r349546:
Fix mutual exclusion in pipe_direct_write().

4 years agoMFC: r348590, r348591
Rick Macklem [Fri, 5 Jul 2019 22:36:31 +0000 (22:36 +0000)]
MFC: r348590, r348591
Modify mountd so that it incrementally updates the kernel exports upon a reload.

Without this patch, mountd would delete/load all exports from the exports
file(s) when it receives a SIGHUP. This works fine for small exports file(s),
but can take several seconds to do when there are large numbers (10000+) of
exported file systems. Most of this time is spent doing the system calls
that delete/export each of these file systems. When the "-S" option
has been specified (the default these days), the nfsd threads are suspended
for several seconds while the reload is done.

This patch changes mountd so that it only does system calls for file systems
where the exports have been changed/added/deleted as compared to the exports
done for the previous load/reload of the exports file(s).
Basically, when SIGHUP is posted to mountd, it saves the exportlist structures
from the previous load and creates a new set of structures from the current
exports file(s). Then it compares the current with the previous and only does
system calls for cases that have been changed/added/deleted.
The nfsd threads do not need to be suspended until the comparison step is
being done. This results in a suspension period of milliseconds for a server
with 10000+ exported file systems.

There is some code using a LOGDEBUG() macro that allow runtime debugging
output via syslog(LOG_DEBUG,...) that can be enabled by creating a file
called /var/log/mountd.debug. This code is expected to be replaced with
code that uses dtrace by cy@ in the near future, once issues w.r.t. dtrace
in stable/12 have been resolved.

The patch should not change the usage of the exports file(s), but improves
the performance of reloading large exports file(s) where there are only a
small number of changes done to the file(s).

PR: 237860

4 years agoMFC r349607: pci(4): Use plural registers
Niclas Zeising [Fri, 5 Jul 2019 22:21:02 +0000 (22:21 +0000)]
MFC r349607: pci(4): Use plural registers

Original commit message:

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.

4 years agoMFC r349098:
Philip Paeps [Fri, 5 Jul 2019 16:43:41 +0000 (16:43 +0000)]
MFC r349098:
  Add macOS-like three finger drag trackpad gesture to psm(4)

4 years agoMFC r349507:
Hans Petter Selasky [Fri, 5 Jul 2019 12:35:49 +0000 (12:35 +0000)]
MFC r349507:
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 @
Sponsored by: Mellanox Technologies

4 years agoMFC r349506:
Hans Petter Selasky [Fri, 5 Jul 2019 12:33:31 +0000 (12:33 +0000)]
MFC r349506:
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
Sponsored by: Mellanox Technologies

4 years agoMFC r340404, r340415, r340417, r340419 and r340420:
Hans Petter Selasky [Fri, 5 Jul 2019 12:26:30 +0000 (12:26 +0000)]
MFC r340404, r340415, r340417, r340419 and r340420:
Synchronize epoch(9) code with -head to make merging new patches
and features easier.
The FreeBSD version has been bumped to force recompilation of
external kernel modules.

Sponsored by: Mellanox Technologies

MFC r340404:
Uninline epoch(9) entrance and exit. There is no proof that modern
processors would benefit from avoiding a function call, but bloating
code. In fact, clang created an uninlined real function for many
object files in the network stack.

- Move epoch_private.h into subr_epoch.c. Code copied exactly, avoiding
  any changes, including style(9).
- Remove private copies of critical_enter/exit.

Reviewed by: kib, jtl
Differential Revision: https://reviews.freebsd.org/D17879

MFC r340415:
The dualism between epoch_tracker and epoch_thread is fragile and
unnecessary. So, expose CK types to kernel and use a single normal
structure for epoch_tracker.

Reviewed by: jtl, gallatin

MFC r340417:
With epoch not inlined, there is no point in using _lite KPI. While here,
remove some unnecessary casts.

MFC r340419:
style(9), mostly adjusting overly long lines.

MFC r340420:
epoch(9) revert r340097 - no longer a need for multiple sections per cpu

I spoke with Samy Bahra and recent changes to CK to make ck_epoch_call and
ck_epoch_poll not modify the record have eliminated the need for this.

4 years agoMFC r349369:
Hans Petter Selasky [Fri, 5 Jul 2019 10:31:37 +0000 (10:31 +0000)]
MFC r349369:
Convert all IPv4 and IPv6 multicast memberships into using a STAILQ
instead of a linear array.

The multicast memberships for the inpcb structure are protected by a
non-sleepable lock, INP_WLOCK(), which needs to be dropped when
calling the underlying possibly sleeping if_ioctl() method. When using
a linear array to keep track of multicast memberships, the computed
memory location of the multicast filter may suddenly change, due to
concurrent insertion or removal of elements in the linear array. This
in turn leads to various invalid memory access issues and kernel
panics.

To avoid this problem, put all multicast memberships on a STAILQ based
list. Then the memory location of the IPv4 and IPv6 multicast filters
become fixed during their lifetime and use after free and memory leak
issues are easier to track, for example by: vmstat -m | grep multi

All list manipulation has been factored into inline functions
including some macros, to easily allow for a future hash-list
implementation, if needed.

This patch has been tested by pho@ .

Differential Revision: https://reviews.freebsd.org/D20080
Reviewed by: markj @
Sponsored by: Mellanox Technologies

4 years agoMFC r349503-349504:
Cy Schubert [Fri, 5 Jul 2019 04:24:09 +0000 (04:24 +0000)]
MFC r349503-349504:

Document the -B, binary logfile, and the -C config file options.
Reference the ipmon.5 man page and ipmon.conf.

PR: 238816

4 years agoMFC r349611, r349614:
Konstantin Belousov [Fri, 5 Jul 2019 01:19:28 +0000 (01:19 +0000)]
MFC r349611, r349614:
Style.

4 years agoMFC: r348452
Rick Macklem [Fri, 5 Jul 2019 00:55:46 +0000 (00:55 +0000)]
MFC: r348452
Replace a single linked list with a hash table of lists.

mountd.c uses a single linked list of "struct exportlist" structures,
where there is one of these for each exported file system on the NFS server.
This list gets long if there are a large number of file systems exported and
the list must be searched for each line in the exports file(s) when
SIGHUP causes the exports file(s) to be reloaded.
A simple benchmark that traverses SLIST() elements and compares two 32bit
fields in the structure for equal (which is what the search is)
appears to take a couple of nsec. So, for a server with 72000 exported file
systems, this can take about 5sec during reload of the exports file(s).
By replacing the single linked list with a hash table with a target of
10 elements per list, the time should be reduced to less than 1msec.
Peter Errikson (who has a server with 72000+ exported file systems) ran
a test program using 5 hashes to see how they worked.
fnv_32_buf(fsid,..., 0)
fnv_32_buf(fsid,..., FNV1_32_INIT)
hash32_buf(fsid,..., 0)
hash32_buf(fsid,..., HASHINIT)
- plus simply using the low order bits of fsid.val[0].
The first three behaved about equally well, with the first one being
slightly better than the others.
It has an average variation of about 4.5% about the target list length
and that is what this patch uses.
Peter Errikson also tested this hash table version and found that the
performance wasn't measurably improved by a larger hash table, so a
load factor of 10 appears adequate.

PR: 237860

4 years agoMFC r349239, r349241: update vm_map_protect.9
Ed Maste [Thu, 4 Jul 2019 19:52:50 +0000 (19:52 +0000)]
MFC r349239, r349241: update vm_map_protect.9

Clarify that vm_map_protect cannot upgrade max_protection

It's implied by the man page's RETURN VALUES section, but be explicit in
the description that vm_map_protect can not set new protection bits that
are already in each entry's max_protection.

Clarify vm_map_protect max_protection downgrade

As reported in review D20709 by brooks calling vm_map_protect to set a
new max_protection value downgrades existing mappings if necessary (as
opposed to returning an error).

Sponsored by: The FreeBSD Foundation

4 years agoMFC r347986:
Justin Hibbits [Thu, 4 Jul 2019 19:02:03 +0000 (19:02 +0000)]
MFC r347986:

Update loader size on powerpc isos

loader has grown to the point it's overflowing the existing 307200 bytes
allocated to it in the HFS boot partition on the isos.

Bump the space reservation up to 500k.

4 years agoMFC r349563:
Mitchell Horne [Thu, 4 Jul 2019 17:24:48 +0000 (17:24 +0000)]
MFC r349563:
readelf: Add RISC-V DWARF register aliases

Approved by: markj (mentor, implicit)

4 years agoMFC r349483:
Mitchell Horne [Thu, 4 Jul 2019 17:19:08 +0000 (17:19 +0000)]
MFC r349483:
libelftc: add RISC-V bfd targets

Approved by: markj (mentor, implicit)

4 years agoMFC r349482,r349563:
Mitchell Horne [Thu, 4 Jul 2019 17:17:00 +0000 (17:17 +0000)]
MFC r349482,r349563:
readelf: Add support for RISC-V specific e_flags

Approved by: markj (mentor, implicit)

4 years agoMFC r349481:
Mitchell Horne [Thu, 4 Jul 2019 17:13:41 +0000 (17:13 +0000)]
MFC r349481:
Add some missing RISC-V ELF defines

Approved by: markj (implicit)

4 years agoMFC r345970: network.subr: improve configuration of cloned gif(4) interfaces
Eugene Grosbein [Thu, 4 Jul 2019 13:20:32 +0000 (13:20 +0000)]
MFC r345970: network.subr: improve configuration of cloned gif(4) interfaces

ifconfig(8) syntax allows to specify only single address_family,
so we need additional invocation of ifconfig to support configuration
of cloned gif interface that may use different address families
for its internal and external addresses.

Also, ifconfig(8) does not allow to omit "inet6" keyword for address family
specifying IPv6 addresses as outer addresses of the interface.

Also, address_family is not "parameter" and it has to go before parameters
including "tunnel" keyword, so "ifconfig gif0 tunnel inet6 $oip1 $oip2" would be
wrong syntax and only "ifconfig gif0 inet6 tunnel $oip1 $oip2" is right.

With this change, the following works:

gifconfig_gif0="inet6 2a00::1 2a01::1"
ifconfig_gif0="inet 10.0.0.1 10.0.0.2 netmask 255.255.255.252"

4 years agoMFC r349188
Leandro Lupori [Thu, 4 Jul 2019 12:40:38 +0000 (12:40 +0000)]
MFC r349188

[PPC] Fix loader input with newer QEMU versions

At least since version 4.0.0, QEMU became bug-compatible with PowerVM's
vty, by inserting a \0 after every \r. As this confuses loader's
interpreter and as a \0 coming from the console doesn't seem reasonable,
it's now being filtered at OFW console input.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20676

4 years agoMFC r349548:
Tijl Coosemans [Thu, 4 Jul 2019 10:16:44 +0000 (10:16 +0000)]
MFC r349548:

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

4 years agoMFC r349505: Upgrade to Bzip2 version 1.0.7.
Xin LI [Thu, 4 Jul 2019 07:29:18 +0000 (07:29 +0000)]
MFC r349505: Upgrade to Bzip2 version 1.0.7.

4 years agoMFC r349450-349451:
Cy Schubert [Thu, 4 Jul 2019 03:08:14 +0000 (03:08 +0000)]
MFC r349450-349451:

Update usage() to refect the current state of ipmon.

PR: 238816

4 years agoMFC r349449, r349452:
Cy Schubert [Thu, 4 Jul 2019 03:04:41 +0000 (03:04 +0000)]
MFC r349449, r349452:

Add the ipmon.5 man page and link ipmon.conf.5 to it.

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

4 years agoMFC r348299
Justin Hibbits [Wed, 3 Jul 2019 21:30:18 +0000 (21:30 +0000)]
MFC r348299

kern/CTF: link_elf_ctf_get() on big endian platforms

Check the CTF magic number in big endian platforms.  This lets DTrace FBT
handle types correctly on these platforms.

4 years agoMFC r349424:
Mark Johnston [Wed, 3 Jul 2019 20:55:08 +0000 (20:55 +0000)]
MFC r349424:
libdwarf: Use the cached strtab pointer when reading string attributes.

4 years agoMFC r349422:
Mark Johnston [Wed, 3 Jul 2019 20:54:52 +0000 (20:54 +0000)]
MFC r349422:
libelftc: Fix the documented prototype for elftc_string_table_destroy().

4 years agoMFC r349421:
Mark Johnston [Wed, 3 Jul 2019 20:54:36 +0000 (20:54 +0000)]
MFC r349421:
libelftc: Consistently use size_t for string table offsets and sizes.

4 years agoMFC r349420
Mark Johnston [Wed, 3 Jul 2019 20:53:05 +0000 (20:53 +0000)]
MFC r349420
libelftc: Micro-optimize string table insertion.

4 years agoMFC r349423
Mark Johnston [Wed, 3 Jul 2019 20:52:07 +0000 (20:52 +0000)]
MFC r349423
elfcopy: Provide a size hint when creating the section string table.

4 years agoMFC r349218:
Mark Johnston [Wed, 3 Jul 2019 20:18:49 +0000 (20:18 +0000)]
MFC r349218:
Group vm_page_activate()'s definition with other related functions.

4 years agoMFC r349432:
Mark Johnston [Wed, 3 Jul 2019 20:17:26 +0000 (20:17 +0000)]
MFC r349432:
Add a return value to vm_page_remove().

4 years agoMFC r349419:
Mark Johnston [Wed, 3 Jul 2019 20:15:09 +0000 (20:15 +0000)]
MFC r349419:
Remove references to splbio in ffs_softdep.c.

4 years agoMFC r349334:
Mark Johnston [Wed, 3 Jul 2019 20:14:43 +0000 (20:14 +0000)]
MFC r349334:
Remove a lingering use of splbio().

4 years agoMFC r349175
Vincenzo Maffione [Wed, 3 Jul 2019 19:59:48 +0000 (19:59 +0000)]
MFC r349175

bhyve: vtnet: fix locking on receive

The vsc_rx_ready and the RX virtqueue is protected by the rx_mtx lock.
However, pci_vtnet_ping_rxq() (currently called only once after each
device reset) accesses those without acquiring the lock.

Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D20609

4 years agoMFC r349019
Vincenzo Maffione [Wed, 3 Jul 2019 19:57:23 +0000 (19:57 +0000)]
MFC r349019

bhyve: move common code to net_utils.c

Both virtio_net and e82545 network frontends have code to validate and
generate MAC addresses. These functionalities are replicated in the two
files, so we move them in a separate compilation unit.

Reviewed by:    rgrimes, bryanv, imp, kevans
Differential Revision:  https://reviews.freebsd.org/D20626

4 years agoMFC r348929
Vincenzo Maffione [Wed, 3 Jul 2019 19:56:05 +0000 (19:56 +0000)]
MFC r348929

bhyve: virtio: introduce vq_kick_enable() and vq_kick_disable()

The VirtIO standard supports two schemes for notification suppression:
a notification enable bit and a more sophisticated one (event_idx) that
also supports delayed notifications. Currently bhyve fully supports
only the first scheme. This patch hides the notification suppression
internals by means of two inline routines, vq_kick_enable() and
vq_kick_disable(), and makes the code more readable.
Moreover, further improve readability by replacing the call to mb()
with a call to atomic_thread_fence_seq_cst(), which is already used
in virtio.c

Reviewed by:    pmooney_pfmooney.com, bryanv
Differential Revision:  https://reviews.freebsd.org/D20581

4 years agoMFC r348834
Vincenzo Maffione [Wed, 3 Jul 2019 19:54:37 +0000 (19:54 +0000)]
MFC r348834

bhyve: vtnet: simplify thread synchronization

On vtnet device reset it is necessary to wait for threads to stop TX and
RX processing. However, the rx_in_progress variable (used for to wait for
RX processing to stop) is actually useless, and can be removed. Acquiring
and releasing the RX lock is enough to synchronize correctly. Moreover,
it is possible to reset the device while holding both TX and RX locks, so
that the "resetting" variable becomes unnecessary for the RX thread, and
can be protected by the TX lock (instead of being volatile).

Reviewed by:    jhb, markj
Differential Revision:  https://reviews.freebsd.org/D20543

4 years agoMFC r349285
Eric van Gyzen [Wed, 3 Jul 2019 19:52:24 +0000 (19:52 +0000)]
MFC r349285

VirtIO SCSI:  validate seg_max on attach

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

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

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

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

bhyve: Fix vtscsi maximum segment config

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

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

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

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

PR: 68905
admbugs: 358

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

powerpc: Add POWER8NVL definition

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

Reported by: Alexey Kardashevskiy

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

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

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

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

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

Book-E pmap

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

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

PR: 238650

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

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

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

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

powerpc: Fix cpufreq statement scoping

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

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

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

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

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

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

Discussed with: kib@
Sponsored by: Mellanox Technologies

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

Sponsored by: Mellanox Technologies

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

PR: 238801
Sponsored by: Mellanox Technologies

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

Sponsored by: Mellanox Technologies

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

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

Sponsored by: Mellanox Technologies

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

Fix a typo.

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

PR: 238816

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

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

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

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

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

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

PR: 238796

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

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

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

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

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

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

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

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

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

PR: 238571

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

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

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

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

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

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

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

  Reported by: Dmitry Selivanov <dseliv at gmail>