]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years ago[PowerPC] [DTrace] Add ELFv2 support in libdtrace
bdragon [Wed, 5 Feb 2020 19:39:48 +0000 (19:39 +0000)]
[PowerPC] [DTrace] Add ELFv2 support in libdtrace

PPC64 ELFv2 acts like a "normal" platform in that it no longer needs
function descriptors. So, ensure we are only enabling them on ELFv1.

Additionally, ELFv2 requires that the ELF header have a nonzero e_flags,
so ensure that the synthesized ELF header in dt_link.c is setting it.

Reviewed by: jhibbits, markj
Approved by: gnn
Differential Revision: https://reviews.freebsd.org/D22403

4 years agodelete empty directories after r357455
emaste [Wed, 5 Feb 2020 19:18:04 +0000 (19:18 +0000)]
delete empty directories after r357455

4 years agoberi: correct kernel printf typo
emaste [Wed, 5 Feb 2020 19:15:36 +0000 (19:15 +0000)]
beri: correct kernel printf typo

(From review D23453)

Submitted by: Gordon Bergling <gbergling_gmail.com>
Reviewed by: rwatson

4 years agoethernet: Add a couple more Ethertypes.
pfg [Wed, 5 Feb 2020 19:11:07 +0000 (19:11 +0000)]
ethernet: Add a couple more Ethertypes.

Powerlink and Sercos III are used in automation. Both have been standardized
and In the case of Ethernet Powerlink there is a BSD-licensed stack.

4 years agoStop compiling dtrace modules with -DSMP.
markj [Wed, 5 Feb 2020 19:08:45 +0000 (19:08 +0000)]
Stop compiling dtrace modules with -DSMP.

I believe this is left over from when dtrace was being ported and
developed out-of-tree.  Now it just ensures that dtrace.ko and a non-SMP
kernel have incompatible KBIs.

PR: 243711
Sponsored by: The FreeBSD Foundation

4 years agoDefine MAXCPU consistently between the kernel and KLDs.
markj [Wed, 5 Feb 2020 19:08:21 +0000 (19:08 +0000)]
Define MAXCPU consistently between the kernel and KLDs.

This reverts r177661.  The change is no longer very useful since
out-of-tree KLDs will be built to target SMP kernels anyway.  Moveover
it breaks the KBI in !SMP builds since cpuset_t's layout depends on the
value of MAXCPU, and several kernel interfaces, notably
smp_rendezvous_cpus(), take a cpuset_t as a parameter.

PR: 243711
Reviewed by: jhb, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23512

4 years agoO_SEARCH test: drop O_SEARCH|O_RDWR local diff
kevans [Wed, 5 Feb 2020 17:21:36 +0000 (17:21 +0000)]
O_SEARCH test: drop O_SEARCH|O_RDWR local diff

In FreeBSD's O_SEARCH implementation, O_SEARCH in conjunction with O_RDWR or
O_WRONLY is explicitly rejected. In this case, O_RDWR was not necessary
anyways as the file will get created with or without it.

This was submitted upstream as misc/54940 and committed in rev 1.8 of the
file.

4 years agolibfetch: disallow invalid escape sequences
emaste [Wed, 5 Feb 2020 16:55:00 +0000 (16:55 +0000)]
libfetch: disallow invalid escape sequences

Per RFC1738 escape is "% hex hex"; other sequences do not form a valid URL.

Suggested by: Matthew Dillon
Reviewed by: Matthew Dillon
MFC after: 1 week

4 years agoregen linuxulator sysent after r357577
emaste [Wed, 5 Feb 2020 16:54:16 +0000 (16:54 +0000)]
regen linuxulator sysent after r357577

4 years agolinuxulator: implement sendfile
emaste [Wed, 5 Feb 2020 16:53:02 +0000 (16:53 +0000)]
linuxulator: implement sendfile

Submitted by: Bora Ã–zarslan <borako.ozarslan@gmail.com>
Submitted by: Yang Wang <2333@outlook.jp>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19917

4 years agoFix a use of an uninitialized pointer in xdr_rpcbs_rmtcalllist().
markj [Wed, 5 Feb 2020 16:10:09 +0000 (16:10 +0000)]
Fix a use of an uninitialized pointer in xdr_rpcbs_rmtcalllist().

This appears to have been introduced in r173763.  Also fix the confusing
indentation that probably led to the bug in the first place.

PR: 243759
Diagnosed by: martin@lispworks.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoImprove validation of the sockaddr length in iruserok_sa().
markj [Wed, 5 Feb 2020 16:09:44 +0000 (16:09 +0000)]
Improve validation of the sockaddr length in iruserok_sa().

