]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agovfs: introduce v_irflag and make v_type smaller
Mateusz Guzik [Sun, 8 Dec 2019 21:30:04 +0000 (21:30 +0000)]
vfs: introduce v_irflag and make v_type smaller

The current vnode layout is not smp-friendly by having frequently read data
avoidably sharing cachelines with very frequently modified fields. In
particular v_iflag inspected for VI_DOOMED can be found in the same line with
v_usecount. Instead make it available in the same cacheline as the v_op, v_data
and v_type which all get read all the time.

v_type is avoidably 4 bytes while the necessary data will easily fit in 1.
Shrinking it frees up 3 bytes, 2 of which get used here to introduce a new
flag field with a new value: VIRF_DOOMED.

Reviewed by: kib, jeff
Differential Revision: https://reviews.freebsd.org/D22715

4 years agovfs: clean up vputx a little
Mateusz Guzik [Sun, 8 Dec 2019 21:13:07 +0000 (21:13 +0000)]
vfs: clean up vputx a little

1. replace hand-rolled macros for operation type with enum
2. unlock the vnode in vput itself, there is no need to branch on it. existence
of VPUTX_VPUT remains significant in that the inactive variant adds LK_NOWAIT
to locking request.
3. remove the useless v_usecount assertion. few lines above the checks if
v_usecount > 0 and leaves. should the value be negative, refcount would fail.
4. the CTR return vnode %p to the freelist is incorrect as vdrop may find the
vnode with holdcnt > 1. if the like should exist, it should be moved there
5. no need to error = 0 for everyone

Reviewed by: kib, jeff (previous version)
Differential Revision: https://reviews.freebsd.org/D22718

4 years agoAdd a MODULE_DEPEND() for the gpioths driver. Also, note that the prior commit
Ian Lepore [Sun, 8 Dec 2019 21:12:33 +0000 (21:12 +0000)]
Add a MODULE_DEPEND() for the gpioths driver. Also, note that the prior commit
changed the sysctl format for the temperature from "I" to "IK", and
correspondingly changed the units from integer degrees C to decikelvin.
For access via sysctl(8) the output will be the same except that now
decimal fractions will be shown when available.

4 years agovfs: factor out vnode destruction out of vdrop
Mateusz Guzik [Sun, 8 Dec 2019 21:11:25 +0000 (21:11 +0000)]
vfs: factor out vnode destruction out of vdrop

Sponsored by: The FreeBSD Foundation

4 years agoAdd support for more chips to the gpioths driver.
Ian Lepore [Sun, 8 Dec 2019 20:42:58 +0000 (20:42 +0000)]
Add support for more chips to the gpioths driver.

Previously the driver supported the DHT11 sensor.  Now it supports

 DHT11, DHT12, DHT21, DHT22, AM3201, AM3202.

