]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoas: add deprecation notice to the man page
emaste [Thu, 1 Aug 2019 19:01:27 +0000 (19:01 +0000)]
as: add deprecation notice to the man page

In the future FreeBSD will ship without GNU binutils 2.17.50.  Add a
note advising users who require GNU as to install the binutils port
or package.

Note that on armv7, arm64, amd64, i386 we currently ship only two
binutils tools (as and objdump).  A deprecation notice was added to
objdump's man page some time ago.

PR: 233611
Discussed with: jhb
MFC after: 1 week
Relnotes: Yes
Sponsored by: The FreeBSD Foundation

4 years agoCapsicumize size(1).
markj [Thu, 1 Aug 2019 18:57:37 +0000 (18:57 +0000)]
Capsicumize size(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21105

4 years agoCapsicumize readelf(1).
markj [Thu, 1 Aug 2019 18:57:08 +0000 (18:57 +0000)]
Capsicumize readelf(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21108

4 years agoCapsicumize addr2line(1).
markj [Thu, 1 Aug 2019 18:56:32 +0000 (18:56 +0000)]
Capsicumize addr2line(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21104

4 years agoAdd an MLINK for daemonfd(3).
markj [Thu, 1 Aug 2019 18:51:18 +0000 (18:51 +0000)]
Add an MLINK for daemonfd(3).

MFC after: 3 days

4 years agoFix formatting.
markj [Thu, 1 Aug 2019 18:51:06 +0000 (18:51 +0000)]
Fix formatting.

MFC after: 3 days

4 years agoOnly skip test cases sometimes failing in CI when they are running in CI
lwhsu [Thu, 1 Aug 2019 18:19:16 +0000 (18:19 +0000)]
Only skip test cases sometimes failing in CI when they are running in CI

Suggested by: jhb
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND
emaste [Thu, 1 Aug 2019 17:59:56 +0000 (17:59 +0000)]
readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

These bits are used for Intel CET IBT/Shadow Stack.

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

4 years agoRevert r349863 (ACPICA 20190703).
jkim [Thu, 1 Aug 2019 17:45:43 +0000 (17:45 +0000)]
Revert r349863 (ACPICA 20190703).

This commit caused boot failures on some systems.

Requested by: scottl

4 years agoiflib: Prevent kernel panic caused by loading driver with a specific interrupt config...
erj [Thu, 1 Aug 2019 17:37:25 +0000 (17:37 +0000)]
iflib: Prevent kernel panic caused by loading driver with a specific interrupt configuration

If a device has only 1 MSI-X interrupt available and does not support either
MSI or legacy interrupts, iflib_device_register() will fail, leak memory and
MSI resources, and the driver will not load. Worse, if another iflib-using
driver tries to unload afterwards, a kernel panic will occur because the
previous failed iflib driver loead did not properly call "taskqgroup_detach()"
during it's cleanup.

This patch is band-aid for this situation -- don't try allocating MSI or legacy
interrupts if a single MSI-X interrupt was allocated, but fail to load instead.
As well, during the cleanup, properly call taskqgroup_detach() on the admin
task to prevent panics when other iflib drivers unload.

This whole interrupt allocation process actually needs re-doing to properly
support devices with only a single MSI-X interrupt, devices that only support
MSI-X, non-PCI devices, and multiple non-MSIX interrupts, as well.

Signed-off-by: Eric Joyner <erj@freebsd.org>
Reviewed by: marius@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D20747

4 years agoWhen responding with an ABORT to an INIT chunk containing a
tuexen [Thu, 1 Aug 2019 17:36:15 +0000 (17:36 +0000)]
When responding with an ABORT to an INIT chunk containing a
HOSTNAME parameter or a parameter with an illegal length, only
include an error cause indicating why the ABORT was sent.
This also fixes an mbuf leak which could occur.

MFC after: 3 days

4 years agoiflib: remove kobject class reference increment
erj [Thu, 1 Aug 2019 17:28:36 +0000 (17:28 +0000)]
iflib: remove kobject class reference increment

Commit message from Jake:
In iflib_register, the context is initialized as a kobject using the
device driver's "driver" kobject class. As part of this, the function
mistakenly increments the ref counter.

The ref counter is incremented twice, once in the code directly, and
once again by kobj_class_compile. However, there is no associated
decrement in the detach path. Because of this, the ref counter will
never go back down to zero, and thus the kobject method table will never
be released.

Remove this unnecessary reference count increment.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: jhb@, erj@
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21125

4 years agoremove obsolete kernel debugging script
emaste [Thu, 1 Aug 2019 17:02:58 +0000 (17:02 +0000)]
remove obsolete kernel debugging script

For quite some time kgdb has been internally handling FreeBSD kernel
module state; add-on scripts and tools are not needed.  asf(8) served
a similar purpose to this script and was removed in r335222.

PR: 229046
Reported by: jhb
Sponsored by: The FreeBSD Foundation

4 years agoobjdump: be explicit that GNU objdump that will be removed
emaste [Thu, 1 Aug 2019 14:42:41 +0000 (14:42 +0000)]
objdump: be explicit that GNU objdump that will be removed

We may install llvm-objdump as objdump (see review D18307) or just
provide no /usr/bin/objdump, but either way GNU objdump won't be
installed in the future.

MFC after: 3 days

4 years agoTry to decrease the number of bugs in unionfs after the VV_TEXT flag removal.
kib [Thu, 1 Aug 2019 14:40:37 +0000 (14:40 +0000)]
Try to decrease the number of bugs in unionfs after the VV_TEXT flag removal.

- Provide unionfs_add_writecount() which passes the writecount to the
  lower or upper vnode as appropriate.
- In unionfs VOP_RECLAIM() implementation, annulate unionfs
  writecounts from upper or lower vnode.  It is not clear that it is
  always correct to remove the all references from either lower or
  upper vnode, but we currently do not track which vnode get how many
  refs anyway.

Reported and tested by: t_uemura@macome.co.jp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoobjdump: move deprecation notice to indended spot in the man page
emaste [Thu, 1 Aug 2019 14:39:26 +0000 (14:39 +0000)]
objdump: move deprecation notice to indended spot in the man page

r335217 added a deprecation notice to the source file for the objdump
man page, and r335219 added it to the rendered objdump.1, but in the
wrong spot.

MFC after: 3 days

4 years agoMake umtxq_check_susp() to correctly handle thread exit requests.
kib [Thu, 1 Aug 2019 14:34:27 +0000 (14:34 +0000)]
Make umtxq_check_susp() to correctly handle thread exit requests.

The check for P_SINGLE_EXIT was shadowed by the (P_SHOULDSTOP || traced) check.

Reported by: bdrewery (might be)
Reviewed by: markj
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21124

4 years agoThis adds the third step in getting BBR into the tree. BBR and
rrs [Thu, 1 Aug 2019 14:17:31 +0000 (14:17 +0000)]
This adds the third step in getting BBR into the tree. BBR and
an updated rack depend on having access to the new
ratelimit api in this commit.

Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D20953

4 years agonewvers: append commit count to uname version string
emaste [Thu, 1 Aug 2019 14:13:04 +0000 (14:13 +0000)]
newvers: append commit count to uname version string

In a git world this provides a facsimile of a monotonically increasing
version number.  This might be refined further, but this provides a
starting point for investigation.

Reviewed by: cem
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20462

4 years agoacpi_resource.c: mention ThunderX2 firmware revision with issue
emaste [Thu, 1 Aug 2019 14:02:59 +0000 (14:02 +0000)]
acpi_resource.c: mention ThunderX2 firmware revision with issue

Presumably this will be fixed in the next version, and the workaround
could eventually be removed.  See r330113 and r346066 details.

4 years agotelnet: use asprintf for r349890 change
emaste [Thu, 1 Aug 2019 13:46:04 +0000 (13:46 +0000)]
telnet: use asprintf for r349890 change

Suggested by: imp
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation

4 years agoppp: correct echo-req magic number on big endian archs
emaste [Thu, 1 Aug 2019 13:42:58 +0000 (13:42 +0000)]
ppp: correct echo-req magic number on big endian archs

The magic number is a 32-bit quantity; use uint32_t to match hton's
return type and avoid sending zeros (upper 32 bits) on big-endian
architectures.

PR: 184141
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoAllow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib,
delphij [Thu, 1 Aug 2019 06:35:33 +0000 (06:35 +0000)]
Allow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib,
with an eventual goal to convert all legacl zlib callers to the new zlib
version:

 * Move generic zlib shims that are not specific to zlib 1.0.4 to
   sys/dev/zlib.
 * Connect new zlib (1.2.11) to the zlib kernel module, currently built
   with Z_SOLO.
 * Prefix the legacy zlib (1.0.4) with 'zlib104_' namespace.
 * Convert sys/opencrypto/cryptodeflate.c to use new zlib.
 * Remove bundled zlib 1.2.3 from ZFS and adapt it to new zlib and make
   it depend on the zlib module.
 * Fix Z_SOLO build of new zlib.

PR: 229763
Submitted by: Yoshihiro Ota <ota j email ne jp>
Reviewed by: markm (sys/dev/zlib/zlib_kmod.c)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19706

4 years agopowerpc/powernv: Only clear EEH freeze for some errors
jhibbits [Thu, 1 Aug 2019 03:59:25 +0000 (03:59 +0000)]
powerpc/powernv: Only clear EEH freeze for some errors

Only clear an EEH freeze if an error occurs.  However, if an OPAL_HARDWARE
error is returned, this indicates a hardware failure which cannot be
unfrozen, and instead needs a hardware reset.  Attempting to unfreeze a
broken PCH will result in console spam for each attempt.  To avoid the spam,
just don't do it.

4 years agopowerpc64/mmu: Use a SLIST for the PVO delete list, instead of a RB_TREE
jhibbits [Thu, 1 Aug 2019 03:55:58 +0000 (03:55 +0000)]
powerpc64/mmu: Use a SLIST for the PVO delete list, instead of a RB_TREE

Summary:
Although it's convenient to reuse the pvo_plist for deletion, RB_TREE
insertion and removal is not free, and can result in a lot of extra work
to rebalance the tree.  Instead, use a SLIST as a LIFO delete queue,
which gives us almost free insertion, deletion, and traversal.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D21061

4 years agovmx: use C99 bool, not boolean_t
emaste [Thu, 1 Aug 2019 02:16:48 +0000 (02:16 +0000)]
vmx: use C99 bool, not boolean_t

Bhyve's vmm is a self-contained modern component and thus a good
candidate for use of C99 types.

Reviewed by: jhb, kib, markj, Patrick Mooney
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21036

4 years agoAdd an entry for the copy_file_range(2) syscall.
rmacklem [Wed, 31 Jul 2019 23:36:23 +0000 (23:36 +0000)]
Add an entry for the copy_file_range(2) syscall.

4 years agoWhen updating the user or group disk quotas for the return of inodes or
mckusick [Wed, 31 Jul 2019 22:44:58 +0000 (22:44 +0000)]
When updating the user or group disk quotas for the return of inodes or
disk blocks, set the FORCE flag in the call to chkiq() or chkdq() since
the user is always allowed to return resources and hence there is no need
to check the user's credential .

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-1-UFS-1: Denial Of Service in mount (prison_priv_check)
Discussed with: kib
MFC:            1 week
Sponsored by:   Netflix

4 years agoSmall cleanup, no functional change intended.
tuexen [Wed, 31 Jul 2019 21:39:03 +0000 (21:39 +0000)]
Small cleanup, no functional change intended.

MFC after: 3 days

4 years agoConsistently cleanup mbufs in case of other memory errors.
tuexen [Wed, 31 Jul 2019 21:29:17 +0000 (21:29 +0000)]
Consistently cleanup mbufs in case of other memory errors.

MFC after: 3 days

4 years agoadd forgotten opening bracket "("
wosch [Wed, 31 Jul 2019 21:21:34 +0000 (21:21 +0000)]
add forgotten opening bracket "("

PR: 237514
Reviewed by: allanjude
MFC after: soon for 11.3 and 12 series
Differential Revision: https://reviews.freebsd.org/D21009

4 years ago[PPC64] Implement CAS
luporl [Wed, 31 Jul 2019 20:31:36 +0000 (20:31 +0000)]
[PPC64] Implement CAS

Guest PPC OSs running under a hypervisor may communicate the features they
support, in order for the hypervisor to expose a virtualized machine in the way
the client (guest OS) expects (see LoPAPR 1.1 - B.6.2.3).

This is done by calling the "/ibm,client-architecture-support" (CAS) method,
informing supported features in option vectors.  Until now, FreeBSD wasn't
using CAS, but instead relied on hypervisor/QEMU's defaults.

The problem is that, without CAS, it is very inconvenient to run POWER9 VMs on
a POWER9 host running with radix enabled.  This happens because, in this case,
the QEMU default is to present the guest OS a dual MMU (HPT/RPT), instead of
presenting a regular HPT MMU, as FreeBSD expects, resulting in an early panic.
The known workarounds required either changing the host to disable radix or
passing a flag to QEMU to run in a POWER8 compatible mode.

With CAS, FreeBSD is now able to communicate that it wants an HPT MMU,
independent of the host setup, which now makes FreeBSD work on POWER9/pseries,
with KVM enabled and without hugepages (support added in a previous commit).

As CAS is invoked through OpenFirmware's call-method interface, it needs to be
performed early, when OpenFirmware is still operational. Besides, now that FDT
is the default way to inspect the device tree on PPC, OFW call-method feature
will be unavailable by default, when control is passed to the kernel. Because
of this, the call to CAS is being performed at the loader, instead of at the
kernel.

To avoid regressions with old platforms, this change uses CAS only on
POWER8/POWER9.

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

4 years agoMake randomized stack gap between strings and pointers to argv/envs.
kib [Wed, 31 Jul 2019 20:23:10 +0000 (20:23 +0000)]
Make randomized stack gap between strings and pointers to argv/envs.

This effectively makes the stack base on the csu _start entry
randomized.

The gap is enabled if ASLR is for the ABI is enabled, and then
kern.elf{64,32}.aslr.stack_gap specify the max percentage of the
initial stack size that can be wasted for gap.  Setting it to zero
disables the gap, and max is capped at 50%.

Only amd64 for now.

Reviewed by: cem, markj
Discussed with: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21081

4 years agoAvoid conflicts with libc symbols in libthr jump table.
kib [Wed, 31 Jul 2019 20:04:39 +0000 (20:04 +0000)]
Avoid conflicts with libc symbols in libthr jump table.

In some corner cases of static linking and unexpected libraries order
on the linker command line, libc symbol might preempt the same libthr
symbol, in which case libthr jump table points back to libc causing
either infinite recursion or loop.  Handle all of such symbols by
using private libthr names for them, ensuring that the right pointers
are installed into the table.

In collaboration with: arichardson
PR: 239475
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21088

4 years agognop: add note to the RELNOTES
oshogbo [Wed, 31 Jul 2019 19:32:39 +0000 (19:32 +0000)]
gnop: add note to the RELNOTES

Submitted by: markj

4 years agoAvoid conflicts with libc symbols in libthr jump table.
kib [Wed, 31 Jul 2019 19:27:20 +0000 (19:27 +0000)]
Avoid conflicts with libc symbols in libthr jump table.

In some corner cases of static linking and unexpected libraries order
on the linker command line, libc symbol might preempt the same libthr
symbol, in which case libthr jump table points back to libc causing
either infinite recursion or loop.  Handle all of such symbols by
using private libthr names for them, ensuring that the right pointers
are installed into the table.

In collaboration with: arichardson
PR: 239475
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21088

4 years agoRegen.
kib [Wed, 31 Jul 2019 19:20:39 +0000 (19:20 +0000)]
Regen.

4 years agofreebsd32 shims for copy_file_range(2).
kib [Wed, 31 Jul 2019 19:20:05 +0000 (19:20 +0000)]
freebsd32 shims for copy_file_range(2).

Reviewed by: brooks, rmacklem (previous version)
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21092

4 years agoFix handling of transient casueword(9) failures in do_sem_wait().
kib [Wed, 31 Jul 2019 19:16:49 +0000 (19:16 +0000)]
Fix handling of transient casueword(9) failures in do_sem_wait().

In particular, restart should be only done when the failure is
transient.  For this, recheck the count1 value after the operation.

Note that do_sem_wait() is older usem interface.

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

4 years agoFeature-complete NVMe Namespace Management.
mav [Wed, 31 Jul 2019 18:44:20 +0000 (18:44 +0000)]
Feature-complete NVMe Namespace Management.

This adds several previously missed but important subcommands to list
namespaces and controllers.  It also fixes few previously added but
just found with real testing to be broken subcommands.

Also while there, add possibility to explicitly specify nsid for
`nvmecontrol identify` subcommand.  It may be useful to specify nsids
not having own devices, for example 0xffffffff, or just newly created
ones.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.

4 years agognop: style nits
oshogbo [Wed, 31 Jul 2019 17:51:06 +0000 (17:51 +0000)]
gnop: style nits

4 years agognop: Introduce requests delay.
oshogbo [Wed, 31 Jul 2019 17:47:12 +0000 (17:47 +0000)]
gnop: Introduce requests delay.

This allows to simulated disk that is responding slowly to the IO requests.

Reviewed by: markj, bcr, pjd (previous version)
Differential Revision: https://reviews.freebsd.org/D21052

4 years agopf: zero (another) output buffer in pfioctl
emaste [Wed, 31 Jul 2019 16:58:09 +0000 (16:58 +0000)]
pf: zero (another) output buffer in pfioctl

Avoid potential structure padding leak.  r350294 identified a leak via
static analysis; although there's no report of a leak with the
DIOCGETSRCNODES ioctl it's a good practice to zero the memory.

Suggested by: kp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years ago[PPC64] Backport fix for missing IRELATIVE relocations
luporl [Wed, 31 Jul 2019 16:22:05 +0000 (16:22 +0000)]
[PPC64] Backport fix for missing IRELATIVE relocations

This is a backport of LLVM commit 8331f61a51a7a0a1efbf5ed398e181593023d151,
llvm-svn: 353981:

ELF: Allow GOT relocs pointing to non-preemptable ifunc to resolve to an
IRELATIVE where possible.

This is needed in order to make ifuncs work correctly on PPC64.

It fixes an issue with lld, in which it would skip emitting necessary IRELATIVE
relocations.  Without this change, indirect calls to ifuncs would result in a
segmentation fault, in static binaries or when defined in the main binary
(outside shared libraries).

This change also reverts the local
"Preserve relocations against ifuncs when -zifunc-noplt" commit and
replaces it by its upstream version, as part of the merge.

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

4 years agokern_shm_open: push O_CLOEXEC into caller control
kevans [Wed, 31 Jul 2019 15:16:51 +0000 (15:16 +0000)]
kern_shm_open: push O_CLOEXEC into caller control

The motivation for this change is to allow wrappers around shm to be written
that don't set CLOEXEC. kern_shm_open currently accepts O_CLOEXEC but sets
it unconditionally. kern_shm_open is used by the shm_open(2) syscall, which
is mandated by POSIX to set CLOEXEC, and CloudABI's sys_fd_create1().
Presumably O_CLOEXEC is intended in the latter caller, but it's unclear from
the context.

sys_shm_open() now unconditionally sets O_CLOEXEC to meet POSIX
requirements, and a comment has been dropped in to kern_fd_open() to explain
the situation and add a pointer to where O_CLOEXEC setting is maintained for
shm_open(2) correctness. CloudABI's sys_fd_create1() also unconditionally
sets O_CLOEXEC to match previous behavior.

This also has the side-effect of making flags correctly reflect the
O_CLOEXEC status on this fd for the rest of kern_shm_open(), but a
glance-over leads me to believe that it didn't really matter.

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21119

4 years agoIn pmap_advise(), when we encounter a superpage mapping, we first demote the
alc [Wed, 31 Jul 2019 05:38:39 +0000 (05:38 +0000)]
In pmap_advise(), when we encounter a superpage mapping, we first demote the
mapping and then destroy one of the 4 KB page mappings so that there is a
potential trigger for repromotion.  Currently, we destroy the first 4 KB
page mapping that falls within the (current) superpage mapping or the
virtual address range [sva, eva).  However, I have found empirically that
destroying the last 4 KB mapping produces slightly better results,
specifically, more promotions and fewer failed promotion attempts.
Accordingly, this revision changes pmap_advise() to destroy the last 4 KB
page mapping.  It also replaces some nearby uses of boolean_t with bool.

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

4 years agoTune some commands desctiption.
mav [Wed, 31 Jul 2019 04:19:53 +0000 (04:19 +0000)]
Tune some commands desctiption.

MFC after: 2 weeks

4 years agoFix usage printing for nested subcommands.
mav [Wed, 31 Jul 2019 03:48:48 +0000 (03:48 +0000)]
Fix usage printing for nested subcommands.

Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc.

MFC after: 2 weeks

4 years agoUse VNASSERT() in checked VOP wrappers.
markj [Tue, 30 Jul 2019 22:41:25 +0000 (22:41 +0000)]
Use VNASSERT() in checked VOP wrappers.

Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21120

4 years agoMake `camcontrol modepage` to use 10 byte commands.
mav [Tue, 30 Jul 2019 20:58:56 +0000 (20:58 +0000)]
Make `camcontrol modepage` to use 10 byte commands.

While old devices may not support 10 byte MODE SENSE/MODE SELECT commands,
new ones may not be able to report all mode pages with 6 byte commands.

This patch makes camcontrol by default start with 10 byte commands and
fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoAdd a CXXWARNFLAGS variable
asomers [Tue, 30 Jul 2019 19:34:39 +0000 (19:34 +0000)]
Add a CXXWARNFLAGS variable

Some warning flags are valid for C++ but not C. GCC 8 complains if you pass
such flags when building a C file. Using a separate variable for these
flags allows building both C and C++ files in the same directory (such as
the fusefs tests) under GCC.

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

4 years agolinuxulator: rename linux_locore.s to .asm
emaste [Tue, 30 Jul 2019 17:18:31 +0000 (17:18 +0000)]
linuxulator: rename linux_locore.s to .asm

It is assembled using "${CC} -x assembler-with-cpp", which by convention
(bsd.suffixes.mk) uses the .asm extension.

This is a portion of the review referenced below (D18344).  That review
also renamed linux_support.s to .S, but that is a functional change
(using the compiler's integrated assembler instead of as) and will be
revisited separately.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18344

4 years agoEnable witness(4) blessings.
markj [Tue, 30 Jul 2019 17:09:58 +0000 (17:09 +0000)]
Enable witness(4) blessings.

witness has long had a facility to "bless" designated lock pairs.  Lock
order reversals between a pair of blessed locks are not reported upon.
We have a number of long-standing false positive LOR reports; start
marking well-understood LORs as blessed.

This change hides reports about UFS vnode locks and the UFS dirhash
lock, and UFS vnode locks and buffer locks, since those are the two that
I observe most often.  In the long term it would be preferable to be
able to limit blessings to a specific site where a lock is acquired,
and/or extend witness to understand why some lock order reversals are
valid (for example, if code paths with conflicting lock orders are
serialized by a third lock), but in the meantime the false positives
frequently confuse users and generate bug reports.

Reviewed by: cem, kib, mckusick
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21039

4 years agocirrus.yml: stop fetching OVMF.fd now that we're using the pkg
emaste [Tue, 30 Jul 2019 16:40:33 +0000 (16:40 +0000)]
cirrus.yml: stop fetching OVMF.fd now that we're using the pkg

Missed in r350302

Sponsored by: The FreeBSD Foundation

4 years agoRegenerate after r350447.
markj [Tue, 30 Jul 2019 16:01:16 +0000 (16:01 +0000)]
Regenerate after r350447.

4 years agoEnable copy_file_range(2) in capability mode.
markj [Tue, 30 Jul 2019 15:59:44 +0000 (15:59 +0000)]
Enable copy_file_range(2) in capability mode.

copy_file_range() operates on a pair of file descriptors; it requires
CAP_READ for the source descriptor and CAP_WRITE for the destination
descriptor.

Reviewed by: kevans, oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21113

4 years agoHandle refcount(9) wraparound.
markj [Tue, 30 Jul 2019 15:57:31 +0000 (15:57 +0000)]
Handle refcount(9) wraparound.

Attempt to mitigate the security risks around refcount overflows by
introducing a "saturated" state for the counter.  Once a counter reaches
INT_MAX+1, subsequent acquire and release operations will blindly set
the counter value to INT_MAX + INT_MAX/2, ensuring that the protected
resource will not be freed; instead, it will merely be leaked.

The approach introduces a small race: if a refcount value reaches
INT_MAX+1, a subsequent release will cause the releasing thread to set
the counter to the saturation value after performing the decrement.  If
in the intervening window INT_MAX refcount releases are performed by a
different thread, a use-after-free is possible.  This is very difficult
to trigger in practice, and any situation where it could be triggered
would likely be vulnerable to reference count wraparound problems
to begin with.  An alternative would be to use atomic_cmpset to acquire
and release references, but this would introduce a larger performance
penalty, particularly when the counter is contended.

Note that refcount_acquire_checked(9) maintains its previous behaviour;
code which must accurately track references should use it instead of
refcount_acquire(9).

Reviewed by: kib, mjg
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21089

4 years agoCreate the /var/account dir with mode 0750; this is a followup to r349974.
ian [Tue, 30 Jul 2019 15:51:28 +0000 (15:51 +0000)]
Create the /var/account dir with mode 0750; this is a followup to r349974.

The rc.d/account script contains code to create the /var/account dir, so
it hadn't occurred to me that it is normally created via mtree; thanks to
jilles@ for pointing it out.

4 years agoFix EFI loader build when LOADER_NET_SUPPORT=no.
br [Tue, 30 Jul 2019 14:54:18 +0000 (14:54 +0000)]
Fix EFI loader build when LOADER_NET_SUPPORT=no.

Sponsored by: DARPA, AFRL

4 years agoFix MMCCAM kernel build.
br [Tue, 30 Jul 2019 14:21:00 +0000 (14:21 +0000)]
Fix MMCCAM kernel build.

Sponsored by: DARPA, AFRL

4 years agoAdd support for the SD/MMC controller found in Terasic DE10-Pro
br [Tue, 30 Jul 2019 12:51:14 +0000 (12:51 +0000)]
Add support for the SD/MMC controller found in Terasic DE10-Pro
(an Intel Stratix 10 GX/SX FPGA Development Kit).

Set the bus speed manually due to lack of clock management support.

Sponsored by: DARPA, AFRL

4 years agofileargs: fix formating in EXAMPLES
oshogbo [Tue, 30 Jul 2019 08:53:03 +0000 (08:53 +0000)]
fileargs: fix formating in EXAMPLES

PR: 239523
Submitted by: mikael.urankar@gmail.com

4 years agoBump __FreeBSD_version after removal of gzip'ed a.out support.
delphij [Tue, 30 Jul 2019 05:14:28 +0000 (05:14 +0000)]
Bump __FreeBSD_version after removal of gzip'ed a.out support.

4 years agoRemove gzip'ed a.out support.
delphij [Tue, 30 Jul 2019 05:13:16 +0000 (05:13 +0000)]
Remove gzip'ed a.out support.

The current implementation of gzipped a.out support was based
on a very old version of InfoZIP which ships with an ancient
modified version of zlib, and was removed from the GENERIC
kernel in 1999 when we moved to an ELF world.

PR: 205822
Reviewed by: imp, kib, emaste, Yoshihiro Ota <ota at j.email.ne.jp>
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D21099

4 years agoFix sound on headset jack for ALC255 and ALC256 codec.
araujo [Tue, 30 Jul 2019 02:01:49 +0000 (02:01 +0000)]
Fix sound on headset jack for ALC255 and ALC256 codec.

PR: 219350 [1], [2]
Submitted by: Masachika ISHIZUKA (ish_at_amail.plala.or.jp) [1]
Neel Chauhan (neel_at_neelc.org) [2]
uri Momotyuk (yurkis_at_gmail.com) [3]
Reported by: miwi
Reviewed by: mav
Obtained from: https://github.com/trueos/trueos/pull/279 [3]
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19017

4 years agoMerge r3778 and r3779 from ELFToolchain.
markj [Mon, 29 Jul 2019 22:07:43 +0000 (22:07 +0000)]
Merge r3778 and r3779 from ELFToolchain.

Modify strip(1) to not accept multiple input files when an output
file is specified.  There is no good way to handle this combination,
and the change is compatible with binutils.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoCentralize the logic in vfs_vmio_unwire() and sendfile_free_page().
markj [Mon, 29 Jul 2019 22:01:28 +0000 (22:01 +0000)]
Centralize the logic in vfs_vmio_unwire() and sendfile_free_page().

Both of these functions atomically unwire a page, optionally attempt
to free the page, and enqueue or requeue the page.  Add functions
vm_page_release() and vm_page_release_locked() to perform the same task.
The latter must be called with the page's object lock held.

As a side effect of this refactoring, the buffer cache will no longer
attempt to free mapped pages when completing direct I/O.  This is
consistent with the handling of pages by sendfile(SF_NOCACHE).

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

4 years agoseqc: add man page
oshogbo [Mon, 29 Jul 2019 21:53:02 +0000 (21:53 +0000)]
seqc: add man page

Reviewed by: markj
Earlier version reviewed by: emaste, mjg, bcr, 0mp
Differential Revision: https://reviews.freebsd.org/D16744

4 years agoproc: make clear_orphan an public API
oshogbo [Mon, 29 Jul 2019 21:42:57 +0000 (21:42 +0000)]
proc: make clear_orphan an public API

This will be useful for other patches with process descriptors.
Change its name as well.

Reviewed by: markj, kib

4 years agolibcasper: remove reference to deprecated system.random
oshogbo [Mon, 29 Jul 2019 21:26:26 +0000 (21:26 +0000)]
libcasper: remove reference to deprecated system.random

4 years agoHave arm64's pmap_fault() handle WnR faults on dirty PTEs.
markj [Mon, 29 Jul 2019 21:21:53 +0000 (21:21 +0000)]
Have arm64's pmap_fault() handle WnR faults on dirty PTEs.

If we take a WnR permission fault on a managed, writeable and dirty
PTE, simply return success without calling the main fault handler.  This
situation can occur if multiple threads simultaneously access a clean
writeable mapping and trigger WnR faults; losers of the race to mark the
PTE dirty would end up calling the main fault handler, which had no work
to do.

Reported by: alc
Reviewed by: alc
MFC with: r350004
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21097

4 years agosendfile: don't panic when VOP_GETPAGES_ASYNC returns an error
asomers [Mon, 29 Jul 2019 20:50:26 +0000 (20:50 +0000)]
sendfile: don't panic when VOP_GETPAGES_ASYNC returns an error

This is a partial merge of 350144 from projects/fuse2

PR: 236466
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21095

4 years agoprintf(1): Note that \c only works in %b strings
jilles [Mon, 29 Jul 2019 20:43:07 +0000 (20:43 +0000)]
printf(1): Note that \c only works in %b strings

PR: 238313
Reported by: Andras Farkas
MFC after: 1 week

4 years agoUse present now scsi_mode_sense_subpage().
mav [Mon, 29 Jul 2019 20:41:11 +0000 (20:41 +0000)]
Use present now scsi_mode_sense_subpage().

MFC after: 2 weeks

4 years agoRemove a duplicate file listing in the libarchive tests.
markj [Mon, 29 Jul 2019 20:37:04 +0000 (20:37 +0000)]
Remove a duplicate file listing in the libarchive tests.

MFC after: 3 days

4 years agoRemove an unneeded trunc_page() in pmap_fault().
markj [Mon, 29 Jul 2019 20:31:28 +0000 (20:31 +0000)]
Remove an unneeded trunc_page() in pmap_fault().

Reported by: alc
MFC with: r350004
Sponsored by: The FreeBSD Foundation

4 years agoAvoid relying on header pollution from sys/refcount.h.
markj [Mon, 29 Jul 2019 20:26:01 +0000 (20:26 +0000)]
Avoid relying on header pollution from sys/refcount.h.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoAdd mkostempsat(3).
markj [Mon, 29 Jul 2019 19:02:16 +0000 (19:02 +0000)]
Add mkostempsat(3).

This is a variant of mkostemps() which takes a directory descriptor and
returns a descriptor for a tempfile relative to that directory.  Unlike
the other mktemp functions, mkostempsat() can be used in capability
mode.

Reviewed by: cem
Discussed with: brooks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21031

4 years agoAdd glue driver for Altera SOCFPGA Ethernet MAC (EMAC) found in
br [Mon, 29 Jul 2019 16:32:23 +0000 (16:32 +0000)]
Add glue driver for Altera SOCFPGA Ethernet MAC (EMAC) found in
Terasic DE10-Pro (an Intel Stratix 10 GX/SX FPGA Development Kit).

The Altera EMAC is an instance of Synopsys DesignWare Gigabit MAC.

This driver sets correct clock range for MDIO interface on Intel Stratix 10
platform.

This is required due to lack of support for clock manager device for
this platform that could tell us the clock frequency value for ethernet
clock domain.

Sponsored by: DARPA, AFRL

4 years agodd ipfw_get_action() function to get the pointer to action opcode.
ae [Mon, 29 Jul 2019 15:09:12 +0000 (15:09 +0000)]
dd ipfw_get_action() function to get the pointer to action opcode.

ACTION_PTR() returns pointer to the start of rule action section,
but rule can keep several rule modifiers like O_LOG, O_TAG and O_ALTQ,
and only then real action opcode is stored.

ipfw_get_action() function inspects the rule action section, skips
all modifiers and returns action opcode.

Use this function in ipfw_reset_eaction() and flush_nat_ptrs().

MFC after: 1 week
Sponsored by: Yandex LLC

4 years agoriscv: Fix copyin/copyout
kp [Mon, 29 Jul 2019 14:59:14 +0000 (14:59 +0000)]
riscv: Fix copyin/copyout

r343275 introduced a performance optimisation to the copyin/copyout
routines by attempting to copy word-per-word rather than byte-per-byte
where possible.

This optimisation failed to account for cases where the buffer is longer
than XLEN_BYTES, but due to misalignment does not not allow for any
word-sized copies. E.g. a 9 byte buffer (with XLEN_BYTES == 8) which is
misaligned by 2 bytes. The code nevertheless did a single full-word
copy, which meant we copied too much data. This potentially clobbered
other data.

This is most easily demonstrated by a simple `sysctl -a`.

Fix it by not assuming that we'll always have at least one full-word
copy to do, but instead checking the remaining length first.

Reviewed by: markj@, mhorne@, br@ (previous version)
MFC after: 1 week
Sponsored by: Axiado
Differential Revision: https://reviews.freebsd.org/D21100

4 years agoFind the correct node of PHY chip using "phy-handle" property of
br [Mon, 29 Jul 2019 14:58:29 +0000 (14:58 +0000)]
Find the correct node of PHY chip using "phy-handle" property of
ethernet MAC node.

This fixes operation on Terasic DE10-Pro (Intel Stratix 10 GX/SX
FPGA Development Kit).

Sponsored by: DARPA, AFRL

4 years agopf: Remove partial RFC2675 support
kp [Mon, 29 Jul 2019 13:21:31 +0000 (13:21 +0000)]
pf: Remove partial RFC2675 support

Remove our (very partial) support for RFC2675 Jumbograms. They're not
used, not actually supported and not a good idea.

Reviewed by: thj@
Differential Revision: https://reviews.freebsd.org/D21086

4 years agoAvoid possible lock leaking.
ae [Mon, 29 Jul 2019 12:55:48 +0000 (12:55 +0000)]
Avoid possible lock leaking.

After r343619 ipfw uses own locking for packets flow. PULLUP_LEN() macro
is used in ipfw_chk() to make m_pullup(). When m_pullup() fails, it just
returns via `goto pullup_failed`. There are two places where PULLUP_LEN()
is called with IPFW_PF_RLOCK() held.

Add PULLUP_LEN_LOCKED() macro to use in these places to be able release
the lock, when m_pullup() fails.

Sponsored by: Yandex LLC

4 years agoarm: ti: cpsw: Check the new slave node address
manu [Mon, 29 Jul 2019 10:42:15 +0000 (10:42 +0000)]
arm: ti: cpsw: Check the new slave node address

Since DTS from >= Linux 5.0 the slave address are relative to the parent
node address and aren't the full ones.
Check both so the cpsw driver can find the phy id.

4 years agoarm: ti: Get the hwmods property either from the node or the parent
manu [Mon, 29 Jul 2019 10:40:51 +0000 (10:40 +0000)]
arm: ti: Get the hwmods property either from the node or the parent

r350229 changed the code to lookup the ti,hwmods property in the parent
as it's now like that in the DTS from >= Linux 5.0, allow the property
to be also in the node itself so we can boot with an older DTB.

Reported by: "Dr. Rolf Jansen" <rj@obsigna.com>

4 years agoWhen performing after_idle() or post_recovery(), don't disable the
tuexen [Mon, 29 Jul 2019 09:19:48 +0000 (09:19 +0000)]
When performing after_idle() or post_recovery(), don't disable the
DCTCP specific methods. Also fallthrough NewReno for non ECN capable
TCP connections and improve the integer arithmetic.

Obtained from: Richard Scheffenegger
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20550

4 years ago* Improve input validation of sysctl parameters for DCTPC.
tuexen [Mon, 29 Jul 2019 08:50:35 +0000 (08:50 +0000)]
* Improve input validation of sysctl parameters for DCTPC.
* Initialize the alpha parameter to a conservative value (like Linux)
* Improve handling of arithmetic.
* Improve man-page

Obtained from: Richard Scheffenegger
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20549

4 years agoAdd some new fields and bits from NVMe 1.4.
mav [Mon, 29 Jul 2019 03:28:46 +0000 (03:28 +0000)]
Add some new fields and bits from NVMe 1.4.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoAdd support for tethering with Nokia 7 plus and the alike.
hselasky [Sun, 28 Jul 2019 21:47:04 +0000 (21:47 +0000)]
Add support for tethering with Nokia 7 plus and the alike.

PR: 239495
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix printing of Server Re-Failed and Server Faults.
rmacklem [Sun, 28 Jul 2019 21:44:01 +0000 (21:44 +0000)]
Fix printing of Server Re-Failed and Server Faults.

nfsstat -s prints bogus large numbers for the Server Re-Failed and Server
Faults fields. This was introduced by r328588.
Although I know nothing about libxo, these lines aren't titles and this
patch seems to fix the problem, so I am committing it for rea@ who emailed
it to me.
It also deleted the trailing ':' from the title lines, since those were not
in the pre-r328588 output.

If there is a more correct fix, someone conversant with libxo will need
to do so.

Submitted by: rea
MFC after: 2 weeks

4 years agoDecode some more IDENTIFY DEVICE bits.
mav [Sun, 28 Jul 2019 20:17:40 +0000 (20:17 +0000)]
Decode some more IDENTIFY DEVICE bits.

MFC after: 2 weeks

4 years agoIn swap_pager_putpages, move the initialization of a free-blocks
dougm [Sun, 28 Jul 2019 19:32:23 +0000 (19:32 +0000)]
In swap_pager_putpages, move the initialization of a free-blocks
counter, and the final freeing of freed swap blocks, outside the
region where an object lock is held.  Correct some style(9) and
spelling errors.  Change a panic() to a KASSERT().  Change a boolean_t
to a bool.

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

4 years agoBetter comments for vlrureclaim
asomers [Sun, 28 Jul 2019 16:07:27 +0000 (16:07 +0000)]
Better comments for vlrureclaim

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoAdd v_inval_buf_range, like vtruncbuf but for a range of a file
asomers [Sun, 28 Jul 2019 00:48:28 +0000 (00:48 +0000)]
Add v_inval_buf_range, like vtruncbuf but for a range of a file

v_inval_buf_range invalidates all buffers within a certain LBA range of a
file. It will be used by fusefs(5). This commit is a partial merge of
r346162, r346606, and r346756 from projects/fuse2.

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

4 years agoReenable UNMAP support on ramdisks by default.
mav [Sat, 27 Jul 2019 18:07:46 +0000 (18:07 +0000)]
Reenable UNMAP support on ramdisks by default.

For some reason, I guess just mechanical editing, it was disable in r333446.

MFC after: 2 weeks

4 years agoAllow WRITE SAME handle more then 2^^32 blocks.
mav [Sat, 27 Jul 2019 17:27:26 +0000 (17:27 +0000)]
Allow WRITE SAME handle more then 2^^32 blocks.

If not limited by write_same_max_lba option, split operation into several
2^^31 blocks chunks in a loop.  For large disks it may take a while, so
setting write_same_max_lba may be useful to avoid timeouts.

While there, fix build with CAM_CTL_DEBUG.

MFC after: 2 weeks

4 years agoRemove support for kernel.tramp and kernel.tramp.gz
imp [Sat, 27 Jul 2019 17:24:19 +0000 (17:24 +0000)]
Remove support for kernel.tramp and kernel.tramp.gz

Nothing uses these anymore. They were for super small armv4 boards without
uboot. We removed armv4 support before 13.0, but neglected to garbage collect
this at the same time. Today, both flavors of armv5 kernels (mv and ralink) boot
via uboot which has its own compression scheme for boards that need it.

Note: OLDFILES has not been updated beacuse installkernel will move the whole
directory out of the way before installing the new kernel.

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

4 years agoarm: Fix TEGRA124 kernel
manu [Sat, 27 Jul 2019 15:04:10 +0000 (15:04 +0000)]
arm: Fix TEGRA124 kernel

Since r350162 device syscon is needed for sdhci driver.
Add it to the config file.

Reported by: dim

4 years agosfxge(4): unify power of 2 alignment check macro
arybchik [Sat, 27 Jul 2019 09:36:45 +0000 (09:36 +0000)]
sfxge(4): unify power of 2 alignment check macro

Substitute driver-defined IS_P2ALIGNED() with EFX_IS_P2ALIGNED()
defined in libefx.

Add type argument and cast value and alignment to one specified type.

Reported by:    Andrea Valsania <andrea.valsania at answervad.it>
Reviewed by:    philip
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision:  https://reviews.freebsd.org/D21076