]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMakefile.inc1: push /usr/libexec into the BPATH/TMPPATH
Kyle Evans [Sun, 12 Jan 2020 04:18:36 +0000 (04:18 +0000)]
Makefile.inc1: push /usr/libexec into the BPATH/TMPPATH

${WORLDTMP}/legacy/usr/libexec will only have libexec/ bits that we've
pushed as bootstrap tools, so this is generally safe to include prior to
PATH. The following are the ramifications of this change:

- BPATH addition gets us at least bootstrap flua in WMAKEENV path for
  buildenv, for those earlier systems where it's bootstrapped still

- Reworked the sysent target to just set PATH and let it get worked out in
  src.lua.mk or individual sysent makefiles -- this gives us back the
  ability to overwrite LUA_CMD and use a different/external lua for these
  targets.  sysent can also now work cleanly in buildenv.

- tools/build/Makefile will now symlink the host flua into build's host
  tools so that the above can work without needing to add the host's
  /usr/libexec explicitly into TMPPATH.

Reviewed by: arichardson, brooks, imp (all slightly earlier version)
Differential Revision: https://reviews.freebsd.org/D22464

4 years agoregulator: small enhancements to regulator_shutdown
Kyle Evans [Sun, 12 Jan 2020 04:07:03 +0000 (04:07 +0000)]
regulator: small enhancements to regulator_shutdown

Highlights:

- Exit early if we're not disabling unused regulators; there's no need to
  take the regulator topology lock and re-evaluate this every iteration, as
  it's not going to change.
- Don't emit a notice that we're shutting down a regulator if it's not
  enabled, to reduce noise.
- Mention the outcome of the shutdown, to aide debugging and easily let
  developer/user collect list of regulators we actually shutdown to
  determine problematic one.

Reviewed by: manu
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D22213

4 years agovfs: only recalculate watermarks when limits are changing
Mateusz Guzik [Sat, 11 Jan 2020 23:00:57 +0000 (23:00 +0000)]
vfs: only recalculate watermarks when limits are changing

Previously they would get recalculated all the time, in particular in:
getnewvnode -> vcheckspace -> vspace

4 years agovfs: deduplicate vnode allocation logic
Mateusz Guzik [Sat, 11 Jan 2020 22:59:44 +0000 (22:59 +0000)]
vfs: deduplicate vnode allocation logic

This creates a dedicated routine (vn_alloc) to allocate vnodes.

As a side effect code duplicationw with getnewvnode_reserve is eleminated.

Add vn_free for symmetry.

4 years agovfs: prealloc vnodes in getnewvnode_reserve
Mateusz Guzik [Sat, 11 Jan 2020 22:58:14 +0000 (22:58 +0000)]
vfs: prealloc vnodes in getnewvnode_reserve

Having a reserved vnode count does not guarantee that getnewvnodes wont
block later. Said blocking partially defeats the purpose of reserving in
the first place.

Preallocate instaed. The only consumer was always passing "1" as count
and never nesting reservations.

4 years agovfs: incomplete pass at converting more ints to u_long
Mateusz Guzik [Sat, 11 Jan 2020 22:56:20 +0000 (22:56 +0000)]
vfs: incomplete pass at converting more ints to u_long

Most notably numvnodes and freevnodes were u_long, but parameters used to
govern them remained as ints.

4 years agovfs: add missing CLTFLA_MPSAFE annotations
Mateusz Guzik [Sat, 11 Jan 2020 22:55:12 +0000 (22:55 +0000)]
vfs: add missing CLTFLA_MPSAFE annotations

This covers all kern/vfs_*.c files.

4 years agopowerpc/mpc85xx: Fix localbus child reg property decoding
Justin Hibbits [Sat, 11 Jan 2020 22:29:44 +0000 (22:29 +0000)]
powerpc/mpc85xx: Fix localbus child reg property decoding

r302340, as an attempt to fix the localbus child handling post-rman change,
actually broke child resource allocation, due to typos in
fdt_lbc_reg_decode().  This went unnoticed because there aren't any drivers
currently in tree that use localbus.

4 years agoPacify gcc.
Gleb Smirnoff [Sat, 11 Jan 2020 20:07:30 +0000 (20:07 +0000)]
Pacify gcc.

Reported by: rlibby

4 years agoin6_mcast: make in6_joingroup_locked() static
Bjoern A. Zeeb [Sat, 11 Jan 2020 18:55:12 +0000 (18:55 +0000)]
in6_mcast: make in6_joingroup_locked() static

in6_joingroup_locked() is only used file-local. No need to export it
hance make it static.

4 years agoarm64: allwinner: dtso: Add spi0 spigen DTSO
Emmanuel Vadot [Sat, 11 Jan 2020 18:36:10 +0000 (18:36 +0000)]
arm64: allwinner: dtso: Add spi0 spigen DTSO

This overlays can be used on A64 board to use spigen and spi(8)
on the spi0 pins.

Tested On:  Pine64-LTS, A64-Olinuxino

Submitted by: Gary Otten <gdotten@gmail.com>

4 years agoCorrect off-by-two issue when determining FAT type.
Xin LI [Sat, 11 Jan 2020 17:41:20 +0000 (17:41 +0000)]
Correct off-by-two issue when determining FAT type.

In the code we used NumClusters as the upper (non-inclusive) boundary
of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
than the real number of clusters. This causes a FAT16 media with
65524 clusters be treated as FAT32 and might affect FAT12 media with
4084 clusters as well.

To fix this, we increment NumClusters by CLUST_FIRST after the type
determination.

PR: 243179
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23082