All these chips are similar, differing primarily in supported temperature
and humidity ranges and accuracy (and, presumably, cost).  There are two
basic data formats reported by the various chips, and it is possible to
figure out at runtime which format to use for decoding the data based on
the range of values in a single byte of the humidity measurement. (which
is detailed in a comment block, so I won't recapitulate it here).

4 years agoSimplify sysctl stuff in the gpioths driver. There is no need to use local
Ian Lepore [Sun, 8 Dec 2019 20:36:13 +0000 (20:36 +0000)]
Simplify sysctl stuff in the gpioths driver.  There is no need to use local
functions to handle the sysctls, they all just access simple readonly
integer variables.  There's no need to track the oids of the ones we add,
since the teardown is done by newbus code, not the driver itself.

Also remove the DDB code, because it just provides access to the same data
that the sysctls already provide.

4 years agoSeveral small fixes for the gpioths (temp/humidity sensor) driver.
Ian Lepore [Sun, 8 Dec 2019 20:13:42 +0000 (20:13 +0000)]
Several small fixes for the gpioths (temp/humidity sensor) driver.

At the end of a read cycle, set the gpio pin to INPUT rather than OUTPUT.
The state of the single-wire "bus" when idle should be high; setting the
pin to input allows the external pullup to pull the line high.  Setting it
to output (and leaving it driving low) was leading a good read cycle followed
by one that would fail, and it just continued like that forever, effectively
reading the sensor once every 10 seconds instead of 5.

In the attach function, do an initial read from the device before registering
the sysctls for accessing the last-read values, to prevent reading spurious
values for the first 5 seconds after the driver attaches.

Do a callout_drain() in the detach function to prevent crashes after
unloading the module.

4 years agoDelete an unused external declaration.
Rick Macklem [Sun, 8 Dec 2019 16:59:36 +0000 (16:59 +0000)]
Delete an unused external declaration.

Since nfsv4_opflag is no longer used in nfs_clcomsubs.c, delete the
external declaration of it. Found during NFSv4.2 code merge.

MFC after: 2 weeks

4 years agopowerpc: Use builtins for fls/flsl
Justin Hibbits [Sun, 8 Dec 2019 04:36:42 +0000 (04:36 +0000)]
powerpc: Use builtins for fls/flsl

Summary:
There's no need to use the fallback fls() and flsl() libkern functions
when the PowerISA includes instructions that already do the bulk of the
work.  Take advantage of this through the GCC builtins __builtin_clz()
and __builtin_clzl().

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D22340

4 years agopowerpc64/pmap: micro-optimize some PVO-PTE logic
Justin Hibbits [Sun, 8 Dec 2019 04:17:04 +0000 (04:17 +0000)]
powerpc64/pmap: micro-optimize some PVO-PTE logic

Summary:
moea64_pte_sync_native() and moea64_pte_unset_native() don't need the
full PTE created, they only need to check that the PVO has a matching
PTE to the PTE in the page table.  Don't waste time creating the full
PTE in this case.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D22341

4 years agopf: Remove references to 'egress'
Kristof Provost [Sun, 8 Dec 2019 02:11:06 +0000 (02:11 +0000)]
pf: Remove references to 'egress'

Avoid giving users the impression that FreeBSD has the automatic interface
group 'egress'.

Submitted by: tj AT mrsk.me

4 years agoFix two problems with r355149. The sysctl name collision code assumed that
Jeff Roberson [Sun, 8 Dec 2019 01:55:23 +0000 (01:55 +0000)]
Fix two problems with r355149.  The sysctl name collision code assumed that
zones would never be freed.  In the case of tmpfs this was not true.  While
here test for the right bit to disable the keg related sysctls for zones
that don't have kegs.

Reported by: pho
Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D22655

4 years agoIt is safe to wire a page while the object is busy.
Jeff Roberson [Sun, 8 Dec 2019 01:49:53 +0000 (01:49 +0000)]
It is safe to wire a page while the object is busy.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22636

4 years agoIt is now safe to rename a page that is still on a queue. Allowing this
Jeff Roberson [Sun, 8 Dec 2019 01:49:03 +0000 (01:49 +0000)]
It is now safe to rename a page that is still on a queue.  Allowing this
is necessary for a forthcoming patch.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22636

4 years agoDo not assert that the object lock is held in vm_object_set_writeable_dirty.
Jeff Roberson [Sun, 8 Dec 2019 01:47:29 +0000 (01:47 +0000)]
Do not assert that the object lock is held in vm_object_set_writeable_dirty.
A valid reference is all that is required.  If we race with a deallocation
we will harmlessly misidentify the type of an already dead object.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22636

4 years agoFix a couple of minor issues with newfs_msdos:
Xin LI [Sun, 8 Dec 2019 01:20:37 +0000 (01:20 +0000)]
Fix a couple of minor issues with newfs_msdos:

 - Do not unnecessarily strdup().
 - Check return value of getdiskinfo(), if it failed, bail out.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22729

4 years agoHandle multiple clock interrupts simultaneously in sched_clock().
Jeff Roberson [Sun, 8 Dec 2019 01:17:38 +0000 (01:17 +0000)]
Handle multiple clock interrupts simultaneously in sched_clock().

Reviewed by: kib, markj, mav
Differential Revision: https://reviews.freebsd.org/D22625

4 years agoReduce duplication in grab functions by providing allocflags based inlines.
Jeff Roberson [Sun, 8 Dec 2019 01:16:22 +0000 (01:16 +0000)]
Reduce duplication in grab functions by providing allocflags based inlines.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22635

4 years agoUse a variant slab structure for offpage zones. This saves space in
Jeff Roberson [Sun, 8 Dec 2019 01:15:06 +0000 (01:15 +0000)]
Use a variant slab structure for offpage zones.  This saves space in
embedded slabs but also is an opportunity to tidy up code and add
accessor inlines.

Reviewed by: markj, rlibby
Differential Revision: https://reviews.freebsd.org/D22609

4 years agoFix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply.
Rick Macklem [Sun, 8 Dec 2019 00:06:00 +0000 (00:06 +0000)]
Fix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply.

When an NFSv4 server replies NFSERR_MINORVERSMISMATCH, it does not generate
a status result for the first operation in the compound. Without this
patch, this will result in a bogus EBADXDR error return.
Returning EBADXDR is relatively harmless, but a correct reply of
NFSERR_MINORVERSMISMATCH is needed by the pNFS client to select the correct
minor version to use for a File Layout DS now that there can be NFSv4.2
DS servers.

mount_nfs.c still needs to be fixed for this, although how the mount fails
is only useful to help sysadmins isolate why a mount fails.

Found during testing of the NFSv4.2 client and server.

MFC after: 2 weeks

4 years agoAdd casts required by the 32-bit build after r355491.
Mark Johnston [Sun, 8 Dec 2019 00:02:36 +0000 (00:02 +0000)]
Add casts required by the 32-bit build after r355491.

4 years agoAdd some definitions for NFSv4.2 which will be used by subsequent commits.
Rick Macklem [Sat, 7 Dec 2019 23:13:51 +0000 (23:13 +0000)]
Add some definitions for NFSv4.2 which will be used by subsequent commits.

This is a preliminary commit of NFSv4.2 definitions that will be used by
subsequent commits which adds NFSv4.2 support to the NFS client and server.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agogcore: Avoid using vm_map_entry_t.
Mark Johnston [Sat, 7 Dec 2019 20:01:55 +0000 (20:01 +0000)]
gcore: Avoid using vm_map_entry_t.

Use an internally defined structure instead, to avoid relying on kernel
structure details.  No functional change intended.

MFC after: 1 week

4 years agoProvide vm_map_entry traversal routines to userspace.
Mark Johnston [Sat, 7 Dec 2019 19:36:40 +0000 (19:36 +0000)]
Provide vm_map_entry traversal routines to userspace.

This is required for now to allow libprocstat to compile.

Discussed with: dougm

4 years agoFix a type error in fixing libprocstat to be compatible with vm_map changes.
Doug Moore [Sat, 7 Dec 2019 18:40:46 +0000 (18:40 +0000)]
Fix a type error in fixing libprocstat to be compatible with vm_map changes.

Approved by: markj
Differential Revision: https://reviews.freebsd.org/D22726

4 years agor355491 broke compilation of libprocstat.c. Change that code to use
Doug Moore [Sat, 7 Dec 2019 18:16:35 +0000 (18:16 +0000)]
r355491 broke compilation of libprocstat.c.  Change that code to use
new methods for accessing first, next map entries.

Approved by: kib
Differential Revision: https://reviews.freebsd.org/D22725

4 years agoOnly return EPERM from kill(-pid) when no process was signalled.
Konstantin Belousov [Sat, 7 Dec 2019 18:07:49 +0000 (18:07 +0000)]
Only return EPERM from kill(-pid) when no process was signalled.

As mandated by POSIX.  Also clarify the kill(2) manpage.

While there, restructure the code in killpg1() to use helper which
keeps overall state of the process list iteration in the killpg1_ctx
structued, later used to infer the error returned.

Reported by: amdmi3
Reviewed by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D22621

4 years agoAdd module build stuff for gpioths(4), a driver for DHT11/DHT22 sensors.
Ian Lepore [Sat, 7 Dec 2019 17:54:40 +0000 (17:54 +0000)]
Add module build stuff for gpioths(4), a driver for DHT11/DHT22 sensors.

4 years agovm: fix sysctl vm.kstack_cache_size change report
Mateusz Guzik [Sat, 7 Dec 2019 17:28:41 +0000 (17:28 +0000)]
vm: fix sysctl vm.kstack_cache_size change report

Cache gets resized correctly, but sysctl reports the wrong number:
# sysctl vm.kstack_cache_size=512
vm.kstack_cache_size: 128 -> 128

patched:
vm.kstack_cache_size: 128 -> 512

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D22717
Fixes: r355002 "Revise the page cache size policy."

4 years agoRemove the next and prev fields from vm_map_entry, to save a bit of
Doug Moore [Sat, 7 Dec 2019 17:14:33 +0000 (17:14 +0000)]
Remove the next and prev fields from vm_map_entry, to save a bit of
space.  Where the vm_map tree now has null pointers, store pointers to
next and previous entries in right and left fields, making the binary
tree threaded.  Have the predecessor and successor functions compute
what the prev and next fields previously stored.

Reviewed by: markj, kib (previous version)
Tested by: pho (previous version)
Differential Revision: https://reviews.freebsd.org/D21964

4 years agoclock_gettime(2): add a HISTORY section
Alan Somers [Sat, 7 Dec 2019 16:45:12 +0000 (16:45 +0000)]
clock_gettime(2): add a HISTORY section

MFC after: 2 weeks

4 years agolio_listio(2): add a HISTORY section
Alan Somers [Sat, 7 Dec 2019 16:29:56 +0000 (16:29 +0000)]
lio_listio(2): add a HISTORY section

MFC after: 2 weeks

4 years agoAdd support for booting kernel directly from U-Boot using booti command.
Michal Meloun [Sat, 7 Dec 2019 16:14:23 +0000 (16:14 +0000)]
Add support for booting kernel directly from U-Boot using booti command.

In some cases, like is locked bootstrap or device's inability to boot from
removable media, we cannot use standard boot sequence and is necessary to
boot kernel directly from U-Boot.

Discussed with: jhibbits
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D13861

4 years agoCorrect a handful of typos/grammos.
Jens Schweikhardt [Sat, 7 Dec 2019 15:17:00 +0000 (15:17 +0000)]
Correct a handful of typos/grammos.

4 years agovfs: clean up delmntque similarly to vdrop r355414
Mateusz Guzik [Sat, 7 Dec 2019 12:56:24 +0000 (12:56 +0000)]
vfs: clean up delmntque similarly to vdrop r355414

4 years agovfs: catch vn_printf up with reality
Mateusz Guzik [Sat, 7 Dec 2019 12:55:58 +0000 (12:55 +0000)]
vfs: catch vn_printf up with reality

- add the missing VV_VMSIZEVNLOCK and VV_READLINK flags
- add decoding v_mflag

While here sort flags.

4 years agopowerpc/pmap: NUMA-ize vm_page_array on powerpc
Justin Hibbits [Sat, 7 Dec 2019 03:34:03 +0000 (03:34 +0000)]
powerpc/pmap: NUMA-ize vm_page_array on powerpc

Summary:
This matches r351198 from amd64.  This only applies to AIM64 and Book-E.
On AIM64 it short-circuits with one domain, to behave similar to
existing.  Otherwise it will allocate 16MB huge pages to hold the page
array, across all NUMA domains.  On the first domain it will shift the
page array base up, to "upper-align" the page array in that domain, so
as to reduce the number of pages from the next domain appearing in this
domain.  After the first domain, subsequent domains will be allocated in
full 16MB pages, until the final domain, which can be short.  This means
some inner domains may have pages accounted in earlier domains.

On Book-E the page array is setup at MMU bootstrap time so that it's
always mapped in TLB1, on both 32-bit and 64-bit.  This reduces the TLB0
overhead for touching the vm_page_array, which reduces up to one TLB
miss per array access.

Since page_range (vm_page_startup()) is no longer used on Book-E but is on
32-bit AIM, mark the variable as potentially unused, rather than using a
nasty #if defined() list.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D21449

4 years agoSet the XATTRSUPPORT attribute bit for NFSv4.2, always cleared for now.
Rick Macklem [Sat, 7 Dec 2019 01:10:38 +0000 (01:10 +0000)]
Set the XATTRSUPPORT attribute bit for NFSv4.2, always cleared for now.

Since r355472 added code which clears the XATTRSUPPORT bit for non-NFSv4.2
mounts, it is now safe to set it.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.
This commit completes updates to nfsproto.h required by the NFSv4.2.

4 years agorc.shutdown: kill shutdown process after logging message
Ed Maste [Sat, 7 Dec 2019 00:33:08 +0000 (00:33 +0000)]
rc.shutdown: kill shutdown process after logging message

Move the kill -KILL $$ back to the pre-r354446 location at the end of
the shutdown timeout handler.

MFC with: r354446

4 years agox86: Restore the critical section around whole ipi_bitmap_handler() if
Konstantin Belousov [Sat, 7 Dec 2019 00:28:08 +0000 (00:28 +0000)]
x86: Restore the critical section around whole ipi_bitmap_handler() if
hardclock IPI is delivered.

In the current code after r355311, critical section is taken only
around hardclockintr() call, and sched_preempt() is called after the
section is exited. If we reschedule after exit, as we typically would
due to conditions that caused IPI, in ULE the runq tdq_ipipending is
not cleared, which blocks generation of further preempt IPIs.

Since all relatively modern (10 years) hardware has per-cpu event
timers, restoring the critical section conditionally does not affect
it.

Reported and tested by: cy
Diagnosed and reviewed by: jeff (previous version)
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D22716

4 years agoamd64: properly set the start of the io permission bitmap for BSP
Konstantin Belousov [Sat, 7 Dec 2019 00:23:19 +0000 (00:23 +0000)]
amd64: properly set the start of the io permission bitmap for BSP

... after the initial common TSS is copied into its final location
during PCPU reallocation.

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

4 years agosysent: Reduce duplication and improve readability.
Brooks Davis [Fri, 6 Dec 2019 23:59:23 +0000 (23:59 +0000)]
sysent: Reduce duplication and improve readability.

Use the power of variable to avoid spelling out source and generated
files too many times.  The previous Makefiles were hard to read, hard to
edit, and badly formatted.

Reviewed by: kevans, emaste
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22714

4 years agoAdd a couple of definitions for NFSv4.2 and update macros to use them.
Rick Macklem [Fri, 6 Dec 2019 23:51:11 +0000 (23:51 +0000)]
Add a couple of definitions for NFSv4.2 and update macros to use them.

This patch adds code to macros to clear attribute bits not supported
by NFSv4.2. For now, these bits are never set anyhow, but this prepares
the code for the addition of NFSv4.2 support in a future commit.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agoFix an inverted condition introduced in r353539.
Mark Johnston [Fri, 6 Dec 2019 23:49:37 +0000 (23:49 +0000)]
Fix an inverted condition introduced in r353539.

This would have most likely resulted in read errors causing page leaks.

Submitted by: jeff

4 years agoFix tail -f in capability mode.
Mark Johnston [Fri, 6 Dec 2019 23:39:38 +0000 (23:39 +0000)]
Fix tail -f in capability mode.

We were not adding CAP_EVENT to input file capabilities, so kevent()
always failed with ENOTCAPABLE.  tail implements a fallback mode to
poll the file in this case, so the failure was not apparent.

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

4 years agoFix fault_type handling in vm_map_lookup().
Mark Johnston [Fri, 6 Dec 2019 23:39:08 +0000 (23:39 +0000)]
Fix fault_type handling in vm_map_lookup().

Suppose that the map entry is wired, so that we later assign
fault_type = entry->protection.  Suppose further that we jump back to
RetryLookup.  Then fault_type will no longer contain the original
fault protection mask, but instead that of the wired entry.

Submitted by: Wuyang Chung <wuyang.chung1@gmail.com>
Reviewed by: kib
MFC after: 3 days
Github PR: https://github.com/freebsd/freebsd/pull/419
Differential Revision: https://reviews.freebsd.org/D22683

4 years agomakesyscalls.lua: improve config processing
Kyle Evans [Fri, 6 Dec 2019 22:45:36 +0000 (22:45 +0000)]
makesyscalls.lua: improve config processing

The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

- Strip only whole-line comments on every single iteration
- Abort if we see a malformed line that doesn't match the key=value format
- For quoted (backtick or double quote) strings, we'll advance to the end of
  the key=value pair and make sure there's not extra stuff left over
- For unquoted key=value pairs, we'll strip any trailing comments and verify
  there's no internal whitespace

This has revealed the caveat that key/value pairs can't even include escaped quotes (and haven't been able to). I don't know if this is actually problematic, as we're usually looking at cases like "#include <foo>" or raw identifiers.The current version will strip out #include directives appearing inside strings, which is clearly wrong. Improve the processing entirely in the following ways:

Reviewed and noticed by: brooks
Differential Revision: https://reviews.freebsd.org/D22698

4 years agoImplement bus_rescan for gpiobus(4). This allows on-the-fly reconfiguration
Ian Lepore [Fri, 6 Dec 2019 22:32:06 +0000 (22:32 +0000)]
Implement bus_rescan for gpiobus(4).  This allows on-the-fly reconfiguration
of gpio devices by using kenv to add hints for a new device and then do
'devctl rescan gpiobus4' to make the new device(s) attach.

It's not particularly easy to detect whether the 'at' hint has been deleted
for a child device that's currently attached, so this doesn't handle that.
But the user can use devctl commands to manually detach an existing device.

4 years agoRemove the extra epoch tracker change sneaked into r355449 and was not part
Bjoern A. Zeeb [Fri, 6 Dec 2019 22:20:26 +0000 (22:20 +0000)]
Remove the extra epoch tracker change sneaked into r355449 and was not part
of the originally reviewed or described change.

Pointyhat to:   bz
Reported by:    glebius

4 years agotrackers always know what qpair they are on
Warner Losh [Fri, 6 Dec 2019 22:12:39 +0000 (22:12 +0000)]
trackers always know what qpair they are on

Don't needlessly pass around qpair pointers when the tracker knows what
qpair it's on.  This will simplify code and make it easier to split
submission and completion queues in the future.

