]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoamd64 pmap: microoptimize local shootdowns for PCID PTI configurations
Konstantin Belousov [Sat, 18 Jul 2020 18:19:57 +0000 (18:19 +0000)]
amd64 pmap: microoptimize local shootdowns for PCID PTI configurations

When pmap operates in PTI mode, we must reload %cr3 on return to
userspace.  In non-PCID mode the reload always flushes all non-global
TLB entries and we take advantage of it by only invalidating the KPT
TLB entries (there is no cached UPT entries at all).

In PCID mode, we flush both KPT and UPT TLB explicitly, but we can
take advantage of the fact that PCID mode command to reload %cr3
includes a flag to flush/not flush target TLB.  In particular, we can
avoid the flush for UPT, instead record that load of pc_ucr3 into %cr3
on return to usermode should be flushing.  This is done by providing
either all-1s or ~CR3_PCID_MASK in pc_ucr3_load_mask.  The mask is
automatically reset to all-1s on return to usermode.

Similarly, we can avoid flushing UPT TLB on context switch, replacing
it by setting pc_ucr3_load_mask.  This unifies INVPCID and non-INVPCID
PTI ifunc, leaving only 4 cases instead of 6.  This trick is also
applicable both to the TLB shootdown IPI handlers, since handlers
interrupt the target thread.

But then we need to check pc_curpmap in handlers, and this would
reopen the same race for INVPCID machines as was fixed in r306350 for
non-INVPCID.  To not introduce the same bug, unconditionally do
spinlock_enter() in pmap_activate().

Reviewed by: alc, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D25483

3 years agoo Move iommu_test_boundary() to sys/iommu.h
Ruslan Bukin [Sat, 18 Jul 2020 13:10:31 +0000 (13:10 +0000)]
o Move iommu_test_boundary() to sys/iommu.h
o Rename DMAR -> IOMMU in comments
o Add IOMMU_PAGE_SIZE / IOMMU_PAGE_MASK macroses
o x86 only: dmar_quirks_pre_use() / dmar_instantiate_rmrr_ctxs()

Reviewed by: kib
Sponsored by: DARPA/AFRL
Differential Revision: https://reviews.freebsd.org/D25665

3 years agoRemove code which is not needed.
Michael Tuexen [Sat, 18 Jul 2020 13:10:02 +0000 (13:10 +0000)]
Remove code which is not needed.

MFC after: 1 week

3 years agobridge: Don't sleep during epoch
Kristof Provost [Sat, 18 Jul 2020 12:43:11 +0000 (12:43 +0000)]
bridge: Don't sleep during epoch

While it doesn't trigger INVARIANTS or WITNESS on head it does in stable/12.
There's also no reason for it, as we can easily report the out of memory error
to the caller (i.e. userspace). All of these can already fail.

PR: 248046
MFC after: 3 days

3 years agoMake linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,
Edward Tomasz Napierala [Sat, 18 Jul 2020 12:21:08 +0000 (12:21 +0000)]
Make linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,
as documented in the man page.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoBump the default linux version from 3.2.0 to 3.10.0, which corresponds
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:37:30 +0000 (11:37 +0000)]
Bump the default linux version from 3.2.0 to 3.10.0, which corresponds
to RHEL 7.  Required for DB2.

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

3 years agoRegen after r363304.
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:31:31 +0000 (11:31 +0000)]
Regen after r363304.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoAdd a trivial linux(4) splice(2) implementation, which simply
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:28:40 +0000 (11:28 +0000)]
Add a trivial linux(4) splice(2) implementation, which simply
returns EINVAL.  Fixes grep (grep-3.1-2build1).

PR: kern/218699
Reported by: avos
Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25636

3 years agoAdd missing SysV IPC stats to linprocfs(4). Fixes 'ipcs -l',
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:56:04 +0000 (10:56 +0000)]
Add missing SysV IPC stats to linprocfs(4).  Fixes 'ipcs -l',
and also helps Oracle.

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

3 years agoFix bogomips calculation. Previously it was off by half. This was
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:53:56 +0000 (10:53 +0000)]
Fix bogomips calculation.  Previously it was off by half.  This was
verified under VMWare Fusion, comparing to what's reported under CentOS,
and by comparing numbers reported by linuxulator on T420 with a googled
up Linux cpuinfo (https://lkml.org/lkml/2011/11/29/116).

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

3 years agoFix two typos in flag names in /proc/cpuinfo.
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:49:17 +0000 (10:49 +0000)]
Fix two typos in flag names in /proc/cpuinfo.

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

3 years agoMFV: r363292
Jung-uk Kim [Sat, 18 Jul 2020 07:35:34 +0000 (07:35 +0000)]
MFV: r363292

Merge ACPICA 20200717.

3 years agoShort-circuit tdfind when looking for the calling thread.
Mateusz Guzik [Sat, 18 Jul 2020 00:14:43 +0000 (00:14 +0000)]
Short-circuit tdfind when looking for the calling thread.

Common occurence with cpuset and other places.

