]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMerge ^/head r357389 through r357407.
dim [Sun, 2 Feb 2020 12:54:38 +0000 (12:54 +0000)]
Merge ^/head r357389 through r357407.

4 years agoPer the firm plan, start to remove sparc64
imp [Sun, 2 Feb 2020 11:37:27 +0000 (11:37 +0000)]
Per the firm plan, start to remove sparc64

The sparc64 architecture is being removed from FreeBSD 13, starting
now. This removes it from the top level only. It is the only
architecture that didn't see substantial work after the call to get
things working with the external toolchain.

4 years agofd: sprinkle some predits around fget
mjg [Sun, 2 Feb 2020 09:38:40 +0000 (09:38 +0000)]
fd: sprinkle some predits around fget

clang inlines fget -> _fget into kern_fstat and eliminates several checkes,
but prior to this change it would assume fget_unlocked was likely to fail
and consequently avoidable jumps got generated.

4 years agofd: use atomic_load_ptr instead of hand-rolled cast through volatile
mjg [Sun, 2 Feb 2020 09:37:16 +0000 (09:37 +0000)]
fd: use atomic_load_ptr instead of hand-rolled cast through volatile

No change in assembly.

4 years agovfs: remove the now empty vop_unlock_post
mjg [Sun, 2 Feb 2020 09:36:32 +0000 (09:36 +0000)]
vfs: remove the now empty vop_unlock_post

4 years agovfs: remove the never set VDESC_VPP_WILLRELE flag
mjg [Sun, 2 Feb 2020 09:35:48 +0000 (09:35 +0000)]
vfs: remove the never set VDESC_VPP_WILLRELE flag

4 years agoMove font.h generation to conf/files from conf/files.*
imp [Sun, 2 Feb 2020 08:27:26 +0000 (08:27 +0000)]
Move font.h generation to conf/files from conf/files.*

Use ${SRCTOP} instead of /usr/share.
Prefer to depend on option sc_dflt_fnt instead of sc.
gc the 4 otherwise identical instances in the tree.
Platforms that don't need this won't included it.

4 years agoFix old-style build
imp [Sun, 2 Feb 2020 08:27:20 +0000 (08:27 +0000)]
Fix old-style build

Fix the old-style build by using ${SRCTOP} instead of a weird
construct that only works for new-style build.
Simplify the building of keymap files by using macros
Move atkbdmap.h in files.x86
This has been broken since r296899 which removed the implicit
dependency on /usr/share.

4 years agoKill old armv4 busdma
imp [Sun, 2 Feb 2020 08:27:14 +0000 (08:27 +0000)]
Kill old armv4 busdma

Move to having one busdma option for arm: the armv6/v7 one.
Kill now-unused option ARM_USE_V6_BUSDMA too.
Fixup files.arm to match rename.

4 years agoMove arm back to having one LINT
imp [Sun, 2 Feb 2020 08:27:08 +0000 (08:27 +0000)]
Move arm back to having one LINT

Now that armv5 is gone, we no longer need multiple LINT files. Kill
the odd-ball support here. From now on, we just have LINT built from
notes like all the other platforms. Keep the removal of LINT-V5/7
to remove stale files for a while still..

4 years agoRemove old boardid/mach-types support.
imp [Sun, 2 Feb 2020 06:52:10 +0000 (06:52 +0000)]
Remove old boardid/mach-types support.

This has been long obsolete in linux and now that all armv4/5 support
is gone, it can be retired too.

4 years agoRemove armv5 marvell support.
imp [Sun, 2 Feb 2020 06:52:04 +0000 (06:52 +0000)]
Remove armv5 marvell support.

Per plans to remove armv5 support, remove the armv5 marvell discovery,
kirkwood and orion families.

4 years agoRemove Ralink RT1310 support
imp [Sun, 2 Feb 2020 06:51:42 +0000 (06:51 +0000)]
Remove Ralink RT1310 support

This armv5 SoC is being removed consistent with the removal of
armv5 support, per discussions in arm@ mailing list.

4 years agoRemove vpo.4
imp [Sun, 2 Feb 2020 04:53:27 +0000 (04:53 +0000)]
Remove vpo.4

The Parallel Port SCSI adapter was interesting for 100MB ZIP drives, but is no
longer used or maintained. Remove it from the tree.

The Parallel Port microsequencer (microseq.9) is now mostly unused in the tree,
but remains. PPI still refrences it, but doesn't use its full functionality.

Relnotes: Yes
Reviewed by: rgrimes@, Ihor Antonov
Discussed on: arch@
Differential Revision:  https://reviews.freebsd.org/D23389

4 years agoAdd deprecation notice to vpo.4
imp [Sun, 2 Feb 2020 04:52:28 +0000 (04:52 +0000)]
Add deprecation notice to vpo.4

This driver has seen no real changes for almost 20 years. It's for
hardware that's 25 years old. It has no reports of active use, nor
has it been seen in the NYCBug dmesg database at all. Schedule
its removal for 13.0.

Reviewed by: rgrimes@ (earlier version)
Relnote: Yes
MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D23403

