Commit Graph

244356 Commits

Author SHA1 Message Date
Toomas Soome
11db1a1654 loader: add memalign() to libsa
Implement memalign(size_t alignment, size_t size) to allocate aligned memory.
2019-09-17 13:15:27 +00:00
Toomas Soome
62ea4c11d5 loader: stand.h should define reallocf as Reallocf
Use the same approach as other zalloc functions.
2019-09-17 13:07:02 +00:00
Toomas Soome
e57c0c2afb loader: cstyle cleanup libsa zalloc sources
Clean up libstand zalloc* sources. Note that it is not 100% whitespace cleanup.
I also reduced block in znalloc and zfree as those were obvious simplifications
and did help to save one level of indent.
2019-09-17 11:35:53 +00:00
Toomas Soome
144c4ca039 loader: factor out guard location setup from Realloc
To simplify and make it easier to read, use ga_Bytes field from guard
structure.
2019-09-17 09:47:35 +00:00
Michael Tuexen
3c19311544 Only allow a SCTP-AUTH shared key to be updated by the application
if it is not deactivated and not used.
This avoids a use-after-free problem.

Reported by:		da_cheng_shao@yeah.net
MFC after:		3 days
2019-09-17 09:46:42 +00:00
Mateusz Guzik
7f65185940 vfs: fix braino resulting in NULL pointer deref in r352424
The breakage was added after all the testing and the testing which followed
was not sufficient to find it.

Reported by:	pho
Sponsored by:	The FreeBSD Foundation
2019-09-17 08:09:39 +00:00
Jason A. Harmening
9d45af5c09 mips: move support for temporary mappings above KSEG0 to per-CPU data
This is derived from similar work done in r310481 for i386 and r312610 for
armv6/armv7. Additionally, use a critical section to keep the thread
pinned for per-CPU operations instead of completely disabling local interrupts.

No objections from:	adrian, jmallett, imp
Differential Revision: 	https://reviews.freebsd.org/D18593
2019-09-17 03:39:31 +00:00
Doug Moore
1399b98ebd Remove dead code from vm_map_unlink_entry made dead by r351476, and also
a no-longer-used enumerant.

Reviewed by: alc
Approved by: markj (mentor, implicit)
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D21668
2019-09-17 02:53:59 +00:00
Dmitri Goutnik
b077310f30 Amend r352422, add missing 'n'
Reported by:	yuripv
Approved by:	araujo (mentor)
Differential Revision:	https://reviews.freebsd.org/D21679
2019-09-17 00:22:20 +00:00
John-Mark Gurney
3ed737eb91 fix the article to be correct... 2019-09-16 22:48:40 +00:00
Mitchell Horne
b698d9178d RISC-V: Support EARLY_AP_STARTUP
The EARLY_AP_STARTUP option initializes non-boot processors
much sooner during startup. This adds support for this option
on RISC-V and enables it by default for GENERIC.

Reviewed by:	jhb, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21661
2019-09-16 22:17:16 +00:00
Mateusz Guzik
4cace859c2 vfs: convert struct mount counters to per-cpu
There are 3 counters modified all the time in this structure - one for
keeping the structure alive, one for preventing unmount and one for
tracking active writers. Exact values of these counters are very rarely
needed, which makes them a prime candidate for conversion to a per-cpu
scheme, resulting in much better performance.

Sample benchmark performing fstatfs (modifying 2 out of 3 counters) on
a 104-way 2 socket Skylake system:
before:   852393 ops/s
after:  76682077 ops/s

Reviewed by:	kib, jeff
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21637
2019-09-16 21:37:47 +00:00
Mateusz Guzik
e87f3f72f1 vfs: manage mnt_writeopcount with atomics
See r352424.

Reviewed by:	kib, jeff
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21575
2019-09-16 21:33:16 +00:00
Mateusz Guzik
ee831b2543 vfs: manage mnt_lockref with atomics
See r352424.

Reviewed by:	kib, jeff
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21574
2019-09-16 21:32:21 +00:00
Mateusz Guzik
a8c8e44bf0 vfs: manage mnt_ref with atomics
New primitive is introduced to denote sections can operate locklessly
on aspects of struct mount, but which can also be disabled if necessary.
This provides an opportunity to start scaling common case modifications
while providing stable state of the struct when facing unmount, write
suspendion or other events.

mnt_ref is the first counter to start being managed in this manner with
the intent to make it per-cpu.