3 years agoFix vnode_pager handling of read ahead/behind pages when a disk read fails.
Chuck Silvers [Fri, 17 Jul 2020 23:10:35 +0000 (23:10 +0000)]
Fix vnode_pager handling of read ahead/behind pages when a disk read fails.
Rather than marking the read ahead/behind pages valid even though they were
not initialized, free them using the new function vm_page_free_invalid().

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoAdd a new function vm_page_free_invalid() for freeing invalid pages
Chuck Silvers [Fri, 17 Jul 2020 23:09:36 +0000 (23:09 +0000)]
Add a new function vm_page_free_invalid() for freeing invalid pages
that might be wired.  If the page is wired then it cannot be freed now,
but the thread that eventually unwires it will free it at that point.

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoRevert my change from r361855 in favor of a better fix.
Chuck Silvers [Fri, 17 Jul 2020 23:08:01 +0000 (23:08 +0000)]
Revert my change from r361855 in favor of a better fix.

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoImport ACPICA 20200717.
Jung-uk Kim [Fri, 17 Jul 2020 22:53:36 +0000 (22:53 +0000)]
Import ACPICA 20200717.

3 years agodevstat(9): Update the man page to reflect the current implementation
Gordon Bergling [Fri, 17 Jul 2020 22:15:02 +0000 (22:15 +0000)]
devstat(9): Update the man page to reflect the current implementation

- Rename devstat_add_entry to devstat_new_entry
- Update the description of devstat_trans_flags
- Add manpage aliases for devstat_start_transaction_bio and devstat_end_transaction_bio

PR: 157316
Submitted by: novel
Reviewed by: cem, bcr (mentor)
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25677

3 years agomount_nfs(8): document alternate form of the gssname option
Gordon Bergling [Fri, 17 Jul 2020 21:55:24 +0000 (21:55 +0000)]
mount_nfs(8): document alternate form of the gssname option

PR: 238506
Submitted by: Greg Veldman <freebsd at gregv dot net>
Reviewed by: 0mp, bcr (mentor)
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25667

3 years agoiwm(4): Document limitations of the driver
Gordon Bergling [Fri, 17 Jul 2020 21:47:06 +0000 (21:47 +0000)]
iwm(4): Document limitations of the driver

Document that iwm(4) currently doesn't support 802.11n and 802.11ac.

PR: 247874
Submitted by: Charles Ross <cwr at sdf dot org>
Reviewed by: brueffer, markj
Approved by: brueffer
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25666

3 years agoat(1): Fix location of at(1) crontab
Allan Jude [Fri, 17 Jul 2020 20:43:00 +0000 (20:43 +0000)]
at(1): Fix location of at(1) crontab

With r318443, atrun was moved from /etc/crontab to /etc/cron.d/at,
but the man-page was unfortunately not updated to reflect this.

PR: 248048
Submitted by: debdrup
Reported by: yoitsmeremember+fbsd at gmail.com
Reviewed by: Pau Amma <pauamma at gundo.com>
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25709

3 years agoFix incorrect byte order in ipfstat -f output.
Cy Schubert [Fri, 17 Jul 2020 19:07:59 +0000 (19:07 +0000)]
Fix incorrect byte order in ipfstat -f output.
- make sure frag is initialized to 0
- initialize ipfr_p field

NetBSD PR: 55137
Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD fil.c r1.32, ip_frag.c r1.8
MFC after: 2 weeks

3 years agopfil_run_hooks() can be called recursively, so we have to
Cy Schubert [Fri, 17 Jul 2020 19:07:56 +0000 (19:07 +0000)]
pfil_run_hooks() can be called recursively, so we have to
define FASTROUTE_RECURSION in fil.c

Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD r1.31
MFC after: 2 weeks

3 years ago-4 and -6 only make sense with -i, -o, and -t.
Cy Schubert [Fri, 17 Jul 2020 19:07:53 +0000 (19:07 +0000)]
-4 and -6 only make sense with -i, -o, and -t.

PR: 247952
MFC after: 1 week

3 years agoThe output from usage() need not contain usage for -t when STATETOP
Cy Schubert [Fri, 17 Jul 2020 19:07:50 +0000 (19:07 +0000)]
The output from usage() need not contain usage for -t when STATETOP
is not compiled in.

PR: 247952
MFC after: 1 week

3 years agoMake ipfstat -t header generic when IPv4 and IPv6 output are
Cy Schubert [Fri, 17 Jul 2020 19:07:47 +0000 (19:07 +0000)]
Make ipfstat -t header generic when IPv4 and IPv6 output are
displayed in the same display.

PR: 247952
MFC after: 1 week

3 years agoipfstat -t defaults to IPv4 output. Make consistent with ipfstat -i
Cy Schubert [Fri, 17 Jul 2020 19:07:44 +0000 (19:07 +0000)]
ipfstat -t defaults to IPv4 output. Make consistent with ipfstat -i
and ipfstat -o where without an argument IPv4 and IPv6 states are
shown. Use -4 and -6 to limit the display to IPv4 or IPv6 respectively.

PR: 247952
MFC after: 1 week

3 years agoHistorically ipfstat listings and stats only listed IPv4 or IPv6 output.
Cy Schubert [Fri, 17 Jul 2020 19:07:40 +0000 (19:07 +0000)]
Historically ipfstat listings and stats only listed IPv4 or IPv6 output.
ipfstat would list IPv4 outputs by default while -6 would produce IPv6
outputs. This commit combines the ipfstat -i and -o outputs into one
listing of IPv4 and IPv6 rules. The -4 option lists only IPv4 rules
(as the default before) while -6 continues to list only rules that affect
IPv6.

PR: 247952
Reported by: joeb1@a1poweruser.com
MFC after: 1 week

3 years agofr_family (the protocol family) must be AF_INET or AF_INET6, as in
Cy Schubert [Fri, 17 Jul 2020 19:07:37 +0000 (19:07 +0000)]
fr_family (the protocol family) must be AF_INET or AF_INET6, as in
the kernel, not an arbitrary 4 or 6.

