freebsd.git
8 hours agoAdd network device event for priority code point, PCP, changes. master github/master
hselasky [Thu, 26 Apr 2018 08:58:27 +0000 (08:58 +0000)]
Add network device event for priority code point, PCP, changes.

When the PCP is changed for either a VLAN network interface or when
prio tagging is enabled for a regular ethernet network interface,
broadcast the IFNET_EVENT_PCP event so applications like ibcore can
update its GID tables accordingly.

MFC after: 3 days
Reviewed by: ae, kib
Differential Revision: https://reviews.freebsd.org/D15040
Sponsored by: Mellanox Technologies

20 hours agozgrep.sh: Add forgotten ';' and remove set -e which prevents looping over files
bapt [Wed, 25 Apr 2018 21:01:02 +0000 (21:01 +0000)]
zgrep.sh: Add forgotten ';' and remove set -e which prevents looping over files
not matching

20 hours agozgrep.sh: remove now useless shift
bapt [Wed, 25 Apr 2018 20:55:18 +0000 (20:55 +0000)]
zgrep.sh: remove now useless shift

20 hours agozgrep: small improvements
bapt [Wed, 25 Apr 2018 20:52:17 +0000 (20:52 +0000)]
zgrep: small improvements

* Use slightly more efficient method to determine the name of the program
called [1]
* Use nicer form to loop over arguments [1]
* add special support for --version along with -V previously added by kevans

Reported by: jilles@ [1]

21 hours agoFix mips32 build after r332951.
lwhsu [Wed, 25 Apr 2018 19:46:39 +0000 (19:46 +0000)]
Fix mips32 build after r332951.

Approved by: jhb

22 hours ago<compress>grep: Special case the -V flag
kevans [Wed, 25 Apr 2018 18:59:29 +0000 (18:59 +0000)]
<compress>grep: Special case the -V flag

In case we need version information of the ultimately chosen grep, allowing
`zgrep -V` to operate would be most helpful.

22 hours agoUpdate release version of FreeBSD.
benno [Wed, 25 Apr 2018 18:56:27 +0000 (18:56 +0000)]
Update release version of FreeBSD.

Sponsored by: iXsystems, Inc.

22 hours agoAllow etdump, makefs and mkimg to be overridden.
benno [Wed, 25 Apr 2018 18:47:52 +0000 (18:47 +0000)]
Allow etdump, makefs and mkimg to be overridden.

Recent changes to makefs and mkimg have led to situations where the
disconnect between this script and the versions installed on the host cause
failures. Provide a way to work around this that doesn't require the
installation of new versions to the host system if that's not desired.

With this change mkisoimages.sh will honour the $ETDUMP, $MAKEFS and $MKIMG
environment variables but fall back to the previous behaviour of finding them
within $PATH.

Reviewed by: gjb
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D15181

23 hours agoFix Issue with adding MUltiCast Addresses. When multicast addresses are
davidcs [Wed, 25 Apr 2018 18:06:22 +0000 (18:06 +0000)]
Fix Issue with adding MUltiCast Addresses. When multicast addresses are
added/deleted, the delete the multicast addresses previously programmed
in HW and reprogram the new set of multicast addresses.

Submitted by:Vaishali.Kulkarni@cavium.com
MFC after:5 days

23 hours agoUpgraded FW Related Files to version 5.4.67
davidcs [Wed, 25 Apr 2018 17:51:17 +0000 (17:51 +0000)]
Upgraded FW Related Files to version 5.4.67

MFC after:5 days

24 hours agoUse CPUID leaf 0x15 to get TSC frequency when the calibration is
kib [Wed, 25 Apr 2018 16:43:45 +0000 (16:43 +0000)]
Use CPUID leaf 0x15 to get TSC frequency when the calibration is
disabled.

Intel finally added this information, which allows us to not parse CPU
identification string looking for the nominal frequency.  The leaf is
present e.g. on Appolo Lake Atom CPUs.  It is only used if the TSC
calibration is disabled by user.

Also, report the TSC frequency in bootverbose mode always, regardless
of the way it was obtained.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

25 hours agobsdgrep(1): Sneak in some man page updates
kevans [Wed, 25 Apr 2018 16:28:51 +0000 (16:28 +0000)]
bsdgrep(1): Sneak in some man page updates

- The --exclude{,-dir} and --include{,-dir} directives now match GNU
  behavior of being processed in order and latest matching directive wins

- --label was previously not really documented, and -L and -l did not
  indicate that --label applied to them

- The flags listed as being extensions to POSIX spec were not updated with
  the removal of compression-related flags

MFC after: 1 week

25 hours agobsdgrep: Update NLS catalogs after r332995
kevans [Wed, 25 Apr 2018 15:41:50 +0000 (15:41 +0000)]
bsdgrep: Update NLS catalogs after r332995

Compression was removed so #2 goes away and everything else needs renumbered
to match, and the usage string was also updated due to removed options.

X-MFC-With: r332995

25 hours agoClean up .Xrs in man(1).
trasz [Wed, 25 Apr 2018 15:39:36 +0000 (15:39 +0000)]
Clean up .Xrs in man(1).

MFC after: 2 weeks

26 hours agoAdd some .Xrs to USB template descriptions.
trasz [Wed, 25 Apr 2018 15:32:12 +0000 (15:32 +0000)]
Add some .Xrs to USB template descriptions.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

26 hours agoTranslate 32-bit ifmedia requests into native ones.
brooks [Wed, 25 Apr 2018 15:30:42 +0000 (15:30 +0000)]
Translate 32-bit ifmedia requests into native ones.

We use transformation rather than accessors as virtually ever driver
implements SIOCGIFMEDIA and all would have to be touched.

Keep the code readable by always performing copies and (possiably no-op)
transforms.

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