4 years agoFix a bug in r356776 where the page allocator was not properly restored to
jeff [Sat, 1 Feb 2020 23:46:30 +0000 (23:46 +0000)]
Fix a bug in r356776 where the page allocator was not properly restored to
the percpu page allocator after it had been temporarily overridden by
startup_alloc.

Reported by: pho, bdragon

4 years agoFix build.
kib [Sat, 1 Feb 2020 23:16:30 +0000 (23:16 +0000)]
Fix build.

Sponsored by: The FreeBSD Foundation

4 years agoMerge ^/head r357368 through r357388.
dim [Sat, 1 Feb 2020 22:07:37 +0000 (22:07 +0000)]
Merge ^/head r357368 through r357388.

4 years agoIn dmar_gas_lowermatch, skip searching a subtree if all its addresses are greater...
dougm [Sat, 1 Feb 2020 21:47:34 +0000 (21:47 +0000)]
In dmar_gas_lowermatch, skip searching a subtree if all its addresses are greater than lowaddr.
In dmar_gas_uppermatch, skip searching a subtree if all its gaps-between-alloctions are too small.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D23391

4 years agoAmend r357367 by using register values from the TPM datasheet.
dim [Sat, 1 Feb 2020 21:43:45 +0000 (21:43 +0000)]
Amend r357367 by using register values from the TPM datasheet.

As Ian Lepore noted, writing ~1 to a register might have a completely
different effect than doing a regular read-modify-write operation.

Follow the TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22
datasheet instead, and use the actual values mentioned there:
(uint32_t)1 to cancel the command, (uint32_t)0 to clear the field.

MFC after: 3 days

4 years agocache: replace kern___getcwd with vn_getcwd
mjg [Sat, 1 Feb 2020 20:38:38 +0000 (20:38 +0000)]
cache: replace kern___getcwd with vn_getcwd

The previous routine was resulting in extra data copies most notably in
linux_getcwd.

4 years agotpm(4): Fix 'go ready' in TPM 2.0 TIS driver
cem [Sat, 1 Feb 2020 20:38:22 +0000 (20:38 +0000)]
tpm(4): Fix 'go ready' in TPM 2.0 TIS driver

tpmtis_go_ready() read the value of the TPM_STS register, ORed
TPM_STS_CMD_READY with it, and wrote it back.  However, the TPM Profile
(PTP) specification states that only one bit in the write request value may
be set to 1, or else the entire write request is ignored.

Fix by just writing TPM_STS_CMD_READY.

Similarly, remove the call which clears the TPM_STS_CMD_READY flag in the
same function.  It was being ignored for the same reason.

Submitted by: Darrick Lew <darrick.freebsd AT gmail.com>
Reviewed by: vangyzen, myself
MFC after: if you care about stable, you might want to do so
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23081

4 years agocache: return the total length from vn_fullpath1
mjg [Sat, 1 Feb 2020 20:37:11 +0000 (20:37 +0000)]
cache: return the total length from vn_fullpath1

This removes strlen from getcwd.

4 years agocache: remove vnode -> path lookup disablement
mjg [Sat, 1 Feb 2020 20:36:35 +0000 (20:36 +0000)]
cache: remove vnode -> path lookup disablement

It seems to be of little to no use even when debugging.

Interested parties can resurrect it and gate compilation with a macro.

4 years agovfs: consistently use size_t for buflen around VOP_VPTOCNP
mjg [Sat, 1 Feb 2020 20:34:43 +0000 (20:34 +0000)]
vfs: consistently use size_t for buflen around VOP_VPTOCNP

4 years agorand(3): Replace implementation with one backed by random(3) algorithm
cem [Sat, 1 Feb 2020 20:33:23 +0000 (20:33 +0000)]
rand(3): Replace implementation with one backed by random(3) algorithm

rand(3)'s standard C API is extremely limiting, but we can do better
than the historical 32-bit state Park-Miller LCG we've shipped since
2001: r73156.

The justification provided at the time for not using random(3) was that
rand_r(3) could not be made to use the same algorithm.  That is still
true.  However, the irrelevance of rand_r(3) is increasingly obvious.
Since that time, POSIX has marked the interface obsolescent.  rand_r(3)
never became part of the standard C library.  If not for API
compatibility reasons, I would just remove rand_r(3) entirely.

So, I do not believe it is a problem for rand_r(3) and rand(3) to
diverge.

The 12 ABI is maintained with compatibility definitions, but this
revision does subtly change the API of rand(3).  The sequences of
pseudorandom numbers produced in programs built against new versions of
libc will differ from programs built against prior versions of libc.

Reviewed by: kevans, markm
MFC after: no
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D23290

4 years agohwpstate_intel(4): Save admin-set EPP/EPB and restore after suspend
cem [Sat, 1 Feb 2020 20:12:02 +0000 (20:12 +0000)]
hwpstate_intel(4): Save admin-set EPP/EPB and restore after suspend

4 years agohwpstate_intel(4): Print failure message only on failure
cem [Sat, 1 Feb 2020 20:11:25 +0000 (20:11 +0000)]
hwpstate_intel(4): Print failure message only on failure

X-MFC-With: r357379