4 years agoMake sure the VNET is properly set when reaping mbufs in ipoib.
Hans Petter Selasky [Sat, 11 Jan 2020 12:02:16 +0000 (12:02 +0000)]
Make sure the VNET is properly set when reaping mbufs in ipoib.
Else the following panic may happen:

panic()
icmp_error()
ipoib_cm_mb_reap()
linux_work_fn()
taskqueue_run_locked()
taskqueue_thread_loop()
fork_exit()
fork_trampoline()

Submitted by: Andreas Kempe <kempe@lysator.liu.se>
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoRevert r356598 for now because it breaks some AMD based XHCI controllers.
Hans Petter Selasky [Sat, 11 Jan 2020 11:38:02 +0000 (11:38 +0000)]
Revert r356598 for now because it breaks some AMD based XHCI controllers.

Reported by: jkim @
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agortld: clean up Makefile.
Konstantin Belousov [Sat, 11 Jan 2020 09:18:58 +0000 (09:18 +0000)]
rtld: clean up Makefile.

Move all MD statements into $MACHINE_ARCH/Makefile.inc.
Unconditionally apply version script to rtld, the interpreter is not
functional without it for long time.

Reviewed by: brooks, emaste
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D23083

4 years agoStop prepending prefix to the result of realpath(3).
Konstantin Belousov [Sat, 11 Jan 2020 09:08:02 +0000 (09:08 +0000)]
Stop prepending prefix to the result of realpath(3).

The path is already absolute.

Noted and reviewed by: rstone
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23121

4 years agoApply typo fix from NetBSD, we have already applied all NetBSD changes so
Xin LI [Sat, 11 Jan 2020 04:02:40 +0000 (04:02 +0000)]
Apply typo fix from NetBSD, we have already applied all NetBSD changes so
update the NetBSD tag while I'm there.

MFC after: 2 weeks

4 years agoRequire FAT to occupy at least one sector.
Xin LI [Sat, 11 Jan 2020 03:59:06 +0000 (03:59 +0000)]
Require FAT to occupy at least one sector.

Obtained from: Android https://r.android.com/1205830
MFC after: 3 days

4 years agoWhen a read error occurs while fetching a directory block to delete
Kirk McKusick [Sat, 11 Jan 2020 03:18:47 +0000 (03:18 +0000)]
When a read error occurs while fetching a directory block to delete
or rename an entry in it, properly reset the link count of the inode
associated with the entry that was to have been changed.

Tested by: Peter Holm
MFC after: 7 days

4 years agoUpdate ELFOSABI_* constants with OpenVOS.
Pedro F. Giffuni [Sat, 11 Jan 2020 01:44:55 +0000 (01:44 +0000)]
Update ELFOSABI_* constants with OpenVOS.

Reference:
https://www.sco.com/developers/gabi/latest/ch4.eheader.html

4 years agoMFV: r356607
Jung-uk Kim [Fri, 10 Jan 2020 22:49:14 +0000 (22:49 +0000)]
MFV: r356607

Import ACPICA 20200110.

4 years agocamdd: initialize devs earlier
Kyle Evans [Fri, 10 Jan 2020 22:20:23 +0000 (22:20 +0000)]
camdd: initialize devs earlier

GCC9 points out that devs may be used initialized after the bailout label;
in-fact, if num_io_opts != 2 then it is. Move the initialization up a little
bit.

Reviewed by: ken
MFC after: 3 days

4 years agosrc.opts.mk: force KERBEROS_SUPPORT off where KERBEROS forced off
Ed Maste [Fri, 10 Jan 2020 22:00:39 +0000 (22:00 +0000)]
src.opts.mk: force KERBEROS_SUPPORT off where KERBEROS forced off

Explicitly setting WITHOUT_KERBEROS implies WITHOUT_KERBEROS_SUPPORT,
but previously other cases that forced KERBEROS off (such as
WITHOUT_CRYPT) did not also set KERBEROS_SUPPORT off.  Because the
_SUPPORT dependent options (KERBEROS/KERBEROS_SUPPORT) are processed
before other dependencies (CRYPT/KERBEROS) it's not easy to make this
happen automatically.  Instead just explicitly set KERBEROS_SUPPORT
off where we set KERBEROS off.

Reported by: Michael Dexter's Build Option Survey run

4 years agotests: fusefs: silence remaining unsigned/signed comparison warnings
Kyle Evans [Fri, 10 Jan 2020 21:51:27 +0000 (21:51 +0000)]
tests: fusefs: silence remaining unsigned/signed comparison warnings

External GCC turns these into errors; cast to long to silence them.

Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D23127

4 years agoAdd pfil(9) hook to vtnet(4).
Gleb Smirnoff [Fri, 10 Jan 2020 21:22:03 +0000 (21:22 +0000)]
Add pfil(9) hook to vtnet(4).

The patch could be simplier, using only the second chunk to
vtnet_rxq_eof(), that passes full mbufs to pfil(9). Packet
filter would m_free() them in case of returning PFIL_DROPPED.

However, we pretend to be a hardware driver, so we first try
to pass a memory buffer via PFIL_MEMPTR feature. This is mostly
done for debugging purposes, so that one can experiment in bhyve
with packet filters utilizing same features as a true driver.

4 years agoAdd myself (lbartoletti) as a ports commiter
Loïc Bartoletti [Fri, 10 Jan 2020 20:53:58 +0000 (20:53 +0000)]
Add myself (lbartoletti) as a ports commiter
Step 5 (Update Mentor and Mentee Information) from Commiters guide.

I also alphababetize mentees from tcberner.

