]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoWe only ever need one devinfo per handle. So allocate it outside of
imp [Mon, 6 May 2019 18:39:22 +0000 (18:39 +0000)]
We only ever need one devinfo per handle. So allocate it outside of
looping over the filesystem modules rather than doing a malloc + free
each time through the loop. In addition, nothing changes from loop to
loop, so setup the new devinfo outside the loop as well.

5 years agoReach over and pull in devpath.c from libefi
imp [Mon, 6 May 2019 18:38:46 +0000 (18:38 +0000)]
Reach over and pull in devpath.c from libefi

This allows us to remove three nearly identical functions because the
differences don't matter, and the size difference is trivial.

5 years agoList-ify kernel dump device configuration
cem [Mon, 6 May 2019 18:24:07 +0000 (18:24 +0000)]
List-ify kernel dump device configuration

Allow users to specify multiple dump configurations in a prioritized list.
This enables fallback to secondary device(s) if primary dump fails.  E.g.,
one might configure a preference for netdump, but fallback to disk dump as a
second choice if netdump is unavailable.

This change does not list-ify netdump configuration, which is tracked
separately from ordinary disk dumps internally; only one netdump
configuration can be made at a time, for now.  It also does not implement
IPv6 netdump.

savecore(8) is already capable of scanning and iterating multiple devices
from /etc/fstab or passed on the command line.

This change doesn't update the rc or loader variables 'dumpdev' in any way;
it can still be set to configure a single dump device, and rc.d/savecore
still uses it as a single device.  Only dumpon(8) is updated to be able to
configure the more complicated configurations for now.

As part of revving the ABI, unify netdump and disk dump configuration ioctl
/ structure, and leave room for ipv6 netdump as a future possibility.
Backwards-compatibility ioctls are added to smooth ABI transition,
especially for developers who may not keep kernel and userspace perfectly
synced.

Reviewed by: markj, scottl (earlier version)
Relnotes: maybe
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19996

5 years agoUse PCIV_INVALID in pci_channel_offline() in the LinuxKPI.
hselasky [Mon, 6 May 2019 16:22:45 +0000 (16:22 +0000)]
Use PCIV_INVALID in pci_channel_offline() in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

MFC after: 1 week
Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoDisabling a PCI device should only disable busmaster in the LinuxKPI.
hselasky [Mon, 6 May 2019 16:17:38 +0000 (16:17 +0000)]
Disabling a PCI device should only disable busmaster in the LinuxKPI.

As Linux comment for this function point:
Signal to the system that the PCI device is not in use by the system
anymore. This only involves disabling PCI bus-mastering, if active.

Build tested drm-current-kmod prior to commit.

MFC after: 1 week
Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoImplement print_hex_dump_debug() function macro in the LinuxKPI.
hselasky [Mon, 6 May 2019 16:10:26 +0000 (16:10 +0000)]
Implement print_hex_dump_debug() function macro in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

MFC after: 1 week
Submitted by: slavash@
Sponsored by: Mellanox Technologies

5 years agoReformat arm64 linux syscalls.master per current style
emaste [Mon, 6 May 2019 16:07:14 +0000 (16:07 +0000)]
Reformat arm64 linux syscalls.master per current style

Equivalent to r339958 for sys/kern/syscalls.master.

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

5 years agoAllow controlling pr_debug at runtime in the LinuxKPI.
hselasky [Mon, 6 May 2019 16:00:20 +0000 (16:00 +0000)]
Allow controlling pr_debug at runtime in the LinuxKPI.

Turning on pr_debug at compile time make it non-optional at runtime.
This often means that the amount of the debugging is unbearable.
Allow developer to turn on pr_debug output only when needed.

Build tested drm-current-kmod prior to commit.

MFC after: 1 week
Submitted by: kib@
Sponsored by: Mellanox Technologies

5 years agogeom: fix initialization order
royger [Mon, 6 May 2019 09:48:34 +0000 (09:48 +0000)]
geom: fix initialization order

There's a race between the initialization of devsoftc.mtx (by devinit)
and the creation of the geom worker thread g_run_events, which calls
devctl_queue_data_f. Both of those are initialized at SI_SUB_DRIVERS
and SI_ORDER_FIRST, which means the geom worked thread can be created
before the mutex has been initialized, leading to the panic below:

 wpanic: mtx_lock() of spin mutex (null) @ /usr/home/osstest/build.135317.build-amd64-freebsd/freebsd/sys/kern/subr_bus.c:620
 cpuid = 3
 time = 1
 KDB: stack backtrace:
 db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe003b968710
 vpanic() at vpanic+0x19d/frame 0xfffffe003b968760
 panic() at panic+0x43/frame 0xfffffe003b9687c0
 __mtx_lock_flags() at __mtx_lock_flags+0x145/frame 0xfffffe003b968810
 devctl_queue_data_f() at devctl_queue_data_f+0x6a/frame 0xfffffe003b968840
 g_dev_taste() at g_dev_taste+0x463/frame 0xfffffe003b968a00
 g_load_class() at g_load_class+0x1bc/frame 0xfffffe003b968a30
 g_run_events() at g_run_events+0x197/frame 0xfffffe003b968a70
 fork_exit() at fork_exit+0x84/frame 0xfffffe003b968ab0
 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe003b968ab0
 --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
 KDB: enter: panic
 [ thread pid 13 tid 100029 ]
 Stopped at      kdb_enter+0x3b: movq    $0,kdb_why

Fix this by initializing geom at SI_ORDER_SECOND instead of
SI_ORDER_FIRST.

Sponsored by: Citrix Systems R&D
Reviewed by: kevans, markj
Differential revision: https://reviews.freebsd.org/D20148

5 years agoDo not flush NFS node from NFS VOP_SET_TEXT().
kib [Mon, 6 May 2019 08:49:43 +0000 (08:49 +0000)]
Do not flush NFS node from NFS VOP_SET_TEXT().