4 years agohwpstate_intel(4): Detect and support PKG variant
cem [Sat, 1 Feb 2020 19:50:10 +0000 (19:50 +0000)]
hwpstate_intel(4): Detect and support PKG variant

If package-level control is present, we default to using it.  Per-core
software control may be enabled by setting the machdep.hwpstate_pkg_ctrl
tunable to "0" in loader.conf(5).

4 years agohwpstate_intel(4): Add fallback EPP using PERF_BIAS MSR
cem [Sat, 1 Feb 2020 19:49:13 +0000 (19:49 +0000)]
hwpstate_intel(4): Add fallback EPP using PERF_BIAS MSR

Per Intel SDM (Vol 3b Part 2), if HWP indicates EPP (energy-performance
preference) is not supported, the hardware instead uses the ENERGY_PERF_BIAS
MSR.  In the epp sysctl handler, fall back to that MSR if HWP does not
support EPP and CPUID indicates the ENERGY_PERF_BIAS MSR is supported.

4 years agox86: Add/amend some power-management comments/macros
cem [Sat, 1 Feb 2020 19:46:02 +0000 (19:46 +0000)]
x86: Add/amend some power-management comments/macros

No functional change.

4 years agohwpstate_intel(4): Error check epp sysctl & bail if HW does not support feature
cem [Sat, 1 Feb 2020 19:45:27 +0000 (19:45 +0000)]
hwpstate_intel(4): Error check epp sysctl & bail if HW does not support feature

4 years agotests: epair: Don't fail if we load if_epair
kp [Sat, 1 Feb 2020 19:40:11 +0000 (19:40 +0000)]
tests: epair: Don't fail if we load if_epair

kldload() returns a positive integer when it loads a ko, so check that the
return value is -1 to detect error cases, not that it's different from zero.

MFC after: 3 days
X-MFC-With: r357234

4 years agoRemove a couple of lingering usages of the page lock.
markj [Sat, 1 Feb 2020 18:23:51 +0000 (18:23 +0000)]
Remove a couple of lingering usages of the page lock.

Update vm_page_scan_contig() and vm_page_reclaim_run() to stop using
vm_page_change_lock().  It has no use after r356157.  Remove
vm_page_change_lock() now that it has no users.

Remove an unncessary check for wirings in vm_page_scan_contig(), which
was previously checking twice.  The check is racy until
vm_page_reclaim_run() ensures that the page is unmapped, so one check is
sufficient.

Reviewed by: jeff, kib (previous versions)
Tested by: pho (previous version)
Differential Revision: https://reviews.freebsd.org/D23279

4 years agointel_hwpstate(4): Use identcpu-cached cpuid 6 leaf
cem [Sat, 1 Feb 2020 17:54:46 +0000 (17:54 +0000)]
intel_hwpstate(4): Use identcpu-cached cpuid 6 leaf

No functional change.

4 years agointel_hwpstate(4): Don't leak bound thread in error conditions
cem [Sat, 1 Feb 2020 17:30:45 +0000 (17:30 +0000)]
intel_hwpstate(4): Don't leak bound thread in error conditions

I don't know why a Skylake CPU with the HWP feature bit present would trap
on MSR reads of the HWP registers, but if this occurs, do not leave the
attach thread bound.  This could conceivably cause reported hangs, although
I have no evidence that this is the cause.

Reported by: ae@, Andreas Nilsson <andrnils AT gmail.com>
X-MFC-With: r357002

4 years agoprci: register tlclk as a fixed clock
mhorne [Sat, 1 Feb 2020 17:13:52 +0000 (17:13 +0000)]
prci: register tlclk as a fixed clock

The PRCI exports tlclk as a constant fixed divisor clock, defined as 1/2
of the coreclk frequency. In older FU540 device trees (such as the one
provided by SiFive), tlclk is represented as its own entity, and is
automatically registered as a fixed-divisor-clock. Unfortunately the
upstream FU540 device tree (that we have in our tree) represents tlclk
as an output of the PRCI block, and we must register it manually. At
worst, users of the old device tree will end up with an unreferenced
duplicate of tlclk.

This fixes device attachment for the SiFive UART on newer device trees,
since it references tlclk via the PRCI.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23406

4 years agoprci: fix up compat
mhorne [Sat, 1 Feb 2020 17:12:15 +0000 (17:12 +0000)]
prci: fix up compat

Add two additional compat strings that can be used to identify the PRCI.

With newer device trees the PRCI has two parents, hfclk and rtcclk, so
allow the driver to attach when more than one parent is found.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23405

4 years agoprci: register the DDR and GEMGX PLLs
mhorne [Sat, 1 Feb 2020 17:09:56 +0000 (17:09 +0000)]
prci: register the DDR and GEMGX PLLs

The PRCI module exports three PLLs. Currently only the coreclk/corepll
is registered, so add the logic to register the DDR (memory) and GEMGX
(ethernet) clocks as well. These clocks are unused at the moment.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23404

4 years agoMerge ^/head r357350 through r357367.
dim [Sat, 1 Feb 2020 17:03:31 +0000 (17:03 +0000)]
Merge ^/head r357350 through r357367.