Approved by: tcberner (mentor)
Differential Revision: https://reviews.freebsd.org/D23125

4 years agoAlways multiple vm.pgcache_zone_max to number of CPUs, and rename it
Gleb Smirnoff [Fri, 10 Jan 2020 19:32:08 +0000 (19:32 +0000)]
Always multiple vm.pgcache_zone_max to number of CPUs, and rename it
respectively.  The tunable controls how big is the size of per-cpu
vm page cache.  Previously the value was split for all CPUs in system,
so configuring same value on machines with different count of CPUs
yielded in different cache size available to a particular CPU.

Reviewed by: markj
Obtained from: Netflix

4 years agoarm: allwinner: axp209: Add regnode_status method
Emmanuel Vadot [Fri, 10 Jan 2020 18:53:14 +0000 (18:53 +0000)]
arm: allwinner: axp209: Add regnode_status method

This allow consumers to check if the regulator is enable or not.

MFC after: 1 week

4 years agotwsi: Rework how we handle the i2c messages
Emmanuel Vadot [Fri, 10 Jan 2020 18:52:14 +0000 (18:52 +0000)]
twsi: Rework how we handle the i2c messages

We use to handle each message separately in i2c_transfer but that cannot
work with message with NOSTOP as it confuses the controller that we disable
the interrupts and start a new message.
Handle every message in the interrupt handler and fire a new start condition
if the previous message have NOSTOP, the controller understand this as a
repeated start.
This fixes booting on Allwinner A10/A20 platform where before the i2c controller
used to write 0 to the PMIC register that control the regulators as it though that
this was the continuation of the write message.

Tested on:   A20 BananaPi, Cubieboard 1 (kevans)
Reported by: kevans
MFC after: 1 month

4 years agoImport ACPICA 20200110.
Jung-uk Kim [Fri, 10 Jan 2020 18:46:46 +0000 (18:46 +0000)]
Import ACPICA 20200110.

4 years agoSet .ORDER for makesyscalls generated files
Kyle Evans [Fri, 10 Jan 2020 18:24:17 +0000 (18:24 +0000)]
Set .ORDER for makesyscalls generated files

When either makesyscalls.lua or syscalls.master changes, all of the
${GENERATED} targets are now out-of-date. With make jobs > 1, this means we
will run the makesyscalls script in parallel for the same ABI, generating
the same set of output files.

Prior to r356603 , there is a large window for interlacing output for some
of the generated files that we were generating in-place rather than staging
in a temp dir. After that, we still should't need to run the script more
than once per-ABI as the first invocation should update all of them. Add
.ORDER to do so cleanly.

Reviewed by: brooks
Discussed with: sjg
Differential Revision: https://reviews.freebsd.org/D23099

4 years agomakesyscalls.lua: generate all files in /tmp, write into place at the end
Kyle Evans [Fri, 10 Jan 2020 18:22:14 +0000 (18:22 +0000)]
makesyscalls.lua: generate all files in /tmp, write into place at the end

This makes makesyscalls.lua more parallel-friendly, or at least not as
hostile to the idea. We get into situations where we're running parallel if
we end up with MAKE_JOBS>1 entering any of the sysent targets, since each
output file is recognized a distinct build step that needs to be executed.

Another commit will add some .ORDER to further improve the situation.

Reported by: jhb
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D23098

4 years agoinetd: two more nits
Kyle Evans [Fri, 10 Jan 2020 14:43:57 +0000 (14:43 +0000)]
inetd: two more nits

Use __COPYRIGHT for copyright to simply either embed it via .ident or have
it properly marked __unused

Move an ipsec reference to IPSEC

4 years agoinetd: free WITHOUT_INET6_SUPPORT build of warnings
Kyle Evans [Fri, 10 Jan 2020 14:40:04 +0000 (14:40 +0000)]
inetd: free WITHOUT_INET6_SUPPORT build of warnings

If inetd is compiled without inet6 support, we need to error out on
rpc+inet6 services rather than attempting to call into rpc bits with an
uninitialized netid.

v4bind is only used with INET6 support, so move it under the proper #ifdefs
with v6bind.

Reported by: Pavel Timofeev <timp87 gmail com>
MFC after: 3 days

4 years agoa10_ahci: grab the target-supply regulator and enable it
Kyle Evans [Fri, 10 Jan 2020 14:09:59 +0000 (14:09 +0000)]
a10_ahci: grab the target-supply regulator and enable it

This regulator is marked regulator-boot-on, but it will get shutdown if it's
not actually used/enabled by a driver. This should fix sata on the
cubieboard{1,2}.

Reported by: Ray White @ UWaterloo
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D23112

4 years agoCheck the XHCI endpoint state before stopping any endpoint.
Hans Petter Selasky [Fri, 10 Jan 2020 09:32:44 +0000 (09:32 +0000)]
Check the XHCI endpoint state before stopping any endpoint.

This avoids getting the XHCI_TRB_ERROR_CONTEXT_STATE error code from the XHCI
controller when the endpoint is disabled or already stopped.

Suggested by: Shichun.Ma@dell.com
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoDefine the XHCI endpoint states.
Hans Petter Selasky [Fri, 10 Jan 2020 09:07:43 +0000 (09:07 +0000)]
Define the XHCI endpoint states.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoInclude human-readable list of rtm flags along with bitmask in error messages
Alexander V. Chernikov [Fri, 10 Jan 2020 08:54:46 +0000 (08:54 +0000)]
Include human-readable list of rtm flags along with bitmask in error messages
 for rtsock tests.

MFC after: 2 weeks

