]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoFix nfsdumpstate(8) so that it can print out INET6 callback addresses.
rmacklem [Sat, 13 Apr 2019 21:45:45 +0000 (21:45 +0000)]
Fix nfsdumpstate(8) so that it can print out INET6 callback addresses.

The patch adds support for printing of INET6 callback addresses.
It also adds the #ifdef INET, INET6 as requested by bz@.

PR: 223036
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19839

5 years agohexdump(1): Exit gracefully on format strings missing conversion
cem [Sat, 13 Apr 2019 16:51:48 +0000 (16:51 +0000)]
hexdump(1): Exit gracefully on format strings missing conversion

PR: 237263
Submitted by: Bojan Petrovic <bojan_petrovic AT fastmail.fm>

5 years agofusefs: add a fusefs(5) man page
asomers [Sat, 13 Apr 2019 13:59:01 +0000 (13:59 +0000)]
fusefs: add a fusefs(5) man page

PR: 233393
Reported by: tech-lists@zyxst.net
Reviewed by: cem
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19651

5 years agoFollowup to -r344552 in which fsck_ffs checks for a size past the
mckusick [Sat, 13 Apr 2019 13:31:06 +0000 (13:31 +0000)]
Followup to -r344552 in which fsck_ffs checks for a size past the
last allocated block of the file and if that is found, shortens the
file to reference the last allocated block thus avoiding having it
reference a hole at its end.

This update corrects an error where fsck_ffs miscalculated the last
logical block of the file when the file contained a large hole.

Reported by:  Jamie Landeg-Jones
Tested by:    Peter Holm
MFC after:    2 weeks
Sponsored by: Netflix

5 years agonetmap: add test cases for multiple host rings
vmaffione [Sat, 13 Apr 2019 12:50:47 +0000 (12:50 +0000)]
netmap: add test cases for multiple host rings

Extend the netmap unit tests with new test cases for the multiple-host-rings
feature introduced by r345269.

MFC after: 1 week

5 years agoWhen sending IPv4 packets on a SOCK_RAW socket using the IP_HDRINCL option,
tuexen [Sat, 13 Apr 2019 10:47:47 +0000 (10:47 +0000)]
When sending IPv4 packets on a SOCK_RAW socket using the IP_HDRINCL option,
ensure that the ip_hl field is valid. Furthermore, ensure that the complete
IPv4 header is contained in the first mbuf. Finally, move the length checks
before relying on them when accessing fields of the IPv4 header.
Reported by: jtl@
Reviewed by: jtl@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19181

5 years agoMove mpr/mps drivers from per-arch NOTES files into the MI notes
imp [Sat, 13 Apr 2019 06:30:45 +0000 (06:30 +0000)]
Move mpr/mps drivers from per-arch NOTES files into the MI notes
file. They are in more arches they they aren't. Add appropriate
nodevice directives in powerpc and arm.

5 years agoFix sbttons for values > 2s
imp [Sat, 13 Apr 2019 04:46:35 +0000 (04:46 +0000)]
Fix sbttons for values > 2s

Add test against negative times. Add code to cope with larger values
properly.

Discussed with: bde@ (quite some time ago, for an earlier version)

5 years agosort(1): Memoize MD5 computation to reduce repeated computation
cem [Sat, 13 Apr 2019 04:42:17 +0000 (04:42 +0000)]
sort(1): Memoize MD5 computation to reduce repeated computation

Experimentally, reduces sort -R time of a 148160 line corpus from about
3.15s to about 0.93s on this particular system.

There's probably room for improvement using some digest other than md5, but
I don't want to look at sort(1) anymore.  Some discussion of other possible
improvements in the Test Plan section of the Differential.

PR: 230792
Reviewed by: jhb (earlier version)
Differential Revision: https://reviews.freebsd.org/D19885

5 years agoAdd NUMA support to powerpc
jhibbits [Sat, 13 Apr 2019 04:03:18 +0000 (04:03 +0000)]
Add NUMA support to powerpc

Summary:
Initial NUMA support:
    - associate CPU with domain
    - associate memory ranges with domain
    - identify domain for devices
    - limit device interrupt binding to appropriate domain

- Additionally fixes a bug in the setting of Maxmem which led to
  only memory attached to the first socket being enabled for DMA

A pmap variant can opt in to numa support by by calling `numa_mem_regions`
at the end of pmap_bootstrap - registering the corresponding ranges with the
VM.

This yields a ~20% improvement in build times of llvm on dual socket POWER9
over non-NUMA.

Original patch by mmacy.

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

5 years agopowerpc/dtrace: Fix dtrace powerpc asm, and simplify stack walking
jhibbits [Sat, 13 Apr 2019 03:32:21 +0000 (03:32 +0000)]
powerpc/dtrace: Fix dtrace powerpc asm, and simplify stack walking

Fix some execution bugs in the dtrace powerpc asm.  addme pulls in the carry
flag which we don't want, and the result wasn't recorded anyways, so the
following beq to check for exit condition wasn't checking the right
condition.