This only affected printing ipfilter stats and rules from a kernel
dump. (This is currently undocumented.)

PR: 247952
MFC after: 1 week

3 years agoOnly use the use_inet6 variable when INET6 is a build option.
Cy Schubert [Fri, 17 Jul 2020 19:07:34 +0000 (19:07 +0000)]
Only use the use_inet6 variable when INET6 is a build option.

This is a prerequisite to upcoming argument processing cleanups which
will resolve consistency as was done with ippool previously.

PR: 247952
MFC after: 1 week

3 years agoFix L2CAP ACL packet PB(Packet Boundary) flag for LE PDU.
Takanori Watanabe [Fri, 17 Jul 2020 15:50:03 +0000 (15:50 +0000)]
Fix L2CAP ACL packet PB(Packet Boundary) flag for LE PDU.

ACL packet boundary flag should be 0 instead of 2 for LE PDU.
Some HCI will drop LE packet with PB flag is 2, and if sent,
some target may reject the packet.

PR: 248024
Reported by: Greg V
Reviewed by: Greg V, emax
Differential Revision: https://reviews.freebsd.org/D25704

3 years agoImprove the locking of address lists by adding some asserts and
Michael Tuexen [Fri, 17 Jul 2020 15:09:49 +0000 (15:09 +0000)]
Improve the locking of address lists by adding some asserts and
rearranging the addition of address such that the lock is not
given up during checking and adding.

MFC after: 1 week

3 years agoAdd acpi_iort_map_pci_smmuv3().
Ruslan Bukin [Fri, 17 Jul 2020 14:51:51 +0000 (14:51 +0000)]
Add acpi_iort_map_pci_smmuv3().

This new function allows us to find the SMMU instance assigned
for a particular PCI RID.

Reviewed by: andrew
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D25687

3 years agoClean up crypto_init().
Mark Johnston [Fri, 17 Jul 2020 14:45:16 +0000 (14:45 +0000)]
Clean up crypto_init().

The function is called from a KLD load handler, so it may sleep.

- Stop checking for errors from uma_zcreate(), they don't happen.
- Convert M_NOWAIT allocations to M_WAITOK.
- Remove error handling for existing M_WAITOK allocations.
- Fix style.

Reviewed by: cem, delphij, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25696

3 years agoDon't overflow the trap frame when accessing lr or xzr.
Andrew Turner [Fri, 17 Jul 2020 14:39:07 +0000 (14:39 +0000)]
Don't overflow the trap frame when accessing lr or xzr.

When emulating a load pair or store pair in dtrace on arm64 we need to
copy the data between the stack and trap frame. When the registers are
either the link register or the zero register we will access memory
past the end of the trap frame as these are encoded as registers 30 and
31 respectively while the array they access only has 30 entries.

Fix this by creating 2 helper functions to perform the operation with
special cases for these registers.

Sponsored by: Innovate UK

3 years agoPromote use of unprivileged users for building ports by documenting SU_CMD.
Piotr Pawel Stefaniak [Fri, 17 Jul 2020 06:33:20 +0000 (06:33 +0000)]
Promote use of unprivileged users for building ports by documenting SU_CMD.
Phrasing by Daniel O'Connor.

Reviewed by: 0mp
MFC after: 14 days
Differential Revision: https://reviews.freebsd.org/D25433

3 years agoRevert r240317 to prevent leaking pmap entries
Conrad Meyer [Thu, 16 Jul 2020 23:29:26 +0000 (23:29 +0000)]
Revert r240317 to prevent leaking pmap entries

Subsequent to r240317, kmem_free() was replaced with kva_free() (r254025).
kva_free() releases the KVA allocation for the mapped region, but no longer
clears the pmap (pagetable) entries.

An affected pmap_unmapdev operation would leave the still-pmap'd VA space
free for allocation by other KVA consumers.  However, this bug easily
avoided notice for ~7 years because most devices (1) never call
pmap_unmapdev and (2) on amd64, mostly fit within the DMAP and do not need
KVA allocations.  Other affected arch are less popular: i386, MIPS, and
PowerPC.  Arm64, arm32, and riscv are not affected.

Reported by: Don Morris <dgmorris AT earthlink.net>
Submitted by: Don Morris (amd64 part)
Reviewed by: kib, markj, Don (!amd64 parts)
MFC after: I don't intend to, but you might want to
Sponsored by: Dell Isilon
Differential Revision: https://reviews.freebsd.org/D25689

3 years agoadd script to help figure out what man pages need MLINKS updated...
John-Mark Gurney [Thu, 16 Jul 2020 23:05:18 +0000 (23:05 +0000)]
add script to help figure out what man pages need MLINKS updated...

3 years agoInclude FreeBSD ABI tag note in the ELF runtime loader.
John Baldwin [Thu, 16 Jul 2020 22:01:01 +0000 (22:01 +0000)]
Include FreeBSD ABI tag note in the ELF runtime loader.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25306

3 years agoInclude ABI note tag in shared libraries.
John Baldwin [Thu, 16 Jul 2020 21:58:43 +0000 (21:58 +0000)]
Include ABI note tag in shared libraries.

Split the ELF feature note into a separate file that is linked into
*crt1.o the same as crtbrand.S was before.  crtbrand.o is now linked
into crti.o on all platforms in addition to *crt1.o.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25304

3 years agoAdd crypto_initreq() and crypto_destroyreq().
John Baldwin [Thu, 16 Jul 2020 21:30:46 +0000 (21:30 +0000)]
Add crypto_initreq() and crypto_destroyreq().