4 years agopowerpc: Prevent infinite loop in moea_sync_icache()
Justin Hibbits [Fri, 10 Jan 2020 04:13:16 +0000 (04:13 +0000)]
powerpc: Prevent infinite loop in moea_sync_icache()

This applies r344049 to the 32-bit pmap.

Reported by: Mark Millard <marklmi_yahoo.com>

4 years agoReplace inline assembly with rdtime macro
Mitchell Horne [Fri, 10 Jan 2020 03:17:28 +0000 (03:17 +0000)]
Replace inline assembly with rdtime macro

This macro is used elsewhere and is slightly cleaner. NFC.

4 years agopowerpc: Mark cpu_feature-based sysctls as MP_SAFE
Justin Hibbits [Fri, 10 Jan 2020 03:16:40 +0000 (03:16 +0000)]
powerpc: Mark cpu_feature-based sysctls as MP_SAFE

hw.floatingpoint and hw.altivec are effectively runtime constants (bits from
the cpu_feature bitfield), so don't need Giant, or any locking for that
matter.

4 years agopowerpc/powernv: Un-Giant-ify opal_nvram driver
Justin Hibbits [Fri, 10 Jan 2020 01:24:49 +0000 (01:24 +0000)]
powerpc/powernv: Un-Giant-ify opal_nvram driver

It may be possible to make this completely lock free, but for now it's using
a statically allocated bounce buffer in the softc, so it needs to be
guarded.

4 years agoRemove scary-looking printf output that happens when you kldload dtrace on
Ian Lepore [Thu, 9 Jan 2020 22:51:37 +0000 (22:51 +0000)]
Remove scary-looking printf output that happens when you kldload dtrace on
arm.  Replace it with a comment block explaining why the function is empty
on 32-bit arm.

4 years agoloader: bioscd probe can get sector size 0
Toomas Soome [Thu, 9 Jan 2020 21:21:08 +0000 (21:21 +0000)]
loader: bioscd probe can get sector size 0

With buggy BIOS, it may happen we get sector size reported 0 for cd, and then
the default 512 is used, which is quite wrong.

PR: 238749

4 years agolibc: Fix a few bugs in the xlocale collation code.
Mark Johnston [Thu, 9 Jan 2020 20:49:26 +0000 (20:49 +0000)]
libc: Fix a few bugs in the xlocale collation code.

- Fix checks for mmap() failures. [1]
- Set the "map" and "maplen" fields of struct xlocale_collate so that
  the table destructor actually does something.
- Free an already-mapped collation file before loading a new one into
  the global table.
- Harmonize the prototype and definition of __collate_load_tables_l() by
  adding the "static" qualifier to the latter.

PR: 243195
Reported by: cem [1]
Reviewed by: cem, yuripv
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23109

4 years agoCatch up with Clang 9.0.
Jung-uk Kim [Thu, 9 Jan 2020 20:07:38 +0000 (20:07 +0000)]
Catch up with Clang 9.0.

4 years agodwc_otg: fix fdt attachment for newer bcm2708-usb nodes
Kyle Evans [Thu, 9 Jan 2020 19:22:11 +0000 (19:22 +0000)]
dwc_otg: fix fdt attachment for newer bcm2708-usb nodes

The newer versions of RPi FDT flipped the order of the interrupts
specification and added an 'interrupt-names' property for driver aide in
finding the correct interrupt, rather than assuming the positions. Use it if
it's available, or fallback to the old method if there is no interrupt-names
property with a usb value.

This has been tested with both old RPi3B FDT and new RPi3B FDT, USB again
works on the latter.

Reported by: Tom Yan <tom.ty89 gmail com>
MFC after: 3 days

4 years agoUMA: Don't destroy zones after the system shutdown process starts.
Mark Johnston [Thu, 9 Jan 2020 19:17:42 +0000 (19:17 +0000)]
UMA: Don't destroy zones after the system shutdown process starts.

Some kernel subsystems, notably ZFS, will destroy UMA zones from a
shutdown eventhandler.  This causes the zone to be drained.  For slabs
that are mapped into KVA this can be very expensive and so it needlessly
delays the shutdown process.

Add a new state to the "booted" variable, BOOT_SHUTDOWN.  Once
kern_reboot() starts invoking shutdown handlers, turn uma_zdestroy()
into a no-op, provided that the zone does not have a custom finalization
routine.

PR: 242427
Reviewed by: jeff, kib, rlibby
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23066

4 years agobcm2835_vcbus: hide 'checking root' messages under bootverbose
Kyle Evans [Thu, 9 Jan 2020 19:13:09 +0000 (19:13 +0000)]
bcm2835_vcbus: hide 'checking root' messages under bootverbose

4 years agoAdd stricter checking on mac key lengths.
John Baldwin [Thu, 9 Jan 2020 18:29:59 +0000 (18:29 +0000)]
Add stricter checking on mac key lengths.

Negative lengths are always invalid.  The key length should also
be zero for hash algorithms that do not accept a key.

admbugs: 949
Reported by: Yuval Kanarenstein <yuvalk@ssd-disclosure.com>
Reviewed by: cem
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23094

4 years agoAdd note to remind me there are three choices for arm32 floating point.
Warner Losh [Thu, 9 Jan 2020 18:14:48 +0000 (18:14 +0000)]
Add note to remind me there are three choices for arm32 floating point.

hard use floating point hardware, pass registers to functions in
floating point registers.
softfp use floating point hardware, but pass registers to functions
in integer registers.
soft do floating point calcuations without using floating point
hardware. Pass arguments in integer registers.

FreeBSD 11 and newer assumes hard. 10 and earlier assumed softfp.  We have no
real support, at the moment, for soft. It's untested, though, if softfp still
works.