Simplify the stack walking in dtrace_isa.c, so there's only a single walker
that handles both pc and sp.  This should make it easier to follow, and any
bugfix that may be needed for walking only needs to be made in one place
instead of two now.

MFC after: 2 weeks

5 years agopowerpc: Add file forgotten in r346144
jhibbits [Sat, 13 Apr 2019 02:29:30 +0000 (02:29 +0000)]
powerpc: Add file forgotten in r346144

Forgot to add the changes for DELAY(), which lowers priority during the
delay period.  Also, mark the timebase read as volatile so newer GCC does
not optimize it away, as it reportedly does currently.

MFC after: 2 weeks
MFC with: r346144

5 years agoFix SCSI sense data pass through.
mav [Fri, 12 Apr 2019 18:54:09 +0000 (18:54 +0000)]
Fix SCSI sense data pass through.

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

5 years agoSuppress old gcc warning about null format string
lwhsu [Fri, 12 Apr 2019 18:35:14 +0000 (18:35 +0000)]
Suppress old gcc warning about null format string

This is workaround to make head build on gcc using architectures

Sponsored by: The FreeBSD Foundation
MFC-with: r346149

5 years agoFix thread name buffer overflow.
mav [Fri, 12 Apr 2019 18:13:57 +0000 (18:13 +0000)]
Fix thread name buffer overflow.

MFC after: 1 week

5 years agoDo not access mutex memory after unlock.
kib [Fri, 12 Apr 2019 17:27:19 +0000 (17:27 +0000)]
Do not access mutex memory after unlock.

PR: 237195
Reported by: freebsd@hurrikhan.eu
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoIgnore doomed vnodes in tmpfs_update_mtime().
kib [Fri, 12 Apr 2019 17:11:50 +0000 (17:11 +0000)]
Ignore doomed vnodes in tmpfs_update_mtime().

Otherwise we might dereference NULL vp->v_data after
VP_TO_TMPFS_NODE().

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoRemove unneeded conditionals for sv_ functions - all the ABIs
trasz [Fri, 12 Apr 2019 14:18:16 +0000 (14:18 +0000)]
Remove unneeded conditionals for sv_ functions - all the ABIs
(apart from null_sysvec) define them, so the 'else' branch is
never taken.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19889

5 years agofor a cache-only zone the destructor tries to destroy a non-existent keg
tychon [Fri, 12 Apr 2019 12:46:25 +0000 (12:46 +0000)]
for a cache-only zone the destructor tries to destroy a non-existent keg

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19835

5 years agoUpdate mandoc to 1.14.5
bapt [Fri, 12 Apr 2019 10:13:17 +0000 (10:13 +0000)]
Update mandoc to 1.14.5

MFC after: 2 weeks

5 years agopowerpc: Adjust priority NOPs, and make them functions
jhibbits [Fri, 12 Apr 2019 00:53:30 +0000 (00:53 +0000)]
powerpc: Adjust priority NOPs, and make them functions

PowerISA 2.07 and PowerISA 3.0 both specify special NOPs for priority
adjustments, with "medium" priority being normal.  We had been setting
medium-low as our normal priority.  Rather than guess each time as to what
we want and the right NOP, wrap them in inline functions, and replace the
occurrances of the NOPs with the functions.  Also, make DELAY() drop to very
low priority while waiting, so we don't burn CPU.

Coupled with r346143, this shaves off a modest 5-8% on buildworld times with
-j72.  There may be more room for improvement with judicious use of these
NOPs.

MFC after: 2 weeks

5 years agopowerpc64: Increase the nap level on power9 idling
jhibbits [Fri, 12 Apr 2019 00:44:33 +0000 (00:44 +0000)]
powerpc64: Increase the nap level on power9 idling

The POWER9 documentation specifies that levels 0-3 are the 'lightest' sleep
level, meaning lowest latency and with no state loss.  However, state 3 is
not implemented, and is instead reserved for future chips.  This now
properly configures the PSSCR, specifying state 2 as the lowest level to
enter, but request level 0 for quickest sleep level.  If the OCC determines
that the CPU can enter states 1 or 2 it will trigger the transition to those
states on demand.

MFC after: 1 week

5 years agoFix an SCTP related locking issue. Don't report that the TCB_SEND_LOCK
tuexen [Thu, 11 Apr 2019 20:39:12 +0000 (20:39 +0000)]
Fix an SCTP related locking issue. Don't report that the TCB_SEND_LOCK
is owned, when it is not.

This issue was found by running syzkaller.
MFC after: 1 week

5 years agostand: refactor overlay loading a little bit
kevans [Thu, 11 Apr 2019 13:26:28 +0000 (13:26 +0000)]
stand: refactor overlay loading a little bit

It was pointed out that manually loading a .dtb to be used rather than
relying on platform-specific method for loading .dtb will result in overlays
not being applied. This was true because overlay loading was hacked into
fdt_platform_load_dtb, rather than done in a way more independent from how
the .dtb is loaded.