These routines are similar to crypto_getreq() and crypto_freereq() but
operate on caller-supplied storage instead of allocating crypto
requests from a UMA zone.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25691

3 years agoHold the mutex when releasing a callout.
Kenneth D. Merry [Thu, 16 Jul 2020 20:43:28 +0000 (20:43 +0000)]
Hold the mutex when releasing a callout.

In xpt_release_device(), callout_stop() was being called without
holding the mutex (send_mtx) that is used to protect the callout.

So, move the mtx_unlock() call so that it is protected.

MFC after: 1 week
Sponsored by: Spectra Logic

3 years ago(Re)-allow 0.0.0.0 to be used as an address in connect() for TCP
Michael Tuexen [Thu, 16 Jul 2020 16:46:24 +0000 (16:46 +0000)]
(Re)-allow 0.0.0.0 to be used as an address in connect() for TCP
In r361752 an error handling was introduced for using 0.0.0.0 or
255.255.255.255 as the address in connect() for TCP, since both
addresses can't be used. However, the stack maps 0.0.0.0 implicitly
to a local address and at least two regressions were reported.
Therefore, re-allow the usage of 0.0.0.0.
While there, change the error indicated when using 255.255.255.255
from EAFNOSUPPORT to EACCES as mentioned in the man-page of connect().

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

3 years agoAdd VIRTIO_BLK_T_DISCARD support to the virtio-blk driver
Allan Jude [Thu, 16 Jul 2020 16:32:16 +0000 (16:32 +0000)]
Add VIRTIO_BLK_T_DISCARD support to the virtio-blk driver

If the hypervisor advertises support for the DISCARD command then the
guest can perform TRIM commands, freeing space on the backing store.

If VIRTIO_BLK_F_DISCARD is enabled, advertise DISKFLAG_CANDELETE

Tested with FreeBSD guests on bhyve and KVM

Reviewed by: jhb
Tested by: freqlabs
MFC after: 1 month
Relnotes: yes
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D21708

3 years agoAdd a RELNOTES entry for r363253.
Mark Johnston [Thu, 16 Jul 2020 15:12:52 +0000 (15:12 +0000)]
Add a RELNOTES entry for r363253.

Sponsored by: The FreeBSD Foundation

3 years agoSwitch from SCTP to SCTP_SUPPORT in GENERIC configs.
Mark Johnston [Thu, 16 Jul 2020 15:09:04 +0000 (15:09 +0000)]
Switch from SCTP to SCTP_SUPPORT in GENERIC configs.

This removes SCTP from in-tree kernel configuration files.  Now, SCTP
can be enabled by simply loading the module, as discussed on
freebsd-net@.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25611

3 years agotuntap: drop redundant if_mtu assignment in tuncreate
Kyle Evans [Thu, 16 Jul 2020 15:02:11 +0000 (15:02 +0000)]
tuntap: drop redundant if_mtu assignment in tuncreate

ether_ifattach will immediately clobber if_mtu with ETHERMTU anyways, just
let it happen.

MFC after: 1 week

3 years agosafexcel(4): Silence an integer truncation warning.
Mark Johnston [Thu, 16 Jul 2020 14:21:55 +0000 (14:21 +0000)]
safexcel(4): Silence an integer truncation warning.

In practice overflow is not possible, but we might as well use the right
type for DMA ring sizes.

CID: 1430468
MFC after: 1 week

3 years agoRelax the rule against declaring variables in nested scopes and for
Warner Losh [Thu, 16 Jul 2020 14:12:54 +0000 (14:12 +0000)]
Relax the rule against declaring variables in nested scopes and for
initializations.

Relax some overly perscriptive rules against declarations: they may be at the
start of any blocks, even if things aren't super complicated. Allow more
initializations (those that call simple functions, like accessor functions for
newbus are fine). Allow the common idiom of declaring the loop variable in a for
loop.

This tries to codify what common exceptions are today, as well as give
some guidance on when it's best to do these things.

Reviewed by: tsoome, kp, markm, allanjude, jiles, cem, rpokala
(earlier versions: seanc, melifaro, bapt, pjd, bz, pstef, arichards,
 jhibits, vangyzen, jmallet, ian, glebius, jhb, dab, adrian,
 sef, gnn)
Differential Revision: https://reviews.freebsd.org/D25312

3 years agovfs: fix vn_poll performance with either MAC or AUDIT
Mateusz Guzik [Thu, 16 Jul 2020 14:09:18 +0000 (14:09 +0000)]
vfs: fix vn_poll performance with either MAC or AUDIT

The code would unconditionally lock the vnode to audit or call the
mac hoook, even if neither want to do anything. Pre-check the state
to avoid locking in the common case of nothing to do.

Note this code should not be normally executed anyway as vnodes are
always return ready. However, poll1/2 from will-it-scale use regular
files for benchmarking, presumably to focus on the interface itself
as the vnode handler is not supposed to do almost anything.

This in particular fixes poll2 which passes 128 fds.

$ ./poll2_processes -s 10
before: 134411
after:  271572

3 years agoRemove old devd rules for ActiveWire and Entrega Serial DB25
Mateusz Piotrowski [Thu, 16 Jul 2020 14:04:29 +0000 (14:04 +0000)]
Remove old devd rules for ActiveWire and Entrega Serial DB25

Those rules have been broken at least since 8-STABLE, when the port
providing the ezdownload binary was removed (misc/ezload).

Reviewed by: kevans, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25686