4 years agoFix new clang 10.0.0 warnings about converting the result of shift
dim [Sat, 1 Feb 2020 17:02:26 +0000 (17:02 +0000)]
Fix new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
  #define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
  ^
  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
  #define BIT(x) (1 << (x))
    ^

In this case, the intent was to clear the zeroth bit, and leave the rest
unaffected.  Therefore, the ~ operator should be used instead.

Noticed by: cem
MFC after: 3 days

4 years agoRevert r357349, since the clang 10.0.0 warning was actually correct, and
dim [Sat, 1 Feb 2020 16:57:04 +0000 (16:57 +0000)]
Revert r357349, since the clang 10.0.0 warning was actually correct, and
the ! operator should have been a ~ instead:

  Merge r357348 from the clang 10.0.0 import branch:

  Disable new clang 10.0.0 warnings about converting the result of
  shift operations to a boolean in tpm(4):

  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
  #define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
  ^
  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
  #define BIT(x) (1 << (x))
    ^

  Such warnings can be useful in C++ contexts, but not so much in kernel
  drivers, where this type of bit twiddling is commonplace.  So disable
  it for this case.

Noticed by: cem
MFC after: 3 days

4 years agotests: epair: Don't fail if the if_epair module is already loaded
kp [Sat, 1 Feb 2020 11:31:45 +0000 (11:31 +0000)]
tests: epair: Don't fail if the if_epair module is already loaded

kldload() returns an error (EEXIST) if the module is already loaded.
That's not a problem for us, so ignore that error.

While here also clean up include statements.

MFC after: 3 days
X-MFC-With: r357234

4 years agobridge.4: Remove notes about FreeBSD 6.2-7.2
0mp [Sat, 1 Feb 2020 10:25:13 +0000 (10:25 +0000)]
bridge.4: Remove notes about FreeBSD 6.2-7.2

Reported by: Mateusz Kwiatkowski
Reviewed by: brueffer
Approved by: bcr (mentor)
Differential Revision:  https://reviews.freebsd.org/D23393

4 years agoThe error variable is not really needed. Remove it.
pjd [Sat, 1 Feb 2020 10:15:23 +0000 (10:15 +0000)]
The error variable is not really needed. Remove it.

4 years agoRestore previous usage presentation (without "pwait: " prefix).
pjd [Sat, 1 Feb 2020 09:13:11 +0000 (09:13 +0000)]
Restore previous usage presentation (without "pwait: " prefix).

Pointed out by: jilles

4 years agovfs: replace VOP_MARKATIME with VOP_MMAPPED
mjg [Sat, 1 Feb 2020 06:46:55 +0000 (06:46 +0000)]
vfs: replace VOP_MARKATIME with VOP_MMAPPED

The routine is only provided by ufs and is only used on mmap and exec.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23422

4 years agoufs: drop ufs_markatime from ufs_fifoops
mjg [Sat, 1 Feb 2020 06:41:44 +0000 (06:41 +0000)]
ufs: drop ufs_markatime from ufs_fifoops

The routine is only called on mmap and exec, both of which are invalid for
this type.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23421

4 years agovfs: save on atomics on the root vnode for absolute lookups
mjg [Sat, 1 Feb 2020 06:40:35 +0000 (06:40 +0000)]
vfs: save on atomics on the root vnode for absolute lookups

There are 2 back-to-back atomics on the vnode, but we can check upfront if one
is sufficient. Similarly we can handle relative lookups where current working
directory == root directory.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23427

4 years agovfs: add vrefactn
mjg [Sat, 1 Feb 2020 06:39:49 +0000 (06:39 +0000)]
vfs: add vrefactn

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

4 years agozfs: ZFS_WLOCK_TEARDOWN_INACTIVE_WLOCKED -> ZFS_TEARDOWN_INACTIVE_WLOCKED
mjg [Sat, 1 Feb 2020 06:39:10 +0000 (06:39 +0000)]
zfs: ZFS_WLOCK_TEARDOWN_INACTIVE_WLOCKED -> ZFS_TEARDOWN_INACTIVE_WLOCKED

Fix up the argument used in one case as well.

4 years agovlan: Fix panic when vnet jail with a vlan interface is destroyed
kp [Fri, 31 Jan 2020 22:54:44 +0000 (22:54 +0000)]
vlan: Fix panic when vnet jail with a vlan interface is destroyed

During vnet cleanup vnet_if_uninit() checks that no more interfaces remain in
the vnet. Any interface borrowed from another vnet is returned by
vnet_if_return(). Other interfaces (i.e. cloned interfaces) should have been
destroyed by their cloner at this point.

The if_vlan VNET_SYSUNINIT had priority SI_ORDER_FIRST, which means it had
equal priority as vnet_if_uninit(). In other words: it was possible for it to
be called *after* vnet_if_uninit(), which would lead to assertion failures.

Set the priority to SI_ORDER_ANY, like other cloners to ensure that vlan
interfaces are destroyed before we enter vnet_if_uninit().

The sys/net/if_vlan test provoked this.

4 years agoAdd two missing fences with comments describing them. These were found by
jeff [Fri, 31 Jan 2020 22:21:15 +0000 (22:21 +0000)]
Add two missing fences with comments describing them.  These were found by
inspection and after a lengthy discussion with jhb and kib.  They have not
produced test failures.