Add a note here since this is a whack-a-doodle combination relative to all other
platforms.

softfp is likely to go away in the future because it was retained for people
using FreeBSD 10 + armv6 needing to transition more slowly from softfp -> hard
than the project. It likely is no longer needed, and may be getting in the
way of people needing 'soft' support.

4 years agoAdd fibnum, family and vnet pointer to each rib head.
Alexander V. Chernikov [Thu, 9 Jan 2020 17:21:00 +0000 (17:21 +0000)]
Add fibnum, family and vnet pointer to each rib head.

Having metadata such as fibnum or vnet in the struct rib_head
 is handy as it eases building functionality in the routing space.
This change is required to properly bring back route redirect support.

Reviewed by: bz
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D23047

4 years agoConst-poison the cam_sim_* convenience accessor functions.
Warner Losh [Thu, 9 Jan 2020 16:34:54 +0000 (16:34 +0000)]
Const-poison the cam_sim_* convenience accessor functions.

These don't modify the cam_sim, so make that parameter const.

4 years agoFix typo: MANGAEMENT_PROTOCOL_OUT -> MANAGEMENT_PROTOCOL_OUT.
Gleb Popov [Thu, 9 Jan 2020 15:21:42 +0000 (15:21 +0000)]
Fix typo: MANGAEMENT_PROTOCOL_OUT -> MANAGEMENT_PROTOCOL_OUT.

Approved by: allanjude

4 years agoChange malloc_domain() to return the allocation size to the caller.
Mark Johnston [Thu, 9 Jan 2020 15:02:48 +0000 (15:02 +0000)]
Change malloc_domain() to return the allocation size to the caller.

Otherwise the malloc type accounting in malloc_domainset(9) is wrong
after r355203.

Reviewed by: rlibby
Reported by: kaktus
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23095

4 years agolagg: Further cleanup of the rr_limit option.
Mark Johnston [Thu, 9 Jan 2020 14:58:41 +0000 (14:58 +0000)]
lagg: Further cleanup of the rr_limit option.

Add an option flag so that arbitrary updates to a lagg's configuration
do not clear sc_stride.  Preseve compatibility for old ifconfig
binaries.  Update ifconfig to use the new flag and improve the casting
used when parsing the option parameter.

Modify the RR transmit function to avoid locklessly reading sc_stride
twice.  Ensure that sc_stride is always 1 or greater.

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

4 years agoRevert r356515 - add LLVM_LIBUNWIND back to sparc64 BROKEN_OPTIONS
Ed Maste [Thu, 9 Jan 2020 14:12:57 +0000 (14:12 +0000)]
Revert r356515 - add LLVM_LIBUNWIND back to sparc64 BROKEN_OPTIONS

r356552 reverted the untested build fix for LLVM libunwind on sparc64,
so mark it broken again.

4 years agorevert r356513: libunwind: untested attempt to fix sparc64 build
Ed Maste [Thu, 9 Jan 2020 14:10:11 +0000 (14:10 +0000)]
revert r356513: libunwind: untested attempt to fix sparc64 build

The patch is untested and is almost certainly insufficient. Per the
author's request, revert until someone with access to sparc64 hardware
can test and report.

4 years agoarp(8): avoid segfaulting due to out-of-bounds memory access
Eugene Grosbein [Thu, 9 Jan 2020 11:58:26 +0000 (11:58 +0000)]
arp(8): avoid segfaulting due to out-of-bounds memory access

Fix obvious mistake that sometimes results in reading memory
past end of an array.

PR: 240825
MFC after: 1 week

4 years agoAdd atomic_testandset/clear on arm64.
Andrew Turner [Thu, 9 Jan 2020 10:26:36 +0000 (10:26 +0000)]
Add atomic_testandset/clear on arm64.

These will reportedly be used in future uma changes.

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

4 years agortld: Return error if $ORIGIN for a dlopen-ed library cannot be resolved ...
Konstantin Belousov [Thu, 9 Jan 2020 10:05:45 +0000 (10:05 +0000)]
rtld: Return error if $ORIGIN for a dlopen-ed library cannot be resolved ...

instead of killing the process.  The same behaviour of terminating
image activation if the $ORIGIN cannot be resolved for the main
object, is kept.

Reported by: Greg V <greg@unrelenting.technology>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23053

4 years agoResolve relative argv0 for direct exec mode to absolute path for AT_EXECPATH.
Konstantin Belousov [Thu, 9 Jan 2020 10:00:24 +0000 (10:00 +0000)]
Resolve relative argv0 for direct exec mode to absolute path for AT_EXECPATH.

We know the binary relative name and can reliably calculate cwd path.
Because realpath(3) was already linked into ld-elf.so.1, reuse it
there to resolve dots and dotdots making the path more canonical.

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

4 years agoFix a XHCI driver issue with Intel's Gemini Lake SOC.
Hans Petter Selasky [Thu, 9 Jan 2020 09:29:24 +0000 (09:29 +0000)]
Fix a XHCI driver issue with Intel's Gemini Lake SOC.

Do not configure any endpoint twice, but instead keep track of which
endpoints are configured on a per device basis, and use an evaluate
endpoint context command instead. When changing the configuration make
sure all endpoints get deconfigured and the configured endpoint mask
is reset.

This fixes an issue where an endpoint might stop working if there is
an error and the endpoint needs to be reconfigured as a part of the
error recovery mechanism in the FreeBSD USB stack.