26 hours agoMake it possible (controlled via sysctl, enabled by default) to mark
trasz [Wed, 25 Apr 2018 15:28:46 +0000 (15:28 +0000)]
Make it possible (controlled via sysctl, enabled by default) to mark
device-side (and only device-side) "virtual USB serial adapters" - the
ones you can get with an OTG-capable board - as consoles.  It boils down
to adding the device name to kern.console sysctl, although doing that
requires jumping through some hoops.  It doesn't change the actual
operation of those virtual devices.  The point is to make it possible
for init(8) to recognize them as console devices and to launch getty(8)
for them, when configured as "onifconsole" in ttys(5).  The point of
that, in turn, is to add such entries to the default ttys(5), so that
init(8) will launch gettys for device-side "virtual serial adapters",
but not for actual USB serial dongles.

Reviewed by: hselasky@
No objections: imp@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

26 hours agoRemove compression support from bsdgrep
bapt [Wed, 25 Apr 2018 14:40:15 +0000 (14:40 +0000)]
Remove compression support from bsdgrep

Compression support is now handled by an external script, remove it from the
bsdgrep(1) utility.
This removes the support for -Z -J -X and -M

Note: that it matches the changes in newer GNU grep

Reviewed by: kevans
Approved by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D15197

27 hours agoIf a trap is encountered upon executing iretq from within doreti() the
tychon [Wed, 25 Apr 2018 14:21:13 +0000 (14:21 +0000)]
If a trap is encountered upon executing iretq from within doreti() the
hardware will ensure the stack pointer is aligned to a 16-byte
boundary before saving the fault state on the stack.

In the PTI case, handle this potential alignment adjustment by copying
both frames independently while unwinding the stack in between.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D15183

28 hours agoUse a script wrapper for <compress>grep
bapt [Wed, 25 Apr 2018 13:23:58 +0000 (13:23 +0000)]
Use a script wrapper for <compress>grep

Import the wrapper script from zstdgrep (written by wiz@netbsd.org)

Modify it to support more than just zstd (adding support for gzip,
lzma, xz and bzip2)

Write a simple manpage dedicated for it.

Only use that new wrapper both for gnu grep and bsd grep

Next step will be removing code related to compression format from bsdgrep

Reviewed by: kevans
Approved by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D15193

33 hours agopci_vendors: update to 2018.04.06
eadler [Wed, 25 Apr 2018 07:51:45 +0000 (07:51 +0000)]
pci_vendors: update to 2018.04.06

Obtained from: https://pci-ids.ucw.cz/v2.2/pci.ids
MFC After: 3 days

33 hours agoFix i386 build after r332970 by adding IS_BSP() definition.
lwhsu [Wed, 25 Apr 2018 07:51:41 +0000 (07:51 +0000)]
Fix i386 build after r332970 by adding IS_BSP() definition.

Approved by: kib

38 hours agomakefs: Use ENODATA instead of ENOMSG as a translation for missing ENOATTR.
pfg [Wed, 25 Apr 2018 02:43:53 +0000 (02:43 +0000)]
makefs: Use ENODATA instead of ENOMSG as a translation for missing ENOATTR.

This is consistent with what some linux filesystems do and has been
adopted in our linuxulator.

MFC after: 3 days

38 hours agoforthloader: Remove "EFI boot environment message"
kevans [Wed, 25 Apr 2018 02:42:57 +0000 (02:42 +0000)]
forthloader: Remove "EFI boot environment message"

Contrary to what the message says, this is not only executed in an EFI
context- it provides functions for use in an EFI environment. I don't think
there's much reason to broadcast this fact when we haven't in the past, so
just remove it.

Reported by: emaste (a while ago), cperciva

38 hours agoIncrease the fdtmemreserv array limit to boot on POWER9
jhibbits [Wed, 25 Apr 2018 02:42:11 +0000 (02:42 +0000)]
Increase the fdtmemreserv array limit to boot on POWER9

Discussing with others, this needs to be at least 20 to boot on some POWER9
nodes.  Linux made a similar change for the same reason, so increase to 32
to give us some extra breathing room as well.  The input and output arrays
are sized at 256, so much greater than the increase in the property array
size.

42 hours agoShorten some recently-added lines that are an extra indent over 80 columns.
jhb [Tue, 24 Apr 2018 23:22:45 +0000 (23:22 +0000)]
Shorten some recently-added lines that are an extra indent over 80 columns.

42 hours agoDocument the TRAP_CAP code for SIGTRAP.
jhb [Tue, 24 Apr 2018 23:20:15 +0000 (23:20 +0000)]
Document the TRAP_CAP code for SIGTRAP.

MFC after: 3 days

44 hours agoImprove VM page queue scalability.
markj [Tue, 24 Apr 2018 21:15:54 +0000 (21:15 +0000)]
Improve VM page queue scalability.

Currently both the page lock and a page queue lock must be held in
order to enqueue, dequeue or requeue a page in a given page queue.
The queue locks are a scalability bottleneck in many workloads. This
change reduces page queue lock contention by batching queue operations.
To detangle the page and page queue locks, per-CPU batch queues are
used to reference pages with pending queue operations. The requested
operation is encoded in the page's aflags field with the page lock
held, after which the page is enqueued for a deferred batch operation.
Page queue scans are similarly optimized to minimize the amount of
work performed with a page queue lock held.

Reviewed by: kib, jeff (previous versions)
Tested by: pho
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14893

44 hours agoMake the sysctl machdep.idle also a tunable.
kib [Tue, 24 Apr 2018 20:49:16 +0000 (20:49 +0000)]
Make the sysctl machdep.idle also a tunable.

It is applied before it is possible for idle threads to execute on any
CPU, allowing to work around against some bugs.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

45 hours agoExtend ap_boot_mtx scope to also cover mca_init().
kib [Tue, 24 Apr 2018 20:33:08 +0000 (20:33 +0000)]
Extend ap_boot_mtx scope to also cover mca_init().