Instead, push overlay loading (for now) out into an
fdt_platform_load_overlays. This method easily allows ubldr to pull in any
fdt_overlays specified in the ub env, and omits overlay-checking on
platforms where they're not tested and/or not desired (e.g. powerpc). If we
eventually stop caring about fdt_overlays from ubenv (if we ever cared),
this method should get chopped out in favor of just calling
fdt_load_dtb_overlays() directly.

Reported by: Manuel Stühn (freebsdnewbie freenet de)

5 years agoCirrus-CI: pass OVMF env var to test script for upcoming changes
emaste [Thu, 11 Apr 2019 13:01:26 +0000 (13:01 +0000)]
Cirrus-CI: pass OVMF env var to test script for upcoming changes

In review D19876 ian@ has some proposed improvements to the
tools/boot/ci-qemu-test.sh script.  Start specifying the location of
OVMF.fd fetched by the Cirrus-CI build in advance of those changes.

5 years agoUse shared vnode locks for the ELF interpreter.
trasz [Thu, 11 Apr 2019 11:21:45 +0000 (11:21 +0000)]
Use shared vnode locks for the ELF interpreter.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19874

5 years agoReinitialize multicast source filter structures after invalidation.
markj [Thu, 11 Apr 2019 08:00:59 +0000 (08:00 +0000)]
Reinitialize multicast source filter structures after invalidation.

When leaving a multicast group, a hole may be created in the inpcb's
source filter and group membership arrays.  To remove the hole, the
succeeding array elements are copied over by one entry.  The multicast
code expects that a newly allocated array element is initialized, but
the code which shifts a tail of the array was leaving stale data
in the final entry.  Fix this by explicitly reinitializing the last
entry following such a copy.

Reported by: syzbot+f8c3c564ee21d650475e@syzkaller.appspotmail.com
Reviewed by: ae
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19872

5 years agosort(1): Simplify and bound random seeding
cem [Thu, 11 Apr 2019 05:08:49 +0000 (05:08 +0000)]
sort(1): Simplify and bound random seeding

Bound input file processing length to avoid the issue reported in [1].  For
simplicity, only allow regular file and character device inputs.  For
character devices, only allow /dev/random (and /dev/urandom symblink).

32 bytes of random is perfectly sufficient to seed MD5; we don't need any
more.  Users that want to use large files as seeds are encouraged to truncate
those files down to an appropriate input file via tools like sha256(1).

(This does not change the sort algorithm of sort -R.)

[1]: https://lists.freebsd.org/pipermail/freebsd-hackers/2018-August/053152.html

PR: 230792
Reported by: Ali Abdallah <aliovx AT gmail.com>
Relnotes: yes

5 years agoThe nvlist_report_missing is also used by the cnvlist.
oshogbo [Thu, 11 Apr 2019 04:24:41 +0000 (04:24 +0000)]
The nvlist_report_missing is also used by the cnvlist.
It can't be a static one.

Reported by: jenkins
MFC after: 2 weeks

5 years agoCatch up to r343631: Avoid "pfil: duplicate hook" due to
cy [Thu, 11 Apr 2019 04:22:06 +0000 (04:22 +0000)]
Catch up to r343631: Avoid "pfil: duplicate hook" due to
ipf_check_wrapper and ipf_check_wrapper6 being registered
under the same pa_rulename.

MFC after: 3 days

5 years agolibnv: fix compilation warnings
oshogbo [Thu, 11 Apr 2019 04:21:58 +0000 (04:21 +0000)]
libnv: fix compilation warnings

When building libnv without a debug those arguments are no longer used
because assertions will be changed to NOP.

Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC after:    2 weeks

5 years agolibnv: fix compilation warnings
oshogbo [Thu, 11 Apr 2019 03:47:53 +0000 (03:47 +0000)]
libnv: fix compilation warnings

When building libnv without a debug those arguments are no longer used
because assertions will be changed to NOP.

Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>
MFC after: 2 weeks

5 years agosort(1): Whitespace and style cleanup
cem [Thu, 11 Apr 2019 00:39:06 +0000 (00:39 +0000)]
sort(1): Whitespace and style cleanup

No functional change.

Sponsored by: Dell EMC Isilon

5 years agoAdd some CMD53-related definitions
kibab [Wed, 10 Apr 2019 20:44:54 +0000 (20:44 +0000)]
Add some CMD53-related definitions

In preparation to adding block mode functions, add necessary definitions.

Reviewed by: bz
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D19832

5 years agoarm: dtb: Compile the Linux DTS for pandaboards
manu [Wed, 10 Apr 2019 20:11:28 +0000 (20:11 +0000)]
arm: dtb: Compile the Linux DTS for pandaboards

Reported by: ci.freebsd.org

5 years agoImplement CMD53 block mode support for SDHCI and AllWinner-based boards
kibab [Wed, 10 Apr 2019 19:53:36 +0000 (19:53 +0000)]
Implement CMD53 block mode support for SDHCI and AllWinner-based boards

If a custom block size requested, use it, otherwise revert to the previous logic
of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise.

Reviewed by: bz
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D19783

5 years agoAdd new fields to mmc_data in preparation to SDIO CMD53 block mode support
kibab [Wed, 10 Apr 2019 19:49:35 +0000 (19:49 +0000)]
Add new fields to mmc_data in preparation to SDIO CMD53 block mode support

SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes,
with a maximum of 511 blocks per request.
Extend mmc_data structure to properly describe such requests,
and initialize the new fields in kernel and userland consumers.

No actual driver changes happen yet, these will follow in the separate changes.

Reviewed by: bz
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D19779

5 years agoarm: kernel: Remove old kernel configs
manu [Wed, 10 Apr 2019 19:27:14 +0000 (19:27 +0000)]
arm: kernel: Remove old kernel configs

Follow up to r346095
All those kernels are either not working or the release have switched
to GENERIC

5 years agoarm: dts: Remove some old DTS
manu [Wed, 10 Apr 2019 19:18:05 +0000 (19:18 +0000)]
arm: dts: Remove some old DTS

RPI is using the firmware provided DTS since 12.0
Pandaboard works with the Linux DTS
RK* Exynos* and Meson*/Odroid* don't even work with current
source code, if someone wants to make them work again they
better use the Linux DTS.

5 years agoFix a small bug in the tcp_log_id where the bucket
rrs [Wed, 10 Apr 2019 18:58:11 +0000 (18:58 +0000)]
Fix a small bug in the tcp_log_id where the bucket
was unlocked and yet the bucket-unlock flag was not
changed to false. This can cause a panic if INVARIANTS
is on and we go through the right path (though rare).
This fixes the correct bug :)

Reported by: syzbot+179a1ad49f3c4c215fa2@syzkaller.appspotmail.com
Reviewed by: tuexen@

5 years agoImport DTS files from Linux 5.0
manu [Wed, 10 Apr 2019 18:15:36 +0000 (18:15 +0000)]
Import DTS files from Linux 5.0

MFC after: 2 months

5 years agoImport DTS files from Linux 5.0
manu [Wed, 10 Apr 2019 17:56:06 +0000 (17:56 +0000)]
Import DTS files from Linux 5.0

5 years agoFix build in sys/modules/nfscommon
lwhsu [Wed, 10 Apr 2019 16:48:45 +0000 (16:48 +0000)]
Fix build in sys/modules/nfscommon

Sponsored by: The FreeBSD Foundation

5 years agoFix segfault that could occur on "automount -LL".
trasz [Wed, 10 Apr 2019 16:09:06 +0000 (16:09 +0000)]
Fix segfault that could occur on "automount -LL".

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoAdd Cirrus CI config file to support CI builds (in downstream projects)
emaste [Wed, 10 Apr 2019 15:38:53 +0000 (15:38 +0000)]
Add Cirrus CI config file to support CI builds (in downstream projects)

Make use of the CI smoke test script added in r346080.

Reviewed by: imp, lwhsu
Sponsored by: The FreeBSD Foundation

5 years agolibbe(3): use libzfs name validation for datasets/snapshot names
kevans [Wed, 10 Apr 2019 14:00:03 +0000 (14:00 +0000)]
libbe(3): use libzfs name validation for datasets/snapshot names

Our home-rolled solution didn't quite capture all of the details, and we
didn't actually validate snapshot names at all. zfs_name_valid captures the
important details, but it doesn't necessarily expose the errors that we're
wanting to see in the be_validate_* functions. Validating lengths
independently, then the names, should make this a non-issue.

5 years agoMake zfsd(8) build obey CFLAGS.
trasz [Wed, 10 Apr 2019 13:42:37 +0000 (13:42 +0000)]
Make zfsd(8) build obey CFLAGS.

Reviewed by: imp
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19865

5 years agoAdd a smoke test QEMU boot script for CI
emaste [Wed, 10 Apr 2019 13:41:34 +0000 (13:41 +0000)]
Add a smoke test QEMU boot script for CI

Reviewed by: imp, lwhsu (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19661

5 years agoar: implement support for /SYM64/ 64-bit archives
emaste [Wed, 10 Apr 2019 13:13:34 +0000 (13:13 +0000)]
ar: implement support for /SYM64/ 64-bit archives

PR: 234454
Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by: imp (earlier)
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18793

5 years agofix cache_lookup's documentation
asomers [Wed, 10 Apr 2019 13:02:33 +0000 (13:02 +0000)]
fix cache_lookup's documentation

cache_lookup's documentation got dislocated by r324378. Relocate and expand
it.

Reviewed by: jhb, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agoImprove vnode lock assertions.
trasz [Wed, 10 Apr 2019 10:21:14 +0000 (10:21 +0000)]
Improve vnode lock assertions.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agourtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)
avos [Wed, 10 Apr 2019 08:17:56 +0000 (08:17 +0000)]
urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)

Tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode.

MFC after: 1 week

5 years agoRevert r346017 pending compiled-in zfs fix
crees [Wed, 10 Apr 2019 07:51:13 +0000 (07:51 +0000)]
Revert r346017 pending compiled-in zfs fix

PR: 237172
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D18670

5 years agoAlways report file with incorrect hash.
sjg [Tue, 9 Apr 2019 22:20:11 +0000 (22:20 +0000)]
Always report file with incorrect hash.

