]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoAdd Accessible Max Address Configuration support to camcontrol.
mav [Fri, 19 Jul 2019 19:15:08 +0000 (19:15 +0000)]
Add Accessible Max Address Configuration support to camcontrol.

AMA replaced HPA in ACS-3 specification.  It allows to limit size of the
disk alike to HPA, but declares inaccessible data as indeterminate.  One
of its practical use cases is to under-provision SATA SSDs for better
reliability and performance.

While there, fix HPA Security detection/reporting.

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

4 years agoRestore WARNS?=1 here. I missed that libexec/bootpd/bootpgw existed.
brooks [Fri, 19 Jul 2019 18:47:13 +0000 (18:47 +0000)]
Restore WARNS?=1 here.  I missed that libexec/bootpd/bootpgw existed.

4 years agoKeep track of the number of commands that exhaust their retry limit.
imp [Fri, 19 Jul 2019 18:39:24 +0000 (18:39 +0000)]
Keep track of the number of commands that exhaust their retry limit.

While we print failure messages on the console, sometimes logs are lost or
overwhelmed. Keeping a count of how many times we've failed retriable commands
helps get a magnitude of the problem.

4 years agoKeep track of the number of retried commands.
imp [Fri, 19 Jul 2019 18:39:18 +0000 (18:39 +0000)]
Keep track of the number of retried commands.

Retried commands can indicate a performance degredation of an nvme drive. Keep
track of the number of retries and report it out via sysctl, just like number of
commands an interrupts.

4 years agoRemove pre-FreeBSD 7.0 compatibility.
imp [Fri, 19 Jul 2019 18:38:47 +0000 (18:38 +0000)]
Remove pre-FreeBSD 7.0 compatibility.

4 years agoChain Makefile.inc's so default are inherited as expected.
brooks [Fri, 19 Jul 2019 17:52:23 +0000 (17:52 +0000)]
Chain Makefile.inc's so default are inherited as expected.

Remove unneeded or duplicate variables.

No functional change.

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoAdd comments about KERN_OPT here.
imp [Fri, 19 Jul 2019 17:48:29 +0000 (17:48 +0000)]
Add comments about KERN_OPT here.

4 years agopkgbase: move man pages from runtime-manual to runtime
manu [Fri, 19 Jul 2019 15:12:20 +0000 (15:12 +0000)]
pkgbase: move man pages from runtime-manual to runtime

We don't split the other man pages in their own package so do the same for runtime.

Reviewed by: bapt, gjb
Differential Revision: https://reviews.freebsd.org/D20962

4 years agobsd.confs.mk: Test the correct value for the destination package
manu [Fri, 19 Jul 2019 15:11:32 +0000 (15:11 +0000)]
bsd.confs.mk: Test the correct value for the destination package

Reviewed by: bapt, gjb
Differential Revision: https://reviews.freebsd.org/D20961

4 years agopkgbase: Add a FreeBSD-dpv package
manu [Fri, 19 Jul 2019 15:10:53 +0000 (15:10 +0000)]
pkgbase: Add a FreeBSD-dpv package

Move the dpv related files from FreeBSD-runtime to a new package named
FreeBSD-dpv
The only consumer is bsdinstall which is already in it's own package.

Reviewed by: bapt, gjb
Differential Revision: https://reviews.freebsd.org/D20960

4 years agopkgbase: Add a FreeBSD-bluetooth package
manu [Fri, 19 Jul 2019 15:10:03 +0000 (15:10 +0000)]
pkgbase: Add a FreeBSD-bluetooth package

Move the bluetooth related files from FreeBSD-runtime to a new package named
FreeBSD-bluetooth
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and bluetooth isn't needed for that.

Reviewed by: bapt, gjb
Differential Revision: https://reviews.freebsd.org/D20959

4 years agopkgbase: Add a FreeBSD-hostapd package
manu [Fri, 19 Jul 2019 15:09:00 +0000 (15:09 +0000)]
pkgbase: Add a FreeBSD-hostapd package

Move the hostapd related files from FreeBSD-runtime to a new package n
FreeBSD-hostapd
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and hostapd isn't needed for that.

Reviewed by: bapt, gjb
Differential Revision: https://reviews.freebsd.org/D20958

4 years agopkgbase: Add a FreeBSD-wpa package
manu [Fri, 19 Jul 2019 15:07:30 +0000 (15:07 +0000)]
pkgbase: Add a FreeBSD-wpa package

Move the wpa related files from FreeBSD-runtime to a new package named
FreeBSD-wpa
The FreeBSD runtime is only intended to have everything for a working
FreeBSD installation and wpa isn't needed for that.

Reviewed by:    bapt, gjb
Differential Revision:  https://reviews.freebsd.org/D20957

4 years agoUse sysctl + CTLRWTUN for hw.nvme.verbose_cmd_dump.
imp [Fri, 19 Jul 2019 00:32:56 +0000 (00:32 +0000)]
Use sysctl + CTLRWTUN for hw.nvme.verbose_cmd_dump.

Also convert it to a bool. While the rest of the driver isn't yet bool clean,
this will help.

Reviewed by: cem@
Differential Revision: https://reviews.freebsd.org/D20988

4 years agoRework some multi-output target dependency handling.
bdrewery [Fri, 19 Jul 2019 00:15:25 +0000 (00:15 +0000)]
Rework some multi-output target dependency handling.

This reworks my last commit in r301285 to more closely match what was in
r241298 (but reverted in r294878).