Otherwise, under bootverbose, the lapic_enable_cmc() banner 'lapicX:
CMCI unmasked' is printed by several CPUs in parallel, causing garbled
output for the LAPIC dumps.

Reported by: royger
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15157

45 hours agoEnsure that cmci_monitor() is not executed in parallel, since shared
kib [Tue, 24 Apr 2018 20:29:40 +0000 (20:29 +0000)]
Ensure that cmci_monitor() is not executed in parallel, since shared
machine check banks must be only monitored by single CPU.

Noted and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15157

45 hours agoUse IS_BSP() macro.
kib [Tue, 24 Apr 2018 20:22:30 +0000 (20:22 +0000)]
Use IS_BSP() macro.

Noted and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D15157

45 hours agoAdd a UMA zone flag to disable the use of buckets.
markj [Tue, 24 Apr 2018 20:05:45 +0000 (20:05 +0000)]
Add a UMA zone flag to disable the use of buckets.

This allows the creation of zones which don't do any caching in front of
the keg. If the zone is a cache zone, this means that UMA will not
attempt any memory allocations when allocating an item from the backend.
This is intended for use after a panic by netdump, but likely has other
applications.

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

45 hours agoRevert r332894 at the request of the submitter.
sbruno [Tue, 24 Apr 2018 19:55:12 +0000 (19:55 +0000)]
Revert r332894 at the request of the submitter.

Submitted by: Johannes Lundberg <johalun0_gmail.com>
Sponsored by: Limelight Networks

45 hours agoAdd deprecation notice for lmc(4)
emaste [Tue, 24 Apr 2018 19:51:05 +0000 (19:51 +0000)]
Add deprecation notice for lmc(4)

We intend to remove support before FreeBSD 12 is branched.  These are
available only as 32-bit PCI devices.  The driver has an ambiguous
license and I have not been successful in contacting the driver's author
in order to address this.

The planned deprecation has been announced on -current and -stable; if
we receive feedback that the driver is still useful and we are able to
resolve the license issue this deprecation notice can be reverted.

Reviewed by: bapt, brooks, imp, rgrimes
MFC after: 2 weeks
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15182

46 hours agolldb: remove assertion that target_arch is FreeBSD
emaste [Tue, 24 Apr 2018 19:26:58 +0000 (19:26 +0000)]
lldb: remove assertion that target_arch is FreeBSD

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

Sponsored by: Turing Robotic Industries Inc.

46 hours agokdump: simplify/remove per-arch #ifdefs
emaste [Tue, 24 Apr 2018 19:23:26 +0000 (19:23 +0000)]
kdump: simplify/remove per-arch #ifdefs

It is acceptable for syscallabi to map SV_ABI to SYSDECODE_ABI on all
architectures; libsysdecode will return not-found sentinel values if
it does not have a syscall name or errno mapping for a given
architecture.

Also, use __LP64__ for the SV_ILP32 -> SYSDECODE_ABI_LINUX32 mapping,
for any future 32- on 64-bit linuxulator implementation.

Reviewed by: jhb
Sponsored by: Turing Robotic Industries Inc.

46 hours agouslcom: Both CP2104 and CP2105 can support up to 2Mbps baudrate
manu [Tue, 24 Apr 2018 19:11:05 +0000 (19:11 +0000)]
uslcom: Both CP2104 and CP2105 can support up to 2Mbps baudrate

MFC after: 1 week

46 hours agoDo not totally silence suppressed secondary kasserts unless debug.kassert.do_log...
cem [Tue, 24 Apr 2018 19:10:51 +0000 (19:10 +0000)]
Do not totally silence suppressed secondary kasserts unless debug.kassert.do_log is disabled

To totally silence and ignore secondary kassert violations after a primary
panic, set debug.kassert.do_log=0 and debug.kassert.suppress_in_panic=1.

Additional assertion warnings shouldn't block core dump and may alert the
developer to another erroneous condition.  Secondary stack traces may be
printed, identically to the unsuppressed case where panic() is reentered --
controlled via debug.trace_all_panics.

Sponsored by: Dell EMC Isilon

46 hours agouslcom: Apply style(9) and be consistant with function names
manu [Tue, 24 Apr 2018 19:09:53 +0000 (19:09 +0000)]
uslcom: Apply style(9) and be consistant with function names

MFC after: 1 week

46 hours agoFix debug.kassert.do_log description text
cem [Tue, 24 Apr 2018 18:59:40 +0000 (18:59 +0000)]
Fix debug.kassert.do_log description text

This has been an (incorrect) copy-paste duplicate of debug.kassert.warn_only
since it was originally committed in r243980.

Sponsored by: Dell EMC Isilon

46 hours agopanic: Optionally, trace secondary panics
cem [Tue, 24 Apr 2018 18:54:20 +0000 (18:54 +0000)]
panic: Optionally, trace secondary panics

To diagnose and fix secondary panics, it is useful to have a stack trace.
When panic tracing is enabled, optionally trace secondary panics as well.

The option is configured with the tunable/sysctl debug.trace_all_panics.

(The original concern that inspired only tracing the primary panic was
likely that the secondary trace may scroll the original panic message or trace
off the screen.  This is less of a concern for serial consoles with logging.
Not everything has a serial console, though, so the behavior is optional.)

Discussed with: jhb
Sponsored by: Dell EMC Isilon

46 hours agoUpdate r332860 by changing the default from suppressing post-panic
jtl [Tue, 24 Apr 2018 18:47:35 +0000 (18:47 +0000)]
Update r332860 by changing the default from suppressing post-panic
assertions to not suppressing post-panic assertions.