Tested by: Shichun.Ma@dell.com
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agokern/Makefile: systrace_args.c is also generated
Kyle Evans [Thu, 9 Jan 2020 06:10:25 +0000 (06:10 +0000)]
kern/Makefile: systrace_args.c is also generated

4 years agomd(4): improve documentation of preloading
Kyle Evans [Thu, 9 Jan 2020 04:39:37 +0000 (04:39 +0000)]
md(4): improve documentation of preloading

It's not immediately clear by what mechanism loader(8) will be loading the
preloaded file. Specifically name-drop loader.conf(5) with a pointer to the
module loading section and a description of what the 'name' should look
like, because that certainly isn't clear from the loader.conf(5) standpoint.

The default loader.conf already has a pointer to md(4) where it appears and
the reference to loader.conf in the new version of this manpage should make
it more clear that this is where one should look for information.

Reported by: swills
Reviewed by: swills, manpages (bcr)
With revision by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D22844

4 years agostand/fdt: Scale blob size better as overlays apply
Kyle Evans [Thu, 9 Jan 2020 04:34:42 +0000 (04:34 +0000)]
stand/fdt: Scale blob size better as overlays apply

Currently, our overlay blob will grow to include the size of the complete
overlay blob we're applying. This doesn't scale very well with a lot of
overlays- they tend to include a lot of overhead, and they will generally
only add a fraction of their total size to the blob they're being applied
to.

To combat this, pack the blob as we apply new overlays and keep track of how
many overlays we've applied. Only ubldr has any fixups to be applied after
overlays, so we only need to re-pad the blob in ubldr. Presumably the
allocation won't fail since we just did a lot worse in trying to apply
overlays and succeeded.

I have no intention of removing the padding in make_dtb.sh. There might be
an argument to be had over whether it should be configurable, since ubldr
*is* the only loader that actually has fixups to be applied and we can do
this at runtime, but I'm not too concerned about this.

This diff has been sitting in Phabricator for a year and a half, but I've
decided to flush it as it does make sure that we're scaling the blob
appropriately and leave room at the end for fixups in case of some freak
circumstance where applying overlays leaves us with a blob of insufficient
size.

Reviewed by: gonzo (a long time ago)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14133

4 years agoshmfd: posix_fallocate(2): only take rangelock for section we need
Kyle Evans [Thu, 9 Jan 2020 04:03:17 +0000 (04:03 +0000)]
shmfd: posix_fallocate(2): only take rangelock for section we need

Other mechanisms that resize the shmfd grab a write lock from 0 to OFF_MAX
for safety, so we still get proper synchronization of shmfd->shm_size in
effect. There's no need to block readers/writers of earlier segments when
we're just reserving more space, so narrow the scope -- it would likely be
safe to narrow it completely to just the section of the range that extends
beyond our current size, but this likely isn't worth it since the size isn't
stable until the writelock is granted the first time.

Suggested by: cem (passing comment)

4 years agoif_vmove: return proper error status
Kyle Evans [Thu, 9 Jan 2020 03:52:50 +0000 (03:52 +0000)]
if_vmove: return proper error status

if_vmove can fail if it lost a race and the vnet's already been moved. The
callers (and their callers) can generally cope with this, but right now
success is assumed. Plumb out the ENOENT from if_detach_internal if it
happens so that the error's properly reported to userland.

Reviewed by: bz, kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22780

4 years agouma: unify layout paths and improve efficiency
Ryan Libby [Thu, 9 Jan 2020 02:03:17 +0000 (02:03 +0000)]
uma: unify layout paths and improve efficiency

Unify the keg layout selection paths (keg_small_init, keg_large_init,
keg_cachespread_init), and slightly improve memory efficiecy by:
 - using the padding of the final item to store the slab header,
 - not going OFFPAGE if we have a choice unless it improves efficiency.

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

4 years agouma: reorganize flags
Ryan Libby [Thu, 9 Jan 2020 02:03:03 +0000 (02:03 +0000)]
uma: reorganize flags

 - Garbage collect UMA_ZONE_PAGEABLE & UMA_ZONE_STATIC.
 - Move flag VTOSLAB from public to private.
 - Introduce public NOTPAGE flag and make HASH private.
 - Introduce public NOTOUCH flag and make OFFPAGE private.
 - Update man page.

The net effect of this should be to make the contract with clients more
clear.  Clients should choose constraints, UMA will figure out how to
implement them.  This also breaks the confusing double meaning of
OFFPAGE.

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

4 years agoRun netoptions startup script in vnet jails.
Bjoern A. Zeeb [Wed, 8 Jan 2020 23:34:50 +0000 (23:34 +0000)]
Run netoptions startup script in vnet jails.

People use rc.conf inside vnet jails to configure networking setups.
Presumably because some sysctl were not virtualised up until r356527 the
script was not run for vnet jails leaving the rc.conf options without
effect for non-obvious reasons.  Run the netoptions startup script also
for VNET jails now to make the rc.conf options work.

PR: 243193
MFC after: 2 weeks

4 years agovnet: virtualise more network stack sysctls.
Bjoern A. Zeeb [Wed, 8 Jan 2020 23:30:26 +0000 (23:30 +0000)]
vnet: virtualise more network stack sysctls.

Virtualise tcp_always_keepalive, TCP and UDP log_in_vain.  All three are
set in the netoptions startup script, which we would love to run for VNETs
as well [1].

While virtualising the log_in_vain sysctls seems pointles at first for as
long as the kernel message buffer is not virtualised, it at least allows
an administrator to debug the base system or an individual jail if needed
without turning the logging on for all jails running on a system.

PR: 243193 [1]
MFC after: 2 weeks