The more appropriate place to do the flushing is VOP_OPEN().  This was
uncovered because VOP_SET_TEXT() is now called with the vnode'
vm_object rlocked, which is incompatible with the flush operations.

After the move, there is no need for NFS-specific VOP_SET_TEXT
overload.

Sponsored by: The FreeBSD Foundation
MFC after: 30 days

5 years agoNoted by: alc
kib [Mon, 6 May 2019 08:46:11 +0000 (08:46 +0000)]
Noted by: alc
Reviewed by: alc, markj (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 6 days

5 years agoAdd ipsec.ko to required_modules for rc.d/ipsec script.
ae [Mon, 6 May 2019 08:30:53 +0000 (08:30 +0000)]
Add ipsec.ko to required_modules for rc.d/ipsec script.

Thus it can be automatically loaded if ipsec_enable="YES" and option IPSEC
is not in the kernel config.

MFC after: 1 week

5 years agozero inputs to vm_page_initfake() for predictable results
tychon [Mon, 6 May 2019 00:57:05 +0000 (00:57 +0000)]
zero inputs to vm_page_initfake() for predictable results

Reviewed by: kib
Submitted by: Anton Rang <rang at acm.org>
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20162

5 years agopowerpc/booke: Use #ifdef __powerpc64__ instead of hw_direct_map in places
jhibbits [Sun, 5 May 2019 20:23:43 +0000 (20:23 +0000)]
powerpc/booke: Use #ifdef __powerpc64__ instead of hw_direct_map in places

Since the DMAP is only available on powerpc64, and is *always* available on
Book-E powerpc64, don't penalize either side (32-bit or 64-bit) by always
checking hw_direct_map to perform operations.  This saves 5-10% time on
various ports builds, and on buildworld+buildkernel on Book-E hardware.

MFC after: 3 weeks

5 years agopowerpc/booke: Fix size check for phys_avail in pmap bootstrap
jhibbits [Sun, 5 May 2019 20:05:50 +0000 (20:05 +0000)]
powerpc/booke: Fix size check for phys_avail in pmap bootstrap

Use the nitems() macro instead of the expansion, a'la r298352.  Also, fix the
location of this check to after initializing availmem_regions_sz, so that the
check isn't always against 0, thus always failing (nitems(phys_avail) is always
more than 0).

5 years agoDecode some more ATA commands found in ACS-4.
mav [Sun, 5 May 2019 17:10:12 +0000 (17:10 +0000)]
Decode some more ATA commands found in ACS-4.

MFC after: 1 week

5 years agoEnsure that error is initialized in ufs_bmap_seekdata().
markj [Sun, 5 May 2019 16:57:03 +0000 (16:57 +0000)]
Ensure that error is initialized in ufs_bmap_seekdata().

Reported and tested by: jhibbits
MFC with: r346932
Sponsored by: The FreeBSD Foundation

5 years agoDecode Deallocate Logical Block Features.
mav [Sun, 5 May 2019 15:47:21 +0000 (15:47 +0000)]
Decode Deallocate Logical Block Features.

MFC after: 1 week

5 years agoSwitch to use shared vnode locks for text files during image activation.
kib [Sun, 5 May 2019 11:20:43 +0000 (11:20 +0000)]
Switch to use shared vnode locks for text files during image activation.

kern_execve() locks text vnode exclusive to be able to set and clear
VV_TEXT flag. VV_TEXT is mutually exclusive with the v_writecount > 0
condition.

The change removes VV_TEXT, replacing it with the condition
v_writecount <= -1, and puts v_writecount under the vnode interlock.
Each text reference decrements v_writecount.  To clear the text
reference when the segment is unmapped, it is recorded in the
vm_map_entry backed by the text file as MAP_ENTRY_VN_TEXT flag, and
v_writecount is incremented on the map entry removal

The operations like VOP_ADD_WRITECOUNT() and VOP_SET_TEXT() check that
v_writecount does not contradict the desired change.  vn_writecheck()
is now racy and its use was eliminated everywhere except access.
Atomic check for writeability and increment of v_writecount is
performed by the VOP.  vn_truncate() now increments v_writecount
around VOP_SETATTR() call, lack of which is arguably a bug on its own.

nullfs bypasses v_writecount to the lower vnode always, so nullfs
vnode has its own v_writecount correct, and lower vnode gets all
references, since object->handle is always lower vnode.

On the text vnode' vm object dealloc, the v_writecount value is reset
to zero, and deadfs vop_unset_text short-circuit the operation.
Reclamation of lowervp always reclaims all nullfs vnodes referencing
lowervp first, so no stray references are left.

Reviewed by: markj, trasz
Tested by: mjg, pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D19923

5 years agoDo not collapse objects with OBJ_NOSPLIT backing swap object.
kib [Sun, 5 May 2019 11:06:19 +0000 (11:06 +0000)]
Do not collapse objects with OBJ_NOSPLIT backing swap object.

NOSPLIT swap objects are not anonymous, they are used by tmpfs regular
files and POSIX shared memory.  For such objects, collapse is not
permitted.

Reported by: mjg
Reviewed by: markj, trasz
Tested by: mjg, pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19923

5 years agoimgact_elf: do not relock the text vnode if possible.
kib [Sun, 5 May 2019 11:04:01 +0000 (11:04 +0000)]
imgact_elf: do not relock the text vnode if possible.

We unlock the vnode around malloc(M_WAITOK), to make it possible for
pagedaemon to flush vnode pages for us.  Instead of doing it
unconditionally, first try M_NOWAIT allocation, which typically
succeed.  Only on failure, unlock the vnode and retry with M_WAITOK.

Reviewed by: markj, trasz
Tested by: mjg, pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19923