There are some post-panic assertions that are valuable and we shouldn't
default to disabling them.  However, when a user trips over them, the
user can still adjust the tunable/sysctl to suppress them temporarily to
get conduct troubleshooting (e.g. get a core dump).

Reported by: cem, markj

46 hours agolockmgr: Add missed neutering during panic
cem [Tue, 24 Apr 2018 18:41:14 +0000 (18:41 +0000)]
lockmgr: Add missed neutering during panic

r313683 introduced new lockmgr APIs that missed the panic-time neutering
present in the rest of our locks.  Correct that by adding the usual check.

Additionally, move the __lockmgr_args neutering above the assertions at the
top of the function.  Drop the interlock unlock because we shouldn't have
an unneutered interlock either.  No point trying to unlock it.

PR: 227749
Reported by: jtl
Sponsored by: Dell EMC Isilon

47 hours agoFix PT_STEP single-stepping for mips.
jhb [Tue, 24 Apr 2018 17:53:16 +0000 (17:53 +0000)]
Fix PT_STEP single-stepping for mips.

Note that GDB at least implements single stepping for MIPS using software
breakpoints explicitly rather than using PT_STEP, so this has only been
tested via tests in ptrace_test which now pass rather than fail.

- Fix several places to use uintptr_t instead of int for virtual addresses.
- Check for errors from ptrace_read_int() when setting a breakpoint for a
  step.
- Properly check for errors from ptrace_write_int() as it returns non-zero,
  not negative values on failure.
- Change the error returns for ptrace_read_int() and ptrace_write_int() from
  ENOMEM to EFAULT.
- Clear a single step breakpoint when it traps rather than waiting for it
  to be cleared from ptrace().  This matches the behavior of the arm port
  and in general seems a bit more reliable than waiting for ptrace() to
  clear it via FIX_SSTEP.
- Drop the PROC_LOCK around ptrace_write_int() in ptrace_clear_single_step()
  since it can sleep.
- Reorder the breakpoint handler in trap() to only read the instruction if
  the address matches the current thread's breakpoint address.
- Replace various #if 0'd debugging printfs with KTR_PTRACE traces.

Tested on: mips64

47 hours agoUse more common format for sysctls/tunables descriptions in USB man pages.
trasz [Tue, 24 Apr 2018 17:46:33 +0000 (17:46 +0000)]
Use more common format for sysctls/tunables descriptions in USB man pages.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

47 hours agoUse dead_bpf_if instead of bp_null.
markj [Tue, 24 Apr 2018 17:42:25 +0000 (17:42 +0000)]
Use dead_bpf_if instead of bp_null.

This fixes a -Wunused error when DEV_BPF and NETGRAPH_BPF are not
defined.

Also remove a stray semicolon added in r332812.

X-MFC with: r332812

2 days agoDon't fetch the current instruction for faults on user "trap" instructions.
jhb [Tue, 24 Apr 2018 17:31:20 +0000 (17:31 +0000)]
Don't fetch the current instruction for faults on user "trap" instructions.

The value of 'instr' was not used to handle the fault.

Reported by: GCC's -Wunused-but-set-variable

2 days agoUse a cleaner test for the branch delay (BD) bit in DELAYBRANCH.
jhb [Tue, 24 Apr 2018 17:22:17 +0000 (17:22 +0000)]
Use a cleaner test for the branch delay (BD) bit in DELAYBRANCH.

Rather than casting the value of cause to int and checking for a negative
value to determine if bit 31 is set, use a binary and with MIPS_CR_BR_DELAY.

2 days agoCarefully update stack guard bytes inside __guard_setup().
kib [Tue, 24 Apr 2018 15:59:39 +0000 (15:59 +0000)]
Carefully update stack guard bytes inside __guard_setup().

This is necessary to make sure that functions that can have stack
protection are not used to update the stack guard. If not, the stack
guard check would fail when it shouldn't.

guard_setup() calls elf_aux_info(), which, in turn, calls memcpy() to
update stack_chk_guard.  If either elf_aux_info() or memcpy() have
stack protection enabled, __stack_chk_guard will be modified before
returning from them, causing the stack protection check to fail.

This change uses a temporary buffer to delay changing
__stack_chk_guard until elf_aux_info() returns.

Submitted by: Luis Pires
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15173

2 days ago[procfs] Split procfs_attr into multiple functions
eadler [Tue, 24 Apr 2018 14:49:09 +0000 (14:49 +0000)]
[procfs] Split procfs_attr into multiple functions

Reviewed by: des, kib
Discussed with: mmacy
Differential Revision: https://reviews.freebsd.org/D15150

2 days agoUse relaxed atomics to access the monitor line.
kib [Tue, 24 Apr 2018 14:02:46 +0000 (14:02 +0000)]
Use relaxed atomics to access the monitor line.

We must ensure that accesses occur, they do not have any other
compiler-visible effects.  Bruce found some situations where
optimization could remove an access, and provided a patch to use
volatile qualifier for the state variables.  Since volatile behaviour
there is the compiler-specific interpretation of the keyword, use
relaxed atomics instead, which gives exactly the desired semantic.

Noted by and discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 days agoCorrect undesirable interaction between caching of %cr4 in bhyve and
kib [Tue, 24 Apr 2018 13:44:19 +0000 (13:44 +0000)]
Correct undesirable interaction between caching of %cr4 in bhyve and
invltlb_glob().

Reviewed by: grehan, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15138

2 days ago[amdsbwd] teach amdsbwd that it has options
eadler [Tue, 24 Apr 2018 13:07:17 +0000 (13:07 +0000)]
[amdsbwd] teach amdsbwd that it has options

AMDSBWD_DEBUG was previously checked for as a #define but it was not
possible to define it

Reviewed by: kevans
Discussed with: kenm

2 days agoFix futexes on i386 after the 4/4G split.
kib [Tue, 24 Apr 2018 12:50:21 +0000 (12:50 +0000)]
Fix futexes on i386 after the 4/4G split.