Signed-off-by: John Meneghini <johnm@netapp.com>
4 years agoRemove ifdefs for FreeBSD 6, 7, 8 and 9. Assume we're past that.
Warner Losh [Fri, 6 Dec 2019 21:50:24 +0000 (21:50 +0000)]
Remove ifdefs for FreeBSD 6, 7, 8 and 9. Assume we're past that.

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

4 years agoAdd a GPIO based MDIO bit-banging bus driver.
Luiz Otavio O Souza [Fri, 6 Dec 2019 20:21:07 +0000 (20:21 +0000)]
Add a GPIO based MDIO bit-banging bus driver.

Uses two GPIO pins as MDC (clock) and MDIO (bidirectional I/O), relies
on mii_bitbang.

Tested on SG-3200 where the PHY for one of the ports is wired independently
of the SoC MDIO bus.

Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoFix the ARM64 build, include the necessary <sys/mutex.h> header.
Luiz Otavio O Souza [Fri, 6 Dec 2019 20:05:08 +0000 (20:05 +0000)]
Fix the ARM64 build, include the necessary <sys/mutex.h> header.

While here, call device_delete_children() to detach and dealloc all the
existent children and handle the child's detach errors properly.

Reported by: jenkins, hselasky, ian
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agolibbe: fix build against sysutils/openzfs, part 1
Kyle Evans [Fri, 6 Dec 2019 19:33:39 +0000 (19:33 +0000)]
libbe: fix build against sysutils/openzfs, part 1