Don't pointer chase through cpu0's smr.  Use cpu correct smr even when not
in a critical section to reduce the likelihood of false sharing.

4 years agomake all is needed to generate .depend.*
bdrewery [Fri, 31 Jan 2020 21:08:33 +0000 (21:08 +0000)]
make all is needed to generate .depend.*

PR: 241746
X-MFC-With: r357043
MFC after: 1 week

4 years agosmrstress: Add 'publishing' fences to operations on smrs_current.
kib [Fri, 31 Jan 2020 20:30:50 +0000 (20:30 +0000)]
smrstress: Add 'publishing' fences to operations on smrs_current.

Reported and tested by: andrew
Reviewed by: jeff
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D23440

4 years agoMerge ^/head r357270 through r357349.
dim [Fri, 31 Jan 2020 19:40:40 +0000 (19:40 +0000)]
Merge ^/head r357270 through r357349.

4 years agoMerge r357348 from the clang 10.0.0 import branch:
dim [Fri, 31 Jan 2020 19:36:14 +0000 (19:36 +0000)]
Merge r357348 from the clang 10.0.0 import branch:

Disable new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
        WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
                                      ^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
                                        ^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
                  ^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace.  So disable it
for this case.

MFC after: 3 days

4 years agoDisable new clang 10.0.0 warnings about converting the result of shift
dim [Fri, 31 Jan 2020 19:35:21 +0000 (19:35 +0000)]
Disable new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
        WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
                                      ^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
                                        ^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
                  ^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace.  So disable it
for this case.

MFC after: 3 days

4 years agoMerge r357345 from the clang1000-import branch:
dim [Fri, 31 Jan 2020 19:06:49 +0000 (19:06 +0000)]
Merge r357345 from the clang1000-import branch:

Disable new clang 10.0.0 warnings about misleading indentation in flex.

As this is contributed code with very messy indentation, which will
almost certainly never be upgraded, just disable the warning.

MFC after: 3 days

4 years agoMerge r357342 from the clang1000-import branch:
dim [Fri, 31 Jan 2020 19:06:01 +0000 (19:06 +0000)]
Merge r357342 from the clang1000-import branch:

Work around two -Werror warning issues in googletest, which have been
solved upstream in the mean time.

The first issue is because one of googletest's generated headers contain
classes with a user-declared copy assignment operator, but rely on the
generation by the compiler of an implicit copy constructor, which is now
deprecated:

/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/internal/gtest-param-util-generated.h:5284:8: error: definition of implicit copy constructor for 'CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  void operator=(const CartesianProductHolder3& other);
       ^
/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/gtest-param-test.h:1277:10: note: in implicit copy constructor for 'testing::internal::CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' first required here
  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
         ^
/usr/src/tests/sys/fs/fusefs/io.cc:534:2: note: in instantiation of function template specialization 'testing::Combine<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' requested here
        Combine(Bool(),                                 /* async read */
        ^

For now, silence the warning using -Wno-deprecated-copy.

The second issue is because one of the googlemock test programs attempts
to use "unsigned wchar_t" and "signed wchar_t", which are non-standard
and at best, hazily defined:

contrib/googletest/googlemock/test/gmock-actions_test.cc:111:37: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get());
                                    ^
contrib/googletest/googlemock/test/gmock-actions_test.cc:112:36: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get());
                                   ^

For now, silence the warning using -Wno-signed-unsigned-wchar.

MFC after: 3 days

4 years agoDisable new clang 10.0.0 warnings about misleading indentation in flex.
dim [Fri, 31 Jan 2020 19:02:53 +0000 (19:02 +0000)]
Disable new clang 10.0.0 warnings about misleading indentation in flex.

As this is contributed code with very messy indentation, which will
almost certainly never be upgraded, just disable the warning.

MFC after: 3 days

4 years agoAdd stricter checks on user changes to SSTATUS.
jhb [Fri, 31 Jan 2020 19:00:48 +0000 (19:00 +0000)]
Add stricter checks on user changes to SSTATUS.

Rather than trying to blacklist which bits userland can't write to via
sigreturn() or setcontext(), only permit changes to whitelisted bits.

- Permit arbitrary writes to bits in the user-writable USTATUS
  register that shadows SSTATUS.

- Ignore changes in write-only bits maintained by the CPU.

- Ignore the user-supplied value of the FS field used to track
  floating point state and instead set it to a value matching the
  actions taken by set_fpcontext().

Discussed with: mhorne
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23338

4 years agoservices: Add PROFInet and EtherCAT.
pfg [Fri, 31 Jan 2020 18:55:21 +0000 (18:55 +0000)]
services: Add PROFInet and EtherCAT.

Both are used in industrial networks.

MFC after: 1 week

4 years agoWork around two -Werror warning issues in googletest, which have been
dim [Fri, 31 Jan 2020 18:26:23 +0000 (18:26 +0000)]
Work around two -Werror warning issues in googletest, which have been
solved upstream in the mean time.

The first issue is because one of googletest's generated headers contain
classes with a user-declared copy assignment operator, but rely on the
generation by the compiler of an implicit copy constructor, which is now
deprecated:

/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/internal/gtest-param-util-generated.h:5284:8: error: definition of implicit copy constructor for 'CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  void operator=(const CartesianProductHolder3& other);
       ^
/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/gtest-param-test.h:1277:10: note: in implicit copy constructor for 'testing::internal::CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' first required here
  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
         ^
/usr/src/tests/sys/fs/fusefs/io.cc:534:2: note: in instantiation of function template specialization 'testing::Combine<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' requested here
        Combine(Bool(),                                 /* async read */
        ^

For now, silence the warning using -Wno-deprecated-copy.

The second issue is because one of the googlemock test programs attempts
to use "unsigned wchar_t" and "signed wchar_t", which are non-standard
and at best, hazily defined:

contrib/googletest/googlemock/test/gmock-actions_test.cc:111:37: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get());
                                    ^
contrib/googletest/googlemock/test/gmock-actions_test.cc:112:36: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get());
                                   ^

For now, silence the warning using -Wno-signed-unsigned-wchar.

MFC after: 3 days

4 years agoregen src.conf.5 after r357338 BSD_CRTBEGIN retirement
emaste [Fri, 31 Jan 2020 18:26:13 +0000 (18:26 +0000)]
regen src.conf.5 after r357338 BSD_CRTBEGIN retirement

4 years agoMerge r357339 from the clang1000-import branch:
dim [Fri, 31 Jan 2020 18:13:00 +0000 (18:13 +0000)]
Merge r357339 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1661:4: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                        return (-1);
                        ^
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1658:5: note: previous statement is here
                } else
                  ^

The intent was to group the return statement with the previous syslog()
call.

MFC after: 3 days

4 years agoFix the following -Werror warning from clang 10.0.0 in bsnmpd:
dim [Fri, 31 Jan 2020 18:09:27 +0000 (18:09 +0000)]
Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1661:4: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                        return (-1);
                        ^
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1658:5: note: previous statement is here
                } else
                  ^

The intent was to group the return statement with the previous syslog()
call.

MFC after: 3 days

4 years agoretire BSD_CRTBEGIN option
emaste [Fri, 31 Jan 2020 18:04:04 +0000 (18:04 +0000)]
retire BSD_CRTBEGIN option

BSD crt is currently used on all architectures (other than sparc64).
Remove the option and use BSD crt everywhere as part of the GCC 4.2.1
retirement plan.

https://lists.freebsd.org/pipermail/freebsd-arch/2020-January/019823.html

PR: 239851
Reviewed by: andrew, brooks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23122

4 years agoFix 64-bit value of SSTATUS_SD to use an unsigned long.
jhb [Fri, 31 Jan 2020 17:49:15 +0000 (17:49 +0000)]
Fix 64-bit value of SSTATUS_SD to use an unsigned long.

While here, fix MSTATUS_SD to match SSTATUS_SD.

Reviewed by: mhorne
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23434

4 years agohwpstate(4): Ignore CurPstateLimit by default
cem [Fri, 31 Jan 2020 17:40:41 +0000 (17:40 +0000)]
hwpstate(4): Ignore CurPstateLimit by default

Add a sysctl knob to allow users to re-enable it, and document the knob and
default in cpufreq.4.  (While here, add a few unrelated updates to
cpufreq.4.)

It seems that the register value in some hardware simply reflects the
configured P-state.  This results in an inadvertent and unintended outcome
where the P-state can only walk down, and then the driver becomes "stuck" in
the slowest possible P-state.

The Linux driver never consults this register, so that's some evidence that
ignoring the contents are relatively harmless.

PR: 234733
Reported by: sigsys AT gmail.com, Erich Dollanksy <freebsd.ed.lists AT
sumeritec.com>

4 years agoRPI3: Add RPi4 firmware files to the FAT partition
kevans [Fri, 31 Jan 2020 15:56:08 +0000 (15:56 +0000)]
RPI3: Add RPi4 firmware files to the FAT partition

I've discovered I have this local diff that never got committed -- this
should have been a part of r355424.

Reproted by: Klaus Küchemann <maciphone2@googlemail.com>

4 years agoReimplement stack capture of running threads on i386 and amd64.
markj [Fri, 31 Jan 2020 15:43:33 +0000 (15:43 +0000)]
Reimplement stack capture of running threads on i386 and amd64.

After r355784 the td_oncpu field is no longer synchronized by the thread
lock, so the stack capture interrupt cannot be delievered precisely.
Fix this using a loop which drops the thread lock and restarts if the
wrong thread was sampled from the stack capture interrupt handler.

Change the implementation to use a regular interrupt instead of an NMI.
Now that we drop the thread lock, there is no advantage to the latter.

Simplify the KPIs.  Remove stack_save_td_running() and add a return
value to stack_save_td().  On platforms that do not support stack
capture of running threads, stack_save_td() returns EOPNOTSUPP.  If the
target thread is running in user mode, stack_save_td() returns EBUSY.

Reviewed by: kib
Reported by: mjg, pho
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23355

4 years agoCall the MAPTI command earlier in the ITS driver
andrew [Fri, 31 Jan 2020 11:33:11 +0000 (11:33 +0000)]
Call the MAPTI command earlier in the ITS driver