Use proper method to access userspace.  For now, only the slow copyout
path is implemented.

Reported and tested by: tijl (previous version)
Sponsored by: The FreeBSD Foundation

2 days agoadd a new ACPI suspend debugging knob, debug.acpi.suspend_deep_bounce
avg [Tue, 24 Apr 2018 09:42:58 +0000 (09:42 +0000)]
add a new ACPI suspend debugging knob, debug.acpi.suspend_deep_bounce

This sysctl allows a deeper dive into the sleep abyss comparing to
debug.acpi.suspend_bounce.  When the new sysctl is set the system will
execute the suspend sequence up to the call to AcpiEnterSleepState().
That includes saving processor contexts and parking APs.  Then, instead
of actually entering the sleep state, the BSP will call resumectx() to
emulate the wakeup.  The APs should get restarted by the sequence of
Init and Startup IPIs that BSP sends to them.

MFC after: 8 days

2 days agolockf: change the owner hash from pid to vnode-based
mjg [Tue, 24 Apr 2018 06:10:36 +0000 (06:10 +0000)]
lockf: change the owner hash from pid to vnode-based

This adds a bit missed due to the patch split, see r332882

Tested by: pho

2 days agoRelock PROC_LOCK before one failure case in ptrace_single_step().
jhb [Tue, 24 Apr 2018 05:42:10 +0000 (05:42 +0000)]
Relock PROC_LOCK before one failure case in ptrace_single_step().

The MIPS ptrace_single_step() unlocks the PROC_LOCK while reading and
writing instructions from userland.  One failure case was not reacquiring
the lock before returning.

2 days agoReport proper signal codes for SIGTRAP traps on MIPS.
jhb [Tue, 24 Apr 2018 05:33:17 +0000 (05:33 +0000)]
Report proper signal codes for SIGTRAP traps on MIPS.

- Use TRAP_TRACE for traps after stepping via PT_STEP.
- Use TRAP_BRKPT for software breakpoint traps and watchpoint traps.

This was tested via the recently added siginfo ptrace() tests.  PT_STEP on
MIPS has several bugs that prevent it from working yet, but this does fix
the ptrace__breakpoint_siginfo test on MIPS.

2 days agoAdd two tests for TRAP_* signal codes for SIGTRAP.
jhb [Tue, 24 Apr 2018 05:30:05 +0000 (05:30 +0000)]
Add two tests for TRAP_* signal codes for SIGTRAP.

- ptrace__breakpoint_siginfo tests that a SIGTRAP for a software breakpoint
  in userland triggers a SIGTRAP with a signal code of TRAP_BRKPT.
- ptrace__step_siginfo tests that a SIGTRAP reported for a step after
  stepping via PT_STEP or PT_SETSTEP has a signal code of TRAP_TRACE.

2 days agoExpose breakpoint() to userland from <machine/cpufunc.h> on MIPS.
jhb [Tue, 24 Apr 2018 05:26:28 +0000 (05:26 +0000)]
Expose breakpoint() to userland from <machine/cpufunc.h> on MIPS.

Enable ptrace() tests using breakpoint on MIPS as well.

Tested on: mips64
MFC after: 1 month

2 days agoExtend support for ptrace() tests using breakpoints.
jhb [Tue, 24 Apr 2018 05:20:16 +0000 (05:20 +0000)]
Extend support for ptrace() tests using breakpoints.

- Use a single list of platforms to define HAVE_BREAKPOINT for platforms
  that expose a functional breakpoint() inline to userland.  Replace
  existing lists of platform tests with HAVE_BREAKPOINT instead.
- Add support for advancing PC past a breakpoint inserted via breakpoint()
  to support the existing ptrace__PT_CONTINUE_different_thread test on
  non-x86 platforms (x86 advances the PC past the breakpoint instruction,
  but other platforms do not).  This is implemented by defining a new
  SKIP_BREAK macro which accepts a pointer to a 'struct reg' as its sole
  argument and modifies the contents to advance the PC.  The intention is
  to use it in between PT_GETREGS and PT_SETREGS.

Tested on: amd64, i386, mips (after adding a breakpoint() to mips)
MFC after: 1 month

2 days agoUse calloc() instead of malloc+bzero.
delphij [Tue, 24 Apr 2018 04:07:51 +0000 (04:07 +0000)]
Use calloc() instead of malloc+bzero.

Reviewed by: ken, emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15166

2 days agopwd_mkdb: default to network (big) endian hash order
emaste [Tue, 24 Apr 2018 01:22:57 +0000 (01:22 +0000)]
pwd_mkdb: default to network (big) endian hash order

For cross-architecture reproducibility.  The db(3) functions work with
hashes of either endianness, and the current (v4) version password db
entries already store integers in network order.  Do so with the hash as
well so that identical password databases can be created on big- and
little-endian hosts.

The -B and -L flags exist to set the endianness for legacy (v3) entries
when the -l flag is used, and they will still control hash endianness
(at least until the backwards compatibility infrastructure is removed).

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 days agodtrace: depessimize dtmalloc when dtrace is active
mjg [Tue, 24 Apr 2018 01:06:20 +0000 (01:06 +0000)]
dtrace: depessimize dtmalloc when dtrace is active

Each malloc/free was testing dtrace_malloc_enabled and forcing
extra reads from the malloc type struct to see if perhaps a
dtmalloc probe was on.

Treat it like lockstat and sdt: have a global bolean.

2 days agolockstat: track lockstat just like sdt probes
mjg [Tue, 24 Apr 2018 01:04:10 +0000 (01:04 +0000)]
lockstat: track lockstat just like sdt probes

In particular flip the frequently tested var to bool.

