]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoNone of these use opt_sched.h
bdrewery [Tue, 28 Apr 2020 16:09:18 +0000 (16:09 +0000)]
None of these use opt_sched.h

4 years agoRestore local kernel "prog" filtering lost in r332099.
bdrewery [Tue, 28 Apr 2020 16:07:15 +0000 (16:07 +0000)]
Restore local kernel "prog" filtering lost in r332099.

This behavior is most relevant for ipfw(4) as documented in syslog.conf(5).
The recent addition of property-based regex filters in r359327 is a
fine workaround for this but the behavior was present since 1997 and
documented.

This only fixes local matching of the "kernel program". It does not
change the forwarded format at all. On the remote side it will still
be "kernel: ipfw:" and not be parsed as a kernel message. This matches
old behavior.

MFC after: 2 weeks
Reviewed by: markj
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D24286

4 years agoAdd le_read_buffer_size command and manpage.
takawata [Tue, 28 Apr 2020 16:00:34 +0000 (16:00 +0000)]
Add le_read_buffer_size command and manpage.
It supports both v1 and v2 command.

PR:245964
Submitted by: Marc Veldman <marc@bumblingdork.com>

4 years agoMake sendfile(SF_SYNC)'s CV wait interruptible.
markj [Tue, 28 Apr 2020 15:02:44 +0000 (15:02 +0000)]
Make sendfile(SF_SYNC)'s CV wait interruptible.

Otherwise, since the CV is not signalled until data is drained from the
socket, it is trivial to create an unkillable process using
sendfile(SF_SYNC) and a process-private PF_LOCAL socket pair.  In
particular, the cv_wait() in sendfile() does not get interrupted until
data is drained from the receiving socket buffer.

Reported by: pho
Discussed with: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agodiff(1): don't reject specifying the same format multiple times
kevans [Tue, 28 Apr 2020 14:33:33 +0000 (14:33 +0000)]
diff(1): don't reject specifying the same format multiple times

This may happen, for instance, if one happens to have an alias of diff to
diff -up and attempts to specify the amount of context on top of that.

Aliases like this may cause other problems, but if they're really not ever
generating non-unified diffs then we should at least not break that
use-case.

In addition, we'll now pick up a format mismatch if -p is specified with
!contextual && !unified && !unset.

Fix up a small trailing whitespace nit in the tests while we're here, and
add tests to make sure that we can double up all the formatting options.

Reported by: jbeich
MFC after: 3 days

4 years agoRe-check for wirings after busying the page in vm_page_release_locked().
markj [Tue, 28 Apr 2020 13:51:41 +0000 (13:51 +0000)]
Re-check for wirings after busying the page in vm_page_release_locked().

A concurrent unlocked lookup can wire the page after
vm_page_release_locked() releases the last wiring, in which case
vm_page_release_locked() must not free the page.  Once the xbusy lock is
acquired, that, the object lock and the fact that the page is unmapped
ensure that the wire count cannot increase, so re-check for new wirings
after the page is xbusied.

Update the comment above vm_page_wired() to reflect the new
synchronization rules.

Reported by: glebius
Reviewed by: alc, jeff, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24592

4 years agoImprove error handling
takawata [Tue, 28 Apr 2020 13:28:58 +0000 (13:28 +0000)]
Improve error handling
Check return values from hci_request()
Check rp.status
Print error messages with hci_status2str()

PR: 245769
Submitted by: Marc Veldman

4 years agoConvert rtalloc_mpath_fib() users to the new KPI.
melifaro [Tue, 28 Apr 2020 08:06:56 +0000 (08:06 +0000)]
Convert rtalloc_mpath_fib() users to the new KPI.

New fib[46]_lookup() functions support multipath transparently.
Given that, switch the last rtalloc_mpath_fib() calls to
 dib4_lookup() and eliminate the function itself.

Note: proper flowid generation (especially for the outbound traffic) is a
 bigger topic and will be handled in a separate review.
This change leaves flowid generation intact.

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

4 years agoEliminate now-unused parts of old routing KPI.
melifaro [Tue, 28 Apr 2020 07:25:34 +0000 (07:25 +0000)]
Eliminate now-unused parts of old routing KPI.

r360292 switched most of the remaining routing customers to a new KPI,
 leaving a bunch of wrappers for old routing lookup functions unused.

Remove them from the tree as a part of routing cleanup.

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

4 years agoRemove rtable dumping code from bootp.
melifaro [Tue, 28 Apr 2020 07:23:41 +0000 (07:23 +0000)]
Remove rtable dumping code from bootp.

This debugging code printing routing table data was introduced in rS25723,
 22+ years ago. The last functional commit to this code was rS67534, 19 years ago.
The code has been turned off by default all this time.
Lastly, this code directly iterates radix tree and rtentries, which is not
 not a proper interaction with routing system.

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

4 years agoDo not overflow when calculating file system size.
delphij [Tue, 28 Apr 2020 05:10:34 +0000 (05:10 +0000)]
Do not overflow when calculating file system size.

Reported by: Hyeongseok Kim <hyeongseok kim lge com>
Reviewed by: cem, Hyeongseok Kim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D24603

4 years agoconfig.lua(8): catch up to recently added hooks
kevans [Tue, 28 Apr 2020 03:43:55 +0000 (03:43 +0000)]
config.lua(8): catch up to recently added hooks

While we're here, let's stylize these as functions instead of just raw text.
A future change may allow arbitrary data arguments to be passed some of
these, and the distinction is useful.

4 years agoconfig.lua(8): "may should" is not proper grammar
kevans [Tue, 28 Apr 2020 02:13:17 +0000 (02:13 +0000)]
config.lua(8): "may should" is not proper grammar

Reported by: rpokala
X-MFC-With: r360421