5 years agoColemak Mod DH keyboard layout
cs [Sun, 5 May 2019 09:02:32 +0000 (09:02 +0000)]
Colemak Mod DH keyboard layout

This is a minor modification of the Colemak keyboard layout.
See: http://colemakmods.github.io/mod-dh/

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D20133

5 years agoloader: validate sectorsize argument in disk_open()
tsoome [Sun, 5 May 2019 06:38:47 +0000 (06:38 +0000)]
loader: validate sectorsize argument in disk_open()

The bug and patch is reported against 11.2, but it is good idea to have
the check in place for all versions.

PR: 236585
Submitted by: john@feith.com
Reported by: john@feith.com
MFC after: 1 day

5 years ago[ath_rate_sample] Have the final attempted rate in 11n modes to be the lowest one.
adrian [Sun, 5 May 2019 06:32:40 +0000 (06:32 +0000)]
[ath_rate_sample] Have the final attempted rate in 11n modes to be the lowest one.

Right now ath_rate_sample has a fixed rate schedule, rather than the minstrel_ht
style "best, good, most reliable" triplet.  So, if higher rates are tried then
it'll not fail back to a lower MCS rate in that transmission schedule.

This means that in low SNR situations it'll not easily drop to MCS0 unless enough
transmissions occur to allow rate control to eventually decide to drop; and if
it's TCP traffic it'll get slowed down because of packet loss.

It's worse for 2-stream and 3-stream rates; it doesn't ever fall back to lower
stream rates, and these higher stream rates required higher SNR to work.

So instead let's (for now?) have each of the 11n transmit rates use MCS0 as
the last attempt. ath_rate_sample will quickly see that rate succeeds more
and will move to it much quicker.

Testing:

* AR9344 (Wasp) - 2G STA mode

5 years ago[ath] [ath_rate] Fix ANI calibration during non-ACTIVE states; start poking at rate...
adrian [Sun, 5 May 2019 04:56:37 +0000 (04:56 +0000)]
[ath] [ath_rate] Fix ANI calibration during non-ACTIVE states; start poking at rate control

These are some fun issues I've found with my upstairs wifi link at such a ridiculous
low signal level (like, < 5dB.)

* Add per-station tx/rx rssi statistics, in potential preparation to use that
  in the RX rate control.

* Call the rate control on each received frame to let it potentially use
  it as a hint for what rates to potentially use.  It's a no-op right now.

* Do ANI calibration during scan as well. The ath_newstate() call was disabling the
  ANI timer and only re-enabling it during transitions to _RUN.  This has the
  unfortunate side-effect that if ANI deafened the NIC because of interference
  and it disassociated, it wouldn't be reset and the scan would never hear beacons.

The ANI configuration is stored at least globally on some HALs and per-channel
on others.  Because of this a NIC reset wouldn't help; the ANI parameters would
simply be programmed back in.

Now, I have a feeling I also need to do this during AUTH/ASSOC too and maybe,
if I'm feeling clever, I need to reset the ANI parameters on a given channel
during a transition through INIT or if the VAP is destroyed/re-created.
However for now this gets me out of the immediate weeds with connectivity
upstairs (and thus I /can/ commit); I'll keep chipping away at tidying this
stuff up in subsequent commits.

Tested:

* AR9344 (Wasp), 2G STA mode

5 years agoMFV r347136:
cy [Sun, 5 May 2019 04:14:17 +0000 (04:14 +0000)]
MFV r347136:

Update sqlite3-3.27.2 (3270200) --> sqlite3-3.28.0 (3280000)

MFC after: 3 days
Security: CVE-2019-9937, CVE-2019-9936

5 years agox86: Implement MWAIT support for stopping a CPU
cem [Sat, 4 May 2019 20:34:26 +0000 (20:34 +0000)]
x86: Implement MWAIT support for stopping a CPU

IPI_STOP is used after panic or when ddb is entered manually.  MONITOR/
MWAIT allows CPUs that support the feature to sleep in a low power way
instead of spinning.  Something similar is already used at idle.

It is perhaps especially useful in oversubscribed VM environments, and is
safe to use even if the panic/ddb thread is not the BSP.  (Except in the
presence of MWAIT errata, which are detected automatically on platforms with
known wakeup problems.)

It can be tuned/sysctled with "machdep.stop_mwait," which defaults to 0
(off).  This commit also introduces the tunable
"machdep.mwait_cpustop_broken," which defaults to 0, unless the CPU has
known errata, but may be set to "1" in loader.conf to signal that mwait
wakeup is broken on CPUs FreeBSD does not yet know about.

Unfortunately, Bhyve doesn't yet support MONITOR extensions, so this doesn't
help bhyve hypervisors running FreeBSD guests.

Submitted by:   Anton Rang <rang AT acm.org> (earlier version)
Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20135

5 years agoarm64: Properly restore PAN when done with userspace access in casueword.
kib [Sat, 4 May 2019 19:40:30 +0000 (19:40 +0000)]
arm64: Properly restore PAN when done with userspace access in casueword.

Approved by: andrew
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agosysv: get rid of fork/exit hooks if the code is compiled in
mjg [Sat, 4 May 2019 19:05:30 +0000 (19:05 +0000)]
sysv: get rid of fork/exit hooks if the code is compiled in

Sponsored by: The FreeBSD Foundation

5 years agoAnnotate nprocs with __exclusive_cache_line
mjg [Sat, 4 May 2019 19:04:17 +0000 (19:04 +0000)]
Annotate nprocs with __exclusive_cache_line

Sponsored by: The FreeBSD Foundation

5 years agoZero out the file directory entry metadata to reduce disk
mckusick [Sat, 4 May 2019 18:00:57 +0000 (18:00 +0000)]
Zero out the file directory entry metadata to reduce disk
scavenging disclosure.

