freebsd.git
4 years agoMerge ^/head r364051 through r364081.
dim [Mon, 10 Aug 2020 16:58:05 +0000 (16:58 +0000)]
Merge ^/head r364051 through r364081.

4 years agoFollow-up to r358851 (llvm-project 10.0.0-rc3 import), where I added
dim [Mon, 10 Aug 2020 16:55:54 +0000 (16:55 +0000)]
Follow-up to r358851 (llvm-project 10.0.0-rc3 import), where I added
subdirectories for compiler-rt's internal fuzzer, profile and xray
headers, but forgot to add installing those headers themselves.

MFC after: 3 days

4 years agocache: let SAVESTART passthrough
mjg [Mon, 10 Aug 2020 12:28:56 +0000 (12:28 +0000)]
cache: let SAVESTART passthrough

The flag is only passed for non-LOOKUP ops and those fallback to the slowpath.

4 years agocache: resize struct namecache to a multiply of alignment
mjg [Mon, 10 Aug 2020 12:05:55 +0000 (12:05 +0000)]
cache: resize struct namecache to a multiply of alignment

For example struct namecache on amd64 is 100 bytes, but it has to occupies
104. Use the extra bytes to support longer names.

4 years agocache: remove unused variables from cache_fplookup_parse
mjg [Mon, 10 Aug 2020 11:51:56 +0000 (11:51 +0000)]
cache: remove unused variables from cache_fplookup_parse

4 years agovfs: clean MNTK_FPLOOKUP if MNT_UNION is set
mjg [Mon, 10 Aug 2020 11:51:21 +0000 (11:51 +0000)]
vfs: clean MNTK_FPLOOKUP if MNT_UNION is set

Elides checking it during lookup.

4 years agodevfs: bool -> int
mjg [Mon, 10 Aug 2020 11:46:39 +0000 (11:46 +0000)]
devfs: bool -> int

Fixes buildworld after r364069

4 years agoMC: add a note with reference to the discussion and history as-to why we
bz [Mon, 10 Aug 2020 10:58:43 +0000 (10:58 +0000)]
MC: add a note with reference to the discussion and history as-to why we
are where we are now.  The main thing is to try to get rid of the delayed
freeing to avoid blocking on the taskq when shutting down vnets.

X-Timeout: if you still see this before 14-RELEASE remove it.

4 years agoMake sure the multicast release tasks are properly drained when
hselasky [Mon, 10 Aug 2020 10:46:08 +0000 (10:46 +0000)]
Make sure the multicast release tasks are properly drained when
destroying a VNET or a network interface.

Else the inm release tasks, both IPv4 and IPv6 may cause a panic
accessing a freed VNET or network interface.

Reviewed by: jmg@
Discussed with: bz@
Differential Revision: https://reviews.freebsd.org/D24914
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoUse proper prototype for SYSINIT() functions.
hselasky [Mon, 10 Aug 2020 10:40:19 +0000 (10:40 +0000)]
Use proper prototype for SYSINIT() functions.
Mark the unused argument using the __unused macro.

Discussed with: kib@
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agocache: strlcpy -> memcpy
mjg [Mon, 10 Aug 2020 10:40:14 +0000 (10:40 +0000)]
cache: strlcpy -> memcpy

4 years agovfs: garbage collect unused ISUNICODE namei flag
mjg [Mon, 10 Aug 2020 10:37:16 +0000 (10:37 +0000)]
vfs: garbage collect unused ISUNICODE namei flag

4 years agodevfs: save on spurious relocking for devfs_populate
mjg [Mon, 10 Aug 2020 10:36:43 +0000 (10:36 +0000)]
devfs: save on spurious relocking for devfs_populate

Tested by: pho

4 years agodevfs: use cheaper lockmgr entry points
mjg [Mon, 10 Aug 2020 10:36:10 +0000 (10:36 +0000)]
devfs: use cheaper lockmgr entry points

Tested by: pho

4 years agodevfs: use vget_prep/vget_finish
mjg [Mon, 10 Aug 2020 10:35:47 +0000 (10:35 +0000)]
devfs: use vget_prep/vget_finish

Tested by: pho

4 years agovfs: partially support file create/delete/rename in lockless lookup
mjg [Mon, 10 Aug 2020 10:35:18 +0000 (10:35 +0000)]
vfs: partially support file create/delete/rename in lockless lookup

Perform the lookup until the last 2 elements and fallback to slowpath.

Tested by: pho
Sponsored by: The FreeBSD Foundation

4 years agovfs: drop the thread argumemnt from vfs_fplookup_vexec
mjg [Mon, 10 Aug 2020 10:34:22 +0000 (10:34 +0000)]
vfs: drop the thread argumemnt from vfs_fplookup_vexec

It is guaranteed curthread.

Tested by: pho
Sponsored by: The FreeBSD Foundation

4 years agovfs: disallow NOCACHE with LOOKUP
mjg [Mon, 10 Aug 2020 10:33:40 +0000 (10:33 +0000)]
vfs: disallow NOCACHE with LOOKUP

This means there is no expectation lookup will purge the terminal entry,
which simplifies lockless lookup.

Tested by: pho
Sponsored by: The FreeBSD Foundation

4 years agonullfs: add missing VOP_STAT handling
mjg [Mon, 10 Aug 2020 10:31:17 +0000 (10:31 +0000)]
nullfs: add missing VOP_STAT handling