This is addressing "missing .meta file" rebuilds but also ensuring that
files are always generated when needed in each case.

Note that this is not a complete rework of the problem areas identified
in r301285 as most are "good enough" right now as the new pattern
is too verbose. It's only worth making this current change where headers
may be generated in the INCS list; where missing .meta file rebuilds are
spotted.

--- Technical details follow ---

Several attempts to deal with this problem of multi-output targets, with and
without META MODE, were explained in r241298, r294878, and r301285.

The general problem is with multi-output targets such as:
        foo.c foo.h:
                touch foo.c foo.h
        foo.c foo.h:
                touch foo.c
                touch foo.h
        foo.c foo.h: foo.in
                ./generator ${.ALLSRC}

This pattern is problematic in jobs mode as both files end up being
built concurrently and leads to races. With META MODE it is worse
as both targets end up rebuilding if they lack a .meta file. So the
generator is force built twice even though it is only needed once.
There are also problems in that 'make foo.h' may be ran before 'make foo.c';
The order of make generating the targets is not guaranteed.

An older attempted workaround to this (discussed in r294878) was:
        foo.h: foo.c
        foo.c: foo.in
                ./generator ${.ALLSRC}
This appears fine except that if foo.h is missing and foo.c exists then
foo.h will never be regenerated. This pattern is close to the solution
in this commit though:

        foo.h: foo.c .NOMETA
        .if !exists(foo.h)
        foo.c: .PHONY .META
        .endif
        foo.c: foo.in
                ./generator ${.ALLSRC}

There's 2 differences here:
1. foo.h will never expect to have a .meta file since the foo.c target
   will generate both and own the .meta file.
2. If foo.h does not exist then it needs to force foo.c to be rebuilt
   with .PHONY. That normally disables META MODE though so .META is
   given to tell bmake we do really expect a .meta file.

This pattern cannot work with implicit suffix rules since the .c and .h files
may be generated at different times (buildincludes vs depend/all).

Sponsored by: Dell EMC
MFC after: 2 weeks

4 years agoProvide new tunable hw.nvme.verbose_cmd_dump
imp [Thu, 18 Jul 2019 21:58:51 +0000 (21:58 +0000)]
Provide new tunable hw.nvme.verbose_cmd_dump

The nvme drive dumps only the most relevant details about a command when it
fails. However, there are times this is not sufficient (such as debugging weird
issues for a new drive with a vendor). Setting hw.nvme.verbose_cmd_dump=1
in loader.conf will enable more complete debugging information about each
command that fails.

Reviewed by: rpokala
Sponsored by: Netflix
Differential Version: https://reviews.freebsd.org/D20988

4 years agoInclude a mode when creating files with openat().
brooks [Thu, 18 Jul 2019 21:37:50 +0000 (21:37 +0000)]
Include a mode when creating files with openat().

Reviewed by: asomers
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20989

4 years agoDocument that setmode(3) is not thread safe.
brooks [Thu, 18 Jul 2019 21:33:55 +0000 (21:33 +0000)]
Document that setmode(3) is not thread safe.

In some circumstances, setmode(3) may call umask(2) twice to retrieve
the current mode and then restore it.  Between calls, the process will
have a umask of 0.

Reviewed by: markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20982

4 years agoProvide macros to extract the sub-fields of the CAP_LO and CAP_HI registers.
imp [Thu, 18 Jul 2019 15:41:10 +0000 (15:41 +0000)]
Provide macros to extract the sub-fields of the CAP_LO and CAP_HI registers.

These macros make places where we extract these easier to read. The shift and
mask stuff is also a bit tedious and error prone. Start with the CAP_LO and
CAP_HI registers since their scope is somewhat constrained. This is style
chagne only, no functional changes.

Reviewed by: chuck
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20979

4 years agoRename arm64 macros in preperation for a script to generate them.
andrew [Thu, 18 Jul 2019 13:58:04 +0000 (13:58 +0000)]
Rename arm64 macros in preperation for a script to generate them.

I have a script to generate most of the ID_AA64* macros from the Arm
XML source [1]. In preperation for using this we need to clean up the
macros to be in line with what the script will generate. This is the
first step, rename the macros to follow the names in said XML.

[1] https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools

MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20976

4 years agoerrno.h is no longer needed as of r340239 so remove it.
delphij [Thu, 18 Jul 2019 07:37:26 +0000 (07:37 +0000)]
errno.h is no longer needed as of r340239 so remove it.

No MFC planned as that revision was not merged.

4 years agoRemove support for FreeBSD 10.x.
delphij [Thu, 18 Jul 2019 07:26:30 +0000 (07:26 +0000)]
Remove support for FreeBSD 10.x.

MFC after: 1 month

4 years agoFix a paste-o, set is212x = false for other chip types. Doh!
ian [Thu, 18 Jul 2019 01:37:00 +0000 (01:37 +0000)]
Fix a paste-o, set is212x = false for other chip types.  Doh!

4 years agoHandle the PCF2127 RTC chip the same as PCF2129 when init'ing the chip.
ian [Thu, 18 Jul 2019 01:30:56 +0000 (01:30 +0000)]
Handle the PCF2127 RTC chip the same as PCF2129 when init'ing the chip.

This affects the detection of 24-hour vs AM/PM mode... the ampm bit is in a
different location on 2127 and 2129 chips compared to other nxp rtc chips.
I noticed the 2127 case wasn't being handled correctly when I accidentally
misconfiged my system by claiming my PCF2129 was a 2127.