Submitted by: David G. Lawrence <dg@dglawrence.com>
MFC after:    1 week

5 years agox86: Define pc_monitorbuf as a logical structure
cem [Sat, 4 May 2019 17:35:13 +0000 (17:35 +0000)]
x86: Define pc_monitorbuf as a logical structure

Rather than just accessing it via pointer cast.

No functional change intended.

Discussed with: kib (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20135

5 years agopowerpc/mpc85xx: Attach MPC85xx PCI bus and root complex at the right pass
jhibbits [Sat, 4 May 2019 16:24:43 +0000 (16:24 +0000)]
powerpc/mpc85xx: Attach MPC85xx PCI bus and root complex at the right pass

No signifcant change, just matches other PCI attachments, attaching at
BUS_PASS_BUS.

MFC after: 2 weeks

5 years agoAdd emmc clock definitions for Rockchip RK3399 SoC.
ganbold [Sat, 4 May 2019 10:48:44 +0000 (10:48 +0000)]
Add emmc clock definitions for Rockchip RK3399 SoC.

5 years agoFix regression issue after r346645 in the LinuxKPI.
hselasky [Sat, 4 May 2019 09:47:01 +0000 (09:47 +0000)]
Fix regression issue after r346645 in the LinuxKPI.

The S/G list must be mapped AS-IS without any optimisations.
This also implies that sg_dma_len() must be equal to sg->length.
Many Linux drivers assume this and this fixes some DRM issues.

Put the BUS DMA map pointer into the scatter-gather list to
allow multiple mappings on the same physical memory address.

The FreeBSD version has been bumped to force recompilation of
external kernel modules.

Sponsored by: Mellanox Technologies

5 years agoFix regression issue after r346645 in the LinuxKPI.
hselasky [Sat, 4 May 2019 09:30:03 +0000 (09:30 +0000)]
Fix regression issue after r346645 in the LinuxKPI.
Properly handle error case when mapping DMA address fails.

Sponsored by: Mellanox Technologies

5 years agopowerpc: Optimize padding in bus_dma_tag
jhibbits [Sat, 4 May 2019 02:45:24 +0000 (02:45 +0000)]
powerpc: Optimize padding in bus_dma_tag

Avoid 8 bytes of padding (2 noncontiguous ints).

Submitted by: Brandon Bergren <git_bdragon.rtk0.net>
Differential Revision: https://reviews.freebsd.org/D20121

5 years agopowerpc: Merge all pmap struct definitions
jhibbits [Sat, 4 May 2019 02:34:28 +0000 (02:34 +0000)]
powerpc: Merge all pmap struct definitions

Summary:
A few ports fail to build due to missing pmap-related definitions, which are
specific per-pmap type.  This tries to appease those ports, by merging all
pmaps together.

A future change will move the inline page directory out of the Book-E pmap,
to eliminate the last #ifdefs in pmap.h and complete the merge.

Reviewed By: luporl
Differential Revision: https://reviews.freebsd.org/D20119

5 years agoFix `clang -Wcast-qual` issues
ngie [Sat, 4 May 2019 02:09:30 +0000 (02:09 +0000)]
Fix `clang -Wcast-qual` issues

Remove unnecessary `char*` casting for arguments passed to `cget*(3)`, and
deconst `_PATH_PRINTCAP` before passing it to `cget*` via the `printcapdb`
variable.

This unblocks ^/projects/runtime-coverage-v2 from building cleanly on
universe13a.freebsd.org. I suspect the issue was introduced through some
changes to `bsd.*.mk` inclusion on the branch, which I will continue to
investigate/isolate.

MFC after: 1 week
Tested with: clang 8 (arm64)

5 years agoThis update eliminates a kernel stack disclosure bug in UFS/FFS
mckusick [Fri, 3 May 2019 21:54:14 +0000 (21:54 +0000)]
This update eliminates a kernel stack disclosure bug in UFS/FFS
directory entries that is caused by uninitialized directory entry
padding written to the disk. It can be viewed by any user with read
access to that directory. Up to 3 bytes of kernel stack are disclosed
per file entry, depending on the the amount of padding the kernel
needs to pad out the entry to a 32 bit boundry. The offset in the
kernel stack that is disclosed is a function of the filename size.
Furthermore, if the user can create files in a directory, this 3
byte window can be expanded 3 bytes at a time to a 254 byte window
with 75% of the data in that window exposed. The additional exposure
is done by removing the entry, creating a new entry with a 4-byte
longer name, extracting 3 more bytes by reading the directory, and
repeating until a 252 byte name is created.

This exploit works in part because the area of the kernel stack
that is being disclosed is in an area that typically doesn't change
that often (perhaps a few times a second on a lightly loaded system),
and these file creates and unlinks themselves don't overwrite the
area of kernel stack being disclosed.

It appears that this bug originated with the creation of the Fast
File System in 4.1b-BSD (Circa 1982, more than 36 years ago!), and
is likely present in every Unix or Unix-like system that uses
UFS/FFS. Amazingly, nobody noticed until now.

This update also adds the -z flag to fsck_ffs to have it scrub
the leaked information in the name padding of existing directories.
It only needs to be run once on each UFS/FFS filesystem after a
patched kernel is installed and running.

Submitted by: David G. Lawrence <dg@dglawrence.com>
Reviewed by:  kib
MFC after:    1 week

5 years agoEmulate the "ADD reg, r/m" instruction (opcode 03H).
jhb [Fri, 3 May 2019 21:48:42 +0000 (21:48 +0000)]
Emulate the "ADD reg, r/m" instruction (opcode 03H).

OVMF's flash variable storage is using add instructions when indexing
the variable store bootrom location.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Reviewed by: rgrimes
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D19975

5 years agoSimplify calculation of DIRECTSIZ. No functional change intended.
mckusick [Fri, 3 May 2019 21:46:25 +0000 (21:46 +0000)]
Simplify calculation of DIRECTSIZ. No functional change intended.

Suggested by: kib
MFC after:    1 week

5 years agoDisallow excessively small times of day in clock_settime(2).
markj [Fri, 3 May 2019 21:26:44 +0000 (21:26 +0000)]
Disallow excessively small times of day in clock_settime(2).

Reported by: syzkaller
Reviewed by: cem, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20151

5 years agoUse SRC+= rather than SRC=
imp [Fri, 3 May 2019 21:13:09 +0000 (21:13 +0000)]
Use SRC+= rather than SRC=

To allow boot1/Makefile to be included, use SRC+= rathern than SRC=
so the including Makefile can add additional sources to the build.

5 years agoSubstitute boot1 with ${BOOT1}
imp [Fri, 3 May 2019 21:13:04 +0000 (21:13 +0000)]
Substitute boot1 with ${BOOT1}

Allow for other names to be built, so parameterize this makefile to
avoid hard coding boot1.

5 years agoWhen we can't get memory, trying again right away is going to
imp [Fri, 3 May 2019 21:09:25 +0000 (21:09 +0000)]
When we can't get memory, trying again right away is going to
fail. Rather than print N failure messages, bail on the first one.

5 years agoRemove stray '*'
imp [Fri, 3 May 2019 21:06:34 +0000 (21:06 +0000)]
Remove stray '*'

We're storing an EFI_HANDLE, not an pointer to a handle. Since
EFI_HANDLE is a void * anyway, this has little practical effect since
the conversion to / from void * and void ** is silent.

5 years agoWhen MAC is enabled and a policy module is loaded, don't unconditionally
rwatson [Fri, 3 May 2019 20:38:43 +0000 (20:38 +0000)]
When MAC is enabled and a policy module is loaded, don't unconditionally
lock mac_ifnet_mtx, which protects labels on struct ifnet, unless at least
one policy is actively using labels on ifnets.  This avoids a global mutex
acquire in certain fast paths -- most noticeably ifnet transmit.  This was
previously invisible by default, as no MAC policies were loaded by default,
but recently became visible due to mac_ntpd being enabled by default.

gallatin@ reports a reduction in PPS overhead from 300% to 2.2% with this
change.  We will want to explore further MAC Framework optimisation to
reduce overhead further, but this brings things more back into the world
of the sane.

MFC after: 3 days

5 years agoAllow iflib drivers to pass a pointer to their own ifmedia structure.
mmacy [Fri, 3 May 2019 20:05:31 +0000 (20:05 +0000)]
Allow iflib drivers to pass a pointer to their own ifmedia structure.

Tested by: emaste@

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

5 years agoIncrease the default size of the GCE disk image from 3GB to 20GB,
gjb [Fri, 3 May 2019 17:23:08 +0000 (17:23 +0000)]
Increase the default size of the GCE disk image from 3GB to 20GB,
as 3GB is too small as discovered in this week's snapshot builds.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoSelect lacp egress ports based on NUMA domain
gallatin [Fri, 3 May 2019 14:43:21 +0000 (14:43 +0000)]
Select lacp egress ports based on NUMA domain

This change creates an array of port maps indexed by numa domain
for lacp port selection. If we have lacp interfaces in more than
one domain, then we select the egress port by indexing into the
numa port maps and picking a port on the appropriate numa domain.

This is behavior is controlled by the new ifconfig use_numa flag
and net.link.lagg.use_numa sysctl/tunable (both modeled after the
existing use_flowid), which default to enabled.

Reviewed by: bz, hselasky, markj (and scottl, earlier version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20060

5 years agoFix copying planar bitmaps when the horizontal start and end are both not
bde [Fri, 3 May 2019 13:06:46 +0000 (13:06 +0000)]
Fix copying planar bitmaps when the horizontal start and end are both not
multiples of 8.  Then the misaligned pixels at the end were not copied.

Clean up variable misuse related to this bug.  The width in bytes was
first calculated correctly and used to do complicated reblocking
correctly, but it was stored in an unrelated scratch variable and later
recalculated with an off-by-1-error, so the last byte (times 4 planes)
in the intermediate copy was not copied.

This doubly-misaligned case is especially slow.  Misalignment complicates
the reblocking, and each misaligment requires a read before write, and this
read is still not done from the shadow buffer.

5 years agoIn order to reduce duplication between MD parts of the Linuxulator
dchagin [Fri, 3 May 2019 08:42:49 +0000 (08:42 +0000)]
In order to reduce duplication between MD parts of the Linuxulator
move bits that are MI out into the headers in compat/linux.
For that remove bogus _packed attribute from struct l_sockaddr
and use MI types for struct members.

And continue to move into the linux_common module a code that is
intended for both Linuxulator modules (both instruction set - 32 & 64 bit)
or for external modules like linsysfs or linprocfs.

To avoid header pollution introduce new sys/compat/linux_common.h header.

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

5 years agoDecode more CPU flags in cpuinfo.
trasz [Fri, 3 May 2019 08:27:03 +0000 (08:27 +0000)]
Decode more CPU flags in cpuinfo.

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

5 years ago[libfetch] Fix compilation with WITHOUT_CRYPT.
adrian [Fri, 3 May 2019 06:06:39 +0000 (06:06 +0000)]
[libfetch] Fix compilation with WITHOUT_CRYPT.

5 years agofls() should find the most significant bit of an int faster than a
dougm [Fri, 3 May 2019 02:55:54 +0000 (02:55 +0000)]
fls() should find the most significant bit of an int faster than a
linear search can, so use it to avoid a linear search in isqrt.

Approved by: kib (mentor), markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20102

5 years agoIncrease the VirtIO segment count to support modern Windows guests.
jhb [Thu, 2 May 2019 22:46:37 +0000 (22:46 +0000)]
Increase the VirtIO segment count to support modern Windows guests.

The Windows virtio driver ignores the advertized seg_max field and
assumes the host can accept up to 67 segments in indirect descriptors,
triggering an assert in the bhyve process.

This brings back r282922 but with a couple of changes:
- It raises the block interface segment limit to 128 instead of 67.
- Linux's virtio driver assumes that the segment limit is no
  larger than the ring size.  To avoid breaking Linux guests,
  raise the VirtIO ring size to 128, and cap the VirtIO segment
  limit at ring size - 2 (effectively 126).

Reviewed by: rgrimes, Patrick Mooney <pmooney@pfmooney.com>
Obtained from: Joyent (Linux workaround)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18831

5 years agodirectory.3: add a STANDARDS section
asomers [Thu, 2 May 2019 19:59:37 +0000 (19:59 +0000)]
directory.3: add a STANDARDS section

Reviewed by: jilles, ngie
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20111

5 years agoiflib: remove assertion that isc_capabilities is nonzero
emaste [Thu, 2 May 2019 19:13:31 +0000 (19:13 +0000)]
iflib: remove assertion that isc_capabilities is nonzero

It's atypical, but not invalid, for a driver to pass no capabilities.

Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by: shurd
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20142

5 years agoFix flags in cpuinfo.
trasz [Thu, 2 May 2019 19:02:16 +0000 (19:02 +0000)]
Fix flags in cpuinfo.

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

5 years agoAdd a COMPAT_FREEBSD12 kernel option.
cem [Thu, 2 May 2019 18:10:23 +0000 (18:10 +0000)]
Add a COMPAT_FREEBSD12 kernel option.

Use it wherever COMPAT_FREEBSD11 is currently specified, like r309749.

Reviewed by: imp, jhb, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20120

5 years agolibbe: set mountpoint=none in be_import
kevans [Thu, 2 May 2019 17:50:56 +0000 (17:50 +0000)]
libbe: set mountpoint=none in be_import

If we're going to set a mountpoint at all, mountpoint=none makes more sense
than mountpoint=/.

MFC after:  3 days

5 years agolibbe(3): Properly mount BEs with mountpoint=none
kevans [Thu, 2 May 2019 17:44:46 +0000 (17:44 +0000)]
libbe(3): Properly mount BEs with mountpoint=none

Instead of pretending to successfully mount them while not actually
mounting anything, we'll now actually mount them *and* claim we mounted them
successfully.

Reported by: ler
MFC after: 3 days

5 years agodtb: Include RK3399 RockPro64 DTS in kernel build
manu [Thu, 2 May 2019 17:04:01 +0000 (17:04 +0000)]
dtb: Include RK3399 RockPro64 DTS in kernel build

The DTS for this board is already present in sys/gnu/dts/arm64/rockchip/
and just needs to be enabled.

Submitted by: alex@wied.io
Differential Revision: https://reviews.freebsd.org/D19823

5 years agostand: correct mis-merge from r346879
kevans [Thu, 2 May 2019 17:01:13 +0000 (17:01 +0000)]
stand: correct mis-merge from r346879

Small mis-merge from multiple WIP resulted in block io media handles getting
double-initialized. This resulted in some installations oddly landing at the
mountroot prompt.

Reported by: ler
Reviewed by: imp

5 years agofdt: Fix installation of aarch64 dtb
kevans [Thu, 2 May 2019 16:56:03 +0000 (16:56 +0000)]
fdt: Fix installation of aarch64 dtb

r345519 rewrote parts of how we build .dtb, but mistakenly dropped the
vendor dir for aarch64.  Simply drop the :T for building ${DTB} in the
aarch64 case- it'll get applied at install-time as-needed, with :H:T for
determining the vendor dir.

Reported by: manu
Tested by: manu
Reviewed by: manu
MFC after: 3 days

5 years agoEnroll new committer Doug Moore (dougm@freebsd.org).
dougm [Thu, 2 May 2019 16:28:33 +0000 (16:28 +0000)]
Enroll new committer Doug Moore (dougm@freebsd.org).

Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D20136

5 years agoCleanup for rtld_malloc.c.
kib [Thu, 2 May 2019 15:03:16 +0000 (15:03 +0000)]
Cleanup for rtld_malloc.c.

- Remove dead and most likely rotten MALLOC_DEBUG, MSTAT, and RCHECK options.
- Remove unused headers.
- Remove one case of undefined behavior where left shift could overflow.
  It is impossible on practice for rtld and libthr consumer.

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

5 years agoarm64: Add support for NanoPI NEO2
manu [Thu, 2 May 2019 12:56:13 +0000 (12:56 +0000)]
arm64: Add support for NanoPI NEO2

Add overlay files and activate devicetree file for NanoPi NEO2 featuring
Allwinner H5 ARM64 core.
To enable sound, dma and codec drivers are enabled for build.

Submitted by: Manuel Stühn (freebsdnewbie@freenet.de)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D20129

5 years agoRemove unneeded includes.
dchagin [Thu, 2 May 2019 09:00:36 +0000 (09:00 +0000)]
Remove unneeded includes.

MFC after: 2 week

5 years agoAdd sys/devices/system/cpu/{possible,present} to linsysfs(5).
trasz [Thu, 2 May 2019 08:17:29 +0000 (08:17 +0000)]
Add sys/devices/system/cpu/{possible,present} to linsysfs(5).
That makes Linux lscpu(1) work.

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

5 years agopowerpc: Drop OPAL_HANDLE_HMI2 for now, to avoid panicking
jhibbits [Thu, 2 May 2019 03:39:03 +0000 (03:39 +0000)]
powerpc: Drop OPAL_HANDLE_HMI2 for now, to avoid panicking

It's possible for a Hypervisor Maintenance Interrupt (HMI) to occur while in
the pmap code, holding locks.  This can cause WITNESS to panic due to lock
errors in calling pmap_kextract().  Since we don't yet handle the flags
returned by OPAL_HANDLE_HMI2, just stop using it, so that we don't call into
pmap_kextract().

Reported by: pkubaj

5 years agoUnbreak the tests after r347002.
trasz [Wed, 1 May 2019 19:35:45 +0000 (19:35 +0000)]
Unbreak the tests after r347002.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agoAdd 'Birth' to 'stat -x' output. Current Linux stat(1)
trasz [Wed, 1 May 2019 18:56:22 +0000 (18:56 +0000)]
Add 'Birth' to 'stat -x' output. Current Linux stat(1)
also includes that.

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

5 years agoAdd MLINKS to atf-c.3.
trasz [Wed, 1 May 2019 18:54:27 +0000 (18:54 +0000)]
Add MLINKS to atf-c.3.

Reviewed by: ngie
MFC after: 2 weeks
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D20125

5 years agoRestore x18 in efi_arch_leave.
andrew [Wed, 1 May 2019 17:12:49 +0000 (17:12 +0000)]
Restore x18 in efi_arch_leave.

Some UEFI implementations trash this register and, as we use it as a
platform register, the kernel doesn't save it before calling into the UEFI
runtime services. As we have a copy in tpidr_el1 restore from there when
exiting the EFI environment.

PR: 237234, 237055
Reviewed by: manu
Tested On: Ampere eMAG
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Sponsored by: Ampere Computing (hardware)
Differential Revision: https://reviews.freebsd.org/D20127

5 years agoAdd a few regression tests for mlock(2).
markj [Wed, 1 May 2019 15:28:23 +0000 (15:28 +0000)]
Add a few regression tests for mlock(2).

These are intended to exercise some rarely executed code paths.

MFC after: 2 weeks

5 years agoDeactivate IRQ resource by calling to intr_deactivate_irq().
br [Wed, 1 May 2019 15:03:12 +0000 (15:03 +0000)]
Deactivate IRQ resource by calling to intr_deactivate_irq().
This is the part of INTRNG support that was missed.

Sponsored by: DARPA, AFRL

5 years agoAdd a hw.model sysctl oid for arm64 which reports the CPU model similar to armv6/7.
ganbold [Wed, 1 May 2019 14:20:31 +0000 (14:20 +0000)]
Add a hw.model sysctl oid for arm64 which reports the CPU model similar to armv6/7.

Reviewed by: andrew, manu
Differential Revision: https://reviews.freebsd.org/D20123

5 years agoFix another race between vm_map_protect() and vm_map_wire().
kib [Wed, 1 May 2019 13:15:06 +0000 (13:15 +0000)]
Fix another race between vm_map_protect() and vm_map_wire().

vm_map_wire() increments entry->wire_count, after that it drops the
map lock both for faulting in the entry' pages, and for marking next
entry in the requested region as IN_TRANSITION. Only after all entries
are faulted in, MAP_ENTRY_USER_WIRE flag is set.

This makes it possible for vm_map_protect() to run while other entry'
MAP_ENTRY_IN_TRANSITION flag is handled, and vm_map_busy() lock does
not prevent it. In particular, if the call to vm_map_protect() adds
VM_PROT_WRITE to CoW entry, it would fail to call
vm_fault_copy_entry(). There are at least two consequences of the
race: the top object in the shadow chain is not populated with
writeable pages, and second, the entry eventually get contradictory
flags MAP_ENTRY_NEEDS_COPY | MAP_ENTRY_USER_WIRED with VM_PROT_WRITE
set.

Handle it by waiting for all MAP_ENTRY_IN_TRANSITION flags to go away
in vm_map_protect(), which does not drop map lock afterwards. Note
that vm_map_busy_wait() is left as is.

Reported and tested by: pho (previous version)
Reviewed by: Doug Moore <dougm@rice.edu>, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D20091

5 years agoRemove trailing slashes from URLs; current mandoc(1) seems to render
trasz [Wed, 1 May 2019 13:00:33 +0000 (13:00 +0000)]
Remove trailing slashes from URLs; current mandoc(1) seems to render
them just fine.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoUse D_PARTISGPT rather than bare 255
imp [Wed, 1 May 2019 05:42:13 +0000 (05:42 +0000)]
Use D_PARTISGPT rather than bare 255

These three cases dovetail with other places in the code where we use
or set D_PARTISGPT when we mean that the partitioning scheme is
GPT. Use this #define to make the code easier to undertand.

Reviewed by: tsoome@
Differential Revision: https://reviews.freebsd.org/D20122

5 years agoRespect quotes and escapes when splitting exports fields.
mav [Tue, 30 Apr 2019 21:38:38 +0000 (21:38 +0000)]
Respect quotes and escapes when splitting exports fields.

Without this r293305 was still unable to handle names with spaces.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

5 years agoAdd a paragraph that mentions gptboot having an interactive mode, and
ian [Tue, 30 Apr 2019 18:48:20 +0000 (18:48 +0000)]
Add a paragraph that mentions gptboot having an interactive mode, and
direct the user to the boot(8) manpage, which provides the details on that.

5 years agozfsboot: to detect disk size, use GPT information first
tsoome [Tue, 30 Apr 2019 17:45:22 +0000 (17:45 +0000)]
zfsboot: to detect disk size, use GPT information first

If we do have GPT on disk, read the disk size from it and do not
call int13.

Since int13 does report bogus informatiopn too often, rather trust the
partition table. We are using the same strategy with loader.

MFC after: 1 month

5 years agoUpdate the manpage text to show the output generated by the first-stage
ian [Tue, 30 Apr 2019 17:42:05 +0000 (17:42 +0000)]
Update the manpage text to show the output generated by the first-stage
bootloader these days (x86 instead of i386).

5 years agoFollow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator.
dchagin [Tue, 30 Apr 2019 17:18:05 +0000 (17:18 +0000)]
Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator.
It was first introduced in r163734 and missied by me in r283383.

MFC after: 1 week

5 years agorevert QEMU q35 platform use from r346748
emaste [Tue, 30 Apr 2019 15:28:52 +0000 (15:28 +0000)]
revert QEMU q35 platform use from r346748

It seems to be incompatible with the OVMF.fd (of unknown provenance)
in use by the Cirrus-CI config.  We will soon have a known OVMF build
via a port/package (see review D19869) and we can switch back to q35
once packages are available.

Discussed with: bcran

5 years agoRetry upon NET_RT_IFLIST sysctl failure.
markj [Tue, 30 Apr 2019 14:44:39 +0000 (14:44 +0000)]
Retry upon NET_RT_IFLIST sysctl failure.

Port the logic used by getifaddrs(3) to handle the case where
NET_RT_IFLIST returns ENOMEM, which can occur if the list size changes
between the buffer allocation and sysctl read.

PR: 195191
Submitted by: Guy Yur <guyyur@gmail.com> (original version)
MFC after: 1 week

5 years agoReduce the default image size for virtual machine disk images from
gjb [Tue, 30 Apr 2019 14:29:09 +0000 (14:29 +0000)]
Reduce the default image size for virtual machine disk images from
30GB to 3GB.  The raw images can be resized using truncate(1), and
other formats can be resized with tools included with other tools
included with other hypervisors.

Enable the growfs(8) rc(8) at firstboot if the disk was resized
prior to booting the virtual machine for the first time.

Discussed with: several
PR: 232313 (requested in other context)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoReduce the number of mutexes after r346645 in the LinuxKPI.
hselasky [Tue, 30 Apr 2019 10:41:20 +0000 (10:41 +0000)]
Reduce the number of mutexes after r346645 in the LinuxKPI.
Make function macro wrappers for locking and unlocking to ease readability.

No functional change.

Discussed with: kib@, tychon@ and zeising@
Sponsored by: Mellanox Technologies

5 years agoMake the dma_pool structure private to the LinuxKPI similar to Linux.
hselasky [Tue, 30 Apr 2019 09:38:22 +0000 (09:38 +0000)]
Make the dma_pool structure private to the LinuxKPI similar to Linux.

No functional change.

Discussed with: kib @
Sponsored by: Mellanox Technologies

5 years agoStore a pointer to the device instead of the PCI device in the DMA pool
hselasky [Tue, 30 Apr 2019 09:26:11 +0000 (09:26 +0000)]
Store a pointer to the device instead of the PCI device in the DMA pool
implementation in the LinuxKPI. This avoids use of container_of().

No functional change.

Discussed with: kib @
Sponsored by: Mellanox Technologies

5 years agopowerpc: Stop pretending we run on e500v1 cores
jhibbits [Tue, 30 Apr 2019 03:45:46 +0000 (03:45 +0000)]
powerpc: Stop pretending we run on e500v1 cores

Unconditional writing to MAS7, which doesn't exist on the e500v1 core, in a
TLB miss handler has been in the code for several years now.  Since this has
gone unnoticed for so long, it's easily concluded that e500v1 is not in use
with FreeBSD.  Simplify the code path a bit, by unconditionally zeroing MAS7
instead of calling a subroutine to do it.

5 years agopowerpc64: Fix switch panic from cpu_throw()
jhibbits [Mon, 29 Apr 2019 22:37:35 +0000 (22:37 +0000)]
powerpc64: Fix switch panic from cpu_throw()

r18 is used to hold the old PCB flags, but cpu_throw doesn't populate r18
with PCB flags, since the old thread is gone.  This can lead to panics on
cores that don't have the registers guarded by these flags.

5 years agoRewrap some long lines.
jhb [Mon, 29 Apr 2019 22:15:51 +0000 (22:15 +0000)]
Rewrap some long lines.

Whitespace only change.

5 years agoOptimize lseek(SEEK_DATA) on UFS.
markj [Mon, 29 Apr 2019 22:05:26 +0000 (22:05 +0000)]
Optimize lseek(SEEK_DATA) on UFS.

This version fixes the problems identified in r345244.

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

5 years agoNote that ccr(4) now supports AES-CCM.
jhb [Mon, 29 Apr 2019 22:00:45 +0000 (22:00 +0000)]
Note that ccr(4) now supports AES-CCM.

5 years agoUpdate/reformat maintainer entries that I am a part of
ngie [Mon, 29 Apr 2019 18:48:43 +0000 (18:48 +0000)]
Update/reformat maintainer entries that I am a part of

* Replace all instances of freebsd-testing with `#test`. `#test` is the
  Phabricator group that focuses on test-related reviews.
* Replace `atf` with contrib/atf, as that's the actual location for the test
  framework.
* Remove jmmv@ from the maintainers list for atf. He is the upstream project
  owner, but was moved to alumni status after r345787.
* Fix a typo accidentally introduced in r346899 (inpact -> impact).

5 years agoAdd a note to MAINTAINERS for lkpi for graphics
zeising [Mon, 29 Apr 2019 18:20:51 +0000 (18:20 +0000)]
Add a note to MAINTAINERS for lkpi for graphics

Add a note to MAINTAINERS requesting pre-commit review from the graphics
team, using phabricator, for changes to the lkpi subsystem.  This is done in
order to give us a chance to test the graphics drivers (drm drivers) for
regressions, and to try to avoid breakage, errors and issues with the
graphics drivers.
The review is done via the #x11 group on phabricator.

Please note that hselasky also want to review changes.

Discussed with: hselasky, imp
Approved by: imp