The GICv3 Software Overview suggests when allocating a new MSI/MSI-X
interrupt we need to call MAPD followed by MAPTI. Unfortunately the code
would place a MOVI command between these. This is invalid as it needs
values set by the MAPTI to be present.

Re-order so we allocate a temporary CPU for the interrupt, then use the
MAPTI command to assign the MSI to it.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agovfs: revert the overzealous assert added in r357285 to vgone
mjg [Fri, 31 Jan 2020 11:31:14 +0000 (11:31 +0000)]
vfs: revert the overzealous assert added in r357285 to vgone

The intent was to make it more likely to catch filesystems with custom
need_inactive routines which fail to call vn_need_pageq_flush (or do an
equivalent).

One immediate case which is missed is vgone from called by inactive itself.

A better assertion may land later. The routine is not added to vputx because
it is of no use to tmpfs et al.

Reported by: syzbot+5f697ec11f89b60941db@syzkaller.appspotmail.com

4 years agoRevert r357293.
hselasky [Fri, 31 Jan 2020 10:51:13 +0000 (10:51 +0000)]
Revert r357293.
The netisr uses rm_ locks not rms_ locks as noted by jeff@ .

Sponsored by: Mellanox Technologies

4 years agoWiden EPOCH(9) usage in mlx4en(4).
hselasky [Fri, 31 Jan 2020 10:41:47 +0000 (10:41 +0000)]
Widen EPOCH(9) usage in mlx4en(4).

Make sure all receive completion callbacks are covered by the network
EPOCH(9), because this is required when calling if_input() and
ether_input() after r357012.

Convert some spaces to tabs while at it.

Sponsored by: Mellanox Technologies

4 years agoOnly create one ITS configuration table
andrew [Fri, 31 Jan 2020 10:30:13 +0000 (10:30 +0000)]
Only create one ITS configuration table

When there are multiple ITS devices in the system we would allocate a
configuration table for each, however only one table is needed as all the
ITS devices share this.

Allocate a table only when the global table is unset.

While here fix the type of this to be a pointer to a uint8_t array as the
entries are all 8 bits wide.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agoIgnore the SMMUv3 and PMCG interrupt controller in the IORT tables
andrew [Fri, 31 Jan 2020 09:51:38 +0000 (09:51 +0000)]
Ignore the SMMUv3 and PMCG interrupt controller in the IORT tables

When mapping MSI/MSI-X interrupts throught he Arm IORT ACPI tables we may
need to ignore an interrupt controller even if it is within the bounds the
entry describes. When the SMMUv3 is not using GSIV (non-MSI/MSI-X)
interrupts we need to read the defined field. The Performance Monitoring
Counter Group always ignores the first table entry.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agozfs: convert z_teardown_inactive_lock to sleepable read-mostly lock
mjg [Fri, 31 Jan 2020 08:38:38 +0000 (08:38 +0000)]
zfs: convert z_teardown_inactive_lock to sleepable read-mostly lock

This eliminates a global serialisation point. It only gets write locked
on unmount.

Sample result doing an incremental -j 40 build:
before: 173.30s user 458.97s system 2595% cpu 24.358 total
after:  168.58s user 254.92s system 2211% cpu 19.147 total

4 years agozfs: provide macros to handle z_teardown_inactive_lock
mjg [Fri, 31 Jan 2020 08:37:35 +0000 (08:37 +0000)]
zfs: provide macros to handle z_teardown_inactive_lock

4 years agoAdd rms_try_rlock and rms_wowned.
mjg [Fri, 31 Jan 2020 08:36:49 +0000 (08:36 +0000)]
Add rms_try_rlock and rms_wowned.

4 years agoRemove an overzealous assert from rms_runlock.
mjg [Fri, 31 Jan 2020 08:36:23 +0000 (08:36 +0000)]
Remove an overzealous assert from rms_runlock.

4 years agoFix NOINET builds.
np [Fri, 31 Jan 2020 02:23:48 +0000 (02:23 +0000)]
Fix NOINET builds.

4 years agoImplement a simple UMA SMR stress testing tool.
jeff [Fri, 31 Jan 2020 02:18:56 +0000 (02:18 +0000)]
Implement a simple UMA SMR stress testing tool.

4 years agoDon't use "All rights reserved" in new copyrights.
jeff [Fri, 31 Jan 2020 02:08:09 +0000 (02:08 +0000)]
Don't use "All rights reserved" in new copyrights.

Requested by: rgrimes

4 years agoFix LINT build with MEMGUARD.
jeff [Fri, 31 Jan 2020 02:03:22 +0000 (02:03 +0000)]
Fix LINT build with MEMGUARD.

4 years agoImplement a safe memory reclamation feature that is tightly coupled with UMA.
jeff [Fri, 31 Jan 2020 00:49:51 +0000 (00:49 +0000)]
Implement a safe memory reclamation feature that is tightly coupled with UMA.

This is in the same family of algorithms as Epoch/QSBR/RCU/PARSEC but is
a unique algorithm.  This has 3x the performance of epoch in a write heavy
workload with less than half of the read side cost.  The memory overhead
is significantly lessened by limiting the free-to-use latency.  A synthetic
test uses 1/20th of the memory vs Epoch.  There is significant further
discussion in the comments and code review.