5 years agoObvious comment correction.
glebius [Tue, 9 Apr 2019 22:15:39 +0000 (22:15 +0000)]
Obvious comment correction.

5 years agoRefine r330113 to honor the ProducerConsumer flag most of the time.
jhb [Tue, 9 Apr 2019 21:18:02 +0000 (21:18 +0000)]
Refine r330113 to honor the ProducerConsumer flag most of the time.

While it is true that the ACPI spec says that the flag is only valid
on Extended Address Space Descriptors, examples of other descriptors
in the spec use the ProducerConsumer flag explicitly, and real
hardware uses it as well.  In fact, even in the ASL of the Thunder X2
for which r330113 was a workaround, some devices use this flag on
non-Extended Address Space Descriptors correctly.  Instead, only
ignore the flag for resources associated with the UART devices on the
Thunder X2 using the "ARMH0011" HID to identify these devices.

This should fix regressions from ignoring this flag in other contexts
such as Hyper-V.

PR: 235876
Reported by: Wei Hu <weh@microsoft.com>
Tested by: emaste (Thunder X2)
MFC after: 2 weeks

5 years agoAdd vn_fsync_buf().
kib [Tue, 9 Apr 2019 20:20:04 +0000 (20:20 +0000)]
Add vn_fsync_buf().

Provide a convenience function to avoid the hack with filling fake
struct vop_fsync_args and then calling vop_stdfsync().

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoFix dirty buf exhaustion easily triggered with msdosfs.
kib [Tue, 9 Apr 2019 19:55:02 +0000 (19:55 +0000)]
Fix dirty buf exhaustion easily triggered with msdosfs.

If truncate(2) is performed on msdosfs file, which extends the file by
system-depended large amount, fs creates corresponding amount of dirty
delayed-write buffers, which can consume all buffers.  Such buffers
cannot be flushed by the bufdaemon because the ftruncate() thread owns
the vnode lock.  So the system runs out of free buffers, and even
truncate() thread starves, which means deadlock because it owns the
vnode lock.

Fix this by doing vnode fsync in extendfile() when low memory or low
buffers condition detected, which flushes all dirty buffers belonging
to the file being extended.

Note that the more usual fallback to bawrite() does not work
acceptable in this situation, because it would only allow one buffer
to be recycled.  Other filesystems, most important UFS, do not allow
userspace to create arbitrary amount of dirty delayed-write buffers
without feedback, so bawrite() is good enough for them.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoDon't pre-reserve resources for CPU devices when they are set.
jhb [Tue, 9 Apr 2019 19:22:08 +0000 (19:22 +0000)]
Don't pre-reserve resources for CPU devices when they are set.

CPUs can use shared (RF_SHAREABLE) resources for the I/O port used for
entering and exiting C states.  If this I/O port is included in an ACPI
system resource device, then this happens to still work, but if the port
wasn't part of a system resource device, only the first CPU could allocate
the I/O port and use C states since resource_list_reserve() was always
allocating the resource from nexus0 without RF_SHAREABLE.  By avoiding
the reservation, the flags from the bus_alloc_resource() in the CPU driver
(which include RF_SHAREABLE) are honored.

PR: 236513
Reported by: stockhausen@collogia.de
Sleuthing by: avg
Reviewed by: avg
MFC after: 2 weeks

5 years agopci_cfgreg.c: Use io port config access for early boot time.
kib [Tue, 9 Apr 2019 18:07:17 +0000 (18:07 +0000)]
pci_cfgreg.c: Use io port config access for early boot time.

Some early PCIe chipsets are explicitly listed in the white-list to
enable use of the MMIO config space accesses, perhaps because ACPI
tables were not reliable source of the base MCFG address at that time.
For that chipsets, MCFG base was read from the known chipset MCFGbase
config register.

During very early stage of boot, when access to the PCI config space
is performed (see e.g. pci_early_quirks.c), we cannot map 255MB of
registers because the method used with pre-boot pmap overflows initial
kernel page tables.

Move fallback to read MCFGbase to the attachment method of the
x86/legacy device, which removes code duplication, and results in the
use of io accesses until MCFG is parsed or legacy attach called.

For amd64, pre-initialize cfgmech with CFGMECH_1, right now we
dynamically assign CFGMECH_1 to it anyway, and remove checks for
CFGMECH_NONE.

There is a mention in the Intel documentation for corresponding
chipsets that OS must use either io port or MMIO access method, but we
already break this rule by reading MCFGbase register, so one more
access seems to be innocent.

Reported by: longwitz@incore.de
PR: 236838
Reviewed by: avg (other version), jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19833

5 years agoPolish netmap(4) testcases a bit
ngie [Tue, 9 Apr 2019 17:52:11 +0000 (17:52 +0000)]
Polish netmap(4) testcases a bit

1. Not all kernels have netmap(4) support. Check for netmap(4) support before
   attempting to run the tests via the `PLAIN_REQUIRE_KERNEL_MODULE(..)` macro.
2. Libraries shouldn't be added to LDFLAGS; they should be added to LIBADD
   instead. This allows the build system to evaluate dependencies for sanity.