2 days agoPull in r329771 from upstream llvm trunk (by Craig Topper):
dim [Mon, 23 Apr 2018 23:07:57 +0000 (23:07 +0000)]
Pull in r329771 from upstream llvm trunk (by Craig Topper):

  [X86] In X86FlagsCopyLowering, when rewriting a memory setcc we need
  to emit an explicit MOV8mr instruction.

  Previously the code only knew how to handle setcc to a register.

  This should fix a crash in the chromium build.

This fixes various assertion failures while building ports targeting
i386:
* www/firefox: isReg() && "This is not a register operand!"
* www/iridium, www/qt5-webengine: (I.atEnd() || std::next(I) ==
  def_instr_end()) && "getVRegDef assumes a single definition or no
  definition"
* devel/powerpc64-gcc: FromReg != ToReg && "Cannot replace a reg with
  itself"

Reported by: jbeich
PR: 225330, 227686, 227698, 227699
MFC after: 1 week
X-MFC-With: r332833

2 days agoMigrate to make_dev_s interface to populate /dev/nvmeX entries
imp [Mon, 23 Apr 2018 22:30:17 +0000 (22:30 +0000)]
Migrate to make_dev_s interface to populate /dev/nvmeX entries

Submitted by: Michael Hordijk
Differential Revision: https://reviews.freebsd.org/D15162

2 days agomalloc: stop reading the subzone if MALLOC_DEBUG_MAXZONES == 1 (the default)
mjg [Mon, 23 Apr 2018 22:28:49 +0000 (22:28 +0000)]
malloc: stop reading the subzone if MALLOC_DEBUG_MAXZONES == 1 (the default)

malloc was showing at the top of profile during while running microbenchmarks.

#define DTMALLOC_PROBE_MAX              2
struct malloc_type_internal {
        uint32_t        mti_probes[DTMALLOC_PROBE_MAX];
        u_char          mti_zone;
        struct malloc_type_stats        mti_stats[MAXCPU];
};

Reading mti_zone it wastes a cacheline to hold mti_probes + mti_zone
(which we know is 0) + part of malloc stats of the first cpu which on top
induces false-sharing.

In particular will-it-scale lock1_processes -t 128 -s 10:
before: average:45879692
after:  average:51655596

Note the counters can be padded but the right fix is to move them to
counter(9), leaving the struct read-only after creation (modulo dtrace
probes).

2 days agoFinish removing FDDI and tokenring media support.
brooks [Mon, 23 Apr 2018 21:10:33 +0000 (21:10 +0000)]
Finish removing FDDI and tokenring media support.

This fixes media display for 802.11 wireless devices.

Software outside the base system that uses these media types and
defines should use #ifdef IFM_FDDI or IFM_TOKEN to include or remove
support.

Reported by: zeising
Reviewed by: emaste, kib, zeising
Tested by: zeising
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D15170

2 days agoLoad balance sockets with new SO_REUSEPORT_LB option
sbruno [Mon, 23 Apr 2018 19:51:00 +0000 (19:51 +0000)]
Load balance sockets with new SO_REUSEPORT_LB option

This patch adds a new socket option, SO_REUSEPORT_LB, which allow multiple
programs or threads to bind to the same port and incoming connections will be
load balanced using a hash function.

Most of the code was copied from a similar patch for DragonflyBSD.

However, in DragonflyBSD, load balancing is a global on/off setting and can not
be set per socket. This patch allows for simultaneous use of both the current
SO_REUSEPORT and the new SO_REUSEPORT_LB options on the same system.

Required changes to structures
Globally change so_options from 16 to 32 bit value to allow for more options.
Add hashtable in pcbinfo to hold all SO_REUSEPORT_LB sockets.

Limitations
As DragonflyBSD, a load balance group is limited to 256 pcbs
(256 programs or threads sharing the same socket).

Submitted by: Johannes Lundberg <johanlun0@gmail.com>
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D11003

2 days agoMap FreeBSD EDOOFUS to Linux EINVAL
emaste [Mon, 23 Apr 2018 18:33:26 +0000 (18:33 +0000)]
Map FreeBSD EDOOFUS to Linux EINVAL

Previously EDOOFUS mapped to EBUSY.  EINVAL seems more appropriate.

Discussed with: cem
MFC after: 1 week
Sponsored by: Turing Robotic Industries Inc.

3 days agoImplement 32-bit atomic_fcmpset() in userland for armv4/v5.
jhb [Mon, 23 Apr 2018 17:00:15 +0000 (17:00 +0000)]
Implement 32-bit atomic_fcmpset() in userland for armv4/v5.

- Add an implementation of atomic_fcmpset_32() using RAS for armv4/v5.
  This fixes recent world breakage due to use of atomic_fcmpset() in
  userland.
- While here, be more careful to not expose wrapper macros for 64-bit
  atomic_*cmpset to userland for armv4/v5 as only 32-bit cmpset is
  implemented.

This has been reviewed, but not runtime-tested, but should fix the arm.arm
and arm.armeb worlds that have been broken for a while.

Reviewed by: imp
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15147

3 days agoFix some harmless type mismatches in the ARM atomic_cmpset implementations.
jhb [Mon, 23 Apr 2018 16:50:37 +0000 (16:50 +0000)]
Fix some harmless type mismatches in the ARM atomic_cmpset implementations.

The return value of atomic_cmpset() and atomic_fcmpset() is an int (which
is really a bool) that has the values 0 or 1.  Some of the inlines were
using the type being operated on (e.g. uint32_t) as either the return type
of the function, or the type of a local 'ret' variable used to hold the
return value.  Fix all of these to just use plain 'int'.  Due to C promotion
rules and the fact that the value can only be 0 or 1, these should all be
harmless.

Reviewed by: imp (only the v4 ones)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D15147

3 days agohda(4)
sbruno [Mon, 23 Apr 2018 16:38:27 +0000 (16:38 +0000)]
hda(4)
 - add quirk for Dell XPS9560 audio gleaned and massages from linux