Reviewed by:	kib, jeff
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21425
2019-09-16 21:31:02 +00:00
Dmitri Goutnik
26a9d16680 Add myself (dmgk) to calendar.freebsd
Approved by:	tz (mentor)
Differential Revision:	https://reviews.freebsd.org/D21675
2019-09-16 20:43:20 +00:00
Dmitri Goutnik
e7e4d3adb7 Add myself (dmgk) as a ports committer
Approved by:	tz (mentor)
Differential Revision:	https://reviews.freebsd.org/D21672
2019-09-16 20:41:37 +00:00
Toomas Soome
41e2c61669 loader: Malloc(0) should return NULL.
We really should not allocate anything with size 0.
2019-09-16 20:28:08 +00:00
Toomas Soome
1781ad707e loader_4th: scan_buffer can leave empty string on stack
When the file processing is done, we will have string with lenght 0 in stack and we will attempt to
allocate 0 bytes.
2019-09-16 20:26:53 +00:00
Alan Somers
320c848ff6 Fix an off-by-one error from r351961
That revision addressed a Coverity CID that could lead to a buffer overflow,
but it had an off-by-one error in the buffer size check.

Reported by:	Coverity
Coverity CID:	1405530
MFC after:	3 days
MFC-With:	351961
Sponsored by:	The FreeBSD Foundation
2019-09-16 16:41:01 +00:00
Alan Somers
9c9634d1db fusefs: initialize C++ classes the Coverity way
Coverity complained that I wasn't initializing some class members until the
SetUp method.  Do it in the constructor instead.

Reported by:	Coverity
Coverity CIDs:	1404352, 1404378
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-09-16 15:56:21 +00:00
Alan Somers
4ca1c0b7f7 fusefs: fix some minor Coverity CIDs in the tests
Where open(2) is expected to fail, the tests should assert or expect that
its return value is -1.  These tests all accepted too much but happened to
pass anyway.

Reported by:	Coverity
Coverity CID:	1404512, 1404378, 1404504, 1404483
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-09-16 15:44:59 +00:00
Mark Johnston
38547d5980 Assert that the refcount value is not VPRC_BLOCKED in vm_page_drop().
VPRC_BLOCKED is a refcount flag used to indicate that a thread is
tearing down mappings of a page.  When set, it causes attempts to wire a
page via a pmap lookup to fail.  It should never represent the last
reference to a page, so assert this.

Suggested by:	kib
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:16:48 +00:00
Mark Johnston
923da43e7c Fix a race in vm_page_dequeue_deferred_free() after r352110.
This function loaded the page's queue index before setting PGA_DEQUEUE.
In this window the page daemon may have deactivated the page, updating
its queue index.  Make the operation atomic using vm_page_pqstate_cmpset();
the page daemon will not modify the page once it observes that PGA_DEQUEUE
is set.

Reported and tested by:	pho
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:12:49 +00:00
Mark Johnston
47aef898ea Fix a page leak in vm_page_reclaim_run().
After r352110 the attempt to remove mappings of the page being replaced
may fail if the page is wired.  In this case we must free the replacement
page.

Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:09:31 +00:00
Mark Johnston
38a20ba16f Fix a couple of nits in r352110.
- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by:	alc
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:06:19 +00:00
Mark Johnston
e8bcf6966b Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
Mark Johnston
41fd4b9422 Fix a couple of nits in r352110.
- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by:	alc
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:03:12 +00:00
Alan Somers
42767f76af fusefs: fix some minor issues with fuse_vnode_setparent
* When unparenting a vnode, actually clear the flag. AFAIK this is basically
  a no-op because we only unparent a vnode when reclaiming it or when
  unlinking.

* There's no need to call fuse_vnode_setparent during reclaim, because we're
  about to free the vnode data anyway.

Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21630
2019-09-16 14:51:49 +00:00
Konstantin Belousov
1246ee664b nfscl_loadattrcache: fix rest of the cases to not call
vnode_pager_setsize() under the node mutex.

r248567 moved some calls of vnode_pager_setsize() after the node lock
is unlocked, do the rest now.

Reported and tested by:	peterj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-09-16 13:26:27 +00:00
Yuri Pankov
e3e469850c sbuf(9): fix sbuf_drain_func typedef markup
Reviewed by:	0mp (previous version)
Differential Revision:	https://reviews.freebsd.org/D21569
2019-09-16 13:10:03 +00:00
Emmanuel Vadot
bf9b4985e9 pkgbase: Move cap_mkdb from runtime to utilities POST-INSTALL
Since login and login.conf moved to the utilities packages move also
the post-install related commands.