4 years agoMFV r350080:
cy [Thu, 18 Jul 2019 00:27:28 +0000 (00:27 +0000)]
MFV r350080:

Update sqlite3-3.28.0 (3280000) --> sqlite3-3.29.0 (3290000)

MFC after: 1 week

4 years agoRemove redundent decleration of __elf_phdr_match_addr().
brooks [Wed, 17 Jul 2019 23:46:47 +0000 (23:46 +0000)]
Remove redundent decleration of __elf_phdr_match_addr().

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoRemove a duplicate global (rfc931_timeout).
brooks [Wed, 17 Jul 2019 23:43:14 +0000 (23:43 +0000)]
Remove a duplicate global (rfc931_timeout).

It is declared here and in rfc931.c and unused here so keep that copy
and discard this one.

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoUse headers instead of manual declerations of standard functions and
brooks [Wed, 17 Jul 2019 23:36:36 +0000 (23:36 +0000)]
Use headers instead of manual declerations of standard functions and
variables.

4 years agoloader: ignore some variable settings if input unverified
sjg [Wed, 17 Jul 2019 23:33:14 +0000 (23:33 +0000)]
loader: ignore some variable settings if input unverified

libsecureboot can tell us if the most recent file opened was
verfied or not.
If it's state is VE_UNVERIFIED_OK, skip if variable
matches one of the restricted prefixes.

Reviewed by: stevek
MFC after: 1 week
Sponsored by: Juniper Networks
Differential Revision: https://reviews.freebsd.org//D20909

4 years agoUse ANSI C function definitions and declerations.
brooks [Wed, 17 Jul 2019 23:09:40 +0000 (23:09 +0000)]
Use ANSI C function definitions and declerations.

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoThe error reported in FS-14-UFS-3 can only happen on UFS/FFS
mckusick [Wed, 17 Jul 2019 22:07:43 +0000 (22:07 +0000)]
The error reported in FS-14-UFS-3 can only happen on UFS/FFS
filesystems that have block pointers that are out-of-range for their
filesystem. These out-of-range block pointers are corrected by
fsck(8) so are only encountered when an unchecked filesystem is
mounted.

A new "untrusted" flag has been added to the generic mount interface
that can be set when mounting media of unknown provenance or integrity.
For example, a daemon that automounts a filesystem on a flash drive
when it is plugged into a system.

This commit adds a test to UFS/FFS that validates all block numbers
before using them. Because checking for out-of-range blocks adds
unnecessary overhead to normal operation, the tests are only done
when the filesystem is mounted as an "untrusted" filesystem.

Reported by:  Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:  FS-14-UFS-3: Out of bounds read in write-2 (ffs_alloccg)
Reviewed by:  kib
Sponsored by: Netflix

4 years agoriscv: Return vm_paddr_t in pmap_early_vtophys()
kp [Wed, 17 Jul 2019 21:25:26 +0000 (21:25 +0000)]
riscv: Return vm_paddr_t in pmap_early_vtophys()

We can't use a u_int to compute the physical address in
pmap_early_vtophys(). Our int is 32-bit, but the physical address is
64-bit. This works fine if everything lives in below 0x100000000, but as
soon as it doesn't this breaks.

MFC after: 1 week
Sponsored by: Axiado

4 years agoRemove now-obsolete comment.
imp [Wed, 17 Jul 2019 20:43:14 +0000 (20:43 +0000)]
Remove now-obsolete comment.

4 years agobsearch.3: Improve the example.
kib [Wed, 17 Jul 2019 19:29:55 +0000 (19:29 +0000)]
bsearch.3: Improve the example.

Submitted by: fernape
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19902

4 years agoRemove an old warning from UPDATING.
markj [Wed, 17 Jul 2019 19:11:24 +0000 (19:11 +0000)]
Remove an old warning from UPDATING.

The clang switchover happened long enough ago that we can
garbage-collect this note.

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

4 years agoAdd an initial RELNOTES file.
markj [Wed, 17 Jul 2019 19:09:05 +0000 (19:09 +0000)]
Add an initial RELNOTES file.

The intent is to provide a convenient location to document changes
that are relevant to users of binary FreeBSD distributions, in contrast
with UPDATING, which exists to document caveats for users who build
FreeBSD from source.

This complements the "Relnotes:" tag in commit messages by providing a
place to document the change in more detail, or in case a "Relnotes:"
tag was accidentally omitted.  In particular, "Relnotes:" should be
used if you do not intend to document the change in RELNOTES for some
reason.

Changes to the file should not be MFCed.  For now the file will exist
only in head, but may be updated via direct commits to stable branches
depending on how things go.

I took the liberty of pre-populating the file with some recent release
notes-worthy changes.

Reviewed by: ian (earlier version)
Discussed with: cy, gjb, imp, rgrimes
Differential Revision: https://reviews.freebsd.org/D20762

4 years agoF_READAHEAD: Fix r349248's overflow protection, broken by r349391
asomers [Wed, 17 Jul 2019 17:01:07 +0000 (17:01 +0000)]
F_READAHEAD: Fix r349248's overflow protection, broken by r349391

I accidentally broke the main point of r349248 when making stylistic changes
in r349391.  Restore the original behavior, and also fix an additional
overflow that was possible when uio->uio_resid was nearly SSIZE_MAX.