Tested by: pho

4 years agoDocument the order in which the kernel and the user environment versions
danfe [Mon, 10 Aug 2020 09:03:29 +0000 (09:03 +0000)]
Document the order in which the kernel and the user environment versions
are printed when both -K and -U options are passed on the command line.

Approved by: 0mp
Differential Revision: https://reviews.freebsd.org/D25970

4 years agoMove ifconfig SFP status functionality into libifconfig
freqlabs [Sun, 9 Aug 2020 16:27:28 +0000 (16:27 +0000)]
Move ifconfig SFP status functionality into libifconfig

libifconfig_sfp.h provides an API in libifconfig for querying SFP module
properties, operational status, and vendor strings, as well as descriptions
of the various fields, string conversions, and other useful helpers for
implementing user interfaces.

SFP module status is obtained by reading registers via an I2C interface.
Descriptions of these registers and the values therein have been collected
in a Lua table which is used to generate all the boilerplace C headers and
source files for accessing these values, their names, and descriptions.
The generated code is fully commented and readable.

This is the first use of libifconfig in ifconfig itself.  For now, the
scope remains very limited.  Over time, more of ifconfig will be replaced
with libifconfig.

Some minor changes to the formatting of ifconfig output have been made:
- Module memory hex dumps are indented one extra space as a result of using
hexdump(3) instead of a bespoke hex dump function.
- Media descriptions have an added two-character short-name in parenthesis.
- QSFP modules were incorrectly displaying TX bias current as power.  Now
  TX channels display bias current, and this change has been made for both
  SFP and QSFP modules for consistency.

A Lua binding for libifconfig including this functionality is implemented
but has not been included in this commit.  The plan is for it to be
committed after dynamic module loading has been enabled in flua.

Reviewed by: kp, melifaro
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D25494

4 years agoCorrect date for Nagasaki bombing.
grog [Sun, 9 Aug 2020 00:35:47 +0000 (00:35 +0000)]
Correct date for Nagasaki bombing.

4 years agoRemove incorrect duplicate.
grog [Sun, 9 Aug 2020 00:34:35 +0000 (00:34 +0000)]
Remove incorrect duplicate.

4 years agoMention the new implementation of bc and dc which has become the default
se [Sat, 8 Aug 2020 19:48:15 +0000 (19:48 +0000)]
Mention the new implementation of bc and dc which has become the default
version in FreeBSD-CURRENT.

4 years agoImprove the ECN negotiation when the TCP SYN-cache is used by making
tuexen [Sat, 8 Aug 2020 19:39:38 +0000 (19:39 +0000)]
Improve the ECN negotiation when the TCP SYN-cache is used by making
sure that
* ECN is disabled if the client sends an non-ECN-setup SYN segment.
* ECN is disabled is the ECN-setup SYN-ACK segment is retransmitted more
  than net.inet.tcp.ecn.maxretries times.

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

4 years agorelease: RPI3: Add the RPI2 DTB
manu [Sat, 8 Aug 2020 16:56:20 +0000 (16:56 +0000)]
release: RPI3: Add the RPI2 DTB

The RPI2 v1.2 is using the same SoC as the RPI3 so it can boot this image
but needs the RPI2 dtb.

MFC after: 3 days

4 years agoMerge ^/head r364041 through r364050.
dim [Sat, 8 Aug 2020 11:08:03 +0000 (11:08 +0000)]
Merge ^/head r364041 through r364050.

4 years agoUse static inline for iface_{setup,delete}_addr in tests/sys/net/routing.
dim [Sat, 8 Aug 2020 11:06:27 +0000 (11:06 +0000)]
Use static inline for iface_{setup,delete}_addr in tests/sys/net/routing.

This fixes possible link errors, similar to:

ld: error: undefined symbol: iface_setup_addr
>>> referenced by test_rtsock_l3.c:111 (tests/sys/net/routing/test_rtsock_l3.c:111)
>>>               test_rtsock_l3.o:(presetup_ipv4)
>>> referenced by test_rtsock_l3.c:79 (tests/sys/net/routing/test_rtsock_l3.c:79)
>>>               test_rtsock_l3.o:(presetup_ipv6)
>>> referenced by test_rtsock_l3.c:512 (tests/sys/net/routing/test_rtsock_l3.c:512)
>>>               test_rtsock_l3.o:(atfu_rtm_change_v4_gw_success_body)
>>> referenced 10 more times

In C (not C++), 'naked' inline is almost always a mistake. Either use
static inline (this is appropriate for most cases), or extern inline.

MFC after: 3 days

4 years agoFix i386 build of chpass after r363992
arichardson [Sat, 8 Aug 2020 10:05:27 +0000 (10:05 +0000)]
Fix i386 build of chpass after r363992

My change to allow bootstrapping pwd_mkdb (r363992) resulted in i386 build
failures because the bootstrap header was being included in non-bootstrap chpass.
Dropping the no longer required pwd_mkdb include path from chpass fixes
the build, but to be certain that the failure doesn't get re-introduced,
I've also moved the bootstrap pwd.h into a subdirectory so that adding
-I${SRCTOP}/usr.sbin/pwd_mkdb doesn't pull it in.

Reported by: mjg

4 years agoufs: add VOP_STAT handler
mjg [Fri, 7 Aug 2020 23:08:17 +0000 (23:08 +0000)]
ufs: add VOP_STAT handler