3. Sort some of the Makefile variables per bsd.README.

1., in particular, will resolve failures when running this testcase on kernels
lacking netmap(4) support, e.g., the i386 GENERIC kernels on ^/stable/11 and
^/stable/12.

PR: 237129
Reviewed by: vmaffione
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19864

5 years agoFix geli device cleanup
ngie [Tue, 9 Apr 2019 16:20:36 +0000 (16:20 +0000)]
Fix geli device cleanup

Final cleanup routines shouldn't be called from testcases; it should be called
from the testcase cleanup routine.

Furthermore, `geli_test_cleanup` should take care of cleaning up geli providers
and the memory disks used for the geli providers. `geli_test_cleanup` will always
be executed whereas the equivalent logic in `geli_test_body`, may not have been
executed if the test failed prior to the logic being run.

Prior to this change, the test case was trying to clean up `$md` twice: once in
at the end of the test case body function, and the other in the cleanup function.
The cleanup function logic was failing because there wasn't anything to clean up
in the cleanup function and the errors weren't being ignored.

This fixes FreeBSD test suite runs after r345864.

PR: 237128
Reviewed by: asomers, pjd
Approved by: emaste (mentor)
MFC with: r345864
Differential Revision: https://reviews.freebsd.org/D19854

5 years agoFix a typo when sanity checking in the bootstrap-tools target
ngie [Tue, 9 Apr 2019 16:17:31 +0000 (16:17 +0000)]
Fix a typo when sanity checking in the bootstrap-tools target

The path is incorrect for the linker in the error message. It should have been
/usr/bin/ld, not /usr/bin/cc .

Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19852

5 years agolibc: update strstr implementation to match musl
emaste [Tue, 9 Apr 2019 15:52:18 +0000 (15:52 +0000)]
libc: update strstr implementation to match musl

musl commits:
122d67f846cb0be2c9e1c3880db9eb9545bbe38c
0239cd0681e889a269fb7691f60e81ef8d081e6b
8f5a820d147da36bcdbddd201b35d293699dacd8

Submitted by: David CARLIER <devnexen_gmail.com>
Obtained from: musl
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19834

5 years agoFactor out section loading into a separate function.
trasz [Tue, 9 Apr 2019 15:24:38 +0000 (15:24 +0000)]
Factor out section loading into a separate function.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19846

5 years agoIn some cases like NanoPI R1, its second USB ethernet
ganbold [Tue, 9 Apr 2019 13:54:08 +0000 (13:54 +0000)]
In some cases like NanoPI R1, its second USB ethernet
RTL8152 (chip version URE_CHIP_VER_4C10) doesn't
have hardwired MAC address, in other words, it is all zeros.
This commit fixes it by setting random MAC address
when MAC address is all zeros.

Reviewed by: kevlo
Differential Revision: https://reviews.freebsd.org/D19856

5 years agoioatcontrol(8) crc-copy flag bug and misc usage tweak
tychon [Tue, 9 Apr 2019 10:33:18 +0000 (10:33 +0000)]
ioatcontrol(8) crc-copy flag bug and misc usage tweak

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19855

5 years agoRemove spurious comma.
trasz [Tue, 9 Apr 2019 10:17:24 +0000 (10:17 +0000)]
Remove spurious comma.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years ago.Xr protect(1) and proccontrol(1) from procctl(2).
trasz [Tue, 9 Apr 2019 10:09:59 +0000 (10:09 +0000)]
.Xr protect(1) and proccontrol(1) from procctl(2).

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoStyle only change: Prefer $() to ``
imp [Mon, 8 Apr 2019 18:25:14 +0000 (18:25 +0000)]
Style only change: Prefer $() to ``

$() is more modern and also nests. Convert the mix of styles to using
only the former (although the latter was more common). It's the more
dominant style in other shell scripts these days as well.

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

5 years agoExercise some care before sending SIGHUP to mountd.
kib [Mon, 8 Apr 2019 18:16:49 +0000 (18:16 +0000)]
Exercise some care before sending SIGHUP to mountd.

Reviewed by: antoine, emaste, oshogbo
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19847

5 years agoHandle races when remounting UFS volume from ro to rw.
kib [Mon, 8 Apr 2019 15:20:05 +0000 (15:20 +0000)]
Handle races when remounting UFS volume from ro to rw.

In particular, ensure that writers are not unleashed before SU
structures are initialized.  Also, correctly handle MNT_ASYNC before
this.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoRefactor ELF interpreter loading into a separate function.
trasz [Mon, 8 Apr 2019 14:31:07 +0000 (14:31 +0000)]
Refactor ELF interpreter loading into a separate function.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19741

5 years agoIn the unlinkat syscall, the operation is performed on the directory
oshogbo [Mon, 8 Apr 2019 14:23:52 +0000 (14:23 +0000)]
In the unlinkat syscall, the operation is performed on the directory
descriptor, not the file descriptor. The file descriptor is used only for
verification so do not expect any additional capabilities on it.

Reported by: antoine
Tested by: antoine
Discussed with: kib, emaste, bapt
Sponsored by: Fudo Security