https://github.com/freebsd/freebsd/pull/137

Submitted by: K Staring
MFC after: 3 days
Relnotes: yes

3 days agoEnable ARM PL330 DMA engine and Cadence Quad SPI flash controller on
br [Mon, 23 Apr 2018 12:23:05 +0000 (12:23 +0000)]
Enable ARM PL330 DMA engine and Cadence Quad SPI flash controller on
Intel Arria 10 SoC boards.

Tested on Intel Arria 10 SoC Development Kit.

Sponsored by: DARPA, AFRL

3 days agoicmp6_reflect() sends ICMPv6 message with new IPv6 header. So, it is
ae [Mon, 23 Apr 2018 12:20:07 +0000 (12:20 +0000)]
icmp6_reflect() sends ICMPv6 message with new IPv6 header. So, it is
considered as originated by our host packet. And thus rcvif should be
NULL, since it is used by ipfw(4) to determine that packet was originated
from this host. Some of icmp6_reflect() consumers reuse mbuf and m_pkthdr
without resetting rcvif pointer. To avoid this always reset m_pkthdr.rcvif
pointer to NULL in icmp6_reflect(). Also remove such line and comment
describing this from icmp6_error(), since it does not longer matters.

PR: 227674
Reported by: eugen
MFC after: 1 week

3 days agoAdd driver for Cadence Quad SPI Flash Controller found on
br [Mon, 23 Apr 2018 10:35:00 +0000 (10:35 +0000)]
Add driver for Cadence Quad SPI Flash Controller found on
Intel┬« Arria┬« 10 SoC.

Cadence Quad SPI Flash is not generic SPI controller, but SPI flash
controller, so don't use spibus here, instead provide quad spi flash
interface.

Since it is not on spibus, then mx25l flash device driver is not usable
here, so provide new n25q flash device driver with quad spi flash
interface.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10245

3 days agolockf: add per-chain locks to the owner hash
mjg [Mon, 23 Apr 2018 08:23:10 +0000 (08:23 +0000)]
lockf: add per-chain locks to the owner hash

This combined with previous changes significantly depessimizes the behaviour
under contentnion.

In particular the lock1_processes test (locking/unlocking separate files)
from the will-it-scale suite was executed with 128 concurrency on a
4-socket Broadwell with 128 hardware threads.

Operations/second (lock+unlock) go from ~750000 to ~45000000 (6000%)
For reference single-process is ~1680000 (i.e. on stock kernel the resulting
perf is less than *half* of the single-threaded run),

Note this still does not really scale all that well as the locks were just
bolted on top of the current implementation. Significant room for improvement
is still here. In particular the top performance fluctuates depending on the
extent of false sharing in given run (which extends beyond the file).
Added chain+lock pairs were not padded w.r.t. cacheline size.

One big ticket item is the hash used for spreading threads: it used to be the
process pid (which basically serialized all threaded ops). Temporarily the
vnode addr was slapped in instead.

Tested by:      pho

3 days agolockf: skip locking the graph if not necessary (common case)
mjg [Mon, 23 Apr 2018 07:54:02 +0000 (07:54 +0000)]
lockf: skip locking the graph if not necessary (common case)

Tested by:      pho

3 days agolockf: perform wakeup onlly when there is anybody waiting
mjg [Mon, 23 Apr 2018 07:52:56 +0000 (07:52 +0000)]
lockf: perform wakeup onlly when there is anybody waiting

Tested by:      pho

3 days agolockf: skip the hard work in lf_purgelocks if possible
mjg [Mon, 23 Apr 2018 07:52:10 +0000 (07:52 +0000)]
lockf: skip the hard work in lf_purgelocks if possible

Tested by:      pho

3 days agolockf: free state only when recycling the vnode
mjg [Mon, 23 Apr 2018 07:51:19 +0000 (07:51 +0000)]
lockf: free state only when recycling the vnode

This avoids malloc/free cycles when locking/unlocking the vnode when
nobody is contending.

Tested by: pho

3 days agoCorrect size for allocation and bzero of fdsr.
delphij [Mon, 23 Apr 2018 07:15:49 +0000 (07:15 +0000)]
Correct size for allocation and bzero of fdsr.

MFC after: 2 weeks

3 days agobsdgrep: Fix build failure WITHOUT_LZMA (incorrect bracket placement)
kevans [Sun, 22 Apr 2018 23:51:24 +0000 (23:51 +0000)]
bsdgrep: Fix build failure WITHOUT_LZMA (incorrect bracket placement)

Submitted by: sbruno
Reported by: sbruno

3 days agopwd_mkdb: add deprecation notice in manpage too
emaste [Sun, 22 Apr 2018 23:10:37 +0000 (23:10 +0000)]
pwd_mkdb: add deprecation notice in manpage too

Followon to r332789; as reported on the -current and -stable lists and
in review D15144 the -l option will be removed before FreeBSD 12.0.

3 days agoUpdate committers-src.dot to show the mentorship arrangement for myself: eadler has...
bcran [Sun, 22 Apr 2018 21:27:59 +0000 (21:27 +0000)]
Update committers-src.dot to show the mentorship arrangement for myself: eadler has agreed to mentor me.

3 days agoUpdate account and given names in committers-src.dot and calendar.freebsd
bcran [Sun, 22 Apr 2018 20:47:16 +0000 (20:47 +0000)]
Update account and given names in committers-src.dot and calendar.freebsd

I have changed my given name from Bruce to Rebecca, and my FreeBSD account
from brucec to bcran.
Update committers-src.dot and calendar.freebsd to show these changes.

Reviewed by: rrs
Differential Revision: https://reviews.freebsd.org/D15125