4 years agoRemove some trailing whitespace; no functional changes.
Ian Lepore [Wed, 8 Jan 2020 23:06:13 +0000 (23:06 +0000)]
Remove some trailing whitespace; no functional changes.

4 years agoSplit the code to find and add iicbus children out to its own function.
Ian Lepore [Wed, 8 Jan 2020 23:03:47 +0000 (23:03 +0000)]
Split the code to find and add iicbus children out to its own function.
Move the decision to take an early exit from that function after adding
children based on FDT data into the #ifdef FDT block, so that it doesn't
offend coverity's notion of how the code should be written.  (What's the
point of compilers optimizing away dead code if static analyzers won't
let you use the feature in conjuction with an #ifdef block?)

Reported by: coverity via vangyzen@

4 years agobhyve: add wrapper for debug printf statements
Vincenzo Maffione [Wed, 8 Jan 2020 22:55:22 +0000 (22:55 +0000)]
bhyve: add wrapper for debug printf statements

Add printf() wrapper to use CR/CRLF terminators depending on whether
stdio is mapped to a tty open in raw mode.
Try to use the wrapper everywhere.
For now we leave the custom DPRINTF/WPRINTF defined by device
models, but we may remove them in the future.

Reviewed by: grehan, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22657

4 years agoChange some KASSERT to device_printf + return EINVAL. There's no need to
Ian Lepore [Wed, 8 Jan 2020 22:48:14 +0000 (22:48 +0000)]
Change some KASSERT to device_printf + return EINVAL.  There's no need to
bring the whole kernel down due to a configuration error detected when a
module is loaded, it suffices to just not attach the device.

4 years agoInit sc->maxbus to -1, not 0. It represents the highest array index that
Ian Lepore [Wed, 8 Jan 2020 22:45:32 +0000 (22:45 +0000)]
Init sc->maxbus to -1, not 0.  It represents the highest array index that
has a non-NULL child bus stored in it, so the "none" value can't be zero
since that's a valid array index.  Also, when adding all possible buses
because there is no specific per-bus config, there's no need to reset
sc->maxbus on each loop iteration, it can be set once after the loop.

4 years agoRemove no-longer-used function prototype.
John Baldwin [Wed, 8 Jan 2020 22:16:26 +0000 (22:16 +0000)]
Remove no-longer-used function prototype.

Reported by: amd64-gcc

4 years agoEnsure any reserved gpio pins get released if an early exit is taken
Ian Lepore [Wed, 8 Jan 2020 22:06:31 +0000 (22:06 +0000)]
Ensure any reserved gpio pins get released if an early exit is taken
from the attach function.

4 years agoRetire build support for GCC's DWARF unwinder
Ed Maste [Wed, 8 Jan 2020 21:07:55 +0000 (21:07 +0000)]
Retire build support for GCC's DWARF unwinder

As of r356514 LLVM's libunwind is used as the DWARF unwinder on all
supported CPU architectures, and GCC and its libraries will be removed
soon.  Retire the build infrastructure for GCC's unwinder; from here
if there are any unwinder bugs (on any arch) the path forward is to fix
LLVM's libunwind.

4 years agoRemove prereq lib support for GNU unwinder
Ed Maste [Wed, 8 Jan 2020 20:56:30 +0000 (20:56 +0000)]
Remove prereq lib support for GNU unwinder

LLVM's libunwind is used for all archs, as of r356514.  As GCC 4.2.1
will soon be removed, and with it the GNU unwinder, start simplifying
the prereq/startup lib logic in Makefile.inc1.  From here if there are
any unwinder bugs (on any arch) the path foward is to fix LLVM's
libunwind.

4 years agosrc.opts.mk: Remove sparc64 LLVM_LIBUNWIND BROKEN_OPTIONS
Ed Maste [Wed, 8 Jan 2020 20:51:07 +0000 (20:51 +0000)]
src.opts.mk: Remove sparc64 LLVM_LIBUNWIND BROKEN_OPTIONS

After r356513 it should build.

4 years agosrc.opts.mk: enable LLVM_UNWIND by default for all archs
Ed Maste [Wed, 8 Jan 2020 20:45:18 +0000 (20:45 +0000)]
src.opts.mk: enable LLVM_UNWIND by default for all archs

Only sparc64 did not enable LLVM_LIBUNWIND. After r356513 LLVM_LIBUNWIND
should at least build on sparc64. The old DWARF unwinder will be removed
along with GCC 4.2.1 in the near future, so switch sparc64 to use LLVM's
unwinder in advance of the removal.  Someone with access to the obsolete
sparc64 hardware supported by FreeBSD will have to test, and investigate
any failures. I will gladly help, but I don't have any suitable hardware
myself.

PR: 233405

4 years agolibunwind: untested attempt to fix sparc64 build
Ed Maste [Wed, 8 Jan 2020 20:37:03 +0000 (20:37 +0000)]
libunwind: untested attempt to fix sparc64 build

sparc64 is the only architecture currently using the DWARF unwinder from
GCC 4.2.1.  Old GCC and related libraries are being removed soon; absent
other changes sparc64 would be left with no unwinder when that happens.

Instead, commit these changes which should at least allow the LLVM
unwinder to build.  Someone with access to the obolete sparc64 hardware
supported by FreeBSD will need to test the result.

PR: 233405
Submitted by: cem

4 years agoposixshm: implement posix_fallocate(2)
Kyle Evans [Wed, 8 Jan 2020 19:08:44 +0000 (19:08 +0000)]
posixshm: implement posix_fallocate(2)

Linux expects to be able to use posix_fallocate(2) on a memfd. Other places
would use this with shm_open(2) to act as a smarter ftruncate(2).