4 years agoGet rid of uio_XXX macros used for the Mac OS/X port.
rmacklem [Tue, 28 Apr 2020 02:11:02 +0000 (02:11 +0000)]
Get rid of uio_XXX macros used for the Mac OS/X port.

The NFS code had a bunch of Mac OS/X accessor functions named uio_XXX
left over from the port to Mac OS/X. Since that port is long forgotten,
replace the calls with the code generated by the FreeBSD macros for these
in nfskpiport.h. This allows the macros to be deleted from nfskpiport.h
and I think makes the code more readable.

This patch should not result in any semantic change.

4 years agolualoader: cli: clobber loader_conf_files before proceeding
kevans [Tue, 28 Apr 2020 02:08:55 +0000 (02:08 +0000)]
lualoader: cli: clobber loader_conf_files before proceeding

This makes sure that config.readConfFiles doesn't see a stale
loader_conf_files from before, in case the newly loaded file doesn't set it.

MFC after: 3 days

4 years agolualoader: cli: add read-conf
kevans [Tue, 28 Apr 2020 02:04:51 +0000 (02:04 +0000)]
lualoader: cli: add read-conf

This is a straightforward match to the command used by many in forthloader;
it uses the newly-exported config.readConfFiles() to make sure that any
loader_conf_files gets done as appropriate.

PR: 244640
Submitted by: Olivier Certner <olivier freebsd free fr>
MFC after: 3 days

4 years agolualoader: config: start exporting readConfFiles
kevans [Tue, 28 Apr 2020 02:03:03 +0000 (02:03 +0000)]
lualoader: config: start exporting readConfFiles

In the process, change it slightly: readConfFiles will take a string like
loader_conf_files in addition to the loaded_files table that it normally
takes. This is to facilitate the addition of a read-conf CLI command, which
will just pass in the single file to read and an empty table.

MFC after: 3 days

4 years agolualoader config: don't call loader.getenv() as much
kevans [Tue, 28 Apr 2020 01:39:34 +0000 (01:39 +0000)]
lualoader config: don't call loader.getenv() as much

We don't actually need to fetch loader_conf_files as much as we do; we've
already fetched it once at the beginning, we only really need to fetch it
again after each file we've processed. If it changes, then we can stash that
off into our local prefiles.

While here, drop a note about the recursion so that I stop trying to
change it. It may very well make redundant some of the work we're doing, but
that's OK.

MFC after: 3 days

4 years agoBump __FreeBSD_version for KTLS RX support.
jhb [Tue, 28 Apr 2020 00:06:49 +0000 (00:06 +0000)]
Bump __FreeBSD_version for KTLS RX support.

4 years agoAdd support for KTLS RX over TOE to T6.
jhb [Mon, 27 Apr 2020 23:59:42 +0000 (23:59 +0000)]
Add support for KTLS RX over TOE to T6.

This largely reuses the TLS TOE support added in r330884.  However,
this uses the KTLS framework in upstream OpenSSL rather than requiring
Chelsio-specific patches to OpenSSL.  As with the existing TLS TOE
support, use of RX offload requires setting the tls_rx_ports sysctl.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D24453

4 years agoFix sosend_generic() so that it can handle a list of ext_pgs mbufs.
rmacklem [Mon, 27 Apr 2020 23:55:09 +0000 (23:55 +0000)]
Fix sosend_generic() so that it can handle a list of ext_pgs mbufs.

Without this patch, sosend_generic() will try to use top->m_pkthdr.len,
assuming that the first mbuf has a pkthdr.
When a list of ext_pgs mbufs is passed in, the first mbuf is not a
pkthdr and cannot be post-r359919.  As such, the value of top->m_pkthdr.len
is bogus (0 for my testing).
This patch fixes sosend_generic() to handle this case, calculating the
total length via m_length() for this case.

There is currently nothing that hands a list of ext_pgs mbufs to
sosend_generic(), but the nfs-over-tls kernel RPC code in
projects/nfs-over-tls will do that and was used to test this patch.

Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D24568

4 years agoExport the nda device's flags as a sysctl.
imp [Mon, 27 Apr 2020 23:43:17 +0000 (23:43 +0000)]
Export the nda device's flags as a sysctl.

4 years agoConvert rotating to a flag bit.
imp [Mon, 27 Apr 2020 23:43:12 +0000 (23:43 +0000)]
Convert rotating to a flag bit.

Move rotating to a flag bit. Add bit definitions for it. Create a
compat sysctl for it.

4 years agoConvert unmappedio over to a flag.
imp [Mon, 27 Apr 2020 23:43:08 +0000 (23:43 +0000)]
Convert unmappedio over to a flag.

Make unmappedio a flag. Move it to the flags definition. Add compat
sysctl for it.

4 years agoAdd flags sysctl to ada
imp [Mon, 27 Apr 2020 23:43:04 +0000 (23:43 +0000)]
Add flags sysctl to ada

Report the ada device flags like we do the da devices. No booleans
have (yet) been converted, but iomapped and rotating are planned.

4 years agoChange the flags back to an enum
imp [Mon, 27 Apr 2020 23:39:32 +0000 (23:39 +0000)]
Change the flags back to an enum

This was changed in the review process for the flags sysctl. The
reasons for the change are no longer valid as the code changed after
that. Cast the one place where it might make a difference (but I don't
think it does).  This restores the ability to see flags for softc in
gdb.

4 years agoInitial support for kernel offload of TLS receive.
jhb [Mon, 27 Apr 2020 23:17:19 +0000 (23:17 +0000)]
Initial support for kernel offload of TLS receive.

- Add a new TCP_RXTLS_ENABLE socket option to set the encryption and
  authentication algorithms and keys as well as the initial sequence
  number.

- When reading from a socket using KTLS receive, applications must use
  recvmsg().  Each successful call to recvmsg() will return a single
  TLS record.  A new TCP control message, TLS_GET_RECORD, will contain
  the TLS record header of the decrypted record.  The regular message
  buffer passed to recvmsg() will receive the decrypted payload.  This
  is similar to the interface used by Linux's KTLS RX except that
  Linux does not return the full TLS header in the control message.