3 years agovfs: fix MAC/AUDIT mismatch in vn_poll
Mateusz Guzik [Thu, 16 Jul 2020 14:04:28 +0000 (14:04 +0000)]
vfs: fix MAC/AUDIT mismatch in vn_poll

Auditing would not be performed without MAC compiled in.

3 years agoether_ifattach: set mtu before calling if_attach()
Kyle Evans [Thu, 16 Jul 2020 13:37:32 +0000 (13:37 +0000)]
ether_ifattach: set mtu before calling if_attach()

if_attach() -> if_attach_internal() will call if_attachdomain1(ifp) any time
an ethernet interface is setup *after*
SI_SUB_PROTO_IFATTACHDOMAIN/SI_ORDER_FIRST.  This eventually leads to
nd6_ifattach() -> nd6_setmtu0() stashing off ifp->if_mtu in ndi->maxmtu
*before* ifp->if_mtu has been properly set in some scenarios, e.g., USB
ethernet adapter plugged in later on.

For interfaces that are created in early boot, we don't have this issue as
domains aren't constructed enough for them to attach and thus it gets
deferred to domainifattach at SI_SUB_PROTO_IFATTACHDOMAIN/SI_ORDER_SECOND
*after* the mtu has been set earlier in ether_ifattach().

PR: 248005
Submitted by: Mathew <mjanelle blackberry com>
MFC after: 1 week

3 years agoamd64: patch ffsl to use the compiler builtin
Mateusz Guzik [Thu, 16 Jul 2020 11:28:24 +0000 (11:28 +0000)]
amd64: patch ffsl to use the compiler builtin

This shortens fdalloc by over 60 bytes. Correctness verified by running both
variants at the same time and comparing the result of each call.

Note someone(tm) should make a pass at converting everything else feasible.

3 years agoefibootmgr: typo in long option name
Toomas Soome [Thu, 16 Jul 2020 10:20:35 +0000 (10:20 +0000)]
efibootmgr: typo in long option name

del-timout should be del-timeout

Reported by: mjg
MFC after: 1 week

3 years ago[ar71xx] fix watchdog to work on subsequent SoCs
Adrian Chadd [Wed, 15 Jul 2020 19:34:19 +0000 (19:34 +0000)]
[ar71xx] fix watchdog to work on subsequent SoCs

The AR9341 AHB runs at 225MHz, much faster than the 33MHz of the
AR71xx AHB.  So not only is the math going to do weird things, it
will also wrap rather than being clamped.

So:

* clamp! don't wrap!
* tidy up some debugging
* add an option to throw an NMI rather than reset!

Tested:

* AR9341 SoC (TP-Link TL-WDR4300), patting/not patting the watchdog!

3 years agoopenssh: refer to OpenSSL not SSLeay, part 2
Ed Maste [Wed, 15 Jul 2020 18:49:00 +0000 (18:49 +0000)]
openssh: refer to OpenSSL not SSLeay, part 2

This change was made upstream between 7.9p1 and 8.0p1.  We've made local
changes in the same places for handling the version_addendum; apply the
SSLeay_version to OpenSSL_version change in advance of importing 8.0p1.
This should have been part of r363225.

Obtained from: OpenSSH-portable a65784c9f9c5
MFC with: r363225
Sponsored by: The FreeBSD Foundation

3 years agoNote the merge of sendmail 8.16.1 from vendor "branch"
Gregory Neil Shapiro [Wed, 15 Jul 2020 18:32:09 +0000 (18:32 +0000)]
Note the merge of sendmail 8.16.1 from vendor "branch"

3 years agoMerge sendmail 8.16.1 to HEAD: See contrib/sendmail/RELEASE_NOTES for details
Gregory Neil Shapiro [Wed, 15 Jul 2020 18:28:54 +0000 (18:28 +0000)]
Merge sendmail 8.16.1 to HEAD: See contrib/sendmail/RELEASE_NOTES for details
Includes build infrastructure & config updates required for changes in 8.16.1

MFC after: 5 days

3 years agobuild DTS for Orange Pi PC Plus as well
Andriy Gapon [Wed, 15 Jul 2020 18:04:01 +0000 (18:04 +0000)]
build DTS for Orange Pi PC Plus as well

Reviewed by: manu
MFC after: 1 week

3 years agoAllow install(1)'s create_tempfile() to work on Linux hosts
Alex Richardson [Wed, 15 Jul 2020 17:24:39 +0000 (17:24 +0000)]
Allow install(1)'s create_tempfile() to work on Linux hosts

GLibc expects six 'X' characters in the mkstemp template argument and
will return EINVAL otherwise.

Reviewed By: emaste, imp, mjg
Differential Revision: https://reviews.freebsd.org/D25662

3 years agoRemove warning that is no longer accurate after r361853
Alex Richardson [Wed, 15 Jul 2020 17:24:34 +0000 (17:24 +0000)]
Remove warning that is no longer accurate after r361853

We now build the skein assembly with clangs integrated assembler.

Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D25664

3 years agoDon't imply that all action values can be OR'd.
Brooks Davis [Wed, 15 Jul 2020 17:05:37 +0000 (17:05 +0000)]
Don't imply that all action values can be OR'd.

This is neither POSIX compliant nor what the implementation does.
This could be allowed by changing the value of TCSAFLUSH from 2 to 3,
but that doesn't seem worthwhile after 25+ years.

Reviewed by: imp
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25659

3 years agoImprove description of the vector argument for i386 smp_targeted_tlb_shootdown().
Konstantin Belousov [Wed, 15 Jul 2020 16:12:00 +0000 (16:12 +0000)]
Improve description of the vector argument for i386 smp_targeted_tlb_shootdown().