This is the half of the changes required that work as-is with both in-tree
ZFS and the new hotness, sysutils/openzfs.  Highlights are less dependency
on header pollution (from somewhere) and using 'mnttab' instead of
'extmnttab'.   In the in-tree ZFS, the latter is a #define for the former,
but in the port extmnttab is actually a distinct struct that's a super-set
of mnttab.  We really want mnttab here anyways, so just use it.

4 years agoRemove SPARE_USRSPACE.
John Baldwin [Fri, 6 Dec 2019 19:20:45 +0000 (19:20 +0000)]
Remove SPARE_USRSPACE.

This constant was used to reserve space at the top of the stack to
hold translated system call arguments for non-default ABIs (the
"stackgap").  However, none of the compatibility ABIs have used the
stackgap in many years and the last use of SPARE_USRSPACE was removed
in r355373.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22697

4 years agoMake devstat_end_transaction_bio() count BIO_ORDERED.
Alexander Motin [Fri, 6 Dec 2019 18:39:05 +0000 (18:39 +0000)]
Make devstat_end_transaction_bio() count BIO_ORDERED.

MFC after: 2 weeks

4 years agoUpdate comment.
Bjoern A. Zeeb [Fri, 6 Dec 2019 16:53:42 +0000 (16:53 +0000)]
Update comment.

Update the comment related to SIIT and v4mapped addresses being rejected
by us when coming from the wire given we have supported IPv6-only kernels
for a few years now.
See also draft-itojun-v6ops-v4mapped-harmful.

Suggested by: melifaro
MFC after: 2 weeks

4 years agoRemove some branching from GEOM_DISK hot path.
Alexander Motin [Fri, 6 Dec 2019 16:48:36 +0000 (16:48 +0000)]
Remove some branching from GEOM_DISK hot path.

pp->private just can not be NULL in those places.

In g_disk_start() and g_disk_ioctl() both dp != NULL and !dp->d_destroyed
should always be true if disk_gone() and disk_destroy() are used properly,
since GEOM does not send requests to errored providers.  If the protocol is
not followed, then no amount of additional checks here give real safety.

In g_disk_access() though the checks are useful, since GEOM blocks only
new opens for errored providers, but allows closes.  It should not happen
if disk_gone() and disk_destroy() are used properly, but may otherwise.

To improve cases when disk_gone() is not used, call it from disk_destroy().
It does not give full guaranties, but it errors the provider and makes
GEOM block unwanted requests at least after some race.

MFC after: 2 weeks

4 years agoip6_input: remove redundant v4mapped check
Bjoern A. Zeeb [Fri, 6 Dec 2019 16:42:58 +0000 (16:42 +0000)]
ip6_input: remove redundant v4mapped check

In ip6_input() we apply the same v4mapped address check twice. The only
case which skipps the first one is M_FASTFWD_OURS which should have passed
the check on the firstinput pass and passed the firewall.
Remove the 2nd redundant check.

Reviewed by: kp, melifaro
MFC after: 2 weeks
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22462

4 years agocarp: replace caddr_t with char *
Bjoern A. Zeeb [Fri, 6 Dec 2019 16:35:48 +0000 (16:35 +0000)]
carp: replace caddr_t with char *

Change the remaining caddr_t usages to char * following the removal
of the KAME macros

No functional change.

Requested by: glebius
Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22399

4 years agoImprove EPOCH_TRACE
Bjoern A. Zeeb [Fri, 6 Dec 2019 16:34:04 +0000 (16:34 +0000)]
Improve EPOCH_TRACE

Two changes to EPOCH_TRACE:
(1) add a sysctl to surpress the backtrace from epoch_trace_report().
    Sometimes the log line for the recursion is enough and the
    backtrace massively spams the console.