Test has been added to go along with this.

Reviewed by: kib (earlier version)
Differential Revision: https://reviews.freebsd.org/D23042

4 years agoBump __FreeBSD_version after r356510
Kyle Evans [Wed, 8 Jan 2020 19:06:22 +0000 (19:06 +0000)]
Bump __FreeBSD_version after r356510

linuxkpi kmod would need to rebuilt at a minimum; fileops layout has
changed.

4 years agoposix_fallocate: push vnop implementation into the fileop layer
Kyle Evans [Wed, 8 Jan 2020 19:05:32 +0000 (19:05 +0000)]
posix_fallocate: push vnop implementation into the fileop layer

This opens the door for other descriptor types to implement
posix_fallocate(2) as needed.

Reviewed by: kib, bcr (manpages)
Differential Revision: https://reviews.freebsd.org/D23042

4 years agoRemove unneeded cdevsw methods and D_NEEDGIANT.
John Baldwin [Wed, 8 Jan 2020 19:05:23 +0000 (19:05 +0000)]
Remove unneeded cdevsw methods and D_NEEDGIANT.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23079

4 years agoUse falloc_noinstall + finstall for crypto file descriptors.
John Baldwin [Wed, 8 Jan 2020 19:03:24 +0000 (19:03 +0000)]
Use falloc_noinstall + finstall for crypto file descriptors.

Reviewed by: cem, kib
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23078

4 years agoAdd a reference count to cryptodev sessions.
John Baldwin [Wed, 8 Jan 2020 18:59:23 +0000 (18:59 +0000)]
Add a reference count to cryptodev sessions.

This prevents use-after-free races with crypto requests (which may
sleep) and CIOCFSESSION as well as races from current CIOCFSESSION
requests.

admbugs: 949
Reported by: Yuval Kanarenstein <yuvalk@ssd-disclosure.com>
Reviewed by: cem
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23077

4 years agoFix copy-paste bug in HMB free code.
Alexander Motin [Wed, 8 Jan 2020 18:26:23 +0000 (18:26 +0000)]
Fix copy-paste bug in HMB free code.

MFC after: 2 weeks
X-MFC-with: r356474

4 years agosrc.conf.5: regen after r356423 and r356499
Ed Maste [Wed, 8 Jan 2020 17:54:44 +0000 (17:54 +0000)]
src.conf.5: regen after r356423 and r356499

riscv now using Clang/lld, riscv64sf reenabled, and googletest adjusted
to avoid only the affected fuse test on mips

4 years agoAdd -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.
John Baldwin [Wed, 8 Jan 2020 17:49:34 +0000 (17:49 +0000)]
Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.

bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it
was always setting the flag since LINKER_FEATURES wasn't defined.

Reported by: mhorne
Reviewed by: imp, mhorne
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23076

4 years agortld: fix after r356300
Konstantin Belousov [Wed, 8 Jan 2020 17:37:20 +0000 (17:37 +0000)]
rtld: fix after r356300

binpath local was changed from char array to a char pointer, update
strlcpy/strlcat uses.

Reported by: Coverity through vangyzen
CID: 1412239 and 1412240
Reviewed by: emaste, imp, vangyzen
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23090

4 years agoAdd notes for MAKE_OBSOLETE_GCC going away and riscv switching to clang/lld.
John Baldwin [Wed, 8 Jan 2020 17:31:54 +0000 (17:31 +0000)]
Add notes for MAKE_OBSOLETE_GCC going away and riscv switching to clang/lld.

4 years agoRemove a mention of MAKE_OBSOLETE_GCC.
John Baldwin [Wed, 8 Jan 2020 17:31:18 +0000 (17:31 +0000)]
Remove a mention of MAKE_OBSOLETE_GCC.

This should have been included in r356452.

4 years agoUse clang and lld as the default toolchain for RISCV.
John Baldwin [Wed, 8 Jan 2020 17:25:59 +0000 (17:25 +0000)]
Use clang and lld as the default toolchain for RISCV.

- Enable clang and lld as system toolchains.
- Don't use external GCC for universe by default.
- Re-enable riscv64sf since it builds fine with clang + lld.

Reviewed by: emaste, mhorne
Relnotes: yes
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23089

4 years agolinprocfs: Fix some bugs in the maps file implementation.
Mark Johnston [Wed, 8 Jan 2020 16:57:08 +0000 (16:57 +0000)]
linprocfs: Fix some bugs in the maps file implementation.

- Export the offset into the backing object, not the object size.
- Fix a bug where we would print the previous entry's "offset" when a
  map_entry has no object.
- Try to identify shared mappings.  Linux prints "s" when the mapping
  "may be shared".  This attempt is not perfect, for example, we print
  "p" for anonymous memory that may be shared via
  minherit(INHERIT_SHARE).

PR: 240992
Reviewed by: kib
MFC after: 1 week
MFC note: no OBJ_ANON in stable/12
Differential Revision: https://reviews.freebsd.org/D23062

4 years agoo Spell "Redundancy" and "Remember" correctly.
Maxim Konovalov [Wed, 8 Jan 2020 14:01:15 +0000 (14:01 +0000)]
o Spell "Redundancy" and "Remember" correctly.

PR: 243187
Submitted by: mikael.urankar@gmail.com (partially)

4 years agoregulator: fix regnode_method_get_voltage
Emmanuel Vadot [Wed, 8 Jan 2020 11:30:42 +0000 (11:30 +0000)]
regulator: fix regnode_method_get_voltage

This method is supposed to write the voltage into uvolt
and return an errno compatible value.

Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D23006