Submitted by: alc
MFC after: 20 days

3 years agoopenssh: refer to OpenSSL not SSLeay
Ed Maste [Wed, 15 Jul 2020 15:35:26 +0000 (15:35 +0000)]
openssh: refer to OpenSSL not SSLeay

This change was made upstream between 7.9p1 and 8.0p1.  We've made local
changes in the same places for handling the version_addendum; apply the
SSLeay_version to OpenSSL_version change in advance of importing 8.0p1.

Obtained from: OpenSSH-portable a65784c9f9c5
Sponsored by: The FreeBSD Foundation

3 years agozpool-features(7): Note that the boot loader has support for large_blocks
Allan Jude [Wed, 15 Jul 2020 14:38:15 +0000 (14:38 +0000)]
zpool-features(7): Note that the boot loader has support for large_blocks

Since r304321 (-current: Aug 18, 2016) and r328866 (stable/11: Feb 5, 2018)
the FreeBSD loader has supported reading from datasets with the
large_blocks feature active.

PR: 247992
Reported by: Anton Saietskii <vsasjason@gmail.com>
MFC after: 2 weeks
Sponsored by: Klara Inc.

3 years agovlan(4): Minor grammar corrections
Allan Jude [Wed, 15 Jul 2020 14:27:23 +0000 (14:27 +0000)]
vlan(4): Minor grammar corrections

Note: date not bumped because "content" was not changed, just inserted some
missing words.

PR: 248001
Submitted by: Jose Luis Duran <jlduran@gmail.com>
MFC after: 2 weeks
Sponsored by: Klara Inc.

3 years ago[PowerPC] Use PVO_PADDR to get the PA from PVO
Leandro Lupori [Wed, 15 Jul 2020 13:43:48 +0000 (13:43 +0000)]
[PowerPC] Use PVO_PADDR to get the PA from PVO

Use PVO_PADDR macro to get the physical address from a PVO, instead of
explicitly ANDing pvo_pte.pa with LPTE_RPGN where it is needed.  Besides
improving readability, this is needed to support superpages (D25237), where
the steps to get the PA from a PVO are different.

Reviewed by: markj
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D25654

3 years agoFix style in r363220
Eric van Gyzen [Wed, 15 Jul 2020 13:26:15 +0000 (13:26 +0000)]
Fix style in r363220

Apply the style change Kostik suggested in the review.

Reported by: kib
MFC after: 2 weeks
X-MFC with: r363220
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25676

3 years agoFix Coverity issues in OFED
Eric van Gyzen [Wed, 15 Jul 2020 13:17:16 +0000 (13:17 +0000)]
Fix Coverity issues in OFED

read_ibdiag_config NULL deref
read_ibdiag_config mem leak
ib_mad_inv_field_str Missing comma in a string array initialization
print_node_header NULL deref
diff_node_ports copy-paste error
ibportstate.c main() missing break in switch
set_thresholds NULL ptr deref
dump_unicast_tables leaks mapnd
umad_cm_attr_str dead code
__ibv_close_device close(-1)
check return value of listen()
mlx5 bitmap.h - bad bit shift - UB
get_dst_addr check return value of inet_pton
osm_perfmgr_init check return value of cl_spinlock_init
osm_port_new memory leak on error path
sa_mad_ctrl_rcv_callback missing break in switch case

I did not include CID numbers because these were found by an internal
run at Isilon.

Reviewed by: cem kib
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D25676

3 years agoFix BUILD_WITH_STRICT_TMPPATH builds
Alex Richardson [Wed, 15 Jul 2020 12:08:06 +0000 (12:08 +0000)]
Fix BUILD_WITH_STRICT_TMPPATH builds

We need dd in $PATH for some of the MK_BOOT code and some tests also use it.

Obtained from: CheriBSD

3 years agoAllow bootstrapping localdef on non-FreeBSD systems
Alex Richardson [Wed, 15 Jul 2020 12:07:59 +0000 (12:07 +0000)]
Allow bootstrapping localdef on non-FreeBSD systems