Reported by: cem
Reviewed by: bde
MFC after: 2 weeks
MFC-With: 349248
Sponsored by: The FreeBSD Foundation

4 years agoRemove obsolete compatibility code from rtadvd.
markj [Wed, 17 Jul 2019 16:50:53 +0000 (16:50 +0000)]
Remove obsolete compatibility code from rtadvd.

MFC after: 1 week

4 years agoFix FASTTRAPIOC_GETINSTR.
markj [Wed, 17 Jul 2019 16:38:29 +0000 (16:38 +0000)]
Fix FASTTRAPIOC_GETINSTR.

This ioctl is used when a breakpoint is encountered while disassembling
a symbol in the target process.  Since only one DTrace consumer can
toggle or enumerate fasttrap probes from a given process at time, this
ioctl does not appear to be used in practice.

4 years agoReference stdint.h types in ctf.5.
markj [Wed, 17 Jul 2019 16:31:50 +0000 (16:31 +0000)]
Reference stdint.h types in ctf.5.

MFC after: 1 week

4 years agotzsetup: upgrade to zone1970.tab
tmunro [Wed, 17 Jul 2019 06:17:27 +0000 (06:17 +0000)]
tzsetup: upgrade to zone1970.tab

zone.tab is deprecated.  Install zone1970.tab alongside it, and use it
for tzsetup(8).  This is also useful for other applications that need
the modern better maintained file.