(2) In order to be able to go without the backtrace do not only
    print where the previous occurance happened, but also where
    the current one happens.  That way we have file:line information
    for both and can look at them without the need for getting line
    numbers from backtrace and a debugging tool.

Reviewed by: glebius
Sponsored by: Netflix (originally)
Differential Revision: https://reviews.freebsd.org/D22641

4 years agoFix compilation issue with mlx5core and sparc64 (gcc48):
Hans Petter Selasky [Fri, 6 Dec 2019 16:20:22 +0000 (16:20 +0000)]
Fix compilation issue with mlx5core and sparc64 (gcc48):

sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a constant

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoImplement hardware TLS via send tags for mlx5en(4), which is supported by
Hans Petter Selasky [Fri, 6 Dec 2019 15:36:32 +0000 (15:36 +0000)]
Implement hardware TLS via send tags for mlx5en(4), which is supported by
ConnectX-6 DX.

Currently TLS v1.2 and v1.3 with AES 128/256 crypto over TCP/IP (v4
and v6) is supported.

A per PCI device UMA zone is used to manage the memory of the send
tags.  To optimize performance some crypto contexts may be cached by
the UMA zone, until the UMA zone finishes the memory of the given send
tag.

An asynchronous task is used manage setup of the send tags towards the
firmware. Most importantly setting the AES 128/256 bit pre-shared keys
for the crypto context.

Updating the state of the AES crypto engine and encrypting data, is
all done in the fast path. Each send tag tracks the TCP sequence
number in order to detect non-contiguous blocks of data, which may
require a dump of prior unencrypted data, to restore the crypto state
prior to wire transmission.

Statistics counters have been added to count the amount of TLS data
transmitted in total, and the amount of TLS data which has been dumped
prior to transmission. When non-contiguous TCP sequence numbers are
detected, the software needs to dump the beginning of the current TLS
record up until the point of retransmission. All TLS counters utilize
the counter(9) API.

In order to enable hardware TLS offload the following sysctls must be set:
kern.ipc.mb_use_ext_pgs=1
kern.ipc.tls.ifnet.permitted=1
kern.ipc.tls.enable=1

Sponsored by: Mellanox Technologies

4 years agoAdd the SPI driver for the Marvell Armada 37x0 SoC.
Luiz Otavio O Souza [Fri, 6 Dec 2019 12:55:39 +0000 (12:55 +0000)]
Add the SPI driver for the Marvell Armada 37x0 SoC.

Interrupt based driver, implements SPI mode and clock configuration.

Tested on espressobin and SG-3200.

Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoloader.efi: print ImageBase so we know where we are
Toomas Soome [Fri, 6 Dec 2019 09:50:29 +0000 (09:50 +0000)]
loader.efi: print ImageBase so we know where we are

Output a bit of debugging aid.

4 years agoDeclare the global kernel symbols created by ldscript.arm in arm's machdep.h,
Ian Lepore [Fri, 6 Dec 2019 03:48:35 +0000 (03:48 +0000)]
Declare the global kernel symbols created by ldscript.arm in arm's machdep.h,
and remove a couple scattered local declarations.

Most of these aren't referenced in C code (there are some references in
asm code), and they also aren't documented anywhere.  This helps a bit
with the latter.

4 years agoBlock ioctls for dying GEOM_DEV instances.
Alexander Motin [Fri, 6 Dec 2019 03:46:38 +0000 (03:46 +0000)]
Block ioctls for dying GEOM_DEV instances.

For normal I/Os consumer and provider statuses are checked by g_io_check().
But ioctl calls often do not go through it, being dispatched directly. This
change makes their semantics more alike, protecting lower levels.

MFC after: 2 weeks

4 years agoMake GEOM_DEV code slightly more compact.
Alexander Motin [Fri, 6 Dec 2019 03:18:37 +0000 (03:18 +0000)]
Make GEOM_DEV code slightly more compact.

Should be no functional change.

MFC after: 2 weeks

4 years agoMove the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
Scott Long [Fri, 6 Dec 2019 02:43:05 +0000 (02:43 +0000)]
Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
They're in both the old and new places in HEAD for the moment for
discussion and transition.  The old locations will be garbage collected
in 4 weeks.  MFCs to 12 an 11 will keep the old and new for transition
purposes.

Reviewed by: kib
MFC after: 4 weeks
Sponsored by: Intel
Differential Revision: https://reviews.freebsd.org/D22590

4 years agoAdd some definitions for NFSv4.2 which will be used by subsequent commits.
Rick Macklem [Fri, 6 Dec 2019 01:53:02 +0000 (01:53 +0000)]
Add some definitions for NFSv4.2 which will be used by subsequent commits.

This is a preliminary commit of NFSv4.2 definitions that will be used by
subsequent commits which adds NFSv4.2 support to the NFS client and server.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agogmultipath: add ATF tests
Alan Somers [Fri, 6 Dec 2019 00:12:14 +0000 (00:12 +0000)]
gmultipath: add ATF tests

Add ATF tests for most gmultipath operations. Add some dtrace probes too,
primarily for configuration changes that happen in response to provider
errors.

PR: 178473
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22235

4 years agoses: sanitize illegal strings in SES element descriptors
Alan Somers [Fri, 6 Dec 2019 00:06:05 +0000 (00:06 +0000)]
ses: sanitize illegal strings in SES element descriptors

The SES4r3 standard requires that element descriptors may only contain ASCII
characters in the range 0x20 to 0x7e.  Some SuperMicro expanders violate
that rule.  This patch adds a sanity check to ses(4).  Descriptors in
violation will be replaced by "<invalid>".