Negative numbers are not valid sockaddr lengths.

PR: 243747
Submitted by: Andrew Reiter <areiter@veracode.com>
MFC after: 1 week

4 years agoAvoid releasing object PIP in vn_sendfile() if no pages were grabbed.
markj [Wed, 5 Feb 2020 16:09:21 +0000 (16:09 +0000)]
Avoid releasing object PIP in vn_sendfile() if no pages were grabbed.

sendfile(2) optionally takes a set of headers that get prepended to the
file data.  If the request length is less than that of the headers,
sendfile may not allocate an sfio structure, in which case its pointer
is null and we should be careful not to dereference.  This was
introduced in r356902.

Reported by: syzkaller
Sponsored by: The FreeBSD Foundation

4 years agoFix map locking in the CLEAR_PKRU sysarch(2) handler.
markj [Wed, 5 Feb 2020 16:09:02 +0000 (16:09 +0000)]
Fix map locking in the CLEAR_PKRU sysarch(2) handler.

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

4 years agowc(1): account for possibility of file == NULL
kevans [Wed, 5 Feb 2020 14:00:27 +0000 (14:00 +0000)]
wc(1): account for possibility of file == NULL

file could reasonably be NULL here if we we're using stdin. Albeit less
likely in normal usage, one could actually hit either of these warnings on
stdin.

ubmitted by: sigsys@gmail.com
MFC after: 3 days

4 years agofollowup on r357497: clean obsolete comment and use shift instead of multiplication
tsoome [Wed, 5 Feb 2020 13:08:24 +0000 (13:08 +0000)]
followup on r357497: clean obsolete comment and use shift instead of multiplication

Based on illumos review feedback: leftover comment, but also
have consistent block size calculation and add missing else leg to if
statement.

4 years agoAdd SYSCTL to get KERNBASE and relocated KERNBASE
luporl [Wed, 5 Feb 2020 11:34:10 +0000 (11:34 +0000)]
Add SYSCTL to get KERNBASE and relocated KERNBASE

This change adds 2 new SYSCTLs, to retrieve the original and relocated KERNBASE
values. This provides an easy, architecture independent way to calculate the
running kernel displacement (current/load address minus original base address).

The initial goal for this change is to add a new libkvm function that returns
the kernel displacement, both for live kernels and crashdumps. This would in
turn be used by kgdb to find out how to relocate kernel symbols (if needed).

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D23284

4 years agozfsboot: vdev_read_pad2 does allocate buffer with wrong size
tsoome [Wed, 5 Feb 2020 11:02:00 +0000 (11:02 +0000)]
zfsboot: vdev_read_pad2 does allocate buffer with wrong size

vdev_read_pad2() does read VDEV_PAD_SIZE of data, and will copy size bytes
of it, hence, we need buffer of VDEV_PAD_SIZE bytes.

Issue introduced in r357497.

Reported by: se

4 years agovdev_read_pad2: freeing wrong pointer
tsoome [Wed, 5 Feb 2020 05:42:42 +0000 (05:42 +0000)]
vdev_read_pad2: freeing wrong pointer

Shoud free previously allocated tmp buffer instead. Issue introduced in
r357497.

Reported by: rpokala

4 years agoAdd RELNOTES entry for various daemons pulling in environment variables
kevans [Wed, 5 Feb 2020 04:43:58 +0000 (04:43 +0000)]
Add RELNOTES entry for various daemons pulling in environment variables

4 years agocron(8): set the environment variables of the user and/or login class
kevans [Wed, 5 Feb 2020 04:35:54 +0000 (04:35 +0000)]
cron(8): set the environment variables of the user and/or login class

Prior to processing environment variable set in the crontab file as those
should be of higher precedent, pull in the user or login class environment.

This is another supporting feature for allowing one to configure system-wide
settings that may affect both regular cron jobs as well as services.

This is the final part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoservice(8): set the environment of the "daemon" class before invoking
kevans [Wed, 5 Feb 2020 04:32:49 +0000 (04:32 +0000)]
service(8): set the environment of the "daemon" class before invoking

As mentioned in r357562, this gives the user a single place to configure
environment variables that need to be used for various services -- the
"daemon" class -- for, e.g., configuring a system-wide HTTP proxy.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoenv(1): grow -L user/class and -U user/class options
kevans [Wed, 5 Feb 2020 04:29:55 +0000 (04:29 +0000)]
env(1): grow -L user/class and -U user/class options

This allows one to set the environment of the specified user either from
login.conf alone (-L) or both login.conf and ~/.login_conf if present (-U).