4 years agotmpfs: add VOP_STAT handler
mjg [Fri, 7 Aug 2020 23:07:47 +0000 (23:07 +0000)]
tmpfs: add VOP_STAT handler

4 years agovfs: add VOP_STAT
mjg [Fri, 7 Aug 2020 23:06:40 +0000 (23:06 +0000)]
vfs: add VOP_STAT

The current scheme of calling VOP_GETATTR adds avoidable overhead.

An example with tmpfs doing fstat (ops/s):
before: 7488958
after:  7913833

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

4 years agommc_da: fix memory leak in sddaregister()
bz [Fri, 7 Aug 2020 19:58:16 +0000 (19:58 +0000)]
mmc_da: fix memory leak in sddaregister()

In case we are failing to allocate mmcdata, we are returning with
a softc allocated but not attached to anything and thus leak the
memory.

Reviewed by: scottl
MFC after: 2 weeks
X-MFC: only if we also mfc other mmccam changes?
Differential Revision: https://reviews.freebsd.org/D25987

4 years agovfs: release the interlock after failing to set VHOLD_NO_SMR
mjg [Fri, 7 Aug 2020 19:36:08 +0000 (19:36 +0000)]
vfs: release the interlock after failing to set VHOLD_NO_SMR

While here add more comments.

Diagnosed by: markj
Reported by: pho
Fixes: r362827 ("vfs: protect vnodes with smr")

4 years agoMerge ^/head r363583 through r364040.
dim [Fri, 7 Aug 2020 19:33:54 +0000 (19:33 +0000)]
Merge ^/head r363583 through r364040.

4 years agoFix clang 11 inline asm constraint error when building powerpc GENERIC64
dim [Fri, 7 Aug 2020 19:32:54 +0000 (19:32 +0000)]
Fix clang 11 inline asm constraint error when building powerpc GENERIC64
kernels:

sys/powerpc/aim/mmu_radix.c:728:19: error: invalid operand for inline asm constraint 'i'
        __asm __volatile(PPC_TLBIEL(%0, %1, %2, %3, 1)
                         ^
sys/powerpc/aim/mmu_radix.c:149:3: note: expanded from macro 'PPC_TLBIEL'
         __XSTRING(.long PPC_INST_TLBIEL | \
         ^
sys/sys/cdefs.h:161:22: note: expanded from macro '__XSTRING'
#define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
                        ^
sys/sys/cdefs.h:160:21: note: expanded from macro '__STRING'
#define __STRING(x)     #x              /* stringify without expanding x */
                        ^
<scratch space>:112:1: note: expanded from here
".long 0x7c000224 | (((%0) & 0x1f) << 11) | (((%1) & 0x1f) << 21) | (((%2) & 0x3) << 18) | (((%3) & 0x1) << 17) | (((1) & 0x1) << 16)"
^

This is solved by making the affected inline functions __always_inline.

Suggested by: jhibbits
MFC after: 3 days

4 years agoscript: Put the terminal in raw mode when playing back a session.
markj [Fri, 7 Aug 2020 18:48:56 +0000 (18:48 +0000)]
script: Put the terminal in raw mode when playing back a session.

Otherwise recorded sessions of some interactive programs do not play
back properly.

PR: 248377
Submitted by: Soumendra Ganguly <0.gangzta@gmail.com>
MFC after: 1 week

4 years agoEnable hw.pci.enable_aspm tunable by default.
mav [Fri, 7 Aug 2020 18:40:56 +0000 (18:40 +0000)]
Enable hw.pci.enable_aspm tunable by default.

While effects on power saving is only a guess, effects on hot-plug are
clearly visible.  Lets try to enable it and see what happen.

MFC after: 3 months

4 years agoAdd some more checks to make APEI driver more robust.
mav [Fri, 7 Aug 2020 18:38:10 +0000 (18:38 +0000)]
Add some more checks to make APEI driver more robust.

MFC after: 5 days

4 years agoRemove obsolete part of comment. It was cut and pasted from the old version of
imp [Fri, 7 Aug 2020 18:21:48 +0000 (18:21 +0000)]
Remove obsolete part of comment. It was cut and pasted from the old version of
this function, and was never relevant to the new version.

4 years agoMerge ^/head r363989 through r364034.
dim [Fri, 7 Aug 2020 18:14:41 +0000 (18:14 +0000)]
Merge ^/head r363989 through r364034.

4 years agoRe-add generated arm_neon.h header, which was accidentally dropped while
dim [Fri, 7 Aug 2020 18:12:37 +0000 (18:12 +0000)]
Re-add generated arm_neon.h header, which was accidentally dropped while
refactoring lib/clang/headers/Makefile in r363984.

4 years agosetlocale(3): Add an EXAMPLES section and add LANG category
gbe [Fri, 7 Aug 2020 17:25:56 +0000 (17:25 +0000)]
setlocale(3): Add an EXAMPLES section and add LANG category

PR: 41824
Submitted by: Slaven Rezic <eserte atvran dot herceg dot de>
Obtained from: NetBSD
MFC after: 1 week

4 years agombsrtowcs(3): Clarify the RETURN VALUES section
gbe [Fri, 7 Aug 2020 16:56:43 +0000 (16:56 +0000)]
mbsrtowcs(3): Clarify the RETURN VALUES section

PR: 215848
Submitted by: Andrew Stevenson <andrew at ugh dot net dot au>
MFC after: 1 week

4 years agoThe practice of creating symbolic links is somewhat fragile. Always
imp [Fri, 7 Aug 2020 16:26:56 +0000 (16:26 +0000)]
The practice of creating symbolic links is somewhat fragile. Always
make copies instead.

There's too many times that we can't run the new binaries with old
libraries. Making the links when things are known to be 'safe' is a
nice optimization, but a copy of all the binaries is only 30MB, so
saving the copies at the cost of increased support when new symbols
are added and used as part of the bootstrap seems to be unwise.

There may be additional optimizations possible here, especially for
!FreeBSD hosts. However, that's beyond the scope of the problem I'm
trying to fix with make failing mid-way through an installworld across
change r363679. This optimization there caused us to run a new binary
with an old library once a new make was installed due to the symbolic
link. One could just copy make, but then other binaries fail as well,
so rather than play whack-a-mole, I opted to take us back to the old
way.  Before r340157 or so we did copies (thogh of a lot fewer
artifacts), and we didn't have issues like this.

Reviewed by: arichards@
Differential Revision: https://reviews.freebsd.org/D25967

4 years agotmpnam(3): Also mention tmpfile in the ENVIRONMENT section
gbe [Fri, 7 Aug 2020 16:20:07 +0000 (16:20 +0000)]
tmpnam(3): Also mention tmpfile in the ENVIRONMENT section

PR: 181785
Submitted by: Kevin P. Neal <kpneal atpobox dot com>
MFC after: 1 week

4 years agoImplement radix_tree_store() in the LinuxKPI for use with the coming
hselasky [Fri, 7 Aug 2020 16:15:44 +0000 (16:15 +0000)]
Implement radix_tree_store() in the LinuxKPI for use with the coming
extensible arrays implementation.

While at it add some more comments explaining the current
radix_tree_insert() function and make sure to clean the root node when
the radix tree reaches the maximum height. This can happen if the
index passed is too big when the tree is empty.

The radix_tree_store() function is basically a copy of the
radix_tree_insert() function with some added functionality.

The radix_tree_store() function is local to FreeBSD and does not yet
exist in Linux.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix linker error in libuutil with recent LLVM
arichardson [Fri, 7 Aug 2020 16:04:21 +0000 (16:04 +0000)]
Fix linker error in libuutil with recent LLVM

Not marking the function as static can result in a linker error:
undefined reference to __assfail [--no-allow-shlib-undefined]
I noticed this error after updating our CHERI LLVM to the latest upstream
LLVM HEAD revision.

This change effectively reverts r329984 and marks dmu_buf_init_user as
static (which keeps the GCC build happy).

Reviewed By: #zfs, asomers, freqlabs, mav
Differential Revision: https://reviews.freebsd.org/D25663

4 years agoFix duplicate assignment of _localedef in Makefile.inc1
arichardson [Fri, 7 Aug 2020 16:04:15 +0000 (16:04 +0000)]
Fix duplicate assignment of _localedef in Makefile.inc1

The same .if exists a few lines below.

4 years agoDon't link against libdialog/ncurses when bootstrapping tzsetup
arichardson [Fri, 7 Aug 2020 16:04:10 +0000 (16:04 +0000)]
Don't link against libdialog/ncurses when bootstrapping tzsetup

4 years agomakefs: Drop unnecessary sys/clock.h include
arichardson [Fri, 7 Aug 2020 16:04:06 +0000 (16:04 +0000)]
makefs: Drop unnecessary sys/clock.h include

This breaks the build on macOS where this header doesn't exist. I could
also add a compat header to tools/build/cross-build but since it's not
needed removing it seems like the better solution.

4 years agoAlways install usr.bin/grep as grep when bootstrapping
arichardson [Fri, 7 Aug 2020 16:04:01 +0000 (16:04 +0000)]
Always install usr.bin/grep as grep when bootstrapping

We have to bootstrap grep when cross-building from macOS/Linux.

4 years agoFix cddl tools bootstrapping on macOS and Linux
arichardson [Fri, 7 Aug 2020 16:03:55 +0000 (16:03 +0000)]
Fix cddl tools bootstrapping on macOS and Linux

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D25979

4 years agogrep(1): correct typos for 'if a name patches' to 'if a name matches'
gbe [Fri, 7 Aug 2020 16:01:05 +0000 (16:01 +0000)]
grep(1): correct typos for 'if a name patches' to 'if a name matches'

PR: 237635
Submitted by: durin42 <raf atdurin42 dot com>
Reviewed by: kevans
Approved by: kevans
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D25994

4 years agoAdd full support support for dynamic allocation and freeing of epoch's.
hselasky [Fri, 7 Aug 2020 15:32:42 +0000 (15:32 +0000)]
Add full support support for dynamic allocation and freeing of epoch's.

Make sure to reclaim epoch structures when they are freed to support
dynamic allocation and freeing of epoch structures.

While at it, move the 64 supported epoch control structures to the
static memory domain. This overall simplifies the management and
debugging of system epoch's.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D25960
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoIPV6_PKTINFO support for v4-mapped IPv6 sockets
bz [Fri, 7 Aug 2020 15:13:53 +0000 (15:13 +0000)]
IPV6_PKTINFO support for v4-mapped IPv6 sockets

When using v4-mapped IPv6 sockets with IPV6_PKTINFO we do not
respect the given v4-mapped src address on the IPv4 socket.
Implement the needed functionality. This allows single-socket
UDP applications (such as OpenVPN) to work better on FreeBSD.

Requested by: Gert Doering (gert greenie.net), pfsense
Tested by: Gert Doering (gert greenie.net)
Reviewed by: melifaro
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24135

4 years agoAllow ACPI APEI driver build without PCI.
mav [Fri, 7 Aug 2020 13:35:34 +0000 (13:35 +0000)]
Allow ACPI APEI driver build without PCI.

On x86 it seems difficult to build ACPI without PCI, but some aarch64
users appears to be doing it.

MFC after: 3 days

4 years agolib80211: fix indentation of comments for some netbands.
bz [Fri, 7 Aug 2020 12:47:00 +0000 (12:47 +0000)]
lib80211: fix indentation of comments for some netbands.

Whitespace only; no functional changes.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")

4 years agonet80211/ifconfig: print hardware device name for wlan interfaces
bz [Fri, 7 Aug 2020 12:24:23 +0000 (12:24 +0000)]
net80211/ifconfig: print hardware device name for wlan interfaces

Add IEEE80211_IOC_IC_NAME to query the ic_name field and in ifconfig
to print the parent interface again. This functionality was lost
around r287197. It helps in case of multiple wlan interfaces and
multiple underlying hardware devices to keep track which wlan
interface belongs to which physical device.

Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")
Reviewed by: adrian, Idwer Vollering
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25832

4 years agopkgbase: We can't easily have a package with either a - or a _
manu [Fri, 7 Aug 2020 12:19:21 +0000 (12:19 +0000)]
pkgbase: We can't easily have a package with either a - or a _

Rename iscsi_legacy to iscsilegacy, having - or _ in a package name cause
problems when we process them and generate the ucl.

4 years agopkgbase: Fix dependancies
manu [Fri, 7 Aug 2020 10:20:39 +0000 (10:20 +0000)]
pkgbase: Fix dependancies

The package name is converted with _ instead of - as we have some variables
that cannot contain -
Convert back the dependancies with - instead of _

4 years agoAdd a .Pp to separate description and sample code for readability.
lwhsu [Fri, 7 Aug 2020 08:57:31 +0000 (08:57 +0000)]
Add a .Pp to separate description and sample code for readability.

4 years agotelnet(1): Document -P option
gbe [Fri, 7 Aug 2020 08:41:14 +0000 (08:41 +0000)]
telnet(1): Document -P option

PR: 248157
Submitted by: Juraj Lutter <juraj at lutter dot sk>
Reviewed by: bcr
Approved by: bcr
Obtained from: NetBSD
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25794

4 years agoAll the other printf() calls cast to (void) here, do the two newer ones for
imp [Fri, 7 Aug 2020 02:48:19 +0000 (02:48 +0000)]
All the other printf() calls cast to (void) here, do the two newer ones for
consistency.

4 years agoiflib: netmap: drop redundant check
vmaffione [Thu, 6 Aug 2020 21:37:38 +0000 (21:37 +0000)]
iflib: netmap: drop redundant check

The validity of head is already checked by nm_rxsync_prologue().

MFC after: 2 weeks

4 years agoiflib: netmap: don't increment ifl_cidx on the wrong free list
vmaffione [Thu, 6 Aug 2020 21:32:25 +0000 (21:32 +0000)]
iflib: netmap: don't increment ifl_cidx on the wrong free list

Netmap only uses free list 0 to keep it consistent with its
one-to-one mapping between each netmap ring and a device RX
(or TX) queue.
However, the current iflib_netmap_rxsync() routine was
mistakenly updating the ifl_cidx field of both free lists.

PR: 248494
MFC after: 2 weeks

4 years agoem(4): honor vlanhwtag offload
vmaffione [Thu, 6 Aug 2020 21:01:26 +0000 (21:01 +0000)]
em(4): honor vlanhwtag offload

The FreeBSD em driver fails to properly reset the VME flag
in the e1000 CTRL register oneg the following ifconfig command

ifconfig em1 -vlanhwtag

Tested on the e1000 device emulated by QEMU, and on a real
NIC (chip=0x10d38086).

PR: 236584
Submitted by:  murat@sunnyvalley.io
Reported by:  murat@sunnyvalley.io
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D25286

4 years agoPut clang/lib/Tooling/Core/Replacement.cpp under SRCS_MIN, since it is
dim [Thu, 6 Aug 2020 20:55:18 +0000 (20:55 +0000)]
Put clang/lib/Tooling/Core/Replacement.cpp under SRCS_MIN, since it is
required by both the static analyzer (MK_CLANG_FULL) and clang-format
(MK_CLANG_FORMAT). We could also invent yet another SRCS variant, but
that seems a bit overkill.

4 years agostand: use portable ln -n instead of ln -h
arichardson [Thu, 6 Aug 2020 20:46:18 +0000 (20:46 +0000)]
stand: use portable ln -n instead of ln -h

This fixes the build on Linux

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

4 years agoAllow bootstrapping pwd_mkdb on Linux/macOS
arichardson [Thu, 6 Aug 2020 20:46:13 +0000 (20:46 +0000)]
Allow bootstrapping pwd_mkdb on Linux/macOS

We need to provide a struct passwd that is compatible with the target
system and this is not the case when cross-building from macOS/Linux.
It should also be a problem when bootstrapping for an i386 target from a
FreeBSD amd64 host since time_t does not match across those systems.
However, pwd_mkdb always truncates integer values to 32-bit so this
difference does not result in different databases.

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D25931

4 years agoctfmerge: Fix missing pthread_cond_init()
arichardson [Thu, 6 Aug 2020 20:44:40 +0000 (20:44 +0000)]
ctfmerge: Fix missing pthread_cond_init()

This does not appear to matter on FreeBSD or Linux, but when building an
amd64 kernel on macOS I was seeing infinite loops in ctfmerge.
It turns out the loop in wip_save_work() was looping forever due to
pthread_cond_wait() always returning -EINVAL.

Reviewed By: markj, brooks
Differential Revision: https://reviews.freebsd.org/D25973

4 years agoMerge ^/head r363583 through r363988.
dim [Thu, 6 Aug 2020 20:33:17 +0000 (20:33 +0000)]
Merge ^/head r363583 through r363988.

4 years agoFix clang 11 -Wformat warnings in yp_mkdb:
dim [Thu, 6 Aug 2020 20:31:50 +0000 (20:31 +0000)]
Fix clang 11 -Wformat warnings in yp_mkdb:

usr.sbin/yp_mkdb/yp_mkdb.c:91:40: error: format specifies type 'char *' but the argument has type 'void *' [-Werror,-Wformat]
                printf("%.*s %.*s\n", (int)key.size, key.data, (int)data.size,
                        ~~~~                         ^~~~~~~~
usr.sbin/yp_mkdb/yp_mkdb.c:92:7: error: format specifies type 'char *' but the argument has type 'void *' [-Werror,-Wformat]
                    data.data);
                    ^~~~~~~~~

MFC after: 3 days

4 years agoMerge ^/head r363739 through r363986.
dim [Thu, 6 Aug 2020 19:34:55 +0000 (19:34 +0000)]
Merge ^/head r363739 through r363986.

4 years agoApply tentative fix for clang 11 warning in pam_exec(8):
dim [Thu, 6 Aug 2020 19:31:52 +0000 (19:31 +0000)]
Apply tentative fix for clang 11 warning in pam_exec(8):

lib/libpam/modules/pam_exec/pam_exec.c:222:56: error: format specifies type 'char *' but the argument has type 'const void *' [-Werror,-Wformat]
               if (asprintf(&envstr, "%s=%s", pam_item_env[i].name, item) < 0)
                                         ~~                         ^~~~

4 years agoTentatively update UPDATING and ObsoleteFiles.inc for 11.0.0.
dim [Thu, 6 Aug 2020 19:30:39 +0000 (19:30 +0000)]
Tentatively update UPDATING and ObsoleteFiles.inc for 11.0.0.

4 years agoUpdate Makefiles under lib/clang and usr.bin/clang for 11.0.0 builds,
dim [Thu, 6 Aug 2020 19:30:00 +0000 (19:30 +0000)]
Update Makefiles under lib/clang and usr.bin/clang for 11.0.0 builds,
and also bump the version in the mtree files.

4 years agoRegenerate lib/clang/liblldb/LLDBWrapLua.cpp with swig 4.0.2.
dim [Thu, 6 Aug 2020 19:28:00 +0000 (19:28 +0000)]
Regenerate lib/clang/liblldb/LLDBWrapLua.cpp with swig 4.0.2.

4 years agoUpdate generated llvm-project related version headers, config.h files
dim [Thu, 6 Aug 2020 19:27:03 +0000 (19:27 +0000)]
Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

4 years agoReapply r362235 (by kp):
dim [Thu, 6 Aug 2020 19:24:17 +0000 (19:24 +0000)]
Reapply r362235 (by kp):

llvm: Default to -mno-relax on RISC-V

Compiling on a RISC-V system fails with 'relocation R_RISCV_ALIGN
requires unimplemented linker relaxation; recompile with -mno-relax'.

Our default linker (ld.lld) doesn't support relaxation, so default to
no-relax so we don't generate object files the linker can't handle.

Reviewed by: mhorne
Sponsored by: Axiado
Differential Revision: https://reviews.freebsd.org/D25210

4 years agoReapply r360852 (by cem):
dim [Thu, 6 Aug 2020 19:23:00 +0000 (19:23 +0000)]
Reapply r360852 (by cem):

clang: Reject %n for __attribute__((format(__freebsd_kprintf__)))

A follow-up to r360849.

Reported by: imp
Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D24786

4 years agoAdd CTL support for REPORT IDENTIFYING INFORMATION command.
mav [Thu, 6 Aug 2020 19:16:11 +0000 (19:16 +0000)]
Add CTL support for REPORT IDENTIFYING INFORMATION command.

It allows to report to initiator LU identifying information, preset via
"ident_info" and "text_ident_info" options.

Unfortunately it is impossible to implement SET IDENTIFYING INFORMATION,
since we have no persistent storage it requires, so the information is
read-only for initiator and has to be set out-of-band.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

4 years agoReapply r359582 (by emaste):
dim [Thu, 6 Aug 2020 19:15:31 +0000 (19:15 +0000)]
Reapply r359582 (by emaste):

lldb: use lua as the default script language

In the FreeBSD base system we do not have Python support in lldb, but
will have Lua support.  Make Lua the default.

This needs to be made into a configure-time option; that is being
discussed upstream and will appear in a future lldb import.  For now
carry this change as a tiny patch to our copy of lldb.

4 years agor356104 | jhibbits | 2019-12-27 00:06:28 +0100 (Fri, 27 Dec 2019) | 25 lines
dim [Thu, 6 Aug 2020 19:11:24 +0000 (19:11 +0000)]
r356104 | jhibbits | 2019-12-27 00:06:28 +0100 (Fri, 27 Dec 2019) | 25 lines

[PowerPC] enable atomic.c in compiler_rt and do not check and forces
lock/lock_free decisions in compiled time

Summary:
Enables atomic.c in compiler_rt and forces clang to not emit a call for runtime
decision about lock/lock_free.  At compiling time, if clang can't decide if
atomic operation can be lock free, it emits calls to external functions  like
`__atomic_is_lock_free`, `__c11_atomic_is_lock_free` and
`__atomic_always_lock_free`, postponing decision to a runtime check.  According
to LLVM code documentation, the mechanism exists due to differences between
x86_64 processors that can't be decided at runtime.

On PowerPC and PowerPCSPE (32 bits), we already know in advance it can't be lock
free, so we force the decision at compile time and avoid having to implement it
in an external library.

This patch was made after 32 bit users testing the PowePC32 bit ISO reported
llvm could not be compiled with in-base llvm due to `__atomic_load8` not
implemented.

Submitted by: alfredo.junior_eldorado.org.br
Reviewed by: jhibbits, dim

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

4 years agoReapply r355803 (by mmel):
dim [Thu, 6 Aug 2020 19:08:28 +0000 (19:08 +0000)]
Reapply r355803 (by mmel):

Fix LLVM libunwnwind _Unwind_Backtrace symbol version for ARM.
In original  GNU libgcc, _Unwind_Backtrace is published with GCC_3.3 version
for all architectures but ARM. For ARM should be publishes with GCC_4.3.0
version. This was originally omitted in r255095, fixed in r318024 and omitted
aging in LLVM libunwind implementation in r354347.

For ARM _Unwind_Backtrace should be published as default with GCC_4.3.0
version , (because this is right original version) and again as
normal(not-default) with GCC_3.3 version (to maintain ABI compatibility
compiled/linked with wrong pre r318024 libgcc)

PR: 233664

4 years agoReapply r354347 (by cem):
dim [Thu, 6 Aug 2020 19:05:59 +0000 (19:05 +0000)]
Reapply r354347 (by cem):

Fix llvm-libunwind userspace build on ARM

GCC's libgcc exports a few ARM-specific symbols for ARM EABI, AEABI, or
EHABI or whatever it's called.  Export the same ones from LLVM-libunwind's
libgcc_s, on ARM.  As part of this, convert libgcc_s from a direct
Version.map to one constructed from component Symbol.map files.  This allows
the ARM-specific Symbol.map to be included only on ARM.

Fix ARM-only oddities in struct name/aliases in LLVM-libunwind to match
non-ARM definitions and ARM-specific expectations in libcxxrt /
libcompiler_rt.

No functional change intended for non-ARM architectures.

This commit does not actually flip the switch for ARM defaults from libgcc
to llvm-libunwind, but makes it possible (to compile, anyway).

4 years ago[POWERPC] Fix ppc64 makecontext() parameter overflow handling.
bdragon [Thu, 6 Aug 2020 17:49:19 +0000 (17:49 +0000)]
[POWERPC] Fix ppc64 makecontext() parameter overflow handling.

On ELFv2, the overflow parameters in the stack frame are at a different offset
from sp than ELFv1. Adjust code to use the correct offset in all cases.

This had resulted in argv[8] and up being copied to the incorrect address
in the new context's initial stack frame.

This is not necessarily the only bug in this function, I need to do a full
review still and ensure the rest of the math is sane for ELFv2 stack frames.

Reported by: pherde (Probably. My notes are a bit unclear.)
Reviewed by: jhibbits (in irc)
Sponsored by: Tag1 Consulting, Inc.

4 years agoReapply r351662 (by emaste):
dim [Thu, 6 Aug 2020 16:44:24 +0000 (16:44 +0000)]
Reapply r351662 (by emaste):

lldb: shorten thread names to make logs easier to follow

lldb prepends the thread name to log entries, and the existing thread
name for the FreeBSD ProcessMonitor thread was longer than the kernel's
supported thread name length, and so was truncated.  This made logs hard
to read, as the truncated thread name ran into the log message.  Shorten
"lldb.process.freebsd.operation" to just "freebsd.op" so that logs are
more readable.

(Upstreaming to lldb still to be done).

4 years agoReapply r349876:
dim [Thu, 6 Aug 2020 16:42:48 +0000 (16:42 +0000)]
Reapply r349876:

Apply a workaround to be able to build clang 8.0.0 headers with clang
3.4.1, which is still in the stable/10 branch.

It looks like clang 3.4.1 implements static_asserts by instantiating a
temporary static object, and if those are in an anonymous union, it
results in "error: anonymous union can only contain non-static data
members".

To work around this implementation limitation, move the static_asserts
in question out of the anonymous unions.

This should make building the latest stable/11 from stable/10 possible
again.

Reported by: Mike Tancsa <mike@sentex.net>

4 years agoReapply r344852:
dim [Thu, 6 Aug 2020 16:27:24 +0000 (16:27 +0000)]
Reapply r344852:

Put in a temporary workaround for what is likely a gcc 6 bug (it does
not occur with gcc 7 or later).  This should prevent the following error
from breaking the head-amd64-gcc CI builds:

In file included from /workspace/src/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp:14:0:
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: 'template<class _InputIterator> lldb_private::MemoryRegionInfos::MemoryRegionInfos(_InputIterator, _InputIterator, const allocator_type&)' inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'
   using std::vector<lldb_private::MemoryRegionInfo>::vector;
                                                      ^~~~~~
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: conflicts with version inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'

Reported by: CI

4 years agoReapply r343111 (partially, by mckusick):
dim [Thu, 6 Aug 2020 16:25:56 +0000 (16:25 +0000)]
Reapply r343111 (partially, by mckusick):

Create new EINTEGRITY error with message "Integrity check failed".

An integrity check such as a check-hash or a cross-correlation failed.
The integrity error falls between EINVAL that identifies errors in
parameters to a system call and EIO that identifies errors with the
underlying storage media. EINTEGRITY is typically raised by intermediate
kernel layers such as a filesystem or an in-kernel GEOM subsystem when
they detect inconsistencies. Uses include allowing the mount(8) command
to return a different exit value to automate the running of fsck(8)
during a system boot.

These changes make no use of the new error, they just add it. Later
commits will be made for the use of the new error number and it will
be added to additional manual pages as appropriate.

Reviewed by:    gnn, dim, brueffer, imp
Discussed with: kib, cem, emaste, ed, jilles
Differential Revision: https://reviews.freebsd.org/D18765

4 years agoReapply r332965 (by emaste):
dim [Thu, 6 Aug 2020 16:20:45 +0000 (16:20 +0000)]
Reapply r332965 (by emaste):

lldb: remove assertion that target_arch is FreeBSD

The target is not necessarily a FreeBSD binary - for example, it may be
a Linux binary running under the linuxulator.  Basic ptrace (live)
debugging already worked in this case, except for the assertion.

Sponsored by: Turing Robotic Industries Inc.

4 years agoPreserve ASLR vm_map flags across fork
brooks [Thu, 6 Aug 2020 16:20:20 +0000 (16:20 +0000)]
Preserve ASLR vm_map flags across fork

In the most common case (fork+execve) this doesn't matter, but further
attempts to apply entropy would fail in (e.g.) a pre-fork server.

Reported by: Alfredo Mazzinghi
Reviewed by: kib, markj
Obtained from: CheriBSD
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D25966

4 years agopkgbase: Add the possibility to choose the output dir
manu [Thu, 6 Aug 2020 16:14:43 +0000 (16:14 +0000)]
pkgbase: Add the possibility to choose the output dir

The output dir is set to ${REPODIR}/${PKG_ABI}/${PKG_VERSION} now.
Add the possibility to specify the last componant and set it by default
to ${PKG_VERSION} as before.
This is useful for tests and also for building packages with the same
PKG_VERSION provided to check differences.

4 years agopkgbase: Add a new variable PKG_TIMESTAMP
manu [Thu, 6 Aug 2020 16:13:54 +0000 (16:13 +0000)]
pkgbase: Add a new variable PKG_TIMESTAMP

libarchive uses the SOURCE_DATE_EPOCH env variable to set the date of file
in an archive, this is useful for reproducibility.
Add a variable name PKG_TIMESTAMP that take a epoch time and set SOURCE_DATE_EPOCH
to this. By default it is the current time so no changes here.

4 years agoReapply r329859 (partially, by imp):
dim [Thu, 6 Aug 2020 16:12:13 +0000 (16:12 +0000)]
Reapply r329859 (partially, by imp):

Do not include float interfaces when using libsa.

We don't support float in the boot loaders, so don't include
interfaces for float or double in systems headers. In addition, take
the unusual step of spiking double and float to prevent any more
accidental seepage.

4 years agopkgbase: Remove vcs revision from kernel and runtime comment
manu [Thu, 6 Aug 2020 16:11:30 +0000 (16:11 +0000)]
pkgbase: Remove vcs revision from kernel and runtime comment

This is not needed and we don't do that for other packages.

4 years agoReapply r327151 (partially):
dim [Thu, 6 Aug 2020 15:46:39 +0000 (15:46 +0000)]
Reapply r327151 (partially):

For our lldb customizations, instead of commenting out lines, use #ifdef
LLDB_ENABLE_ALL / #endif preprocess directives instead, so our diffs
against upstream only consist of added lines.

(Note that upstream has largely reshuffled the way optional lldb plugins
are handled, so we need a lot less of these #ifdefs. However, not all of
them can be dropped, unless we re-import several sources that we have
always skipped.)

4 years agoClean up reassignbuf() and buf_vlist_remove() a bit.
markj [Thu, 6 Aug 2020 15:43:15 +0000 (15:43 +0000)]
Clean up reassignbuf() and buf_vlist_remove() a bit.

- Convert panic() calls to INVARIANTS-only assertions.  The PCTRIE code
  provides some of the same protection since it will panic upon an
  attempt to remove a non-resident buffer.
- Update the comment above reassignbuf() to reflect reality.

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

4 years agoRemove the vfs.reassignbufcalls counter and sysctl.
markj [Thu, 6 Aug 2020 15:42:59 +0000 (15:42 +0000)]
Remove the vfs.reassignbufcalls counter and sysctl.

As the 20-year old comment above it suggests, the counter is of dubious
value.  Moreover, the (global) counter was not updated precisely and
hurts scalability.

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