- Add plumbing to the TOE KTLS interface to request either transmit
  or receive KTLS sessions.

- When a socket is using receive KTLS, redirect reads from
  soreceive_stream() into soreceive_generic().

- Note that this interface is currently only defined for TLS 1.1 and
  1.2, though I believe we will be able to reuse the same interface
  and structures for 1.3.

4 years agoAdd the initial sequence number to the TLS enable socket option.
jhb [Mon, 27 Apr 2020 22:31:42 +0000 (22:31 +0000)]
Add the initial sequence number to the TLS enable socket option.

This will be needed for KTLS RX.

Reviewed by: gallatin
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D24451

4 years agoUpdate the cached MSI state when any MSI capability register is written.
jhb [Mon, 27 Apr 2020 22:27:35 +0000 (22:27 +0000)]
Update the cached MSI state when any MSI capability register is written.

bhyve uses cached copies of the MSI capability registers to generate
MSI interrupts for device models.  Previously, these cached fields
were only set when the MSI capability control register was updated.
The Linux kernel recently adopted a change to deal with races in MSI
interrupt delivery that writes to the MSI capability address and data
registers to alter the destination of MSI interrupts without writing
to the MSI capability control register.  bhyve was not updating its
cached registers for these writes and continued to send interrupts
with the old data value to the old address.  Fix this by recomputing
the cached values for every write to any MSI capability register.

Reported by: Jason Tubnor, Ryan Moeller
Reported by: Marc Dionne (bisected the Linux kernel commit)
Reviewed by: grehan
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24593

4 years agoiflib: Stop interface before (un)registering VLAN
erj [Mon, 27 Apr 2020 22:02:44 +0000 (22:02 +0000)]
iflib: Stop interface before (un)registering VLAN

This patch is intended to solve a specific problem that iavf(4)
encounters, but what it does can be extended to solve other issues.

To summarize the iavf(4) issue, if the PF driver configures VLAN
anti-spoof, then the VF driver needs to make sure no untagged traffic is
sent if a VLAN is configured, and vice-versa. This can be an issue when
a VLAN is being registered or unregistered, e.g. when a packet may be on
the ring with a VLAN in it, but the VLANs are being unregistered. This
can cause that tagged packet to go out and cause an MDD event.

To fix this, include a new interface-dependent function that drivers can
implement named IFDI_NEEDS_RESTART(). Right now, this function is called
in iflib_vlan_unregister/register() to determine whether the interface
needs to be stopped and started when a VLAN is registered or
unregistered. The default return value of IFDI_NEEDS_RESTART() is true,
so this fixes the MDD problem that iavf(4) encounters, since the
interface rings are flushed during a stop/init.

A future change to iavf(4) will implement that function just in case the
default value changes, and to make it explicit that this interface reset
is required when a VLAN is added or removed.

Reviewed by: gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22086

4 years agoRetire the GENERICSF kernel config.
jhb [Mon, 27 Apr 2020 21:51:22 +0000 (21:51 +0000)]
Retire the GENERICSF kernel config.

Now that hw.machine_arch handles soft-float vs hard-float there is no
longer a reason for this config.

Submitted by: mhorne (kern.mk hunk)
Reviewed by: imp (earlier version), kp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24544

4 years agoSet use_nvd=0 in EC2 AMIs.
cperciva [Mon, 27 Apr 2020 21:44:02 +0000 (21:44 +0000)]
Set use_nvd=0 in EC2 AMIs.

FreeBSD is in the process of switching from nvd(4) to nda(4) as the disk
device front-end to NVMe. Changing the default in the kernel is tricky
since existing systems may have /dev/nvd* hard-coded e.g. in /etc/fstab;
however, there's no reason to not change the default in HEAD for *new*
systems.

At present I have no intention of MFCing this to stable branches, since
someone might reasonably expect scripts they use for launching and
configuring FreeBSD 12.1 instances to work with FreeBSD 12.2 AMIs, for
example.

Reviewed by: gjb, imp
Relnotes: NVMe disks in EC2 instances launched from 13.0 and later
now show up as nda(4) devices.
Differential Revision: https://reviews.freebsd.org/D24583

4 years agoDon't run strcmp() against strings stored in user memory.
jhb [Mon, 27 Apr 2020 18:04:42 +0000 (18:04 +0000)]
Don't run strcmp() against strings stored in user memory.

Instead, copy the strings into a temporary buffer on the stack and
run strcmp on the copies.

Reviewed by: brooks, kib
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24567

4 years agoImprove MACHINE_ARCH handling for hard vs soft-float on RISC-V.
jhb [Mon, 27 Apr 2020 17:55:40 +0000 (17:55 +0000)]
Improve MACHINE_ARCH handling for hard vs soft-float on RISC-V.

For userland, MACHINE_ARCH reflects the current ABI via preprocessor
directives.  For the kernel, the hw.machine_arch sysctl uses the ELF
header flags of the current process to select the correct MACHINE_ARCH
value.

Reviewed by: imp, kp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24543

4 years agoExtend support in sysctls for supporting multiple native ABIs.
jhb [Mon, 27 Apr 2020 17:53:38 +0000 (17:53 +0000)]
Extend support in sysctls for supporting multiple native ABIs.

This extends some of the changes in place to support reporting support
for 32-bit ABIs to permit reporting hard-float vs soft-float ABIs.

Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24542

4 years agoThis change does a small prepratory step in getting the
rrs [Mon, 27 Apr 2020 16:30:29 +0000 (16:30 +0000)]
This change does a small prepratory step in getting the
latest rack and bbr in from the NF repo. When those come
in the OOB data handling will be fixed where Skyzaller crashes.

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