This is a supporting feature to allow service(8) to pull in the environment
of the "daemon" class before invoking the rc script.

This is a part of D21481.

Submitted by: Andrew Gierth < andrew_tao173.riddles.org.uk>

4 years agoinit(8): set environment variables from the "daemon" class as well
kevans [Wed, 5 Feb 2020 04:27:44 +0000 (04:27 +0000)]
init(8): set environment variables from the "daemon" class as well

Specifically, when running /etc/rc. This allows one to specify via
login.conf(5) an environment that should be used when running services to
ease, e.g., setting up env vars for an HTTP proxy consistently across cron
and services alike.

Future changes will extend cron(8)/service(8) to use environment vars
pecified in login.conf(5) as well to promote a more cohesive experience.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agologin.conf(5): set a default PATH for the daemon class
kevans [Wed, 5 Feb 2020 04:27:08 +0000 (04:27 +0000)]
login.conf(5): set a default PATH for the daemon class

This is a sensible default used by, e.g., cron(8), and useful if one wanted
to honor it.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agologin.conf(5): split MAIL env var out into a "mail" capability
kevans [Wed, 5 Feb 2020 04:17:14 +0000 (04:17 +0000)]
login.conf(5): split MAIL env var out into a "mail" capability

This allows it to be easily suppressed in, e.g., the "daemon" class where it
will not be properly expanded.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

4 years agoI doubt anybody in the world uses ng_device, but its write method should
glebius [Wed, 5 Feb 2020 03:07:20 +0000 (03:07 +0000)]
I doubt anybody in the world uses ng_device, but its write method should
also enter the network epoch when sending data from user level to netgraph.

4 years agoEnter the network epoch when ng_socket sends data or control from user
glebius [Wed, 5 Feb 2020 03:06:29 +0000 (03:06 +0000)]
Enter the network epoch when ng_socket sends data or control from user
land to the netgraph and potentially further down the network stack.

4 years agonetgraph(4) callouts need to be executed in the network epoch.
glebius [Wed, 5 Feb 2020 02:53:40 +0000 (02:53 +0000)]
netgraph(4) callouts need to be executed in the network epoch.

4 years agoO_SEARCH tests: plug trivial fd leak
kevans [Wed, 5 Feb 2020 02:30:46 +0000 (02:30 +0000)]
O_SEARCH tests: plug trivial fd leak

Coverity correctly reports this as a resource leak. It's an admittedly minor
one, but plug it anyways.

This has been submitted upstream as misc/54939.

CID: 978288

4 years agofd: always nullify *fdp in fget* routines
mjg [Wed, 5 Feb 2020 00:20:26 +0000 (00:20 +0000)]
fd: always nullify *fdp in fget* routines

Some consumers depend on the pointer being NULL if an error is returned.

The guarantee got broken in r357469.

Reported by: https://syzkaller.appspot.com/bug?extid=0c9b05e2b727aae21eef
Noted by: markj

4 years agocxgbe(4): Add a knob to allow netmap tx traffic to be checksummed by
np [Wed, 5 Feb 2020 00:13:15 +0000 (00:13 +0000)]
cxgbe(4): Add a knob to allow netmap tx traffic to be checksummed by
the hardware.

hw.cxgbe.nm_txcsum=1

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Allow nm_black_hole and nm_cong_drop to be set at any time.
np [Wed, 5 Feb 2020 00:08:58 +0000 (00:08 +0000)]
cxgbe(4): Allow nm_black_hole and nm_cong_drop to be set at any time.

The cong_drop setting will apply to queues created after the setting is
changed and not to existing queues.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Report accurate rx_buf_maxsize to netmap.
np [Tue, 4 Feb 2020 23:55:21 +0000 (23:55 +0000)]
cxgbe(4): Report accurate rx_buf_maxsize to netmap.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agouma: multipage chicken switch
rlibby [Tue, 4 Feb 2020 22:40:45 +0000 (22:40 +0000)]
uma: multipage chicken switch

Add a switch to allow disabling multipage slabs, in order to facilitate
measuring memory usage and performance effects.  The tunable
vm.debug.uma_multipage_slabs defaults to 1 and can be set to 0 to
disable.  The name may change soon.