This code should be considered experimental.  I will write a man page after
it has settled.  After further validation the VM will begin using this
feature to permit lockless page lookups.

Both markj and cperciva tested on arm64 at large core counts to verify
fences on weaker ordering architectures.  I will commit a stress testing
tool in a follow-up.

Reviewed by: mmacy, markj, rlibby, hselasky
Discussed with: sbahara
Differential Revision: https://reviews.freebsd.org/D22586

4 years agoTrim duplicate CSR swaps from user exceptions.
jhb [Thu, 30 Jan 2020 22:19:48 +0000 (22:19 +0000)]
Trim duplicate CSR swaps from user exceptions.

The stack pointer is swapped with the sscratch CSR just before the
jump to cpu_exception_handler_user where the first instruction swaps
it again.  The two swaps together are a no-op, but the csr swap
instructions can be expensive (e.g. on Bluespec RISC-V cores csr swap
instructions force a full pipeline stall).

Reported by: jrtc27
Reviewed by: br
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23394

4 years agoRemove duplicated empty lines from kern/*.c
mjg [Thu, 30 Jan 2020 20:05:05 +0000 (20:05 +0000)]
Remove duplicated empty lines from kern/*.c

No functional changes.

4 years agoTidy up 2 comments in smp_rendezvous_cpus.
mjg [Thu, 30 Jan 2020 20:02:14 +0000 (20:02 +0000)]
Tidy up 2 comments in smp_rendezvous_cpus.

4 years agoamd64: sync up libc memcmp with the kernel version (r357309)
mjg [Thu, 30 Jan 2020 19:57:05 +0000 (19:57 +0000)]
amd64: sync up libc memcmp with the kernel version (r357309)

4 years agoamd64: speed up failing case for memcmp
mjg [Thu, 30 Jan 2020 19:56:22 +0000 (19:56 +0000)]
amd64: speed up failing case for memcmp

Instead of branching on up to 8 bytes, drop the size to 4.

Assorted clean ups while here.

Validated with glibc test suite.

4 years agoAssert that smp_rendezvous_cpus is called with interrupts enabled.
mjg [Thu, 30 Jan 2020 19:38:51 +0000 (19:38 +0000)]
Assert that smp_rendezvous_cpus is called with interrupts enabled.

4 years agovfs: keep the mount point referenced across sys_quotactl
mjg [Thu, 30 Jan 2020 19:38:12 +0000 (19:38 +0000)]
vfs: keep the mount point referenced across sys_quotactl

Otherwise we risk running into use-after-free.

In particular this codepath ends up dropping all protection before
suspending writes:

ufs_quotactl -> quotaoff_inchange -> vfs_write_suspend_umnt

Reported by: pho

4 years agoFix a bug in r357199.
kib [Thu, 30 Jan 2020 19:34:37 +0000 (19:34 +0000)]
Fix a bug in r357199.

Around a generic call to null_nodeget(), there is nothing that would
prevent the unmount of the nullfs mp until we process to the
insmntque1() point.  Calculate the VV_ROOT flag after insmntque1() to
not access mp->mnt_data before we have an exclusively locked vnode
from this mount point on the mp vnode list.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoRemove unused fields from struct pcb.
jhb [Thu, 30 Jan 2020 19:15:27 +0000 (19:15 +0000)]
Remove unused fields from struct pcb.

cpu_switch/throw() and savectx() do not save or restore any values in
these fields which mostly held non-callee-save registers.

makectx() copied these fields from kdb_frame, but they weren't used
except for PC_REGS using pcb_sepc.  Change PC_REGS to use
kdb_frame->tf_sepc directly instead.

Reviewed by: br
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23395

4 years agoShift the ITS processor ID after reading it.
andrew [Thu, 30 Jan 2020 18:49:19 +0000 (18:49 +0000)]
Shift the ITS processor ID after reading it.

When using the processor ID value we mask off the low and high bits that
should be zero. Unfortunatly we don't shift the ID value so it won't be
affected. Add the shift when reading the ID as this will need to align
with the address based target value.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agoFix an indentation bug in r357169.
brooks [Thu, 30 Jan 2020 18:34:08 +0000 (18:34 +0000)]
Fix an indentation bug in r357169.

4 years agoFix use of an uninitialized variable.
jhb [Thu, 30 Jan 2020 18:28:02 +0000 (18:28 +0000)]
Fix use of an uninitialized variable.

ctx (and thus ctx.flags) is stack garbage at the start of this
function, so initialize ctx.flags to an explicit value instead of
using binary operations on the garbage.

Reported by: gcc9
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D23368

4 years agocontrib/apr: Rip out bogus [CS]PRNG implementation
cem [Thu, 30 Jan 2020 18:12:41 +0000 (18:12 +0000)]
contrib/apr: Rip out bogus [CS]PRNG implementation

This construction used some relatively slow design involving SHA2; even if
it were fed real entropy (unclear; external to the design), it did not
handle fork in a safe way, and it was difficult to audit for correctness.
So just rip it out and use the very simple and known-correct arc4random(3)
interface in its place.