4 years agoDocument handling of connection-mode sockets by sendto(2).
markj [Mon, 27 Apr 2020 16:12:32 +0000 (16:12 +0000)]
Document handling of connection-mode sockets by sendto(2).

sendto(2), sendmsg(2) and sendmmsg(2) return ENOTCONN if a destination
address is specified and the socket is not connected and the socket
protocol does not automatically connect ("implied connect").  Document
that.  Also document the fact that the destination address is ignored
for connection-mode sockets if the socket is already connected.

PR: 245817
Submitted by: Erik Inge Bolsø <knan-bfo@modirum.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24530

4 years agoAdd some regression tests for read and write kevents on pipes.
markj [Mon, 27 Apr 2020 15:59:34 +0000 (15:59 +0000)]
Add some regression tests for read and write kevents on pipes.

Submitted by: Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24528

4 years agoFix handling of EV_EOF for named pipes.
markj [Mon, 27 Apr 2020 15:59:19 +0000 (15:59 +0000)]
Fix handling of EV_EOF for named pipes.

Contrary to the kevent man page, EV_EOF on a fifo is not cleared by
EV_CLEAR.  Modify the read and write filters to clear EV_EOF when the
fifo's PIPE_EOF flag is clear, and update the man page to document the
new behaviour.

Modify the write filter to return the amount of buffer space available
even if no readers are present.  This matches the behaviour for sockets.

When reading from a pipe, only call pipeselwakeup() if some data was
actually read.  This prevents the continuous re-triggering of a
EVFILT_READ event on EOF when in edge-triggered mode.

PR: 203366, 224615
Submitted by: Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24528

4 years agoCall pipeselwakeup() after toggling PIPE_EOF.
markj [Mon, 27 Apr 2020 15:59:07 +0000 (15:59 +0000)]
Call pipeselwakeup() after toggling PIPE_EOF.

This ensures that pipe_poll() and the pipe kqueue filters observe
PIPE_EOF and set EV_EOF accordingly.  As a result an extra call to
knote() after setting PIPE_EOF is unnecessary.

Submitted by: Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24528

4 years agoAvoid returning POLLIN if the pipe descriptor is not open for reading.
markj [Mon, 27 Apr 2020 15:58:55 +0000 (15:58 +0000)]
Avoid returning POLLIN if the pipe descriptor is not open for reading.

Submitted by: Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24528

4 years agoAdd support for reading temperature in mlx5en(4).
hselasky [Mon, 27 Apr 2020 14:35:39 +0000 (14:35 +0000)]
Add support for reading temperature in mlx5en(4).

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agopwd: unbreak repeated calls to set_rootvnode
mjg [Mon, 27 Apr 2020 13:54:00 +0000 (13:54 +0000)]
pwd: unbreak repeated calls to set_rootvnode

Prior to the change the once set pointer would never be updated.

Unbreaks reboot -r.

Reported by: Ross Gohlke

4 years agoiwm: Print the command code for any unhandled commands.
markj [Mon, 27 Apr 2020 13:26:43 +0000 (13:26 +0000)]
iwm: Print the command code for any unhandled commands.

Reported by: Marc Veldman <marc@bumblingdork.com>
MFC after: 1 week

4 years agong_eiface: fix kernel panic due to the racecondition in ng_eiface shutdown.
afedorov [Mon, 27 Apr 2020 10:00:46 +0000 (10:00 +0000)]
ng_eiface: fix kernel panic due to the racecondition in ng_eiface shutdown.

PR: 244247
Reported by: Vladislav V. Prodan <admin@support.od.ua>
Reviewed by: vmaffione, lutz_donnerhacke.de
Approved by: vmaffione (mentor)
Sponsored by: vstack.com
Differential Revision: https://reviews.freebsd.org/D24557

4 years agoResolve vendor id to string.
takawata [Mon, 27 Apr 2020 09:13:22 +0000 (09:13 +0000)]
Resolve vendor id to string.

4 years agoFix advertise packet parsing.
takawata [Mon, 27 Apr 2020 02:48:49 +0000 (02:48 +0000)]
Fix advertise packet parsing.

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

4 years agoFix a bug with dirty file system handling.
delphij [Mon, 27 Apr 2020 02:01:48 +0000 (02:01 +0000)]
Fix a bug with dirty file system handling.

r356313 broke handling of dirty file system because we have restricted
the correction of "odd" byte sequences to checkfat(), and as a result
the dirty bit is never cleared.  The old fsck_msdosfs code would write
FAT twice to fix the dirty bit, which is also not ideal.

Fix this by introducing a new rountine, cleardirty() which will perform
the set of clean bit only, and use it in checkfilesys() if we thought
the file system was dirty.

Reviewed by: cem, emaste
MFC after: 3 day
Differential Revision: https://reviews.freebsd.org/D24581

4 years agosnd_hda: use bool for hdac_reset's boolean wakeup param
emaste [Sun, 26 Apr 2020 22:08:47 +0000 (22:08 +0000)]
snd_hda: use bool for hdac_reset's boolean wakeup param

4 years agoFix up i386 thread structure layout assertions after r360354.
markj [Sun, 26 Apr 2020 22:04:43 +0000 (22:04 +0000)]
Fix up i386 thread structure layout assertions after r360354.

Reported by: Jenkins

4 years agosockstat: Attach to jail if in new vnet
freqlabs [Sun, 26 Apr 2020 20:55:11 +0000 (20:55 +0000)]
sockstat: Attach to jail if in new vnet

Attach sockstat -j to the specified jail if the jail is in a new vnet.
Otherwise we do not see all sockets belonging to the jail.

