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
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
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
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.
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
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
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
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
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
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
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
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
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.
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.
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.
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
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
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
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
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.
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.
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
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
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).
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
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
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.
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
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
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
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
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
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
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
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
mjg [Mon, 23 Apr 2018 07:52:56 +0000 (07:52 +0000)]
lockf: perform wakeup onlly when there is anybody waiting
Tested by: pho
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
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
delphij [Mon, 23 Apr 2018 07:15:49 +0000 (07:15 +0000)]
Correct size for allocation and bzero of fdsr.
MFC after: 2 weeks
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
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.
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.
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
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
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.
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
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.
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.
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.
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.
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
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
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.
kevans [Sat, 21 Apr 2018 14:58:45 +0000 (14:58 +0000)]
bsdgrep: Use grep_strdup instead of grep_malloc+strcpy
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
kevans [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
jhibbits [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).
cem [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.
kevans [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).
kevans [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
kevans [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.
emaste [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
emaste [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
manu [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)
manu [Fri, 20 Apr 2018 19:37:08 +0000 (19:37 +0000)]
gnu/dts: Update our copy of arm dts from Linux 4.16
manu [Fri, 20 Apr 2018 18:44:52 +0000 (18:44 +0000)]
dts: Update our copy from files from Linux 4.16
dim [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
kevans [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.
kib [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
avg [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
rmacklem [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
ae [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
kevans [Fri, 20 Apr 2018 03:29:06 +0000 (03:29 +0000)]
bsdgrep: Add some TODOs for future work on operating on chunks
jhibbits [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
jhibbits [Fri, 20 Apr 2018 03:19:44 +0000 (03:19 +0000)]
powerpc64: Add DSCR support
Summary:
Powerpc64 has support for a register called Data Stream Control Register
(DSCR), which basically controls how the hardware controls the caching and
prefetch for stream operations.
Since mfdscr and mtdscr are privileged instructions, we need to emulate them,
and
keep the custom DSCR configuration per thread.
The purpose of this feature is to change DSCR depending on the operation, set
to DSCR Default Prefetch Depth to deepest on string operations, as memcpy.
Submitted by: Breno Leitao
Differential Revision: https://reviews.freebsd.org/D15081
kevans [Fri, 20 Apr 2018 03:11:51 +0000 (03:11 +0000)]
bsdgrep: Clean up procmatches a little bit
kevans [Fri, 20 Apr 2018 03:08:46 +0000 (03:08 +0000)]
bsdgrep: Split match processing out of procfile
procfile is getting kind of hairy, and it's not going to get better as we
correct some more bits that assume we process one line at a time.
emaste [Fri, 20 Apr 2018 00:59:53 +0000 (00:59 +0000)]
lld: use correct number of digits in __FreeBSD_version-style ID
__FreeBSD_version-style IDs should have 5 digits following the major.
mckusick [Thu, 19 Apr 2018 22:43:55 +0000 (22:43 +0000)]
Fix incorrect output for a file consisting of a single full-size
block followed by a discontiguous fragment.
Add checks for unallocated inodes and inodes with unknown mode
types.
Cleanup variable declarations by changing from type `int' to types
like ufs_lbn_t, ufs2_daddr_t, etc.
Reported by: bde
brooks [Thu, 19 Apr 2018 21:53:57 +0000 (21:53 +0000)]
Add sortbench.
This is a set of benchmarks of qsort, mergesort, heapsort, and
optionally wikisort and a script to run them.
Submitted by: Miles Fertel <milesfertel@college.harvard.edu>
Sponsored by: Google Summer of Code 2017
Differential Revision: https://reviews.freebsd.org/D12677
emaste [Thu, 19 Apr 2018 20:58:09 +0000 (20:58 +0000)]
Add support for linker-type-specific flags
r332090 added a LINKER_TYPE test to add the --no-rosegment flag when
linking the i386 loader components with lld. Instead, introduce a
general mechanism for setting LDFLAGS for a specific linker type,
and use it for --no-rosegment.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14998
brooks [Thu, 19 Apr 2018 20:36:15 +0000 (20:36 +0000)]
Replace SOFTFLOAT with __riscv_float_abi_*.
With SOFTFLOAT, libc and libm were built correctly, but any program
including fenv.h itself assumed it was on a hardfloat systen and emitted
inline fpu instructions for fedisableexcept() and friends.
Unlike r315424 which did this for MIPS, I've used riscv_float_abi_soft
and riscv_float_abi_double macros as appropriate rather than using
__riscv_float_abi_soft exclusively. This ensures that attempts to use an
unsupported hardfloat ABI will fail.
Reviewed by: br
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10039
markm [Thu, 19 Apr 2018 20:31:52 +0000 (20:31 +0000)]
Remove empty dir no longer required.
Reported by: Jung-uk Kim
rmacklem [Thu, 19 Apr 2018 20:30:33 +0000 (20:30 +0000)]
Fix OpenDowngrade for NFSv4.1 if a client sets the OPEN_SHARE_ACCESS_WANT* bits.
The NFSv4.1 RFC specifies that the OPEN_SHARE_ACCESS_WANT bits can be set
in the OpenDowngrade share_access argument and are basically ignored.
I do not know of a extant NFSv4.1 client that does this, but this little
patch fixes it just in case.
It also changes the error from NFSERR_BADXDR to NFSERR_INVAL since the NFSv4.1
RFC specifies this as the error to be returned if bogus bits are set.
(The NFSv4.0 RFC didn't specify any error for this, so the error reply can
be changed for NFSv4.0 as well.)
Found by inspection while looking at a problem with OpenDowngrade reported
for the ESXi 6.5 NFSv4.1 client.
Reported by: andreas.nagy@frequentis.com
PR: 227214
MFC after: 1 week
emaste [Thu, 19 Apr 2018 20:25:19 +0000 (20:25 +0000)]
pwd_mkdb: warn that legacy support is deprecated (if specified)
r283981 switched pwd_mkdb to emit only v4 database entries by default,
and introduced a -l (legacy) option emit v3 entries in addition. The
commit message claims that legacy support will be removed in 12.0, so
emit a warning now if it is used.
nwhitehorn [Thu, 19 Apr 2018 18:34:38 +0000 (18:34 +0000)]
Fix detection of memory overlap with the kernel in the case where a memory
region marked "available" by firmware is contained entirely in the kernel.
This had a tendency to happen with FDTs passed by loader, though could for
other reasons as well, and would result in the kernel slowly cannibalizing
itself for other purposes, eventually resulting in a crash.
A similar fix is needed for mmu_oea.c and should probably just be rolled
at that point into some generic code in platform.c for taking a mem_region
list and removing chunks.
PR: 226974
Submitted by: leandro.lupori@gmail.com
Reviewed by: jhibbits
Differential Revision: D15121
np [Thu, 19 Apr 2018 18:10:44 +0000 (18:10 +0000)]
cxgbe(4): Fix bugs in the handling of COP rules that match on VLAN tag.
Retrieve the tag from the correct ifnet and use the provided tag
(instead of hardcoded 0xffff, implying no tag) in the routines that
process offload policy.
Submitted by: Krishnamraju Eraparaju @ Chelsio
Sponsored by: Chelsio Communications
kib [Thu, 19 Apr 2018 18:08:46 +0000 (18:08 +0000)]
Use symbolic constant, explaining the operation.
Sponsored by: The FreeBSD Foundation
imp [Thu, 19 Apr 2018 16:05:48 +0000 (16:05 +0000)]
Reword comment to remove awkward constructs, including an "it's" that
shouldn't have been there at all (it wasn't a typo for its, rather a
left-over from an older revision of the comment).
Noticed by: many
jhb [Thu, 19 Apr 2018 16:00:34 +0000 (16:00 +0000)]
Simplify the code to allocate stack for auxv, argv[], and environment vectors.
Remove auxarg_size as it was only used once right after a confusing
assignment in each of the variants of exec_copyout_strings().
Reviewed by: emaste
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D15123
imp [Thu, 19 Apr 2018 15:39:20 +0000 (15:39 +0000)]
Intel drives have an optimal alignment for I/O. While they honor I/Os
that cross this boundary, they perform better when this isn't the
case. Intel uses the 3rd byte in the vendor specific area for
this. The DC P3500 was previously listed without any explanation. Add
the DC P3520 and DC P4500 to the list.
There won't be any others drives needing this quirk. Intel has
standardized a field in the namespace data in 1.3 (noiob). A future
patch will use that if it exists, with fallback to this method.
Submitted by: Keith Busch
Reviewed by: jimharris@
mav [Thu, 19 Apr 2018 15:29:10 +0000 (15:29 +0000)]
Release memory resource on cuda driver attach failure.
Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
cem [Thu, 19 Apr 2018 15:24:21 +0000 (15:24 +0000)]
cryptosoft: Do not exceed crd_len around *crypt_multi
When a caller passes in a uio or mbuf chain that is longer than crd_len, in
tandem with a transform that supports the multi-block interface,
swcr_encdec() would process the entire mbuf or uio instead of just the
portion indicated by crd_len (+ crd_skip).
De/encryption are performed in-place, so this would trash subsequent uio or
mbuf contents.
This was introduced in r331639 (mea culpa). It only affects the
{de,en}crypt_multi() family of interfaces. That interface only has one
consumer transform in-tree (for now): Chacha20.
PR: 227605
Submitted by: Valentin Vergez <valentin.vergez AT stormshield.eu>
rrs [Thu, 19 Apr 2018 15:03:48 +0000 (15:03 +0000)]
These two modules need the tcp_hpts.h file for
when the option is enabled (not sure how LINT/build-universe
missed this) opps.
Sponsored by: Netflix Inc
kevans [Thu, 19 Apr 2018 15:02:53 +0000 (15:02 +0000)]
Fix ddb rc script
r288291 added a call to limits(1), which isn't available before partitions
are mounted. This broke the ddb rc script, which does not provide its own
start_cmd.
Alleviate the situation here by providing a start_cmd. We still have other
problems with diskless setups that need to be considered, but this is a
start.
PR: 206291
Submitted by: cy
Discussed with: rgrimes
MFC after: 3 days
markj [Thu, 19 Apr 2018 14:09:44 +0000 (14:09 +0000)]
Initialize marker pages in vm_page_domain_init().
They were previously initialized by the corresponding page daemon
threads, but for vmd_inacthead this may be too late if
vm_page_deactivate_noreuse() is called during boot.
Reported and tested by: cperciva
Reviewed by: alc, kib
MFC after: 1 week
rrs [Thu, 19 Apr 2018 13:37:59 +0000 (13:37 +0000)]
This commit brings in the TCP high precision timer system (tcp_hpts).
It is the forerunner/foundational work of bringing in both Rack and BBR
which use hpts for pacing out packets. The feature is optional and requires
the TCPHPTS option to be enabled before the feature will be active. TCP
modules that use it must assure that the base component is compile in
the kernel in which they are loaded.
MFC after: Never
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D15020
emaste [Thu, 19 Apr 2018 12:50:49 +0000 (12:50 +0000)]
chpass: reject change/expiry dates beyond y2106
The pwd.db and spwd.db files store the change and expire dates as
unsigned 32-bit ints, which overflow in 2106. Reject larger values for
now, until the introduction of a v5 password database.
i386 has 32-bit time_t and so dates beyond y2038 are already rejected by
mktime.
PR: 227589
Reviewed by: lidl
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
avg [Thu, 19 Apr 2018 05:06:56 +0000 (05:06 +0000)]
set kdb_why to "trap" when calling kdb_trap from trap_fatal
This will allow to hook a ddb script to "kdb.enter.trap" event.
Previously there was no specific name for this event, so it could only
be handled by either "kdb.enter.unknown" or "kdb.enter.default" hooks.
Both are very unspecific.
Having a specific event is useful because the fatal trap condition is
very similar to panic but it has an additional property that the current
stack frame is the frame where the trap occurred. So, both a register
dump and a stack bottom dump have additional information that can help
analyze the problem.
I have added the event only on architectures that have trap_fatal()
function defined. I haven't looked at other architectures. Their
maintainers can add support for the event later.
Sample script:
kdb.enter.trap=bt; show reg; x/aS $rsp,20; x/agx $rsp,20
Reviewed by: kib, jhb, markj
MFC after: 11 days
Sponsored by: Panzura
Differential Revision: https://reviews.freebsd.org/D15093
kevans [Thu, 19 Apr 2018 03:31:41 +0000 (03:31 +0000)]
efi loader: Address two nits with recent graphics changes
- We should be setting a known graphics mode on conout, but we aren't.
- We shouldn't be setting gop mode if we didn't find a good resolution to
set, but we were. This made efi_max_resolution=1x1 effectively worthless,
since it would always set gop mode 0 if nothing else.