Reviewed by: markj (previous version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23487

4 years agouma: grow slabs to enforce minimum memory efficiency
rlibby [Tue, 4 Feb 2020 22:40:34 +0000 (22:40 +0000)]
uma: grow slabs to enforce minimum memory efficiency

Memory efficiency can be poor with awkward item sizes (e.g. 1/2 or 1
page size + epsilon).  In order to achieve a minimum memory efficiency,
select a slab size with a potentially larger number of pages if it
yields a lower portion of waste.

This may mean using page_alloc instead of uma_small_alloc, which could
be more costly.

Discussed with: jeff, mckusick
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23239

4 years agouma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others
rlibby [Tue, 4 Feb 2020 22:40:23 +0000 (22:40 +0000)]
uma: convert mbuf_jumbo_alloc to UMA_ZONE_CONTIG & tag others

Remove mbuf_jumbo_alloc and let large mbuf zones use the new uma default
contig allocator (a copy of mbuf_jumbo_alloc).  Tag other zones which
require contiguous objects, even if they don't use the new default
contig allocator, so that uma knows about their constraints.

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

4 years agouma: add UMA_ZONE_CONTIG, and a default contig_alloc
rlibby [Tue, 4 Feb 2020 22:40:11 +0000 (22:40 +0000)]
uma: add UMA_ZONE_CONTIG, and a default contig_alloc

For now, copy the mbuf allocator.

Reviewed by: jeff, markj (previous version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23237

4 years agouma: pcpu_page_free needs to startup_free pages from startup_alloc
rlibby [Tue, 4 Feb 2020 22:39:58 +0000 (22:39 +0000)]
uma: pcpu_page_free needs to startup_free pages from startup_alloc

After r357392, it is apparent that we do have some early-boot PCPU
zones.  Make it so we can safely free pages from them if they are
actually used during early boot.

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

4 years agoObsoleteFiles: Update after simple_httpd removal
kevans [Tue, 4 Feb 2020 21:43:39 +0000 (21:43 +0000)]
ObsoleteFiles: Update after simple_httpd removal

There should have perhaps been an entry in OptionalObsoleteFiles for it
before, but alas- let it be removed now with `make delete-old` if it was
installed.

Reported by: Oliver Pinter

4 years agosrc.conf(5): regen after r357543, HTTPD removal
kevans [Tue, 4 Feb 2020 21:28:04 +0000 (21:28 +0000)]
src.conf(5): regen after r357543, HTTPD removal

4 years agoRemove simple_httpd
kevans [Tue, 4 Feb 2020 21:27:39 +0000 (21:27 +0000)]
Remove simple_httpd

simple_httpd was granted a reprieve from the picobsd removal based on having
some reported user; it turns out this user isn't actually using the version
in base and merging their changes would be difficult at this point, so the
version in base will simply continue to rot. Retire it now, it may make a
comeback to ports with the improved version.

No notice issued because its current visibility has only been for ~3
months, and a notice has been previously issued about picobsd removal.

4 years agoreadelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.
markj [Tue, 4 Feb 2020 21:18:56 +0000 (21:18 +0000)]
readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

CID: 1292493
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: Fix the check for an error from realloc().
markj [Tue, 4 Feb 2020 21:18:37 +0000 (21:18 +0000)]
readelf: Fix the check for an error from realloc().

Use err() instead of errx() while here, since realloc() sets errno.

CID: 1401326
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: Fix a double close of the input file.
markj [Tue, 4 Feb 2020 21:18:16 +0000 (21:18 +0000)]
readelf: Fix a double close of the input file.

The caller of dump_object() is responsible for opening the file, let it
be responsible for closing too.

CID: 1411588
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agosize: Avoid returning a stack pointer from xlatetom().
markj [Tue, 4 Feb 2020 21:17:59 +0000 (21:17 +0000)]
size: Avoid returning a stack pointer from xlatetom().

The callers only check whether the returned pointer is non-NULL, so this
was harmless in practice, but change the return value to guard against
the issue.

CID: 1411597
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoelfcopy: Avoid leaking dst's fd when we fail to copy a file.
markj [Tue, 4 Feb 2020 21:16:56 +0000 (21:16 +0000)]
elfcopy: Avoid leaking dst's fd when we fail to copy a file.

We should really create the output file in the same directory as the
destination file so that rename() works.  This will be done in a future
change as part of some work to run in capability mode.

CID: 1262523
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoelfcopy: Handle multiple data descriptors properly.
markj [Tue, 4 Feb 2020 21:16:41 +0000 (21:16 +0000)]
elfcopy: Handle multiple data descriptors properly.

The code clearly meant to resize the buffer in the case where a section
was backed by multiple data descriptors.

In practice this shouldn't have been a problem since libelf would return
a single data descriptor for each section in a newly opened file.

CID: 1262522
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Add a missing check for an error from vector_str_init().
markj [Tue, 4 Feb 2020 21:16:16 +0000 (21:16 +0000)]
libelftc: Add a missing check for an error from vector_str_init().

While here consistently use the same spelling for such checks.

CID: 1376769
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibelftc: Fix memory leaks in the C++ demanglers.
markj [Tue, 4 Feb 2020 21:15:52 +0000 (21:15 +0000)]
libelftc: Fix memory leaks in the C++ demanglers.

CID: 1262518126251912625201262529
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Fix a memory leak in _dwarf_frame_section_init().
markj [Tue, 4 Feb 2020 21:15:29 +0000 (21:15 +0000)]
libdwarf: Fix a memory leak in _dwarf_frame_section_init().

If frame length validation failed we would leak memory.

CID: 1193366
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.
markj [Tue, 4 Feb 2020 21:15:11 +0000 (21:15 +0000)]
libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

All callers pass a non-NULL pointer, and otherwise it was possible to
leak memory if the abbrev was not added to a CU.

CID: 1193365
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().
markj [Tue, 4 Feb 2020 21:14:53 +0000 (21:14 +0000)]
libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

CID: 1193364
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agolibdwarf: Remove unnecessary NULL checks.
markj [Tue, 4 Feb 2020 21:14:34 +0000 (21:14 +0000)]
libdwarf: Remove unnecessary NULL checks.

All callers of _dwarf_add_expr() and _dwarf_expr_into_block() pass a
non-NULL expr pointer, and these functions assume that expr is non-NULL
anyway.

CID: 11933051193306
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoRemove unneeded assert for curproc. Simplify.
kib [Tue, 4 Feb 2020 21:02:08 +0000 (21:02 +0000)]
Remove unneeded assert for curproc.  Simplify.

Reported by: syzkaller by markj
Sponsored by: The FreeBSD Foundation

4 years ago[PowerPC] Fix VSX context handling
bdragon [Tue, 4 Feb 2020 20:40:45 +0000 (20:40 +0000)]
[PowerPC] Fix VSX context handling

In r356767, memcpy/memmove/bcopy optimizations were added to libc to
improve performance.

This exposed an existing kernel issue in VSX handling. The PSL_VSX flag was
not being excluded from the psl_userstatic set, which meant that any thread
that used these and then called swapcontext(3) would get an EINVAL error.

Fixing this exposed a second issue - in r344123, the FPU was being forced
off in set_mcontext(). However, this was neglecting to ensure VSX was turned
off at the same time.

While here, add some code comments to explain what's going on.

Reviewed by: jhibbits, luporl (earlier rev), pkubaj (earlier rev)
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D23497

4 years agoAdd an explicit busy state for free pages. This improves behavior with
jeff [Tue, 4 Feb 2020 20:33:01 +0000 (20:33 +0000)]
Add an explicit busy state for free pages.  This improves behavior with
potential bugs that access freed pages as well as providing a path
towards lockless page lookup.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23444

4 years agoUse literal bucket sizes for smaller buckets rather than the rounding
jeff [Tue, 4 Feb 2020 20:28:06 +0000 (20:28 +0000)]
Use literal bucket sizes for smaller buckets rather than the rounding
system.  Small bucket sizes already pack well even if they are an odd
number of words.  This prevents any potential new instances of the
problem fixed in r357463 as well as making the system easier to
understand.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D23494

4 years agoCorrect the malloc tag used when freeing the temporary semop(2) buffer.
markj [Tue, 4 Feb 2020 20:00:45 +0000 (20:00 +0000)]
Correct the malloc tag used when freeing the temporary semop(2) buffer.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoRevert r357201: downgrade sqlite3 from sqlite3-3.31.0 (3310000) to
cy [Tue, 4 Feb 2020 19:45:51 +0000 (19:45 +0000)]
Revert r357201: downgrade sqlite3 from sqlite3-3.31.0 (3310000) to
sqlite3-3.30.1 (3300100), as it causes svnlite segfaults on PowerPC,
resulting in corruption.

Reported by: Mark Millard <marklmi at yahoo.com>
Francis Little <oggy at farscape.co.uk>

4 years agotmpfs: add nomtime mount option,
kib [Tue, 4 Feb 2020 19:05:58 +0000 (19:05 +0000)]
tmpfs: add nomtime mount option,

which disables tracking mtime updates due to writes through the shared
mapped areas backed by tmpfs files.  This removes periodic scans which
downgrades rw mapped pages to ro to note the writes.

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

4 years agoEnable vm_object_mightbedirty() and vm_object_page_clean() for swap
kib [Tue, 4 Feb 2020 19:03:37 +0000 (19:03 +0000)]
Enable vm_object_mightbedirty() and vm_object_page_clean() for swap
objects backing tmpfs vnodes data.

The clean scan is limited to only remove write permissions from the
mapped pages of the objects.  This fixes the issue that tmpfs vnode
mtime is not updated from writes to the mmaped area after the initial
page-in.

Noted by: mjg
Reviewed by: markj
Discussed with: jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23432

4 years agoAdd sys/systm.h to several places that use vm headers.
kib [Tue, 4 Feb 2020 18:56:26 +0000 (18:56 +0000)]
Add sys/systm.h to several places that use vm headers.

It is needed (but not enough) to use e.g. KASSERT() in inline functions.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agotmpfs_mount update: simplify, cache the value of VFS_TO_TMPFS() calculation.
kib [Tue, 4 Feb 2020 18:52:25 +0000 (18:52 +0000)]
tmpfs_mount update: simplify, cache the value of VFS_TO_TMPFS() calculation.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agopsm: use make_dev_s instead of make_dev
kevans [Tue, 4 Feb 2020 18:45:28 +0000 (18:45 +0000)]
psm: use make_dev_s instead of make_dev

This most importantly reduces duplication, but it also removes any potential
race with usage of dev->si_drv1 since it's now set prior to the device being
constructed enough to be accessible.

4 years agopsm: release resources on attach failure
kevans [Tue, 4 Feb 2020 18:29:06 +0000 (18:29 +0000)]
psm: release resources on attach failure

In exactly 1/3 cases we'll release resources on failure; touch up the other
two to do so as well.

4 years agoRegen after r357503.
trasz [Tue, 4 Feb 2020 16:02:04 +0000 (16:02 +0000)]
Regen after r357503.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoAdd missing linux(4) syscall entries. This fixes missing debug
trasz [Tue, 4 Feb 2020 16:01:06 +0000 (16:01 +0000)]
Add missing linux(4) syscall entries.  This fixes missing debug
messages for some of the unimplemented syscalls, in particular
the AIO-related ones.

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

4 years agoFew microoptimizations to dbuf layer.
mav [Tue, 4 Feb 2020 15:53:51 +0000 (15:53 +0000)]
Few microoptimizations to dbuf layer.

Move db_link into the same cache line as db_blkid and db_level.
It allows significantly reduce avl_add() time in dbuf_create() on
systems with large RAM and huge number of dbufs per dnode.

Avoid few accesses to dbuf_caches[].size, which is highly congested
under high IOPS and never stays in cache for a long time.  Use local
value we are receiving from zfs_refcount_add_many() any way.

Remove cache_size_bytes_max bump from dbuf_evict_one().  I don't see
a point to do it on dbuf eviction after we done it on insertion in
dbuf_rele_and_unlock().

Reviewed by: mahrens, Brian Behlendorf
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoRemove unused timer.
tuexen [Tue, 4 Feb 2020 14:01:07 +0000 (14:01 +0000)]
Remove unused timer.

Submitted by: Taylor Brandstetter

4 years agoImprove numbering of debug information.
tuexen [Tue, 4 Feb 2020 12:34:16 +0000 (12:34 +0000)]
Improve numbering of debug information.

Submitted by: Taylor Brandstetter
MFC after: 1 week

4 years agoPrint useful debug data on unhandled kernel fault on arm64
andrew [Tue, 4 Feb 2020 12:33:00 +0000 (12:33 +0000)]
Print useful debug data on unhandled kernel fault on arm64

When panicing because of an unhandled data abort from the kernel it is
useful to know the register state and faulting address to aid debugging.
Print these registers before calling panic.

Sponsored by: DARPA, AFRL

4 years agoBump __FreeBSD_version to 1300077 for r357455
imp [Tue, 4 Feb 2020 09:12:12 +0000 (09:12 +0000)]
Bump __FreeBSD_version to 1300077 for r357455

sparc64 was removed, bump to reflect that.

Pointy-hat-to: imp
Noticed by: linimon@

4 years agoloader: rewrite zfs reader zap code to use malloc
tsoome [Tue, 4 Feb 2020 07:37:55 +0000 (07:37 +0000)]
loader: rewrite zfs reader zap code to use malloc

First step on removing zfs_alloc.

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D23433

4 years agoFix libmemstat_uma build after r357485.
jeff [Tue, 4 Feb 2020 05:27:45 +0000 (05:27 +0000)]
Fix libmemstat_uma build after r357485.

Submitted by: cy

4 years agoFix clock_gettime() and clock_getres() for cpu clocks:
dchagin [Tue, 4 Feb 2020 05:27:05 +0000 (05:27 +0000)]
Fix clock_gettime() and clock_getres() for cpu clocks:
- handle the CLOCK_{PROCESS,THREAD}_CPUTIME_ID specified directly;
- fix thread id calculation as in the Linuxulator we should
  convert the user supplied thread id to struct thread * by linux_tdfind();
- fix CPUCLOCK_SCHED case by using kern_{process,thread}_cputime()
  directly as native get_cputime() used by kern_clock_gettime() uses
  native tdfind()/pfind() to find proccess/thread.

PR: 240990
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23341
MFC after: 2 weeks

4 years agoFor code reuse in Linuxulator rename get_proccess_cputime()
dchagin [Tue, 4 Feb 2020 05:25:51 +0000 (05:25 +0000)]
For code reuse in Linuxulator rename get_proccess_cputime()
and get_thread_cputime() and add prototypes for it to <sys/syscallsubr.h>.

As both functions become a public interface add process lock assert
to ensure that the process is not exiting under it.

Fix whitespace nit while here.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23340
MFC after 2 weeks

4 years agolinux_to_native_clockid() properly initializes nwhich variable (or return error),
dchagin [Tue, 4 Feb 2020 05:23:34 +0000 (05:23 +0000)]
linux_to_native_clockid() properly initializes nwhich variable (or return error),
so don't initialize nwhich in declaration and remove stale comment from r161304.

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

4 years agoImplement a deferred write advancement feature that can be used to further
jeff [Tue, 4 Feb 2020 02:44:52 +0000 (02:44 +0000)]
Implement a deferred write advancement feature that can be used to further
amortize shared cacheline writes.

Discussed with: rlibby
Differential Revision: https://reviews.freebsd.org/D23462

4 years agoFix a recursion on the thread lock by acquiring it after call rtp_to_pri().
jeff [Tue, 4 Feb 2020 02:42:54 +0000 (02:42 +0000)]
Fix a recursion on the thread lock by acquiring it after call rtp_to_pri().

Reported by: swills
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D23495

4 years agoUse STAILQ instead of TAILQ for bucket lists. We only need FIFO behavior
jeff [Tue, 4 Feb 2020 02:41:24 +0000 (02:41 +0000)]
Use STAILQ instead of TAILQ for bucket lists.  We only need FIFO behavior
and this is more space efficient.

Stop queueing recently used buckets to the head of the list.  If the bucket
goes to a different processor the cache coherency will be more expensive.
We already try to encourage cache-hot behavior in the per-cpu layer.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D23493

4 years agocxgbe(4): Add pfil(9) hooks to the driver's rx.
np [Tue, 4 Feb 2020 01:09:02 +0000 (01:09 +0000)]
cxgbe(4): Add pfil(9) hooks to the driver's rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Treat NIC rx as special and run its handler directly and not
np [Tue, 4 Feb 2020 01:01:35 +0000 (01:01 +0000)]
cxgbe(4): Treat NIC rx as special and run its handler directly and not
via the t4_cpl_handler dispatch table.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Retire the allow_mbufs_in_cluster optimization.
np [Tue, 4 Feb 2020 00:51:10 +0000 (00:51 +0000)]
cxgbe(4): Retire the allow_mbufs_in_cluster optimization.

This simplifies the driver's rx fast path as well as the bookkeeping
code that tracks various rx buffer sizes and layouts.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoSet the LMA of the riscv kernel to the OpenSBI jump target by default
arichardson [Tue, 4 Feb 2020 00:06:16 +0000 (00:06 +0000)]
Set the LMA of the riscv kernel to the OpenSBI jump target by default

This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line
options. When using that option, QEMU maps the kernel ELF file to the
addresses specified in the LMAs in the program headers.

Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows
booting FreeBSD using the following command line:
qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt

Without this change the -kernel option cannot be used since the LMAs start
at address zero and QEMU already maps a ROM to these low physical addresses.

For targets that require a different kernel LMA the make variable
KERNEL_LMA can be overwritten in the config file. For example, adding
`makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be
loaded at 0xc0200000.

Before:
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000
  DYNAMIC        0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R   0x4

After:

There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000
  DYNAMIC        0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R   0x4

Reviewed By: br, mhorne (earlier version)
Differential Revision: https://reviews.freebsd.org/D23436

4 years agocxgbe(4): Avoid ext_arg2 in rxb_free.
np [Mon, 3 Feb 2020 23:50:29 +0000 (23:50 +0000)]
cxgbe(4): Avoid ext_arg2 in rxb_free.

ext_arg2 is the only item in the third cacheline in an mbuf and could be
cold by the time rxb_free runs.  Put the information needed by rxb_free
in the same line as the refcount, which is very likely to be hot given
that rxb_free runs when the refcount is decremented and reaches 0.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoports.7: Update examples with install-missing-packages
0mp [Mon, 3 Feb 2020 23:40:27 +0000 (23:40 +0000)]
ports.7: Update examples with install-missing-packages

The ports framework recently grew support for installing dependencies with
a dedicated target called "install-missing-packages". Let's retire the
carefully constructed one-liner that was used for getting dependencies so
far and use the official ports target instead.

Reviewed by: bcr
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23485

4 years agoReplace *-out with star-out to ease legibility
0mp [Mon, 3 Feb 2020 23:30:47 +0000 (23:30 +0000)]
Replace *-out with star-out to ease legibility

"*-out" is a complex way of phrasing the fact, and it causes
confusion for people.

Submitted by: debdrup
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23482

4 years agocxgbe(4): Do not use pack boundary > 512B unless it is explicitly
np [Mon, 3 Feb 2020 23:30:39 +0000 (23:30 +0000)]
cxgbe(4): Do not use pack boundary > 512B unless it is explicitly
requested.

This is a tradeoff between PCIe efficiency during large packet rx and
packing efficiency during small packet rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Initialize the rx buffer's metadata on first-use and not on
np [Mon, 3 Feb 2020 23:25:12 +0000 (23:25 +0000)]
cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
allocation.

refill_fl doesn't touch any part of a freshly allocated cluster after
this change.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Only checksummed TCP should be considered for LRO.
np [Mon, 3 Feb 2020 23:06:42 +0000 (23:06 +0000)]
cxgbe(4): Only checksummed TCP should be considered for LRO.

This avoids the per-packet nanouptime in tcp_lro_rx for traffic that's
not even TCP.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoFix the !SMP case in sched_add() after r355779.
markj [Mon, 3 Feb 2020 22:49:05 +0000 (22:49 +0000)]
Fix the !SMP case in sched_add() after r355779.

If the thread's lock is already that of the runqueue, don't recurse on
the queue lock.

Reviewed by: jeff, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23492

4 years agofd: partially unengrish the previous commit
mjg [Mon, 3 Feb 2020 22:34:50 +0000 (22:34 +0000)]
fd: partially unengrish the previous commit

4 years agofd: streamline fget_unlocked
mjg [Mon, 3 Feb 2020 22:32:49 +0000 (22:32 +0000)]
fd: streamline fget_unlocked

clang has the unfortunate property of paying little attention to prediction
hints when faced with a loop spanning the majority of the rotuine.

In particular fget_unlocked has an unlikely corner case where it starts almost
from scratch. Faced with this clang generates a maze of taken jumps, whereas
gcc produces jump-free code (in the expected case).

Work around the problem by providing a variant which only tries once and
resorts to calling the original code if anything goes wrong.

While here note that the 'seq' parameter is almost never passed, thus the
seldom users are redirected to call it directly.

4 years agofd: remove the seq argument from fget_unlocked
mjg [Mon, 3 Feb 2020 22:27:55 +0000 (22:27 +0000)]
fd: remove the seq argument from fget_unlocked

It is almost always NULL.

4 years agofd: remove the seq argument from fget routines
mjg [Mon, 3 Feb 2020 22:27:03 +0000 (22:27 +0000)]
fd: remove the seq argument from fget routines

It is almost always NULL.

4 years agoseqc: provide seqc_read_any
mjg [Mon, 3 Feb 2020 22:26:29 +0000 (22:26 +0000)]
seqc: provide seqc_read_any

4 years agoktrace: provide ktrstat_error
mjg [Mon, 3 Feb 2020 22:26:00 +0000 (22:26 +0000)]
ktrace: provide ktrstat_error

This eliminates a branch from its consumers trading it for an extra call
if ktrace is enabled for curthread. Given that this is almost never true,
the tradeoff is worth it.

4 years agoCouple protocol drain routines (frag6_drain and sctp_drain) may send
glebius [Mon, 3 Feb 2020 20:48:57 +0000 (20:48 +0000)]
Couple protocol drain routines (frag6_drain and sctp_drain) may send
packets.  An unexpected behaviour for memory reclamation routine.
Anyway, we need enter the network epoch for doing that.

4 years agoMinor cleanups to allow handing vast datasets.
phk [Mon, 3 Feb 2020 20:46:31 +0000 (20:46 +0000)]
Minor cleanups to allow handing vast datasets.

Submitted by: dds