5 years agoFix URE_WDT6_SET_MODE value in the register definition.
ganbold [Mon, 8 Apr 2019 13:40:46 +0000 (13:40 +0000)]
Fix URE_WDT6_SET_MODE value in the register definition.
Both linux and u-boot sources for RTL8152 driver has this value.
RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet.
This fixes for me RTL8152 USB ethernet not detected problem after
reboot on NanoPI R1 board.

Both NetBSD and OpenBSD have a wrong value so far.

5 years agoFix copying of MEMBUFs to MEMBUFs. This case was implemented by using
bde [Mon, 8 Apr 2019 04:54:15 +0000 (04:54 +0000)]
Fix copying of MEMBUFs to MEMBUFs.  This case was implemented by using
the same code as the VIDBUF8 case, so it only worked for depths <= 8.
The 2 directions for copying between VIDBUFs and MEMBUFs worked by using
a Read/Write organization which makes the destination a VIDBUF so the
MEMBUF case was not reached, and the VIDBUF cases have already been fixed.

Fix this by removing "optimizations" for the VIDBUF8 case so that the
MEMBUF case can fall through to the general (non-segmented) case.  The
optimizations were to duplicate code for the VIDBUF8 case so as to
avoid 2 multiplications by 1 at runtime.  This optimization is not useful
since the multiplications are not in the inner loop.

Remove the same "optimization" for the VIDBUF8S case.  It was even less
useful there since it duplicated more to do relatively less.

5 years agoFix restoring the geometry when recovering from an error. Just restore the
bde [Mon, 8 Apr 2019 04:07:37 +0000 (04:07 +0000)]
Fix restoring the geometry when recovering from an error.  Just restore the
previous geometry, and don't do extra work to calculate the default geometry
so as to reset to that.

5 years agostrings: disable Casper support while building native-xtools
oshogbo [Mon, 8 Apr 2019 03:35:47 +0000 (03:35 +0000)]
strings: disable Casper support while building native-xtools

Reported by: Charlie Li
Tested by: Charlie Li

5 years agoMake RELDATE be on a single line.
imp [Sun, 7 Apr 2019 21:01:02 +0000 (21:01 +0000)]
Make RELDATE be on a single line.

All variable assignments that start in column 1 have to be on a single
line for amd to build due to as weird dependency there (most likely it
can be fixed to use the new VARS_ONLY feature, but it isn't
today). usr.sbin/amd/include/Makefile calls
usr.sbin/amd/include/newvers.sh which does:
eval `LC_ALL=C egrep '^[A-Z]+=' $1 | grep -v COPYRIGHT`
which is where that requirement comes from. It handles COPYRIGHT since
that's an exception. Rather than add additional exceptions, cope with
the long line in newvers.sh instead. Note: it no longer needs to
filter COPYRIGHT because the assignment doesn't start in column 1
anymore.

I had done a universe when I had an earlier version of r346018 that
had it as one line. When I changed it to multi-line as suggested in
the review, I only built kernels on a couple of architectures to make
sure it didn't break anything.

Add comment to newvers.sh noting this.

Obviously, this unbreaks the amd build.

5 years agoRISC-V: initialize pcpu slightly earlier
mhorne [Sun, 7 Apr 2019 20:12:24 +0000 (20:12 +0000)]
RISC-V: initialize pcpu slightly earlier

In certain scenarios, it is possible for PCPU data to be
accessed before it has been initialized (e.g. during printf
if the kernel was built with the TSLOG option).

Initialize the PCPU pointer for hart 0 at the beginning of
initriscv() rather than near the end.

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D19726

5 years agoUse default shell assignment rather more complicated if then
imp [Sun, 7 Apr 2019 18:39:55 +0000 (18:39 +0000)]
Use default shell assignment rather more complicated if then
construct.

Discussed with: emaste@, allanjude@ (changes (or not) based on their feedback)
Differential Revision: https://reviews.freebsd.org/D19797

5 years agoRemove now unnecessary kldstat check before attempting to load modules.
crees [Sun, 7 Apr 2019 18:31:45 +0000 (18:31 +0000)]
Remove now unnecessary kldstat check before attempting to load modules.

Since r233109, kldload has the -n option, which silently ignores options
that are already loaded.

https://lists.freebsd.org/pipermail/freebsd-rc/2018-December/003899.html

Note that this script no longer reports if the module is already loaded,
but it could be argued this wasn't particularly useful information.

PR: docs/234248
Reviewed by: bcr (docs), kib, rgrimes (visual)
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D18670

5 years agoAdd option to build LLVM RISC-V target
mhorne [Sun, 7 Apr 2019 18:24:26 +0000 (18:24 +0000)]
Add option to build LLVM RISC-V target

Reviewed by: emaste, dim
Approved by: markj (mentor)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D19759

5 years agoAdd g_label_flashmap.c to the module, should have been part of r345480.
ian [Sun, 7 Apr 2019 16:33:22 +0000 (16:33 +0000)]
Add g_label_flashmap.c to the module, should have been part of r345480.

Reported by: Jia-Shiun Li <jiashiun@gmail.com>