Reported by:	mj-mailinglist@gmx.de
Reviewed by:	bapt
2019-09-16 12:51:30 +00:00
Kyle Evans
15e9beb765 Fix 20190507 UPDATING entry
The rc mechanism for loading kernel modules is actually called 'kld_list',
not 'kld_load'

Reported by:	yuripv
2019-09-16 12:44:44 +00:00
Michael Tuexen
5b66b7f11b Don't write to memory outside of the allocated array for SACK blocks.
Obtained from:		rrs@
MFC after:		3 days
Sponsored by:		Netflix, Inc.
2019-09-16 08:18:05 +00:00
Baptiste Daroussin
f370355791 Do not use our custom completion function, it is not needed anymore 2019-09-16 07:31:59 +00:00
Konstantin Belousov
505a58ec45 Increase the size of the send and receive buffers for YP client rpc
calls to max allowed UDP datagram size.

Since max allowed size both for keys and values where increased, the
old sizes of around 1K cause ypmatch(3) failures, while plain maps
fetches work.

The buffers were reduced in r34146 from default UDP rpcclient values
to 1024/2304 due to the key and value size being 1K.

Reviewed by:	slavash
Sponsored by:	Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D21586
2019-09-16 06:42:01 +00:00
Simon J. Gerraty
84bfb424e2 Document logic for __DEFAULT_DEPENDENT_OPTIONS
Reviewed by:	stevek
Differential Revision:	https://reviews.freebsd.org/D21640
2019-09-16 00:32:23 +00:00
Alexander Motin
3a97344265 Relax TX draining in ns8250_bus_transmit().
Since TX interrupt is generated when THRE is set, wait for TEMT set means
wait for full character transmission time.  At low speeds that may take
awhile, burning CPU time while holding sc_hwmtx lock, also congested.

This is partial revert of r317659.

PR:		240121
MFC after:	2 weeks
2019-09-15 23:56:39 +00:00
Xin LI
eb1c42c1f0 Avoid mixing cluster numbers and sector numbers. Makes code more readable.
Obtained from:	NetBSD
MFC after:	2 weeks
2019-09-15 19:41:54 +00:00
Ian Lepore
7887a5a140 Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.
The latest imported FDT data defines a node for an iomuxc-gpr device,
which we don't support (or need, right now) in addition to the usual
iomuxc device.  Unfortunately, the dts improperly assigns overlapping
ranges of mmio space to both devices.  The -gpr device is also a syscon
and simple_mfd device.

At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
when the real iomuxc driver comes along later, it fails to attach because
it tries to allocate its register space, and it's already partially in
use by the bogus instance of simple_mfd.

This change works around the problem by simply disabling the node for
the iomuxc-gpr device, since we don't need it for anything.
2019-09-15 19:38:15 +00:00
Michael Tuexen
52f6a8090e When the IP layer calls back into the SCTP layer to perform the SCTP
checksum computation, do not assume that the IP header chain and the
SCTP common header are in contiguous memory although the SCTP lays
out the mbuf chains that way. If there are IP-level options inserted
by the IP layer, the constraint is not fulfilled anymore.

This issues was found by running syzkaller. Thanks to markj@ who is
running an instance which also provides kernel dumps. This allowed me
to find this issue.

MFC after:		3 days
2019-09-15 18:29:45 +00:00
Kyle Evans
3155f2f0e2 rangelock: add rangelock_cookie_assert
A future change to posixshm to add file sealing (in DIFF_21391[0] and child)
will move locking out of shm_dotruncate as kern_shm_open() will require the
lock to be held across the dotruncate until the seal is actually applied.
For this, the cookie is passed into shm_dotruncate_locked which asserts
RCA_WLOCKED.

[0] Name changed to protect the innocent, hopefully, from getting autoclosed
due to this reference...

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D21628
2019-09-15 02:59:53 +00:00
Ian Lepore
3dffab60f3 Make the ti_sysc device quiet. It's an internal utility pseudo-device
that makes the upstream FDT data work right, so we don't need to see a
couple dozen instances of it spam the dmesg at boot time unless it's a
verbose boot.
2019-09-15 01:02:01 +00:00
Dimitry Andric
c0f37bf652 Fix arm and aarch64 builds of libedit after r352275
On arm and arm64, where chars are unsigned by default, buildworld dies
with:

--- terminal.o ---
/usr/src/contrib/libedit/terminal.c:569:41: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     el->el_cursor.v][where & 0370] !=
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/src/contrib/libedit/terminal.c:659:28: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     [el->el_cursor.h] == MB_FILL_CHAR)
                                     ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~

Fix this by making MB_FILL_CHAR a wint_t, so no casting is needed.

Note that in https://reviews.freebsd.org/D21584 this was also proposed
by Yuichiro Naito <naito.yuichiro_gmail.com>.

Reviewed by:	bapt
Subscribers:	naito.yuichiro_gmail.com, ml_vishwin.info
MFC after:	3 weeks
X-MFC-With:	r352275
Differential Revision: https://reviews.freebsd.org/D21657
2019-09-14 21:49:42 +00:00
Brandon Bergren
d020b3ebde Fix aux_info corruption in rtld direct execution mode.
After the aux vector is moved, it is necessary to re-digest aux_info so the
pointers are updated to the new locations.

This was causing thread creation to fail on powerpc64 when using direct
execution due to a nonsense value being read for aux_info[AT_STACKPROT].

Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D21656
2019-09-14 21:18:10 +00:00
Ian Lepore
b897b02c6c Create a mechanism for encoding a system errno into the IIC_Exxxxx space.
Errors are communicated between the i2c controller layer and upper layers
(iicbus and slave device drivers) using a set of IIC_Exxxxxx constants which
effectively define a private number space separate from (and having values
that conflict with) the system errno number space. Sometimes it is necessary
to report a plain old system error (especially EINTR) from the controller or
bus layer and have that value make it back across the syscall interface
intact.

I initially considered replicating a few "crucial" errno values with similar
names and new numbers, e.g., IIC_EINTR, IIC_ERESTART, etc. It seemed like
that had the potential to grow over time until many of the errno names were
duplicated into the IIC_Exxxxx space.

So instead, this defines a mechanism to "encode" an errno into the IIC_Exxxx
space by setting the high bit and putting the errno into the lower-order
bits; a new errno2iic() function does this. The existing iic2errno()
recognizes the encoded values and extracts the original errno out of the
encoded value. An interesting wrinkle occurs with the pseudo-error values
such as ERESTART -- they aleady have the high bit set, and turning it off
would be the wrong thing to do. Instead, iic2errno() recognizes that lots of
high bits are on (i.e., it's a negative number near to zero) and just
returns that value as-is.

Thus, existing drivers continue to work without needing any changes, and
there is now a way to return errno values from the lower layers. The first
use of that is in iicbus_poll() which does mtx_sleep() with the PCATCH flag,
and needs to return the errno from that up the call chain.

Differential Revision:	https://reviews.freebsd.org/D20975
2019-09-14 19:33:36 +00:00
Edward Tomasz Napierala
fad4b12b90 Introduce arb(3), the Array-based Red-Black Tree macros: similar
to the traditional tree(3) RB trees, but using an array (preallocated,
linear chunk of memory) to store the tree.

This avoids allocation overhead, improves memory locality,
and makes it trivially easy to share/transfer/copy the entire tree
without the need for marshalling.  The downside is that the size
is fixed at initialization time; there is no mechanism to resize
it.

This is one of the dependencies for the new stats(3) framework
(https://reviews.freebsd.org/D20477).

Reviewed by:	bcr (man pages), markj
Discussed with:	cem
MFC after:	2 weeks
Sponsored by:	Klara Inc, Netflix
Obtained from:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20324
2019-09-14 19:23:46 +00:00
Edward Tomasz Napierala
cf38985293 Make pseudofs(9) create directory entries in order, instead
of the reverse.

This fixes Linux sysctl(8) binary - it assumes the first two
directory entries are always "." and "..". There might be other
Linux apps affected by this.

NB it might be a good idea to rewrite it using queue(3).

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21550
2019-09-14 19:16:07 +00:00
Ian Lepore
53117a36f8 Include <lock.h>, required to use spinlocks in this code. 2019-09-14 18:20:14 +00:00
Stephen Gregoratto
f1343abc96 amend r:352320 Fix date for sg@
Approved by:    bcr (mentor)
2019-09-14 14:26:30 +00:00