4 days agoMake bufdaemon and bufspacedaemon use kthread_suspend_check instead of
tijl [Sun, 22 Apr 2018 16:05:29 +0000 (16:05 +0000)]
Make bufdaemon and bufspacedaemon use kthread_suspend_check instead of
kproc_suspend_check.  In r329612 bufspacedaemon was turned into a thread
of the bufdaemon process causing both to call kproc_suspend_check with the
same proc argument and that function contains the following while loop:

while (SIGISMEMBER(p->p_siglist, SIGSTOP)) {
wakeup(&p->p_siglist);
msleep(&p->p_siglist, &p->p_mtx, PPAUSE, "kpsusp", 0);
}

So one thread wakes up the other and the other wakes up the first again,
locking up UP machines on shutdown.

Also register the shutdown handlers with SHUTDOWN_PRI_LAST + 100 so they
run after the syncer has shutdown, because the syncer can cause a
situation where bufdaemon help is needed to proceed.

PR: 227404
Reviewed by: kib
Tested by: cy, rmacklem

4 days agolockf: slightly depessimize
mjg [Sun, 22 Apr 2018 09:30:07 +0000 (09:30 +0000)]
lockf: slightly depessimize

1. check if P_ADVLOCK is already set and if so, don't lock to set it
(stolen from DragonFly)
2. when trying for fast path unlock, check that we are doing unlock
first instead of taking the interlock for no reason (e.g. if we want
to *lock*). whilere make it more likely that falling fast path will
not take the interlock either by checking for state

Note the code is severely pessimized both single- and multithreaded.

4 days agoRemove the "load drivers" logic from libibverbs.
hselasky [Sun, 22 Apr 2018 06:11:46 +0000 (06:11 +0000)]
Remove the "load drivers" logic from libibverbs.

The "load drivers" logic in the libibverbs configuration file is relevant
for Linux only.

MFC after: 3 days
Sponsored by: Mellanox Technologies

4 days agoFix the build post r332859
jhibbits [Sun, 22 Apr 2018 03:58:04 +0000 (03:58 +0000)]
Fix the build post r332859

sysentvec::sv_hwcap/sv_hwcap2 are pointers to  u_long, so cpu_features* need
to be u_long to use the pointers.  This also requires a temporary cast in
printing the bitfields, which is fine because the feature flag fields are
only 32 bits anyway.

4 days agodwatch(1): Remove the line used to demonstrate `-dev' option
dteske [Sun, 22 Apr 2018 02:40:21 +0000 (02:40 +0000)]
dwatch(1): Remove the line used to demonstrate `-dev' option

In recently added sendrecv profile, there was a line purposefully
added to introduce a compilation error in which `-dev' is used to
debug the entry. Removing the entry.

Sponsored by: Smule, Inc.

4 days agodwatch(1): Add profile for send(2)/recv(2) syscalls
dteske [Sun, 22 Apr 2018 02:36:06 +0000 (02:36 +0000)]
dwatch(1): Add profile for send(2)/recv(2) syscalls

Sponsored by: Smule, Inc.

4 days agodwatch(1): Add `-dev' option to aid debugging of profiles
dteske [Sun, 22 Apr 2018 02:20:17 +0000 (02:20 +0000)]
dwatch(1): Add `-dev' option to aid debugging of profiles

The options `-d' (debug), `-e' (exit after compile), and `-v' (verbose)
when combined in any order (though best remembered as `-dev') will run
the conflated script through dtrace(1), test for error conditions, and
show the line that dtrace(1) failed at (with context).

If no errors are found, the output is the same as `-e[v]'.

When writing a new profile for dwatch(1), you can quickly test to
make sure it compiles by running `dwatch -devX profile_name' where
profiles live in /usr/libexec/dwatch or /usr/local/libexec/dwatch
(the latter being where profiles installed via ports should go).

Sponsored by: Smule, Inc.

4 days agoRemove unused definition bl_dfp; fix build with bktr compiled into kernel
riggs [Sat, 21 Apr 2018 18:43:09 +0000 (18:43 +0000)]
Remove unused definition bl_dfp; fix build with bktr compiled into kernel

PR: 216566
Submitted by: mail@fbsd.e4m.org
Reviewed by: riggs, cognet
Approved by: cognet
MFC after: 3 days

5 days agoWhen running with INVARIANTS, the kernel contains extra checks. However,
jtl [Sat, 21 Apr 2018 17:05:00 +0000 (17:05 +0000)]
When running with INVARIANTS, the kernel contains extra checks.  However,
these assumptions may not hold true once we've panic'd. Therefore, the
checks hold less value after a panic.  Additionally, if one of the checks
fails while we are already panic'd, this creates a double-panic which can
interfere with debugging the original panic.

Therefore, this commit allows an administrator to suppress a response to
KASSERT checks after a panic by setting a tunable/sysctl.  The
tunable/sysctl (debug.kassert.suppress_in_panic) defaults to being
enabled.

Reviewed by: kib
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D12920

5 days agoExport powerpc CPU features for auxvec
jhibbits [Sat, 21 Apr 2018 15:15:47 +0000 (15:15 +0000)]
Export powerpc CPU features for auxvec

FreeBSD exports the AT_HWCAP* auxvec items if provided by the ELF sysentvec
structure.  Add the CPU features to be exported, so user space can more
easily check for them without using the hw.cpu_features and hw.cpu_features2
sysctls.

5 days agobsdgrep: Use grep_strdup instead of grep_malloc+strcpy
kevans [Sat, 21 Apr 2018 14:58:45 +0000 (14:58 +0000)]
bsdgrep: Use grep_strdup instead of grep_malloc+strcpy

5 days agoAdd cfumass rc script, to create a LUN for cfumass(4).
trasz [Sat, 21 Apr 2018 14:56:41 +0000 (14:56 +0000)]
Add cfumass rc script, to create a LUN for cfumass(4).

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