Reviewed by: jamie
Approved by: mmacy (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24413

4 years agoig4(4): Add PCI IDs for Intel Bay Trail I2C controllers.
wulf [Sun, 26 Apr 2020 20:16:18 +0000 (20:16 +0000)]
ig4(4): Add PCI IDs for Intel Bay Trail I2C controllers.

PR: 245654
Reported by: <xspbe3ho3p5uac@protonmail.com>
MFC after: 1 week

4 years agoUse a single VM object for kernel stacks.
markj [Sun, 26 Apr 2020 20:08:57 +0000 (20:08 +0000)]
Use a single VM object for kernel stacks.

Previously we allocated a separate VM object for each kernel stack.
However, fully constructed kernel stacks are cached by UMA, so there is
no harm in using a single global object for all stacks.  This reduces
memory consumption and makes it easier to define a memory allocation
policy for kernel stack pages, with the aim of reducing physical memory
fragmentation.

Add a global kstack_object, and use the stack KVA address to index into
the object like we do with kernel_object.

Reviewed by: kib
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24473

4 years agopsm(4): Fix wrong key-release event occuring after trackpoint use.
wulf [Sun, 26 Apr 2020 20:06:08 +0000 (20:06 +0000)]
psm(4): Fix wrong key-release event occuring after trackpoint use.

Some models of laptops e.g. "X1 Carbon 3rd Gen Thinkpad" have LRM buttons
wired as so called "Synaptic touchpads extended buttons" rather thah real
trackpoint buttons. Handle this case with merging of events from both
sources.

PR: 245877
Reported by: Raichoo <raichoo@googlemail.com>
MFC after: 1 week

4 years agoTentatively apply https://reviews.llvm.org/D78877 (by Dave Green):
dim [Sun, 26 Apr 2020 19:17:45 +0000 (19:17 +0000)]
Tentatively apply https://reviews.llvm.org/D78877 (by Dave Green):

  [ARM] Only produce qadd8b under hasV6Ops

  When compiling for a arm5te cpu from clang, the +dsp attribute is
  set. This meant we could try and generate qadd8 instructions where we
  would end up having no pattern. I've changed the condition here to be
  hasV6Ops && hasDSP, which is what other parts of ARMISelLowering seem
  to use for similar instructions.

  Fixed PR45677.

This fixes "fatal error: error in backend: Cannot select: t37: i32 =
ARMISD::QADD8b t43, t44" when compiling sys/dev/sound/pcm/feeder_mixer.c
for armv5. For some reason we do not encounter this on head, but this
error popped up while building universes for stable/12.

MFC after: 3 days

4 years agoConvert debugnet to the new routing KPI.
melifaro [Sun, 26 Apr 2020 18:42:38 +0000 (18:42 +0000)]
Convert debugnet to the new routing KPI.

Introduce new fib[46]_lookup_debugnet() functions serving as a
special interface for the crash-time operations. Underlying
implementation will try to return lookup result if
datastructures are not corrupted, avoding locking.

Convert debugnet to use fib4_lookup_debugnet() and switch it
to use nexthops instead of rtentries.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D24555

4 years agoFix IPv6 link-local operations with RADIX_MPATH.
melifaro [Sun, 26 Apr 2020 18:07:35 +0000 (18:07 +0000)]
Fix IPv6 link-local operations with RADIX_MPATH.

It was broken by r360292 as fib6_lookup() assumes de-embedded addresses
 while rtalloc_mpath_fib() requires sockaddr with embedded ones.

New fib6_lookup() transparently supports multipath, hence
 remove old RADIX_MPATH condition.

4 years agopf: Virtualise pf_frag_mtx
kp [Sun, 26 Apr 2020 16:30:00 +0000 (16:30 +0000)]
pf: Virtualise pf_frag_mtx

The pf_frag_mtx mutex protects the fragments queue. The fragments queue
is virtualised already (i.e. per-vnet) so it makes no sense to block
jail A from accessing its fragments queue while jail B is accessing its
own fragments queue.

Virtualise the lock for improved concurrency.

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

4 years agobridge tests: Test for #216510
kp [Sun, 26 Apr 2020 16:27:03 +0000 (16:27 +0000)]
bridge tests: Test for #216510

We used to have an issue with recursive locking with
net.link.bridge.inherit_mac. This causes us to send an ARP request while
we hold the BRIDGE_LOCK, which used to cause us to acquire the
BRIDGE_LOCK again. We can't re-acquire it, so this caused a panic.

Now that we no longer need to acquire the BRIDGE_LOCK for
bridge_transmit() this should no longer panic. Test this.

PR: 216510
Reviewed by: emaste, philip
MFC after: 2 months
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24251

4 years agobridge: epoch-ification
kp [Sun, 26 Apr 2020 16:22:35 +0000 (16:22 +0000)]
bridge: epoch-ification

Run the bridge datapath under epoch, rather than under the
BRIDGE_LOCK().

We still take the BRIDGE_LOCK() whenever we insert or delete items in
the relevant lists, but we use epoch callbacks to free items so that
it's safe to iterate the lists without the BRIDGE_LOCK.

Tests on mercat5/6 shows this increases bridge throughput significantly,
from 3.7Mpps to 18.6Mpps.

Reviewed by: emaste, philip, melifaro
MFC after: 2 months
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24250

4 years agopf: Improve input validation
kp [Sun, 26 Apr 2020 16:16:39 +0000 (16:16 +0000)]
pf: Improve input validation

If we pass an anchor name which doesn't exist pfr_table_count() returns
-1, which leads to an overflow in mallocarray() and thus a panic.

Explicitly check that pfr_table_count() does not return an error.

Reported-by: syzbot+bd09d55d897d63d5f4f4@syzkaller.appspotmail.com
Reviewed by: melifaro
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24539

4 years agomac_bsdextended: ATFify the tests
asomers [Sun, 26 Apr 2020 15:51:46 +0000 (15:51 +0000)]
mac_bsdextended: ATFify the tests

The new tests have more complete setup and cleanup, are more granular, and
correctly annotate expected failures and skipped tests. A follow-up commit
will resolve a conflict with the fusefs tests (bug 244229).

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24257

4 years agoFix order of arguments in fib[46]_lookup calls in SCTP.
melifaro [Sun, 26 Apr 2020 13:02:42 +0000 (13:02 +0000)]
Fix order of arguments in fib[46]_lookup calls in SCTP.

r360292 introduced the wrong order, resulting in returned
 nhops not being referenced, despite the fact that references
 were requested. That lead to random GPF after using SCTP sockets.

Special defined macro like IPV[46]_SCOPE_GLOBAL will be introduced
 soon to reduce the chance of putting arguments in wrong order.

Reported-by: syzbot+5c813c01096363174684@syzkaller.appspotmail.com
4 years agoProperly update AD field length in hccontrol(8).
hselasky [Sun, 26 Apr 2020 08:31:08 +0000 (08:31 +0000)]
Properly update AD field length in hccontrol(8).

While at it use strtol() instead of atoi() to support hexadecimal
numbers aswell as 10-base numbers.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245899
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix handling of NMIs from unknown sources (BMC, hypervisor)
vangyzen [Sun, 26 Apr 2020 00:41:29 +0000 (00:41 +0000)]
Fix handling of NMIs from unknown sources (BMC, hypervisor)

Release kernels have no KDB backends enabled, so they discard an NMI
if it is not due to a hardware failure.  This includes NMIs from
IPMI BMCs and hypervisors.

Furthermore, the interaction of panic_on_nmi, kdb_on_nmi, and
debugger_on_panic is confusing.

Respond to all NMIs according to panic_on_nmi and debugger_on_panic.
Remove kdb_on_nmi.  Expand the meaning of panic_on_nmi by making
it a bitfield.  There are currently two bits: one for NMIs due to
hardware failure, and one for all others.  Leave room for more.

If panic_on_nmi and debugger_on_panic are both true, don't actually panic,
but directly enter the debugger, to allow someone to leave the debugger
and [hopefully] resume normal execution.

Reviewed by: kib
MFC after: 2 weeks
Relnotes: yes: machdep.kdb_on_nmi is gone; machdep.panic_on_nmi changed
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D24558

4 years agoAvoid the GEOM topology lock recursion when we automatically expand a pool.
pjd [Sat, 25 Apr 2020 21:45:31 +0000 (21:45 +0000)]
Avoid the GEOM topology lock recursion when we automatically expand a pool.

The steps to reproduce the problem:

mdconfig -a -t swap -s 3g -u 0
gpart create -s GPT md0
gpart add -t freebsd-zfs -s 1g md0
zpool create -o autoexpand=on foo md0p1
gpart resize -i 1 -s 2g md0

4 years agoAdd g_topology_locked() macro that returns true if we already hold the GEOM
pjd [Sat, 25 Apr 2020 21:41:09 +0000 (21:41 +0000)]
Add g_topology_locked() macro that returns true if we already hold the GEOM
topology lock.

4 years agoFix race between prebuilding libsbuf and libgeom
dim [Sat, 25 Apr 2020 20:24:41 +0000 (20:24 +0000)]
Fix race between prebuilding libsbuf and libgeom

The latter needs the former, but with a multi-job build on a fast
machine, the race is sometimes lost. This leads to "ld: error: unable to
find library -lsbuf", when linking libgeom.so.

Submitted by: kevans
MFC after: 3 days

4 years agorelease: arm64: rockpro64: Set hw.ncpu to 4
manu [Sat, 25 Apr 2020 20:00:44 +0000 (20:00 +0000)]
release: arm64: rockpro64: Set hw.ncpu to 4

Since there is known issue with big.LITTLE set the number of CPU to 4
which is the number present in the LITTLE cluster.

4 years agoarm64: rockchip: rk805: Use a tailq for the attached regulator
manu [Sat, 25 Apr 2020 15:34:48 +0000 (15:34 +0000)]
arm64: rockchip: rk805: Use a tailq for the attached regulator

Store the attached regulator in a tailq to later find them in ofw_map.
While here, do not attempt to attach a regulator without a name, a node
might exists but if it doesn't have a name the regulator is unused.

MFC after: 1 month

4 years agolibc: partially revert r326576
cem [Sat, 25 Apr 2020 14:24:54 +0000 (14:24 +0000)]
libc: partially revert r326576

In r326576 ("use @@@ instead of @@ in __sym_default"), an earlier version of
the phabricator-discussed patch was inadvertently committed.  The commit
message claims that @@@ means that weak is not needed, but that was due to a
misunderstanding of the use of weak symbols in this context by the submitted
in the first draft of the patch; the description text was not updated to
match the discussion.  As discussed in phabricator, weak is needed for
symbol interposing because of the behavior of our rtld, and is widely used
elsewhere in libc.

This partial revert restores the approved version of the patch and permits
symbol interposing for openat.

Reported by: Raymond Ramsden <rramsden AT isilon.com>
Reviewed by: dim, emaste, kib (2017)
Discussed with: kib (2020)
Differential Revision: https://reviews.freebsd.org/D11653

4 years agoFix LINT build #2 after r360292.
melifaro [Sat, 25 Apr 2020 11:35:38 +0000 (11:35 +0000)]
Fix LINT build #2 after r360292.

Pointyhat to: melifaro

4 years agoFix LINT build broken by r360292.
melifaro [Sat, 25 Apr 2020 10:31:56 +0000 (10:31 +0000)]
Fix LINT build broken by r360292.

4 years agoFix userland build broken by r360292.
melifaro [Sat, 25 Apr 2020 09:25:06 +0000 (09:25 +0000)]
Fix userland build broken by r360292.

4 years agoReorder initialization steps for given pin.
mmel [Sat, 25 Apr 2020 09:17:49 +0000 (09:17 +0000)]
Reorder initialization steps for given pin.
If pin is switched from fixed function to GPIO, it should have prepared
direction, pull-up/down and default value before function gets switched.
Otherwise we may produce unwanted glitch on output pin.
Right order of drive strength settings is questionable, but I think that
is slightly safer to do it also before function switch.

This fixes serial port corruption observed after DT 5.6 import.

MFC after: 1 week

4 years agoConvert route caching to nexthop caching.
melifaro [Sat, 25 Apr 2020 09:06:11 +0000 (09:06 +0000)]
Convert route caching to nexthop caching.

This change is build on top of nexthop objects introduced in r359823.

Nexthops are separate datastructures, containing all necessary information
 to perform packet forwarding such as gateway interface and mtu. Nexthops
 are shared among the routes, providing more pre-computed cache-efficient
 data while requiring less memory. Splitting the LPM code and the attached
 data solves multiple long-standing problems in the routing layer,
 drastically reduces the coupling with outher parts of the stack and allows
 to transparently introduce faster lookup algorithms.

Route caching was (re)introduced to minimise (slow) routing lookups, allowing
 for notably better performance for large TCP senders. Caching works by
 acquiring rtentry reference, which is protected by per-rtentry mutex.
 If the routing table is changed (checked by comparing the rtable generation id)
 or link goes down, cache record gets withdrawn.

Nexthops have the same reference counting interface, backed by refcount(9).
This change merely replaces rtentry with the actual forwarding nextop as a
 cached object, which is mostly mechanical. Other moving parts like cache
 cleanup on rtable change remains the same.

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

4 years agoRemove Mac OS/X macros that did nothing for FreeBSD.
rmacklem [Sat, 25 Apr 2020 02:18:59 +0000 (02:18 +0000)]
Remove Mac OS/X macros that did nothing for FreeBSD.

The macros CAST_USER_ADDR_T() and CAST_DOWN() were used for the Mac OS/X
port. The first of these macros was a no-op for FreeBSD and the second
is no longer used.
This patch gets rid of them. It also deletes the "mbuf_t" typedef which
is no longer used in the FreeBSD code from nfskpiport.h

This patch should not change semantics.

4 years agoPut advertising data in correct place.
hselasky [Sat, 25 Apr 2020 00:57:48 +0000 (00:57 +0000)]
Put advertising data in correct place.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agofreebsd-update: rehash certs
kevans [Sat, 25 Apr 2020 00:14:17 +0000 (00:14 +0000)]
freebsd-update: rehash certs

With the inclusion of caroot bits, we'll need to also rehash on update as we
do in mergemaster/etcupdate.

If certctl's installed on the system, just unconditionally rehash. This
isn't an expensive operation, and we can refine it to compare
INDEX-{OLD,NEW} later if we really want to.

Reviewed by: emaste, allanjude
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21805

4 years agoDon't indirect user pointers directly in two 802.11s ioctls.
jhb [Fri, 24 Apr 2020 22:10:02 +0000 (22:10 +0000)]
Don't indirect user pointers directly in two 802.11s ioctls.

IEEE80211_MESH_RTCMD_ADD was invoking memcmp() to validate the
supplied address directly on the user pointer rather than first doing
a copyin() and validating the copied value.

IEEE80211_MESH_RTCMD_DELETE was passing the user pointer directly to
ieee80211_mesh_rt_del() rather than copying the user buffer into a
temporary kernel buffer.

Reviewed by: brooks, kib
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24562

4 years agoFix a typo
0mp [Fri, 24 Apr 2020 22:04:14 +0000 (22:04 +0000)]
Fix a typo

Reported by: pstef
MFC after: 2 days

4 years agoFix invalid use of macros and two typos
0mp [Fri, 24 Apr 2020 22:02:22 +0000 (22:02 +0000)]
Fix invalid use of macros and two typos

It turns out that currently mandoc(1) is not handling Fl in Ss
correctly (maybe it never was). Let's just replace "Fl S \&Ss ..."
with "-S ...". After all, this subsection title is stylized anyway, so Fl
is not that helpful.

MFC after: 2 weeks

4 years agoFix a race in pmap_emulate_modified().
markj [Fri, 24 Apr 2020 21:21:49 +0000 (21:21 +0000)]
Fix a race in pmap_emulate_modified().

pmap_emulate_modify() was assuming that no changes to the pmap could
take place between the TLB signaling the fault and
pmap_emulate_modify()'s acquisition of the pmap lock, but that's clearly
not even true in the uniprocessor case, nevermind the SMP case.

Submitted by: Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24523

4 years agoFix a race between _pmap_unwire_ptp() and MipsDoTLBMiss().
markj [Fri, 24 Apr 2020 21:21:23 +0000 (21:21 +0000)]
Fix a race between _pmap_unwire_ptp() and MipsDoTLBMiss().

MipsDoTLBMiss() will load a segmap entry or pde, check that it isn't
zero, and then chase that pointer to a physical page. If that page has
been freed in the interim, it will read garbage and go on to populate
the TLB with it.

This can happen because pmap_unwire_ptp zeros out the pde and
vm_page_free_zero()s the ptp (or, recursively, zeros out the segmap
entry and vm_page_free_zero()s the pdp) without interlocking against
MipsDoTLBMiss(). The pmap is locked, and pvh_global_lock may or may not
be held, but this is not enough. Solve this issue by inserting TLB
shootdowns within _pmap_unwire_ptp(); as MipsDoTLBMiss() runs with IRQs
deferred, the IPIs involved in TLB shootdown are sufficient to ensure
that MipsDoTLBMiss() sees either a zero segmap entry / pde or a non-zero
entry and the pointed-to page still not freed.

Submitted by: Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D24491

4 years agoFix handling of 1GB mappings in the arm64 minidump code.
markj [Fri, 24 Apr 2020 18:47:57 +0000 (18:47 +0000)]
Fix handling of 1GB mappings in the arm64 minidump code.

For such mappings we need to dump 512 page table pages, not one, and
they need to be included in the pmap size recorded in the minidump
header.

MFC after: 2 weeks
Sponsored by: Juniper Networks, Klara Inc.

4 years agoRemove an obsolete TODO comment from several minidump implementations.
markj [Fri, 24 Apr 2020 18:47:42 +0000 (18:47 +0000)]
Remove an obsolete TODO comment from several minidump implementations.

The comment referenced a non-existent function, and these minidump
implementations already buffer discontiguous physical data pages by
mapping them into a single VA range that gets passed to the dump device,
so there is no real advantage in batching calls to blk_write().

The RISC-V and MIPS minidump implementations still write a page at a
time and so would benefit from some form of batching.

MFC after: 2 weeks
Sponsored by: Juniper Networks, Klara Inc.

4 years agoAdd PINE64 ROCK64 config for generation of release images
manu [Fri, 24 Apr 2020 16:33:07 +0000 (16:33 +0000)]
Add PINE64 ROCK64 config for generation of release images

4 years agoAdd PINE64 ROCKPro64 config for generation of release images
manu [Fri, 24 Apr 2020 16:32:25 +0000 (16:32 +0000)]
Add PINE64 ROCKPro64 config for generation of release images

Submitted by: Daniel Engberg
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D22538

4 years agoAdd support for generating release images using GPT for ARM
manu [Fri, 24 Apr 2020 16:31:27 +0000 (16:31 +0000)]
Add support for generating release images using GPT for ARM

Submitted by: Daniel Engberg (Original version)
Differential Revision: https://reviews.freebsd.org/D22537

4 years agoMap family 0x5F (Denverton) to goldmont.
mav [Fri, 24 Apr 2020 16:05:35 +0000 (16:05 +0000)]
Map family 0x5F (Denverton) to goldmont.

According to the 325462-071US document, they should be the same.

MFC after: 1 week

4 years agoAdd family 0x5F (Denverton) to PMC_CPU_INTEL_ATOM_GOLDMONT.
mav [Fri, 24 Apr 2020 15:09:30 +0000 (15:09 +0000)]
Add family 0x5F (Denverton) to PMC_CPU_INTEL_ATOM_GOLDMONT.

According to the 325462-071US document, they should be the same.

MFC after: 1 week

4 years agoRename two commands to match the Bluetooth specification in hccontrol(8).
hselasky [Fri, 24 Apr 2020 14:53:55 +0000 (14:53 +0000)]
Rename two commands to match the Bluetooth specification in hccontrol(8).
Fix some bad spelling while at it.

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245868
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoStop setting PG_U in bootstrap mappings.
markj [Fri, 24 Apr 2020 13:53:40 +0000 (13:53 +0000)]
Stop setting PG_U in bootstrap mappings.

These mappings are never visible to userspace as they get replaced when
the amd64 pmap is bootstrapped, but there is no need to set PG_U in the
first place.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D24547

4 years agoUPDATING: Fix the date of the closefrom(2) entry
kevans [Fri, 24 Apr 2020 12:57:03 +0000 (12:57 +0000)]
UPDATING: Fix the date of the closefrom(2) entry

Apologies; my internal calendar says it's still February, but that doesn't
seem to match reality where we've apparently advanced two months.

4 years agoUPDATING: add a note about closefrom(2) marked COMPAT12
kevans [Fri, 24 Apr 2020 12:54:35 +0000 (12:54 +0000)]
UPDATING: add a note about closefrom(2) marked COMPAT12

Some of the consumers in-base may make it enticing enough to ensure that
COMPAT_FREEBSD12, which is notably a fairly light option at the moment, is
included in custom kernel configs.

Suggested by: netchild
Casualty: mail jail

4 years agoRemove PCI_IO_WINDOW_OFFSET from the pci host generic fdt attachment.
andrew [Fri, 24 Apr 2020 11:03:15 +0000 (11:03 +0000)]
Remove PCI_IO_WINDOW_OFFSET from the pci host generic fdt attachment.

It doesn't seem to be needed, and breaks booting under bhyve/arm64.

Discussed with: br
MFC after: 2 weeks
Sponsored by: Innovate UK

4 years agoccp: add a new hardware ID, found on AMD Ryzen 3 3200U
avg [Fri, 24 Apr 2020 10:20:54 +0000 (10:20 +0000)]
ccp: add a new hardware ID, found on AMD Ryzen 3 3200U

pciconf reports the device as:
Family 17h (Models 10h-1fh) Platform Security Processor

dmesg:
ccp0: <AMD CCP-5a> mem 0xfe500000-0xfe5fffff,0xfe68c000-0xfe68dfff at device 0.2 on pci4
crypto: assign ccp0 driver id 1, flags 0x1000000

MFC after: 1 week

4 years agoBuild the arm64 loader with -ffixed-x18
andrew [Fri, 24 Apr 2020 10:03:11 +0000 (10:03 +0000)]
Build the arm64 loader with -ffixed-x18

This stops the compiler from using the x18 register. Some UEFI
implementations assume this will be preserved when calling the Boot
Services.

MFC after: 2 weeks
Sponsored by: Innovate UK

4 years agoacpi_video: fix a crash in detach with an LCD output
avg [Fri, 24 Apr 2020 09:32:20 +0000 (09:32 +0000)]
acpi_video: fix a crash in detach with an LCD output

The crash happened because of a video output object was removed from a
wrong container, crt_units instead of lcd_units.

MFC after: 1 week

4 years agoAdd support for LE advertising to hccontrol(8).
hselasky [Fri, 24 Apr 2020 08:07:59 +0000 (08:07 +0000)]
Add support for LE advertising to hccontrol(8).

Submitted by: Marc Veldman <marc@bumblingdork.com>
PR: 245848
MFC after: 1 week
Sponsored by: Mellanox Technologies