This patch fixes "sesutil --libxo xml" on such systems.  Previously it would
generate non-well-formed XML output.

PR: 241929
Reviewed by: allanjude
MFC after: 2 weeks
Sponsored by: Axcient

4 years agoAdd support for new sound HDA hardware
Scott Long [Thu, 5 Dec 2019 19:39:51 +0000 (19:39 +0000)]
Add support for new sound HDA hardware

Sponsored by: Intel

4 years agoAdd a new "riscv-relaxations" linker feature.
John Baldwin [Thu, 5 Dec 2019 19:37:30 +0000 (19:37 +0000)]
Add a new "riscv-relaxations" linker feature.

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld.  If lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Reviewed by: mhorne
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22659

4 years agoOn a context switch, handle the possibility that the old thread was
Alan Cox [Thu, 5 Dec 2019 19:25:49 +0000 (19:25 +0000)]
On a context switch, handle the possibility that the old thread was
preempted after an "ic" or "tlbi" instruction but before it performed a
"dsb" instruction.  The "ic" and "tlbi" instructions have unusual
synchronization requirements.  If the old thread migrates to a new
processor, its completion of a "dsb" instruction on that new processor does
not guarantee that the "ic" or "tlbi" instructions performed on the old
processor have completed.

This issue is not restricted to the kernel.  Since locore.S sets the UCI bit
in SCTLR, user-space programs can perform "ic ivau" instructions (as well as
some forms of the "dc" instruction).

Reviewed by: andrew, kib, markj, mmel
X-MFC with: r355145
Differential Revision: https://reviews.freebsd.org/D22622

4 years agoUse a void * argument to callout handlers instead of timeout_t casts.
John Baldwin [Thu, 5 Dec 2019 18:47:29 +0000 (18:47 +0000)]
Use a void * argument to callout handlers instead of timeout_t casts.

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

4 years agoRemove useless NULL check
Kristof Provost [Thu, 5 Dec 2019 16:50:54 +0000 (16:50 +0000)]
Remove useless NULL check

Coverity points out that we've already dereferenced m by the time we check, so
there's no reason to keep the check. Moreover, it's safe to pass NULL to
m_freem() anyway.

CID: 1019092

4 years agorelease: chase ports r519089 (rpi-firmware update)
Kyle Evans [Thu, 5 Dec 2019 16:17:56 +0000 (16:17 +0000)]
release: chase ports r519089 (rpi-firmware update)

The recent rpi-firmware update renamed "0" to "zero" in the RPi0 DTB
filename

It also included the components needed to boot the RPi4, so install those
now -- interested parties can install sysutils/u-boot-rpi4 and copy
config_rpi4.txt to config.txt on the FAT partition in order to boot the
board. Do note that we currently don't support ethernet/usb/pci.

Reviewed by: manu
MFC after: 3 days

4 years agoUPDATING: Add long-belated note about certs in base
Kyle Evans [Thu, 5 Dec 2019 15:32:33 +0000 (15:32 +0000)]
UPDATING: Add long-belated note about certs in base

While the interaction between this and the ETCSYMLINK option of
security/ca_root_nss isn't necessarily fatal, one should be aware and
attempt to understand the ramifications of mixing the two.

ports-secteam will be contacted to discuss the default option for branches
where certs are being included in base.

4 years agomlx5: Do not poke hardware for statistic after teardown is started.
Konstantin Belousov [Thu, 5 Dec 2019 15:21:13 +0000 (15:21 +0000)]
mlx5: Do not poke hardware for statistic after teardown is started.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agoAdd basic support for TCP/IP based hardware TLS offload to mlx5core.
Hans Petter Selasky [Thu, 5 Dec 2019 15:16:19 +0000 (15:16 +0000)]
Add basic support for TCP/IP based hardware TLS offload to mlx5core.

The hardware offload is primarily targeted for TLS v1.2 and v1.3,
using AES 128/256 bit pre-shared keys. This patch adds all the needed
hardware structures, capabilites and firmware commands.

Sponsored by: Mellanox Technologies

4 years agoRemove duplicate g_debugflags declaration.
Alexander Motin [Thu, 5 Dec 2019 15:07:32 +0000 (15:07 +0000)]
Remove duplicate g_debugflags declaration.

While there, define G_F_FOOTSHOOTING instead of numeric constants.

MFC after: 13 days
X-MFX-with: r355412

4 years agosx: check for SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER when exclusive-locking
Mateusz Guzik [Thu, 5 Dec 2019 13:43:44 +0000 (13:43 +0000)]
sx: check for SX_LOCK_SHARED | SX_LOCK_WRITE_SPINNER when exclusive-locking

First, this removes a spurious difference compared to rw locks.
More importantly though this avoids a trip through sleepq code if the lock
happens to be caught in this state.

4 years agonullfs: locklessly check for entries in null_hashget
Mateusz Guzik [Thu, 5 Dec 2019 13:41:22 +0000 (13:41 +0000)]
nullfs: locklessly check for entries in null_hashget

During random sampling over poudriere -j 104 over 10% of calls returned NULL.

4 years agovfs: remove 'active' variable from _vdrop
Mateusz Guzik [Thu, 5 Dec 2019 13:40:10 +0000 (13:40 +0000)]
vfs: remove 'active' variable from _vdrop

No functional changes.

4 years agoUpdate ELF Tool Chain to upstream r3769
Ed Maste [Thu, 5 Dec 2019 13:20:15 +0000 (13:20 +0000)]
Update ELF Tool Chain to upstream r3769

