]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoUse a script wrapper for <compress>grep
Baptiste Daroussin [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

6 years agopci_vendors: update to 2018.04.06
Eitan Adler [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

6 years agoFix i386 build after r332970 by adding IS_BSP() definition.
Li-Wen Hsu [Wed, 25 Apr 2018 07:51:41 +0000 (07:51 +0000)]
Fix i386 build after r332970 by adding IS_BSP() definition.

Approved by: kib

6 years agomakefs: Use ENODATA instead of ENOMSG as a translation for missing ENOATTR.
Pedro F. Giffuni [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

6 years agoforthloader: Remove "EFI boot environment message"
Kyle Evans [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

6 years agoIncrease the fdtmemreserv array limit to boot on POWER9
Justin Hibbits [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.

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

6 years agoDocument the TRAP_CAP code for SIGTRAP.
John Baldwin [Tue, 24 Apr 2018 23:20:15 +0000 (23:20 +0000)]
Document the TRAP_CAP code for SIGTRAP.

MFC after: 3 days

6 years agoImprove VM page queue scalability.
Mark Johnston [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

6 years agoMake the sysctl machdep.idle also a tunable.
Konstantin Belousov [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

6 years agoExtend ap_boot_mtx scope to also cover mca_init().
Konstantin Belousov [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

6 years agoEnsure that cmci_monitor() is not executed in parallel, since shared
Konstantin Belousov [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

6 years agoUse IS_BSP() macro.
Konstantin Belousov [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

6 years agoAdd a UMA zone flag to disable the use of buckets.
Mark Johnston [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

6 years agoRevert r332894 at the request of the submitter.
Sean Bruno [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

6 years agoAdd deprecation notice for lmc(4)
Ed Maste [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

6 years agolldb: remove assertion that target_arch is FreeBSD
Ed Maste [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.

6 years agokdump: simplify/remove per-arch #ifdefs
Ed Maste [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.

6 years agouslcom: Both CP2104 and CP2105 can support up to 2Mbps baudrate
Emmanuel Vadot [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

6 years agoDo not totally silence suppressed secondary kasserts unless debug.kassert.do_log...
Conrad Meyer [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

6 years agouslcom: Apply style(9) and be consistant with function names
Emmanuel Vadot [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

6 years agoFix debug.kassert.do_log description text
Conrad Meyer [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

6 years agopanic: Optionally, trace secondary panics
Conrad Meyer [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

6 years agoUpdate r332860 by changing the default from suppressing post-panic
Jonathan T. Looney [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

6 years agolockmgr: Add missed neutering during panic
Conrad Meyer [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

6 years agoFix PT_STEP single-stepping for mips.
John Baldwin [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

6 years agoUse more common format for sysctls/tunables descriptions in USB man pages.
Edward Tomasz Napierala [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

6 years agoUse dead_bpf_if instead of bp_null.
Mark Johnston [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

6 years agoDon't fetch the current instruction for faults on user "trap" instructions.
John Baldwin [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

6 years agoUse a cleaner test for the branch delay (BD) bit in DELAYBRANCH.
John Baldwin [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.

6 years agoCarefully update stack guard bytes inside __guard_setup().
Konstantin Belousov [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

6 years ago[procfs] Split procfs_attr into multiple functions
Eitan Adler [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

6 years agoUse relaxed atomics to access the monitor line.
Konstantin Belousov [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

6 years agoCorrect undesirable interaction between caching of %cr4 in bhyve and
Konstantin Belousov [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

6 years ago[amdsbwd] teach amdsbwd that it has options
Eitan Adler [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

6 years agoFix futexes on i386 after the 4/4G split.
Konstantin Belousov [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

6 years agoadd a new ACPI suspend debugging knob, debug.acpi.suspend_deep_bounce
Andriy Gapon [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

6 years agolockf: change the owner hash from pid to vnode-based
Mateusz Guzik [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

6 years agoRelock PROC_LOCK before one failure case in ptrace_single_step().
John Baldwin [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.

6 years agoReport proper signal codes for SIGTRAP traps on MIPS.
John Baldwin [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.

6 years agoAdd two tests for TRAP_* signal codes for SIGTRAP.
John Baldwin [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.

6 years agoExpose breakpoint() to userland from <machine/cpufunc.h> on MIPS.
John Baldwin [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

6 years agoExtend support for ptrace() tests using breakpoints.
John Baldwin [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

6 years agoUse calloc() instead of malloc+bzero.
Xin LI [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

6 years agopwd_mkdb: default to network (big) endian hash order
Ed Maste [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

6 years agodtrace: depessimize dtmalloc when dtrace is active
Mateusz Guzik [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.

6 years agolockstat: track lockstat just like sdt probes
Mateusz Guzik [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.

6 years agoPull in r329771 from upstream llvm trunk (by Craig Topper):
Dimitry Andric [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

6 years agoMigrate to make_dev_s interface to populate /dev/nvmeX entries
Warner Losh [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

6 years agomalloc: stop reading the subzone if MALLOC_DEBUG_MAXZONES == 1 (the default)
Mateusz Guzik [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).

6 years agoFinish removing FDDI and tokenring media support.
Brooks Davis [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

6 years agoLoad balance sockets with new SO_REUSEPORT_LB option
Sean Bruno [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

6 years agoMap FreeBSD EDOOFUS to Linux EINVAL
Ed Maste [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.

6 years agoImplement 32-bit atomic_fcmpset() in userland for armv4/v5.
John Baldwin [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

6 years agoFix some harmless type mismatches in the ARM atomic_cmpset implementations.
John Baldwin [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

6 years agohda(4)
Sean Bruno [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

6 years agoEnable ARM PL330 DMA engine and Cadence Quad SPI flash controller on
Ruslan Bukin [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

6 years agoicmp6_reflect() sends ICMPv6 message with new IPv6 header. So, it is
Andrey V. Elsukov [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

6 years agoAdd driver for Cadence Quad SPI Flash Controller found on
Ruslan Bukin [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

6 years agolockf: add per-chain locks to the owner hash
Mateusz Guzik [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

6 years agolockf: skip locking the graph if not necessary (common case)
Mateusz Guzik [Mon, 23 Apr 2018 07:54:02 +0000 (07:54 +0000)]
lockf: skip locking the graph if not necessary (common case)

Tested by:      pho

6 years agolockf: perform wakeup onlly when there is anybody waiting
Mateusz Guzik [Mon, 23 Apr 2018 07:52:56 +0000 (07:52 +0000)]
lockf: perform wakeup onlly when there is anybody waiting

Tested by:      pho

6 years agolockf: skip the hard work in lf_purgelocks if possible
Mateusz Guzik [Mon, 23 Apr 2018 07:52:10 +0000 (07:52 +0000)]
lockf: skip the hard work in lf_purgelocks if possible

Tested by:      pho

6 years agolockf: free state only when recycling the vnode
Mateusz Guzik [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

6 years agoCorrect size for allocation and bzero of fdsr.
Xin LI [Mon, 23 Apr 2018 07:15:49 +0000 (07:15 +0000)]
Correct size for allocation and bzero of fdsr.

MFC after: 2 weeks

6 years agobsdgrep: Fix build failure WITHOUT_LZMA (incorrect bracket placement)
Kyle Evans [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

6 years agopwd_mkdb: add deprecation notice in manpage too
Ed Maste [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.

6 years agoUpdate committers-src.dot to show the mentorship arrangement for myself: eadler has...
Rebecca Cran [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.

6 years agoUpdate account and given names in committers-src.dot and calendar.freebsd
Rebecca Cran [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

6 years agoMake bufdaemon and bufspacedaemon use kthread_suspend_check instead of
Tijl Coosemans [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

6 years agolockf: slightly depessimize
Mateusz Guzik [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.

6 years agoRemove the "load drivers" logic from libibverbs.
Hans Petter Selasky [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

6 years agoFix the build post r332859
Justin Hibbits [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.

6 years agodwatch(1): Remove the line used to demonstrate `-dev' option
Devin Teske [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.

6 years agodwatch(1): Add profile for send(2)/recv(2) syscalls
Devin Teske [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.

6 years agodwatch(1): Add `-dev' option to aid debugging of profiles
Devin Teske [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.

6 years agoRemove unused definition bl_dfp; fix build with bktr compiled into kernel
Thomas Zander [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

6 years agoWhen running with INVARIANTS, the kernel contains extra checks. However,
Jonathan T. Looney [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

6 years agoExport powerpc CPU features for auxvec
Justin Hibbits [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.

6 years agobsdgrep: Use grep_strdup instead of grep_malloc+strcpy
Kyle Evans [Sat, 21 Apr 2018 14:58:45 +0000 (14:58 +0000)]
bsdgrep: Use grep_strdup instead of grep_malloc+strcpy

6 years agoAdd cfumass rc script, to create a LUN for cfumass(4).
Edward Tomasz Napierala [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

6 years agobsdgrep: Fix --include/--exclude ordering issues
Kyle Evans [Sat, 21 Apr 2018 13:46:07 +0000 (13:46 +0000)]
bsdgrep: Fix --include/--exclude ordering issues

Prior to r332851:
* --exclude always win out over --include
* --exclude-dir always wins out over --include-dir

r332851 broke that behavior, resulting in:
* First of --exclude, --include wins
* First of --exclude-dir, --include-dir wins

As it turns out, both behaviors are wrong by modern grep standards- the
latest rule wins. e.g.:

`grep --exclude foo --include foo 'thing' foo`
foo is included

`grep --include foo --exclude foo 'thing' foo`
foo is excluded

As tested with GNU grep 3.1.

This commit makes bsdgrep follow this behavior.

Reported by: se

6 years agoSync powerpc feature flags with Linux
Justin Hibbits [Sat, 21 Apr 2018 04:18:17 +0000 (04:18 +0000)]
Sync powerpc feature flags with Linux

Not all feature flags are synced.  Those for processors we don't currently
support are ignored currently.  Those that are supported are synced best I
can tell.  One flag was renamed to match the Linux flag name
(PPC_FEATURE2_VCRYPTO -> PPC_FEATURE2_VEC_CRYPTO).

6 years agoblake2: Disable warnings (not just error) for code we will not modify
Conrad Meyer [Sat, 21 Apr 2018 02:08:56 +0000 (02:08 +0000)]
blake2: Disable warnings (not just error) for code we will not modify

Leave libb2 pristine and silence the warnings for mjg.

6 years agobsdgrep: if chain => switch
Kyle Evans [Sat, 21 Apr 2018 01:42:02 +0000 (01:42 +0000)]
bsdgrep: if chain => switch

This makes some of this a little easier to follow (in my opinion).

6 years agobsdgrep: More trivial cleanup/style cleanup
Kyle Evans [Sat, 21 Apr 2018 01:33:13 +0000 (01:33 +0000)]
bsdgrep: More trivial cleanup/style cleanup

We can avoid branching for these easily reduced patterns

6 years agobsdgrep: Some light cleanup
Kyle Evans [Sat, 21 Apr 2018 01:02:35 +0000 (01:02 +0000)]
bsdgrep: Some light cleanup

There's no point checking for a bunch of file modes if we're not a
practicing believer of DIR_SKIP or DEV_SKIP.

This also reduces some style violations that were particularly ugly looking
when browsing through.

6 years agolldb: propagate error to user if memory read fails
Ed Maste [Sat, 21 Apr 2018 00:34:46 +0000 (00:34 +0000)]
lldb: propagate error to user if memory read fails

Previously, an attempt to read an unreadable access reported zeros:

(lldb) memory read -format hex -size 8 0
0x00000000: 0x0000000000000000 0x0000000000000000
0x00000010: 0x0000000000000000 0x0000000000000000
...

Now, if DoReadMemory encounters error then return 0 (bytes read) so we
report the error to the user:

(lldb) memory read -format hex -size 8 0
error: Bad address

LLVM PR: 37190

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

6 years agomakefs: tidy up reach-over source
Ed Maste [Fri, 20 Apr 2018 22:23:38 +0000 (22:23 +0000)]
makefs: tidy up reach-over source

- cd9660 relies on an #include "iso.h" but does not build any .c files
  out of source, so remove reach-over .PATH
- ffs does not rely on any sys/ headers, so remove -I from CFLAGS.
- ffs_tables from sys/ is used by ffs; move the SRCS entry from the top-
  level Makefile to ffs' Makefile.inc.

Sponsored by: The FreeBSD Foundation

6 years agoregulator: Check status before disabling
Emmanuel Vadot [Fri, 20 Apr 2018 20:30:33 +0000 (20:30 +0000)]
regulator: Check status before disabling

When disabling regulator when they are unused, check before is they are
enabled.
While here don't check the enable_cnt on the regulator entry as it is
checked by regnode_stop.
This solve the panic on any board using a fixed regulator that is driven
by a gpio when the regulator is unused.

Tested On: OrangePi One
Pointy Hat to:     myself
Reported by: kevans, Milan Obuch (freebsd-arm@dino.sk)

6 years agognu/dts: Update our copy of arm dts from Linux 4.16
Emmanuel Vadot [Fri, 20 Apr 2018 19:37:08 +0000 (19:37 +0000)]
gnu/dts: Update our copy of arm dts from Linux 4.16

6 years agodts: Update our copy from files from Linux 4.16
Emmanuel Vadot [Fri, 20 Apr 2018 18:44:52 +0000 (18:44 +0000)]
dts: Update our copy from files from Linux 4.16

6 years agoRecommit r332501, with an additional upstream fix for "Cannot lower
Dimitry Andric [Fri, 20 Apr 2018 18:20:55 +0000 (18:20 +0000)]
Recommit r332501, with an additional upstream fix for "Cannot lower
EFLAGS copy that lives out of a basic block!" errors on i386.

Pull in r325446 from upstream clang trunk (by me):

  [X86] Add 'sahf' CPU feature to frontend

  Summary:
  Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
  `+sahf` feature for the backend, for bug 36028 (Incorrect use of
  pushf/popf enables/disables interrupts on amd64 kernels).  This was
  originally submitted in bug 36037 by Jonathan Looney
  <jonlooney@gmail.com>.

  As described there, GCC also uses `-msahf` for this feature, and the
  backend already recognizes the `+sahf` feature. All that is needed is
  to teach clang to pass this on to the backend.

  The mapping of feature support onto CPUs may not be complete; rather,
  it was chosen to match LLVM's idea of which CPUs support this feature
  (see lib/Target/X86/X86.td).

  I also updated the affected test case (CodeGen/attr-target-x86.c) to
  match the emitted output.

  Reviewers: craig.topper, coby, efriedma, rsmith

  Reviewed By: craig.topper

  Subscribers: emaste, cfe-commits

  Differential Revision: https://reviews.llvm.org/D43394

Pull in r328944 from upstream llvm trunk (by Chandler Carruth):

  [x86] Expose more of the condition conversion routines in the public
  API for X86's instruction information. I've now got a second patch
  under review that needs these same APIs. This bit is nicely
  orthogonal and obvious, so landing it. NFC.

Pull in r329414 from upstream llvm trunk (by Craig Topper):

  [X86] Merge itineraries for CLC, CMC, and STC.

  These are very simple flag setting instructions that appear to only
  be a single uop. They're unlikely to need this separation.

Pull in r329657 from upstream llvm trunk (by Chandler Carruth):

  [x86] Introduce a pass to begin more systematically fixing PR36028
  and similar issues.

  The key idea is to lower COPY nodes populating EFLAGS by scanning the
  uses of EFLAGS and introducing dedicated code to preserve the
  necessary state in a GPR. In the vast majority of cases, these uses
  are cmovCC and jCC instructions. For such cases, we can very easily
  save and restore the necessary information by simply inserting a
  setCC into a GPR where the original flags are live, and then testing
  that GPR directly to feed the cmov or conditional branch.

  However, things are a bit more tricky if arithmetic is using the
  flags.  This patch handles the vast majority of cases that seem to
  come up in practice: adc, adcx, adox, rcl, and rcr; all without
  taking advantage of partially preserved EFLAGS as LLVM doesn't
  currently model that at all.

  There are a large number of operations that techinaclly observe
  EFLAGS currently but shouldn't in this case -- they typically are
  using DF.  Currently, they will not be handled by this approach.
  However, I have never seen this issue come up in practice. It is
  already pretty rare to have these patterns come up in practical code
  with LLVM. I had to resort to writing MIR tests to cover most of the
  logic in this pass already.  I suspect even with its current amount
  of coverage of arithmetic users of EFLAGS it will be a significant
  improvement over the current use of pushf/popf. It will also produce
  substantially faster code in most of the common patterns.

  This patch also removes all of the old lowering for EFLAGS copies,
  and the hack that forced us to use a frame pointer when EFLAGS copies
  were found anywhere in a function so that the dynamic stack
  adjustment wasn't a problem. None of this is needed as we now lower
  all of these copies directly in MI and without require stack
  adjustments.

  Lots of thanks to Reid who came up with several aspects of this
  approach, and Craig who helped me work out a couple of things
  tripping me up while working on this.

  Differential Revision: https://reviews.llvm.org/D45146

Pull in r329673 from upstream llvm trunk (by Chandler Carruth):

  [x86] Model the direction flag (DF) separately from the rest of
  EFLAGS.

  This cleans up a number of operations that only claimed te use EFLAGS
  due to using DF. But no instructions which we think of us setting
  EFLAGS actually modify DF (other than things like popf) and so this
  needlessly creates uses of EFLAGS that aren't really there.

  In fact, DF is so restrictive it is pretty easy to model. Only STD,
  CLD, and the whole-flags writes (WRFLAGS and POPF) need to model
  this.

  I've also somewhat cleaned up some of the flag management instruction
  definitions to be in the correct .td file.

  Adding this extra register also uncovered a failure to use the
  correct datatype to hold X86 registers, and I've corrected that as
  necessary here.

  Differential Revision: https://reviews.llvm.org/D45154

Pull in r330264 from upstream llvm trunk (by Chandler Carruth):

  [x86] Fix PR37100 by teaching the EFLAGS copy lowering to rewrite
  uses across basic blocks in the limited cases where it is very
  straight forward to do so.

  This will also be useful for other places where we do some limited
  EFLAGS propagation across CFG edges and need to handle copy rewrites
  afterward. I think this is rapidly approaching the maximum we can and
  should be doing here. Everything else begins to require either heroic
  analysis to prove how to do PHI insertion manually, or somehow
  managing arbitrary PHI-ing of EFLAGS with general PHI insertion.
  Neither of these seem at all promising so if those cases come up,
  we'll almost certainly need to rewrite the parts of LLVM that produce
  those patterns.

  We do now require dominator trees in order to reliably diagnose
  patterns that would require PHI nodes. This is a bit unfortunate but
  it seems better than the completely mysterious crash we would get
  otherwise.

  Differential Revision: https://reviews.llvm.org/D45673

Together, these should ensure clang does not use pushf/popf sequences to
save and restore flags, avoiding problems with unrelated flags (such as
the interrupt flag) being restored unexpectedly.

Requested by: jtl
PR: 225330
MFC after: 1 week

6 years agobsdgrep: Break procmatches down a little bit more
Kyle Evans [Fri, 20 Apr 2018 18:06:03 +0000 (18:06 +0000)]
bsdgrep: Break procmatches down a little bit more

Split the matching and non-matching cases out into their own functions to
reduce future complexity. As the name implies, procmatches will eventually
process more than one match itself in the future.

6 years agoRename PROC_PDEATHSIG_SET -> PROC_PDEATHSIG_CTL and PROC_PDEATHSIG_GET
Konstantin Belousov [Fri, 20 Apr 2018 15:19:27 +0000 (15:19 +0000)]
Rename PROC_PDEATHSIG_SET -> PROC_PDEATHSIG_CTL and PROC_PDEATHSIG_GET
-> PROC_PDEATHSIG_STATUS for consistency with other procctl(2)
operations names.

Requested by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 13 days

6 years agocall racct_proc_ucred_changed() under the proc lock
Andriy Gapon [Fri, 20 Apr 2018 13:08:04 +0000 (13:08 +0000)]
call racct_proc_ucred_changed() under the proc lock

The lock is required to ensure that the switch to the new credentials
and the transfer of the process's accounting data from the old
credentials to the new ones is done atomically.  Otherwise, some updates
may be applied to the new credentials and then additionally transferred
from the old credentials if the updates happen after proc_set_cred() and
before racct_proc_ucred_changed().

The problem is especially pronounced for RACCT_RSS because
- there is a strict accounting for this resource (it's reclaimable)
- it's updated asynchronously by the vm daemon
- it's updated by setting an absolute value instead of applying a delta

I had to remove a call to rctl_proc_ucred_changed() from
racct_proc_ucred_changed() and make all callers of latter call the
former as well.  The reason is that rctl_proc_ucred_changed, as it is
implemented now, cannot be called while holding the proc lock, so the
lock is dropped after calling racct_proc_ucred_changed.  Additionally,
I've added calls to crhold / crfree around the rctl call, because
without the proc lock there is no gurantee that the new credentials,
owned by the process, will stay stable.  That does not eliminate a
possibility that the credentials passed to the rctl will get stale.
Ideally, rctl_proc_ucred_changed should be able to work under the proc
lock.

Many thanks to kib for pointing out the above problems.

PR: 222027
Discussed with: kib
No comment: trasz
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15048

6 years agoFix use of pointer after being set NULL.
Rick Macklem [Fri, 20 Apr 2018 11:38:29 +0000 (11:38 +0000)]
Fix use of pointer after being set NULL.

Using a pointer after setting it NULL is probably not a good plan.
Spotted by inspection during changes for Flexible File Layout Ioerr handling.
This code path obviously isn't normally executed.

MFC after: 1 week

6 years agoAdd dead_bpf_if structure, that should be used as fake bpf_if
Andrey V. Elsukov [Fri, 20 Apr 2018 09:57:31 +0000 (09:57 +0000)]
Add dead_bpf_if structure, that should be used as fake bpf_if
during ifnet detach.

Since destroying interface is not atomic operation and due to the
lack of synhronization during destroy, it is possible, that in the
time between bpfdetach() and if_free() some queued on destroying
interface mbuf will be used by ether_input_internal() and
bpf_peers_present() can dereference NULL bpf_if pointer. To protect
from this, assign pointer to empty bpf_if_ext structure instead of
NULL pointer after bpfdetach().

Reviewed by: melifaro, eugen
Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D15083

6 years agobsdgrep: Add some TODOs for future work on operating on chunks
Kyle Evans [Fri, 20 Apr 2018 03:29:06 +0000 (03:29 +0000)]
bsdgrep: Add some TODOs for future work on operating on chunks

6 years agopowerpc64: Set n_slbs = 32 for POWER9
Justin Hibbits [Fri, 20 Apr 2018 03:23:19 +0000 (03:23 +0000)]
powerpc64: Set n_slbs = 32 for POWER9

Summary:
POWER9 also contains 32 slbs entries as explained by the POWER9 User Manual:

 "For HPT translation, the POWER9 core contains a unified (combined for both
   instruction and data), 32-entry, fully-associative SLB per thread"

Submitted by: Breno Leitao
Differential Revision: https://reviews.freebsd.org/D15128