Reviewed by: philip
Approved by: allanjude (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20646

4 years agoI add the ability to accept the default pin widget configuration to help
sbruno [Wed, 17 Jul 2019 04:13:46 +0000 (04:13 +0000)]
I add the ability to accept the default pin widget configuration to help
with various laptops using hdaa(4) sound devices.  We don't seem to know
the "correct" configurations for these devices and the defaults are far
superiour, e.g. they work if you don't nuke the default configs.

PR: 200526
Differential Revision: https://reviews.freebsd.org/D17772

4 years agobhyve: update the NVMe CQ based on the status
chuck [Wed, 17 Jul 2019 03:19:30 +0000 (03:19 +0000)]
bhyve: update the NVMe CQ based on the status

Instead of skipping the NVMe Completion Queue update based on the
opcode, define a synthetic status value which indicates the completion
queue entry is invalid. This will also allow deferred completion queue
updates for other commands.

Also returns the correct status for unrecognized opcodes ("invalid
opcode").

Reviewed by: imp, jhb, araujo
Approved by: imp (mentor), jhb (maintainer)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20945

4 years agoMore follow-up to r350075, I forgot to update ObsoleteFiles.
kevlo [Wed, 17 Jul 2019 02:24:16 +0000 (02:24 +0000)]
More follow-up to r350075,  I forgot to update ObsoleteFiles.

Spotted by: lwhsu

4 years agoAdd an MLINK for igb.
kevlo [Wed, 17 Jul 2019 02:08:57 +0000 (02:08 +0000)]
Add an MLINK for igb.

Discussed with: lwhsu

4 years agoMention iflib(4).
kevlo [Wed, 17 Jul 2019 01:56:40 +0000 (01:56 +0000)]
Mention iflib(4).

4 years agoStyle.
mckusick [Tue, 16 Jul 2019 23:39:39 +0000 (23:39 +0000)]
Style.
No change intended.

4 years agoWhen a process attempts to allocate space on a full filesystem, a
mckusick [Tue, 16 Jul 2019 23:12:27 +0000 (23:12 +0000)]
When a process attempts to allocate space on a full filesystem, a
filesystem full message is sent to the offending process or the
kernel log if the offending process cannot be identified.

To prevent an explotion of messages, the kernel ppsratecheck()
function is used to limit the messages to one per second. This
revision changes the variable that tracks the rate of these messages
from a systemwide limit to a per-filesystem limit by moving it from
a global variable to a variable in the ufsmount structure.

Suggested by: kib
Reviewed by:  kib
Sponsored by: Netflix

4 years agoUse PT_GET_SC_ARGS and PT_GET_SC_RET in truss.
jhb [Tue, 16 Jul 2019 22:59:15 +0000 (22:59 +0000)]
Use PT_GET_SC_ARGS and PT_GET_SC_RET in truss.

This removes all of the architecture-specific functions from truss.

A per-ABI structure is still needed to map syscall numbers to names
and FreeBSD errno values to ABI error values as well as hold syscall
counters.  However, the linker set of ABI structures is now replaced
with a simple table mapping ABI names to structures.  This approach
permits sharing the same ABI structure among separate names such as
i386 a.out and ELF binaries as well as ELF v1 vs ELF v2 for powerpc64.

A few differences are visible due to using PT_GET_SC_RET to fetch the
error value of a system call.  Note that ktrace/kdump have had the
"new" behaviors for a long time already:
- System calls that return with EJUSTRETURN or ERESTART will now be
  noticed and logged as such.  Previously sigreturn (which uses
  EJUSTRETURN) would report whatever random value was in the register
  holding errno from the previous system call for example.  Now it
  reports EJUSTRETURN.
- System calls that return errno as their error value such as
  posix_fallocate() and posix_fadvise() now report non-zero return
  values as errors instead of success with a non-zero return value.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20963

4 years agoAssume that the timeout value from the capacity is 1-based
imp [Tue, 16 Jul 2019 22:55:30 +0000 (22:55 +0000)]
Assume that the timeout value from the capacity is 1-based

Neither the 1.3 or 1.4 standards say this number is 1's based, but adding 1
costs little and copes with those NVMe drives that report '0' in this field
cheaply. This is consistent with what the Linux driver does as well.

4 years agoAdd missing mode in open(2) calls with O_CREAT.
brooks [Tue, 16 Jul 2019 22:27:49 +0000 (22:27 +0000)]
Add missing mode in open(2) calls with O_CREAT.

When O_CREAT is specified, the third, variadic argument is
required as the permission. If on is not passed, then depending
on the ABI, either the contents of the third argument register
or some arbitrary stuff on the stack will be used as the permission.

This has been merged to NetBSD.

Reviewed by: asomers, ngie
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20972

4 years agoAs of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
cy [Tue, 16 Jul 2019 19:00:42 +0000 (19:00 +0000)]
As of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
ipfilter 5.1.2 into FreeBSD-10, the fix for, 2580062 from/to targets
should be able to use any interface name, moved frentry.fr_cksum to
prior to frentry.fr_func thereby making this code redundant. After
investigating whether this fix to move fr_cksum was correct and if it
broke anything, it has been determined that the fix is correct and this
code is redundant. We remove it here.

MFC after: 2 weeks

4 years agoRefactor, removing one compare.
cy [Tue, 16 Jul 2019 19:00:38 +0000 (19:00 +0000)]
Refactor, removing one compare.

This changes the return code however the caller only tests for 0 and != 0.
One might ask then, why multiple return codes when the caller only tests
for 0 and != 0? From what I can tell, Darren probably passed various
return codes for sake of debugging. The debugging code is long gone
however we can still use the different return codes using DTrace FBT
traces. We can still determine why the compare failed by examining the
differences between the fr1 and fr2 frentry structs, which is a simple
test in DTrace. This allows reducing the number of tests, improving the
code while not affecting our ability to capture information for
diagnostic purposes.

MFC after: 1 week

4 years agoFix compilation on platforms using gcc.
tuexen [Tue, 16 Jul 2019 17:54:20 +0000 (17:54 +0000)]
Fix compilation on platforms using gcc.
When compiling RACK on platforms using gcc, a warning that tcp_outflags
is defined but not used is issued and terminates compilation on PPC64,
for example. So don't indicate that tcp_outflags is used.

Reviewed by: rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D20971

4 years agoImplement {io,admin}-passthru commands.
imp [Tue, 16 Jul 2019 17:24:25 +0000 (17:24 +0000)]
Implement {io,admin}-passthru commands.

These are mostly compatible with Linux, with three exceptions.
1. We don't do metadata segment stuff. Our passthrough interface
   doesn't cope. The code is there, but generates an error.
2. Linux lets you specify a namespace ID for the command. We current
   do not: we get ours from the namespace device, or pass in a generic
   one. Generally, this will lead to the same command, but FreeBSD's
   is safer since you can't specify the wrong id.
3. --show-command outputs to stderr instead of stdout so you can both
   see your command, and capture its output with a simple redirect.

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

4 years agoCreate generic command / arg parsing routines
imp [Tue, 16 Jul 2019 17:24:03 +0000 (17:24 +0000)]
Create generic command / arg parsing routines

Create a set of routines and structures to hold the data for the args
for a command. Use them to generate help and to parse args. Convert
all the current commands over to the new format. "comnd" is a hat-tip
to the TOPS-20 %COMND JSYS that (very) loosely inspired much of the
subsequent command line notions in the industry, but this is far
simpler (the %COMND man page is longer than this code) and not in the
kernel... Also, it implements today's de-facto
command [verb]+ [opts]* [args]*
format rather than the old, archaic TOPS-20 command format :)

This is a snapshot of a work in progress to get the nvme passthru
stuff committed. In time it will become a private library and used
by some other programs in the tree that conform to the above pattern.

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

4 years agoAdd a regression test which transfers varying number of rights.
markj [Tue, 16 Jul 2019 16:33:44 +0000 (16:33 +0000)]
Add a regression test which transfers varying number of rights.

This exercises the PKG_MAX_SIZE limit mentioned in r350054.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoUse a platform-independent constant for PKG_MAX_SIZE.
markj [Tue, 16 Jul 2019 16:28:50 +0000 (16:28 +0000)]
Use a platform-independent constant for PKG_MAX_SIZE.

This constant determines the number of rights libnv will attempt to
transmit in a given control message.  In practice, the upper limit
defined by the kernel is machine-dependent and is smaller on 64-bit
kernels than on 32-bit kernels.  To ensure that a 32-bit libnv works
as expected when run on a 64-bit kernel, use a limit that will work
on both 32-bit and 64-bit kernels.

PR: 238511
Discussed with: oshogbo
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20942

4 years agoConvert the nvlist send/recv tests to ATF.
markj [Tue, 16 Jul 2019 16:25:27 +0000 (16:25 +0000)]
Convert the nvlist send/recv tests to ATF.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoFix two mismatches between function declaration and definition.
brooks [Tue, 16 Jul 2019 16:03:08 +0000 (16:03 +0000)]
Fix two mismatches between function declaration and definition.

In both cases, function pointer arguments were inconsistently declared
and the result worked because of C's odd rules around function pointer
(de)references.  With a stricter compiler these fail to compile.

Reviewed by: cem
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20964

4 years agoChase r350037.
markj [Tue, 16 Jul 2019 16:02:20 +0000 (16:02 +0000)]
Chase r350037.

Reported by: jenkins
MFC with: r350037
Sponsored by: The FreeBSD Foundation

4 years agoAdds signal number format to kern.corefile
vangyzen [Tue, 16 Jul 2019 15:51:09 +0000 (15:51 +0000)]
Adds signal number format to kern.corefile

Add format capability to core file names to include signal
that generated the core. This can help various validation workflows
where all cores should not be considered equally (SIGQUIT is often
intentional and not an error unlike SIGSEGV or SIGBUS)

Submitted by: David Leimbach (leimy2k@gmail.com)
Reviewed by: markj
MFC after: 1 week
Relnotes: sysctl kern.corefile can now include the signal number
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20970

4 years agoAlways use the software DBM bit for now.
markj [Tue, 16 Jul 2019 15:41:09 +0000 (15:41 +0000)]
Always use the software DBM bit for now.

r350004 added most of the machinery needed to support hardware DBM
management, but it did not intend to actually enable use of the hardware
DBM bit.

Reviewed by: andrew
MFC with: r350004
Sponsored by: The FreeBSD Foundation

4 years agoFix the arm64 page table entry attribute mask.
markj [Tue, 16 Jul 2019 15:38:01 +0000 (15:38 +0000)]
Fix the arm64 page table entry attribute mask.

It did not include the DBM or contiguous bits.

Reported by: andrew
Reviewed by: andrew
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoPropagate attribute changes during demotion.
markj [Tue, 16 Jul 2019 14:40:49 +0000 (14:40 +0000)]
Propagate attribute changes during demotion.

After r349117 and r349122, some mapping attribute changes do not trigger
superpage demotion. However, pmap_demote_l2() was not updated to ensure
that the replacement L3 entries carry any attribute changes that
occurred since promotion.

Reported and tested by: manu
Reviewed by: alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20965

4 years agoAdd support for ICMPv6 messages indicating a parameter problem related
tuexen [Tue, 16 Jul 2019 12:57:59 +0000 (12:57 +0000)]
Add support for ICMPv6 messages indicating a parameter problem related
to an unrecognized next header.

MFC after: 2 weeks

4 years agoLet packet_op() explicitly return the type and code instead of doing
tuexen [Tue, 16 Jul 2019 12:38:17 +0000 (12:38 +0000)]
Let packet_op() explicitly return the type and code instead of doing
this implicitly by encoding it in a number space.

No functional change intended.

This is done as a preparation to add support for ICMPv6 mesages
indicating a parameter problem related to the next header.

MFC after: 2 weeks

4 years agoWhitespace change. No functional change.
tuexen [Tue, 16 Jul 2019 10:06:41 +0000 (10:06 +0000)]
Whitespace change. No functional change.

MFC after: 2 weeks

4 years agobge: check that the bus is a pci bus before using it as such
avg [Tue, 16 Jul 2019 08:36:49 +0000 (08:36 +0000)]
bge: check that the bus is a pci bus before using it as such

This fixes the following panic on powerpc:
  pci_get_vendor failed for pcib1 on bus ofwbus0, error = 2

PR: 238730
Reported by: Dennis Clarke <dclarke@blastwave.org>
Tested by: Dennis Clarke <dclarke@blastwave.org>
MFC after: 2 weeks

4 years agostrings: extends rights
oshogbo [Tue, 16 Jul 2019 04:17:25 +0000 (04:17 +0000)]
strings: extends rights

The libelf is using mmap if it can, if not it was fall backing to read.

Reported by: markj

4 years agopowerpc: Fix casueword(9) post-r349951
jhibbits [Tue, 16 Jul 2019 03:55:27 +0000 (03:55 +0000)]
powerpc: Fix casueword(9) post-r349951

'=' asm constraint marks a variable as write-only.  Because of this, gcc
throws away the initialization of 'res', causing garbage to be returned if
the CAS was successful.  Use '+' to mark res as read/write, so that the
initialization stays in the generated asm.  Also, fix the reservation
clearing stwcx store index register in casueword32, and only do the dummy
store when needed, skip it if the real store has already succeeded.

4 years agostrings: fix entering to the capability mode
oshogbo [Tue, 16 Jul 2019 03:32:21 +0000 (03:32 +0000)]
strings: fix entering to the capability mode

Reported by: markj

4 years agoRevert r349973. Upon further reflection, I realized that the comment
alc [Tue, 16 Jul 2019 03:09:03 +0000 (03:09 +0000)]
Revert r349973.  Upon further reflection, I realized that the comment
deleted by r349973 is still valid on i386.  Restore it.

Discussed with:    markj

4 years agoUse a different approach to range check.
imp [Mon, 15 Jul 2019 23:43:38 +0000 (23:43 +0000)]
Use a different approach to range check.

gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
type. Since that's a compiler choice and may be affected by weird stuff, instead
use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
regardless of the signedness of dt.

4 years agoFix filename to avoid skipping lib/libc/net/servent test.
olivier [Mon, 15 Jul 2019 23:41:00 +0000 (23:41 +0000)]
Fix filename to avoid skipping lib/libc/net/servent test.

PR: 239177
Approved by: ngie
MFC after: 1 month
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20943

4 years agoImplement a devtype command.
imp [Mon, 15 Jul 2019 22:33:37 +0000 (22:33 +0000)]
Implement a devtype command.

List the device's protocol. The returned value is one of the following:
ata direct attach ATA or SATA device
satl a SATA device attached via SAS
scsi A parallel SCSI or SAS
nvme A direct attached NVMe device
mmcsd A MMC or SD attached device

Reviewed by: scottl@, rpokala@
Differential Revision: https://reviews.freebsd.org/D20950

4 years agoAdd ptrace op PT_GET_SC_RET.
jhb [Mon, 15 Jul 2019 21:48:02 +0000 (21:48 +0000)]
Add ptrace op PT_GET_SC_RET.

This ptrace operation returns a structure containing the error and
return values from the current system call.  It is only valid when a
thread is stopped during a system call exit (PL_FLAG_SCX is set).

The sr_error member holds the error value from the system call.  Note
that this error value is the native FreeBSD error value that has _not_
been translated to an ABI-specific error value similar to the values
logged to ktrace.

If sr_error is zero, then the return values of the system call will be
set in sr_retval[0] and sr_retval[1].

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20901

4 years agoIn nxprtc(4), use the countdown timer for better timekeeping resolution
ian [Mon, 15 Jul 2019 21:47:40 +0000 (21:47 +0000)]
In nxprtc(4), use the countdown timer for better timekeeping resolution
on PCx2129 chips too.

The datasheet for the PCx2129 chips says that there is only a watchdog
timer, no countdown timer.  It turns out the countdown timer hardware is
there and works just the same as it does on a PCx2127 chip, except that you
can't use it to trigger an interrupt or toggle an output pin.  We don't need
interrupts or output pins, we only need to read the timer register to get
sub-second resolution.  So start treating the 2129 chips the same as 2127.

4 years agoFix nxprtc(4) on systems that support i2c repeat-start correctly.
ian [Mon, 15 Jul 2019 21:40:58 +0000 (21:40 +0000)]
Fix nxprtc(4) on systems that support i2c repeat-start correctly.

An obscure footnote in the datasheets for the PCx2127, PCx2129, and
PCF8523 rtc chips states that the chips do not support i2c repeat-start
operations.  When the driver was originally written and tested, the i2c
bus on that system also didn't support repeat-start and just quietly
turned repeat-start operations into a stop-then-start, making it appear
that the nxprtc driver was working properly.

The repeat-start situation only comes up on reads, so instead of using
the standard iicdev_readfrom(), use a local nxprtc_readfrom(), which is
just a cut-and-pasted copy of iicdev_readfrom(), modified to send two
separate start-data-stop sequences instead of using repeat-start.

4 years agoAdd a test for PT_GET_SC_ARGS.
jhb [Mon, 15 Jul 2019 21:26:55 +0000 (21:26 +0000)]
Add a test for PT_GET_SC_ARGS.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20899

4 years agoDon't pass error from syscallenter() to syscallret().
jhb [Mon, 15 Jul 2019 21:25:16 +0000 (21:25 +0000)]
Don't pass error from syscallenter() to syscallret().

syscallret() doesn't use error anymore.  Fix a few other places to permit
removing the return value from syscallenter() entirely.
- Remove a duplicated assertion from arm's syscall().
- Use td_errno for amd64_syscall_ret_flush_l1d.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D2090

4 years agoAlways set td_errno to the error value of a system call.
jhb [Mon, 15 Jul 2019 21:16:01 +0000 (21:16 +0000)]
Always set td_errno to the error value of a system call.

Early errors prior to a system call did not set td_errno.  This commit
sets td_errno for all errors during syscallenter().  As a result,
syscallret() can now always use td_errno without checking TDP_NERRNO.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20898

4 years agoDon't free read control entries, which are still on the stream queue when
tuexen [Mon, 15 Jul 2019 20:45:01 +0000 (20:45 +0000)]
Don't free read control entries, which are still on the stream queue when
adding them the the read queue fails

MFC after: 1 week

4 years agoUse the more proper term of SATL instead of ATA_BEHIND_SCSI.
imp [Mon, 15 Jul 2019 20:25:41 +0000 (20:25 +0000)]
Use the more proper term of SATL instead of ATA_BEHIND_SCSI.

Most people know SAS attached SATA devices by the name SAT or SATL
(with the latter being a little more common). Change the device type
ATA_BEHIND_SCSI to SATL since it's more specific and meaningful.

Suggested by: scottl@

4 years agoIn do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry.
kib [Mon, 15 Jul 2019 19:18:25 +0000 (19:18 +0000)]
In do_sem2_wait(), balance umtx_key_get() with umtx_key_release() on retry.

Reported by: ler
Bisected and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 12 days

4 years agoImplement software access and dirty bit management for arm64.
markj [Mon, 15 Jul 2019 17:13:32 +0000 (17:13 +0000)]
Implement software access and dirty bit management for arm64.

Previously the arm64 pmap did no reference or modification tracking;
all mappings were treated as referenced and all read-write mappings
were treated as dirty.  This change implements software management
of these attributes.

Dirty bit management is implemented to emulate ARMv8.1's optional
hardware dirty bit modifier management, following a suggestion from alc.
In particular, a mapping with ATTR_SW_DBM set is logically writeable and
is dirty if the ATTR_AP_RW_BIT bit is clear.  Mappings with
ATTR_AP_RW_BIT set are write-protected, and a write access will trigger
a permission fault.  pmap_fault() handles permission faults for such
mappings and marks the page dirty by clearing ATTR_AP_RW_BIT, thus
mapping the page read-write.

Reviewed by: alc
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20907

4 years agopmap_clear_modify() needs to clear PTE_W.
markj [Mon, 15 Jul 2019 15:45:33 +0000 (15:45 +0000)]
pmap_clear_modify() needs to clear PTE_W.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoFix reference counting in pmap_ts_referenced() on RISC-V.
markj [Mon, 15 Jul 2019 15:43:15 +0000 (15:43 +0000)]
Fix reference counting in pmap_ts_referenced() on RISC-V.

pmap_ts_referenced() does not necessarily clear the access bit from
all accessed mappings of a given page.  Thus, if a scan of the mappings
needs to be restarted, we should be careful to avoid double-counting
accessed mappings whose access bits were not cleared in a previous
attempt.

Reported by: alc
Reviewed by: alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20926

4 years agoRemove duplicated device firmware entry in generic arm kernel config added in r333191
manu [Mon, 15 Jul 2019 15:07:55 +0000 (15:07 +0000)]
Remove duplicated device firmware entry in generic arm kernel config added in r333191

Submitted by: Daniel Engberg (daniel.engberg.lists@pyret.net)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20680

4 years agoRemove RELEASE_CRUNCH here. It's obsolete.
imp [Mon, 15 Jul 2019 15:02:40 +0000 (15:02 +0000)]
Remove RELEASE_CRUNCH here. It's obsolete.

Remove RELEASE_CRUNCH here. It's obsolete and hasn't worked in a while.  The
build options need to be revisited, since many older ones are listed, while
newer useful ones are not. But that rototilling I'll leave to others.

4 years agoAdd support for MSG_EOR and MSG_EOF in sendmsg() for SCTP.
tuexen [Mon, 15 Jul 2019 14:54:04 +0000 (14:54 +0000)]
Add support for MSG_EOR and MSG_EOF in sendmsg() for SCTP.

This is an FreeBSD extension, not covered by Posix.

This issue was found by running syzkaller.

MFC after: 1 week

4 years agoFix socket state handling when freeing an SCTP endpoint.
tuexen [Mon, 15 Jul 2019 14:52:52 +0000 (14:52 +0000)]
Fix socket state handling when freeing an SCTP endpoint.

This issue was found by runing syzkaller.

MFC after: 1 week

4 years agoReplace complicated expression to disable libedit when no libthr is being built
imp [Mon, 15 Jul 2019 14:23:51 +0000 (14:23 +0000)]
Replace complicated expression to disable libedit when no libthr is being built
with a simpler one.

4 years agoRemove all the RELEASE_CRUNCH instances that partially disable IPSEC
imp [Mon, 15 Jul 2019 14:19:39 +0000 (14:19 +0000)]
Remove all the RELEASE_CRUNCH instances that partially disable IPSEC

We remove IPSEC only in parts of the tree, and not others. RELEASE_CRUNCH to
disable it has not kept up with all its uses. Remove it. Should there be a real
need to disable IPSEC, one that hasn't shown up in the base system to date,
it can be re-added behind a WITHOUT_IPSEC build option.

4 years agoIn do_lock_pi(), do not return prematurely.
kib [Mon, 15 Jul 2019 08:39:52 +0000 (08:39 +0000)]
In do_lock_pi(), do not return prematurely.

If umtxq_check_susp() indicates an exit, we should clean the resources
before returning.  Do it by breaking out of the loop and relying on
post-loop cleanup.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
Differential revision: https://reviews.freebsd.org/D20949

4 years agoCorrectly check for casueword(9) success in do_set_ceiling().
kib [Mon, 15 Jul 2019 08:38:01 +0000 (08:38 +0000)]
Correctly check for casueword(9) success in do_set_ceiling().

After r349951, the return code must be checked instead of old == new
comparision.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
Differential revision: https://reviews.freebsd.org/D20949

4 years agoMK_OPENSSL makes RELEASE_CRUNCH redundant here
imp [Mon, 15 Jul 2019 07:39:28 +0000 (07:39 +0000)]
MK_OPENSSL makes RELEASE_CRUNCH redundant here

Since these things are more completely controlled by the MK_OPENSSL knob, remove
RELEASE_CRUNCH here. It's no longer needed for the release and other users can
use the more proper knob if they so desire.

4 years agoNow that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.
imp [Mon, 15 Jul 2019 07:35:46 +0000 (07:35 +0000)]
Now that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.

The RELEASE_CRUNCH check is redundant here. We don't need it for releases
anymore, and picobsd can control this more directly without making it a special
case.

4 years agoImprove the input validation for l_linger.
tuexen [Sun, 14 Jul 2019 21:44:18 +0000 (21:44 +0000)]
Improve the input validation for l_linger.
When using the SOL_SOCKET level socket option SO_LINGER, the structure
struct linger is used as the option value. The component l_linger is of
type int, but internally copied to the field so_linger of the structure
struct socket. The type of so_linger is short, but it is assumed to be
non-negative and the value is used to compute ticks to be stored in a
variable of type int.

Therefore, perform input validation on l_linger similar to the one
performed by NetBSD and OpenBSD.

Thanks to syzkaller for making me aware of this issue.

Thanks to markj@ for pointing out that a similar check should be added
to so_linger_set().

Reviewed by: markj@
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20948

4 years agoPR: 239143
kib [Sun, 14 Jul 2019 21:08:54 +0000 (21:08 +0000)]
PR: 239143
Reported and tested by: Wes Maag <jwmaag@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week