This contains many small bugfixes and documentation improvements.

Sponsored by: The FreeBSD Foundation

4 years agoWrap g_trace() into a macro to avoid unneeded calls.
Alexander Motin [Thu, 5 Dec 2019 04:52:19 +0000 (04:52 +0000)]
Wrap g_trace() into a macro to avoid unneeded calls.

In most cases with debug disabled this function does nothing, but argument
passing and the call still cost measurable time due to cache misses, etc.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoFix a trivial typo and add a missing word.
Ian Lepore [Thu, 5 Dec 2019 04:18:22 +0000 (04:18 +0000)]
Fix a trivial typo and add a missing word.

4 years agoSwitch GEOM_DEV from make_dev_p() to make_dev_s().
Alexander Motin [Thu, 5 Dec 2019 04:03:08 +0000 (04:03 +0000)]
Switch GEOM_DEV from make_dev_p() to make_dev_s().

It closes the race condition and so allows to remove few NULL checks.

Also while there, use dev->si_drv1 in addition to cp->private to store
softc pointer.  For calls coming from the dev side it gives reliable cache
hit instead of often miss before.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoFix the build, use the correct include path.
Luiz Otavio O Souza [Thu, 5 Dec 2019 02:01:47 +0000 (02:01 +0000)]
Fix the build, use the correct include path.

Pointy hat to: loos

4 years agoAdd the I2C driver for the Armada 37x0.
Luiz Otavio O Souza [Thu, 5 Dec 2019 00:56:03 +0000 (00:56 +0000)]
Add the I2C driver for the Armada 37x0.

This controller is a bit tricky as the STOP condition must be indicated in
the last tranferred byte, some devices will not like the repeated start
behavior of this controller.  A proper fix to this issue is in the works.

This driver works in polling mode, can be used early in the boot (required
in some cases).

Tested on espressobin/SG-1100 and the SG-3200.

Obtained from: pfSense
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoStop using per-mount tmpfs zones.
Konstantin Belousov [Thu, 5 Dec 2019 00:03:17 +0000 (00:03 +0000)]
Stop using per-mount tmpfs zones.

Requested and reviewed by: jeff
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22643

4 years agoAdd some definitions for NFSv4.2 which will be used by subsequent commits.
Rick Macklem [Wed, 4 Dec 2019 23:24:40 +0000 (23:24 +0000)]
Add some definitions for NFSv4.2 which will be used by subsequent commits.

This is a preliminary commit of NFSv4.2 definitions that will be used by
subsequent commits which adds NFSv4.2 support to the NFS client and server.

There will be a series of these preliminary commits that will prepare for
a major commit of the NFSv4.2 client/server changes currently found in
subversion under projects/nfsv42/sys.

4 years agoFix regression from r354484. Don't leak pcb lock if cr_canseeinpcb()
Gleb Smirnoff [Wed, 4 Dec 2019 22:41:52 +0000 (22:41 +0000)]
Fix regression from r354484.  Don't leak pcb lock if cr_canseeinpcb()
returns non-zero.

PR: 242415

4 years agoMark some more hot global variables with __read_mostly.
Alexander Motin [Wed, 4 Dec 2019 21:26:03 +0000 (21:26 +0000)]
Mark some more hot global variables with __read_mostly.

MFC after: 1 week

4 years agoUse "far" calls and branches so that lld uses valid relocations.
John Baldwin [Wed, 4 Dec 2019 21:01:13 +0000 (21:01 +0000)]
Use "far" calls and branches so that lld uses valid relocations.

Conditional branch and jump instructions do not always call via PLT
stubs and thus will not honor LD_PRELOAD, etc.  lld warns about using
non-preemptible relocations for preemptible or unknown symbols whereas
bfd does not (at least for RISC-V).

Reviewed by: br, James Clarke
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22658

4 years agoUse a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.
John Baldwin [Wed, 4 Dec 2019 20:50:49 +0000 (20:50 +0000)]
Use a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.

This saves an instruction in each case as well as an extra memory
indirection via the GOT for PIC code.

Reviewed by: br, James Clarke
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22656

4 years agoDefine __SOFT_FP__ for riscv64sf to avoid infinite recursion.
John Baldwin [Wed, 4 Dec 2019 20:18:12 +0000 (20:18 +0000)]
Define __SOFT_FP__ for riscv64sf to avoid infinite recursion.

Submitted by: James Clarke <jrtc27@jrtc27.com>
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22660

4 years agobistring: avoid gcc -Wsign-compare
Ryan Libby [Wed, 4 Dec 2019 20:15:17 +0000 (20:15 +0000)]
bistring: avoid gcc -Wsign-compare

Appease gcc after after r355377, which broke gcc builds.

Reviewed by: dougm
MFC with: r355377
Differential Revision: https://reviews.freebsd.org/D22682

4 years agoFix an off-by-one error in vm_map_pmap_enter().
Mark Johnston [Wed, 4 Dec 2019 19:46:48 +0000 (19:46 +0000)]
Fix an off-by-one error in vm_map_pmap_enter().

If the starting pindex is equal to object->size, there is nothing to do.
This was harmless since the rest of vm_map_pmap_enter() has no effect
when psize == 0.

Submitted by: Wuyang Chung <wuyang.chung1@gmail.com>
Reviewed by: alc, dougm, kib
MFC after: 1 week
Github PR: https://github.com/freebsd/freebsd/pull/417
Differential Revision: https://reviews.freebsd.org/D22678