5 years agoBump FreeBSD version after r345982.
oshogbo [Sun, 7 Apr 2019 16:07:41 +0000 (16:07 +0000)]
Bump FreeBSD version after r345982.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
Discussed with: imp, cy, rgrimes

5 years agoStop compiling bhyve(8) with -O0.
markj [Sun, 7 Apr 2019 14:30:17 +0000 (14:30 +0000)]
Stop compiling bhyve(8) with -O0.

DEBUG_FLAGS is always added to CFLAGS.  This setting appears to be
accidental and came in with r243327.

Reviewed by: anish, emaste, jhb, rgrimes
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19787

5 years agoFix indentation.
markj [Sun, 7 Apr 2019 14:28:02 +0000 (14:28 +0000)]
Fix indentation.

No functional change intended.

Reviewed by: bcran, jhb, rgrimes
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19786

5 years agoSet the p_oppid field of orphans when exiting.
markj [Sun, 7 Apr 2019 14:26:14 +0000 (14:26 +0000)]
Set the p_oppid field of orphans when exiting.

Such processes will be reparented to the reaper when the current
parent is done with them (i.e., ptrace detached), so p_oppid must be
updated accordingly.

Add a regression test to exercise this code path.  Previously it
would not be possible to reap an orphan with a stale oppid.

Reviewed by: kib, mjg
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19825

5 years agoloader: command_lsefi: ret can be used uninitialized
tsoome [Sun, 7 Apr 2019 14:07:28 +0000 (14:07 +0000)]
loader: command_lsefi: ret can be used uninitialized

MFC after: 1w

5 years agoloader: add file_remove() function to undo file_insert_tail().
tsoome [Sun, 7 Apr 2019 13:36:17 +0000 (13:36 +0000)]
loader: add file_remove() function to undo file_insert_tail().

346002 did miss the fact that we do not only undo the loadaddr, but also
we need to remove the inserted module. Implement file_remove() to do the job.

MFC after: 1w

5 years agoloader: mod_loadkld() error: we previously assumed 'last_file' could be null
tsoome [Sun, 7 Apr 2019 12:20:17 +0000 (12:20 +0000)]
loader: mod_loadkld() error: we previously assumed 'last_file' could be null

The last_file variable is used to reset the loadaddr variable back to original
value; however, it is possible the last_file is NULL, so we can not blindly
trust it. But then again, we can just save the original loadaddr and use
the saved value for recovery.

MFC after: 1w

5 years agoloader: file_addmetadata() should check for memory allocation
tsoome [Sun, 7 Apr 2019 12:10:19 +0000 (12:10 +0000)]
loader: file_addmetadata() should check for memory allocation

malloc() can return NULL.

MFC after: 1w

5 years agoloader: remove pointer checks before free() in module.c
tsoome [Sun, 7 Apr 2019 11:55:11 +0000 (11:55 +0000)]
loader: remove pointer checks before free() in module.c

free() does check for NULL argument, remove duplicate checks.

MFC after: 1w

5 years agoloader: file_addmodule should check for memory allocation
tsoome [Sun, 7 Apr 2019 11:50:41 +0000 (11:50 +0000)]
loader: file_addmodule should check for memory allocation

strdup() can return NULL.

MFC after: 1w

5 years agoloader: malloc+bzero is calloc
tsoome [Sun, 7 Apr 2019 11:48:41 +0000 (11:48 +0000)]
loader: malloc+bzero is calloc

Replace malloc+bzero in module.c with calloc.

MFC after: 1w

5 years agoGive new home to the comment from ppt_pci_reset(), explaining a nuance
kib [Sun, 7 Apr 2019 08:58:09 +0000 (08:58 +0000)]
Give new home to the comment from ppt_pci_reset(), explaining a nuance
of power reset.

Noted by: soralx@cydem.org
Sponsored by: Mellanox Technologies
MFC after: 12 days

5 years agoMFV r345988:
cy [Sat, 6 Apr 2019 23:35:23 +0000 (23:35 +0000)]
MFV r345988:

Update sqlite3-3.26.0 (3260000) --> sqlite3-3.27.1 (3270100)

MFC after: 2 weeks

5 years agoDelete the BUGS entry related to failing when jails are enabled.
rmacklem [Sat, 6 Apr 2019 22:14:03 +0000 (22:14 +0000)]
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.

PR: 205193
MFC after: 2 weeks

5 years agoFix nfsuserd so that it handles the mapped localhost address when jails
rmacklem [Sat, 6 Apr 2019 22:05:51 +0000 (22:05 +0000)]
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.

Tested by: freebsd@danielengel.com (earlier version)
PR: 205193
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19218

5 years agokern/subr_pctrie: Fix mismatched signedness in assertion comparison
cem [Sat, 6 Apr 2019 21:56:24 +0000 (21:56 +0000)]
kern/subr_pctrie: Fix mismatched signedness in assertion comparison

'tos' is an index into an array and never holds a negative value.  Correct
its signedness to match PCTRIE_LIMIT, which it is compared to in assertions.

No functional change (kills a warning).