The current localedef simply assumes that the locale headers on build system
are compatible with those on the target system which is not necessarily true.
It generally works on FreeBSD (as long as we don't change the locale headers),
but Linux and macOS provide completely different locale headers.

This change adds new bootstrap headers that namespace certain xlocale
structures defined or used by in the headers that localdef needs.
This is required since system headers *must* be able to include the "real"
locale headers for printf(), etc., but we also want to access the target
systems's internal locale structures.

Reviewed By: yuripv, brooks
Differential Revision: https://reviews.freebsd.org/D25229

3 years agoAdd missing newline and return in localedef error message
Alex Richardson [Wed, 15 Jul 2020 12:07:53 +0000 (12:07 +0000)]
Add missing newline and return in localedef error message

I hit those error messages when using a localedef built against headers
that don't match the target system (cross-building from a Linux host).
This problem will be fixed in the next commit.

3 years agoAvoid rebuilding libpmc in every incremental rebuild
Alex Richardson [Wed, 15 Jul 2020 12:07:47 +0000 (12:07 +0000)]
Avoid rebuilding libpmc in every incremental rebuild

Generate libpmc_events.c in a temporary file first and only overwrite it
if the files are actually different.
This avoids compiling and relinking the different variants of libpmc on
every incremental build.

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D24784

3 years agopoll: factor fd lookup out of scan and rescan
Mateusz Guzik [Wed, 15 Jul 2020 10:24:39 +0000 (10:24 +0000)]
poll: factor fd lookup out of scan and rescan

3 years agofd: remove fd_lastfile
Mateusz Guzik [Wed, 15 Jul 2020 10:24:04 +0000 (10:24 +0000)]
fd: remove fd_lastfile

It keeps recalculated way more often than it is needed.

Provide a routine (fdlastfile) to get it if necessary.

Consumers may be better off with a bitmap iterator instead.

3 years agofd: add obvious branch predictions to fdalloc
Mateusz Guzik [Wed, 15 Jul 2020 10:14:00 +0000 (10:14 +0000)]
fd: add obvious branch predictions to fdalloc

3 years agolibprocstat: fix kvm filedesc access after introduction of fdescenttbl
Mateusz Guzik [Wed, 15 Jul 2020 10:13:23 +0000 (10:13 +0000)]
libprocstat: fix kvm filedesc access after introduction of fdescenttbl

3 years agoGrammar and typo fixes.
Konstantin Belousov [Wed, 15 Jul 2020 09:48:36 +0000 (09:48 +0000)]
Grammar and typo fixes.

Submitted by: alc
MFC after: 20 days

3 years agoFix the pNFS flexible file layout client for servers with small write size.
Rick Macklem [Wed, 15 Jul 2020 01:26:28 +0000 (01:26 +0000)]
Fix the pNFS flexible file layout client for servers with small write size.

The code in nfscl_dofflayout() loops when a flexible file layout server
provides a small write data limit (no extant server is known to do this).
If/when it looped, it erroneously reused the "drpc" argument for the
mirror worker thread, corrupting it.
This patch fixes the problem by only using the calling thread after the
first loop iteration.

Found during testing by simulating a server with a small write size.

Since no extant pNFS server is known to provide a small write size,
this fix it not needed in practice at this time.

MFC after: 2 weeks

3 years agoRemove obsolete files after byacc 20200330 import (r363171).
Jung-uk Kim [Wed, 15 Jul 2020 00:13:15 +0000 (00:13 +0000)]
Remove obsolete files after byacc 20200330 import (r363171).

Reported by: lwhsu

3 years agoRemove a redundant file from test directory to unbreak yacc regression test.
Jung-uk Kim [Tue, 14 Jul 2020 23:59:00 +0000 (23:59 +0000)]
Remove a redundant file from test directory to unbreak yacc regression test.

It looks like the obsolete file from old regression test was accidentally
re-added between version 20170709 and 20180510.

Reported by: lwhsu

3 years agotop: VIS_SAFE turned out to be unsafe
Yuri Pankov [Tue, 14 Jul 2020 22:43:40 +0000 (22:43 +0000)]
top: VIS_SAFE turned out to be unsafe

Unset VIS_SAFE flag as it turned out to be actually unsafe
for continuos top display as it's passing through sequences
resulting cursor movement (backspace, tab, carriage-return),
and explicitly set VIS_TAB for the same reason.

Reported by: Mark Millard <marklmi@yahoo.com>, swills
Tested by: Mark Millard <marklmi@yahoo.com>, swills

3 years agohwpmc: Always set pmc_cpuid to something
Ryan Moeller [Tue, 14 Jul 2020 22:25:06 +0000 (22:25 +0000)]
hwpmc: Always set pmc_cpuid to something

pmc_cpuid was uninitialized for most AMD processor families.  We can still
populate this string for unimplemented families.

Also added a CPUID_TO_STEPPING macro and converted existing code to use it.

Reviewed by: mav
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25673

3 years agolinuxkpi: Ignore NULL pointers passed to string parameter of kstr(n)dup
Vladimir Kondratyev [Tue, 14 Jul 2020 21:56:59 +0000 (21:56 +0000)]
linuxkpi: Ignore NULL pointers passed to string parameter of kstr(n)dup

That follows Linux and fixes related drm-kmod-5.3 panic.

Reviewed by: imp, hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25657

3 years agoImport sendmail 8.16.1
Gregory Neil Shapiro [Tue, 14 Jul 2020 21:40:53 +0000 (21:40 +0000)]
Import sendmail 8.16.1

3 years agocache: make negative shrinker round robin on all lists every time
Mateusz Guzik [Tue, 14 Jul 2020 21:19:33 +0000 (21:19 +0000)]
cache: make negative shrinker round robin on all lists every time

Previously it would check 4, 3, 2, 1 lists. In practice by the time
it is getting called all lists have some elements and consequently
this does not result in new evictions.

Nonetheless, the code is clearer.

Tested by: pho

3 years agocache: remove numcalls
Mateusz Guzik [Tue, 14 Jul 2020 21:17:46 +0000 (21:17 +0000)]
cache: remove numcalls

The counter is not very useful and if necessary the value can be
found by summing up other counters.

3 years agocache: count dropped entries
Mateusz Guzik [Tue, 14 Jul 2020 21:17:08 +0000 (21:17 +0000)]
cache: count dropped entries

3 years agocache: remove neg_locked argument from cache_zap_locked
Mateusz Guzik [Tue, 14 Jul 2020 21:16:48 +0000 (21:16 +0000)]
cache: remove neg_locked argument from cache_zap_locked

Tested by: pho

3 years agocache: remove a useless argument from cache_negative_insert
Mateusz Guzik [Tue, 14 Jul 2020 21:16:07 +0000 (21:16 +0000)]
cache: remove a useless argument from cache_negative_insert

3 years agoReally fix cleandir after r362973
Mitchell Horne [Tue, 14 Jul 2020 21:15:16 +0000 (21:15 +0000)]
Really fix cleandir after r362973

I made an attempt to fix this in r362978, but all it really did was
confine the issue to the $MACHINE_CPUARCH == "riscv" case. The real
problem is that LINKER_FEATURES is not defined here, so bsd.linker.mk
needs to be included.

This error with cleandir only occurs when META_MODE is disabled, which
explains why it was missed by both CI and myself.

Note that this effectively reverts r362978.

Reported by: mjg
Reviewed by: imp, kevans (in IRC)

3 years agocache: create a dedicate struct for negative entries
Mateusz Guzik [Tue, 14 Jul 2020 21:14:59 +0000 (21:14 +0000)]
cache: create a dedicate struct for negative entries

.. and stuff if into the unused target vnode field

This gets rid of concurrent nc_flag modifications racing with the
shrinker and consequently fixes a bug where such a change could have
been missed when cache_ncp_invalidate was being issued..

Reported by: zeising
Tested by: pho, zeising
Fixes: r362828 ("cache: lockless forward lookup with smr")

3 years agoamd64: allow parallel shootdown IPIs
Konstantin Belousov [Tue, 14 Jul 2020 20:37:50 +0000 (20:37 +0000)]
amd64: allow parallel shootdown IPIs

Stop using smp_ipi_mtx to protect global shootdown state, and
move/multiply the global state into pcpu.  Now each CPU can initiate
shootdown IPI independently from other CPUs.  Initiator enters
critical section, then fills its local PCPU shootdown info
(pc_smp_tlb_XXX), then clears scoreboard generation at location (cpu,
my_cpuid) for each target cpu.  After that IPI is sent to all targets
which scan for zeroed scoreboard generation words.  Upon finding such
word the shootdown data is read from corresponding cpu' pcpu, and
generation is set.  Meantime initiator loops waiting for all zeroed
generations in scoreboard to update.

Initiator does not disable interrupts, which should allow
non-invalidation IPIs from deadlocking, it only needs to disable
preemption to pin itself to the instance of the pcpu smp_tlb data.

The generation is set before the actual invalidation is performed in
handler. It is safe because target CPU cannot return to userspace
before handler finishes. In principle only NMI can preempt the
handler, but NMI would see the kernel handler frame and not touch
not-invalidated user page table.

Handlers loop until they do not see zeroed scoreboard generations.
This, together with hardware keeping one pending IPI in LAPIC IRR
should prevent lost shootdowns.

Notes.
1. The code does protect writes to LAPIC ICR with exclusion. I believe
   this is fine because we in fact do not send IPIs from interrupt
   handlers. More for !x2APIC mode where ICR access for write requires
   two registers write, we disable interrupts around it. If considered
   incorrect, I can add per-cpu spinlock around ipi_send().
2. Scoreboard lines owned by given target CPU can be padded to the
   cache line, to reduce ping-pong.

Reviewed by: markj (previous version)
Discussed with: alc
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D25510

3 years agoImprove the error handling in generating ASCONF chunks.
Michael Tuexen [Tue, 14 Jul 2020 20:32:50 +0000 (20:32 +0000)]
Improve the error handling in generating ASCONF chunks.
In case of errors, the cleanup was not consistent.
Thanks to Felix Weinrank for fuzzing the userland stack and making
me aware of the issue.

MFC after: 1 week

3 years agoMake CLOCK_REALTIME and TIMER_ABSTIME available for XOPEN_SOURCE >= 500.
Konstantin Belousov [Tue, 14 Jul 2020 20:23:27 +0000 (20:23 +0000)]
Make CLOCK_REALTIME and TIMER_ABSTIME available for XOPEN_SOURCE >= 500.

Reported by: jbeich
PR: 247701
Reviewed by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25554

3 years agoUpdate to D25266, bin/ps: Make the rtprio option actually show
Kirk McKusick [Tue, 14 Jul 2020 18:57:31 +0000 (18:57 +0000)]
Update to D25266, bin/ps: Make the rtprio option actually show
realtime priorities

The current `ps -axO rtprio' show threads running at interrupt
priority such as the [intr] thread as '1:48' and threads running
at kernel priority such as [pagedaemon] as normal:4294967260.

This change shows [intr] as intr:48 and [pagedaemon] as kernel:4.

Reviewed by:    kib
MFC after: 1 week (together with -r362369)
Differential Revision: https://reviews.freebsd.org/D25660

3 years agoPrint the arm64 registers in more exception handling panics
Andrew Turner [Tue, 14 Jul 2020 18:50:48 +0000 (18:50 +0000)]
Print the arm64 registers in more exception handling panics

It can be useful to get a dump of all registers when investigating why we
received an exception that we are unable to handle. In these cases we
already call panic, however we don't always print the registers.

Add calls to print_registers and print esr and far when applicable.

Sponsored by: Innovate UK

3 years agoAdd stepping to the kern.hwpmc.cpuid string on x86.
Alexander Motin [Tue, 14 Jul 2020 18:11:05 +0000 (18:11 +0000)]
Add stepping to the kern.hwpmc.cpuid string on x86.

It follows the equivalent Linux change to be able to differentiate
skylakex and cascadelakex, sharing the same model but not stepping.

This fixes skylakex handling broken by r363144.

MFC after: 6 days

3 years agoEnable EFI system partition on amd64 and i386 VM images
Oleksandr Tymoshenko [Tue, 14 Jul 2020 18:02:24 +0000 (18:02 +0000)]
Enable EFI system partition on amd64 and i386 VM images

EFI support is a hard requirement for generating Hyper-V Gen2 VM images.

Reviewed by: gjb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25655