]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agofilt_timerexpire: do not iterate over the interval
Konstantin Belousov [Wed, 28 Apr 2021 16:28:49 +0000 (19:28 +0300)]
filt_timerexpire: do not iterate over the interval

User-supplied data might make this loop too time-consuming. Divide
directly, and handle both the possibility that we were woken up earlier,
and arithmetic overflows/underflows from the calculation.

Reported and tested by: pho (previous version)
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D30069

3 years agondis: remove leftover ndis_events binary and manpage
Dimitry Andric [Mon, 3 May 2021 16:37:31 +0000 (18:37 +0200)]
ndis: remove leftover ndis_events binary and manpage

Fixes: bfc99943b04b ("ndis(4): remove as previous announced")

3 years agogcore: add option to dump core using kernel facility
Konstantin Belousov [Sat, 24 Apr 2021 11:20:24 +0000 (14:20 +0300)]
gcore: add option to dump core using kernel facility

-k switch causes gcore to use ptrace(PT_COREDUMP) instead of manually
reading process memory and constructing the core.

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

3 years agogcore: split code to open core file into helper
Konstantin Belousov [Sat, 24 Apr 2021 10:31:58 +0000 (13:31 +0300)]
gcore: split code to open core file into helper

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

3 years agoAdd ptrace(PT_COREDUMP)
Konstantin Belousov [Fri, 23 Apr 2021 13:26:01 +0000 (16:26 +0300)]
Add ptrace(PT_COREDUMP)

It writes the core of live stopped process to the file descriptor
provided as an argument.

Based on the initial version from https://reviews.freebsd.org/D29691,
submitted by Michał Górny <mgorny@gentoo.org>.

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

3 years agoptracestop: mark threads suspended there with the new TDB_SSWITCH flag
Konstantin Belousov [Sat, 24 Apr 2021 12:02:40 +0000 (15:02 +0300)]
ptracestop: mark threads suspended there with the new TDB_SSWITCH flag

This way threads in ptracestop can be discovered by debugger

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

3 years agoptrace: do not allow for parallel ptrace requests
Konstantin Belousov [Sat, 24 Apr 2021 11:57:40 +0000 (14:57 +0300)]
ptrace: do not allow for parallel ptrace requests

Set a new P2_PTRACEREQ flag around the request Wait for the target     .
process P2_PTRACEREQ flag to clear before setting ours                 .

Otherwise, we rely on the moment that the process lock is not dropped
until the stopped target state is important.  This is going to be no
longer true after some future change.

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

3 years agokern_ptrace(): extract code to determine ptrace eligibility into helper
Konstantin Belousov [Sat, 24 Apr 2021 11:52:11 +0000 (14:52 +0300)]
kern_ptrace(): extract code to determine ptrace eligibility into helper

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

3 years agokern_ptrace: change type of proctree_locked to bool
Konstantin Belousov [Fri, 30 Apr 2021 21:14:26 +0000 (00:14 +0300)]
kern_ptrace: change type of proctree_locked to bool

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

3 years agoAdd thread_run_flash() helper
Konstantin Belousov [Sat, 24 Apr 2021 11:47:53 +0000 (14:47 +0300)]
Add thread_run_flash() helper

It unsuspends single suspended thread, passed as the argument.
It is up to the caller to arrange the target thread to suspend later,
since the state of the process is not changed from stopped.  In particular,
the unsuspended thread must not leave to userspace, since boundary code
is not prepared to this situation.

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

3 years agoAdd sleepq_remove_nested()
Konstantin Belousov [Sun, 25 Apr 2021 00:01:32 +0000 (03:01 +0300)]
Add sleepq_remove_nested()

The helper removes the thread from a sleep queue, assuming that it would
need to sleep. The sleepq_remove_nested() function is intended for quite
special case, where suspended thread from traced stopped process is
temporary unsuspended to do some work on behalf of the debugger in the
target context, and this work might require sleep.

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

3 years agoELF coredump: define several useful flags for the coredump operations
Konstantin Belousov [Sat, 24 Apr 2021 11:45:01 +0000 (14:45 +0300)]
ELF coredump: define several useful flags for the coredump operations

- SVC_ALL request dumping all map entries, including those marked as
  non-dumpable
- SVC_NOCOMPRESS disallows compressing the dump regardless of the sysctl
  policy
- SVC_PC_COREDUMP is provided for future use by userspace core dump
  request

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

3 years agoimgact_elf: consistently pass flags from coredump down to helper functions
Konstantin Belousov [Sat, 24 Apr 2021 11:42:56 +0000 (14:42 +0300)]
imgact_elf: consistently pass flags from coredump down to helper functions

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

3 years agodaemon: add some basic tests
Alan Somers [Wed, 17 Mar 2021 16:35:00 +0000 (10:35 -0600)]
daemon: add some basic tests

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

3 years agocam: fix integer overflow during inquiry
Edward Tomasz Napierala [Mon, 3 May 2021 13:46:11 +0000 (14:46 +0100)]
cam: fix integer overflow during inquiry

From my understanding this could happen with iSCSI LUNs with
unusually long names.  The bug would make CAM fail to retrieve
the full inquiry data.  Instead of bumping the size of the local
variable, just use a macro.

Reviewed By: imp, mav
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #50
Differential Revision: https://reviews.freebsd.org/D29991

3 years agoAdd Apollo Lake SIO/LPSS UARTs PCI IDs
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
Add Apollo Lake SIO/LPSS UARTs PCI IDs

Add PCI IDs for Intel Apollo Lake Series HSUARTs:

    # pciconf -ll
    drv   selector      class    rev  hdr  vendor device subven subdev
    uart0@pci0:0:24:0:  118000   0b   00   8086   5abc   8086   7270
    uart1@pci0:0:24:1:  118000   0b   00   8086   5abe   8086   7270
    uart2@pci0:0:24:2:  118000   0b   00   8086   5ac0   8086   7270
    uart3@pci0:0:24:3:  118000   0b   00   8086   5aee   8086   7270

NB (Intel Document Number 336256-004US):
1. The E3900 and A3900 Series Processors support four LPSS_UART ports,
   while the N- and J- Series Processors support only LPSS_UART [2:1]
   ports.
2. The LPSS_UART1 port is dedicated for discrete Global Navigation
   Satellite System (GNSS).  This port can be used for generic UART
   functionality if GNSS is not used.
3. The LPSS_UART2 port is dedicated for host OS debug.
4. The LPSS_UART0 and LPSS_UART3 ports are for generic UART functionality.
5. Only UART [1:0] ports support DMA.

PR: 255556
Submitted by: Jose Luis Duran <jlduran@gmail.com>
MFC after: 1 week

3 years agouart_bus_pci.c: Style
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
uart_bus_pci.c: Style

Wrap long lines, use tab instead of spaces.

PR: 255556
Submitted by: Jose Luis Duran <jlduran@gmail.com>
MFC after: 1 week

3 years agoifconfig: Minor documentation fix
Jose Luis Duran [Thu, 29 Apr 2021 11:03:48 +0000 (11:03 +0000)]
ifconfig: Minor documentation fix

Fix what appears to have been a small copy/paste typo in ifconfig(8)'s
documentation (man page and header file).

Not that it matters anymore.

Reference: Table I-2 in IEEE Std 802.1Q-2014.

PR: 255557
Submitted by: Jose Luis Duran <jlduran@gmail.com>
MFC after: 1 week

3 years agoAlso enable IPIs on 32-bit arm
Andrew Turner [Sun, 2 May 2021 10:05:03 +0000 (10:05 +0000)]
Also enable IPIs on 32-bit arm

This was missed in 2420f6a

Reported by: tuexen, imp

3 years agoservice/ipfw: Silence warning on restart
Lutz Donnerhacke [Sun, 2 May 2021 20:47:04 +0000 (22:47 +0200)]
service/ipfw: Silence warning on restart

Once the ipfw0 interface has been created, ifconfig(8) create will
throw a warning: ifconfig: create: bad value' when trying to create it
again.

PR: 241013
Submitted by: Jose Luis Duran
Approved by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30083

3 years agostress2: Added a regression test
Peter Holm [Mon, 3 May 2021 07:08:43 +0000 (09:08 +0200)]
stress2: Added a regression test

3 years agostress2: Added a syzkaller reproducer
Peter Holm [Mon, 3 May 2021 07:05:32 +0000 (09:05 +0200)]
stress2: Added a syzkaller reproducer

3 years agostress2: Fix a typo.
Peter Holm [Mon, 3 May 2021 06:45:55 +0000 (08:45 +0200)]
stress2: Fix a typo.

3 years agosctp: improve address list scanning
Michael Tuexen [Mon, 3 May 2021 00:50:05 +0000 (02:50 +0200)]
sctp: improve address list scanning

If the alternate address has to be removed, force the stack to
find a new one, if it is still needed.

MFC after: 3 days

3 years agosctp: improve restart handling
Michael Tuexen [Mon, 3 May 2021 00:20:24 +0000 (02:20 +0200)]
sctp: improve restart handling

This fixes in particular a possible use after free bug reported
Anatoly Korniltsev and Taylor Brandstetter for the userland stack.

MFC after: 3 days

3 years agoFix build after 5f2e1835054ee84f2e68ebc890d92716a91775b7.
Alexander Motin [Mon, 3 May 2021 00:07:38 +0000 (20:07 -0400)]
Fix build after 5f2e1835054ee84f2e68ebc890d92716a91775b7.

3 years agoImprove UMA cache reclamation.
Alexander Motin [Sun, 2 May 2021 23:35:28 +0000 (19:35 -0400)]
Improve UMA cache reclamation.

When estimating working set size, measure only allocation batches, not free
batches.  Allocation and free patterns can be very different.  For example,
ZFS on vm_lowmem event can free to UMA few gigabytes of memory in one call,
but it does not mean it will request the same amount back that fast too, in
fact it won't.

Update working set size on every reclamation call, shrinking caches faster
under pressure.  Lack of this caused repeating vm_lowmem events squeezing
more and more memory out of real consumers only to make it stuck in UMA
caches.  I saw ZFS drop ARC size in half before previous algorithm after
periodic WSS update decided to reclaim UMA caches.

Introduce voluntary reclamation of UMA caches not used for a long time. For
each zdom track longterm minimal cache size watermark, freeing some unused
items every UMA_TIMEOUT after first 15 minutes without cache misses. Freed
memory can get better use by other consumers.  For example, ZFS won't grow
its ARC unless it see free memory, since it does not know it is not really
used.  And even if memory is not really needed, periodic free during
inactivity periods should reduce its fragmentation.

Reviewed by: markj, jeff (previous version)
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29790

3 years agosctp: improve error handling in INIT/INIT-ACK processing
Michael Tuexen [Sun, 2 May 2021 20:38:27 +0000 (22:38 +0200)]
sctp: improve error handling in INIT/INIT-ACK processing

When processing INIT and INIT-ACK information, also during
COOKIE processing, delete the current association, when it
would end up in an inconsistent state.

MFC after: 3 days

3 years agocopy_file_range(2): improve copying of a large hole to EOF
Rick Macklem [Sun, 2 May 2021 23:04:27 +0000 (16:04 -0700)]
copy_file_range(2): improve copying of a large hole to EOF

PR#255523 reported that a file copy for a file with a large hole
to EOF on ZFS ran slowly over NFSv4.2.
The problem was that vn_generic_copy_file_range() would
loop around reading the hole's data and then see it is all
0s. It was coded this way since UFS always allocates a data
block near the end of the file, such that a hole to EOF never exists.

This patch modifies vn_generic_copy_file_range() to check for a
ENXIO returned from VOP_IOCTL(..FIOSEEKDATA..) and handle that
case as a hole to EOF. asomers@ confirms that it works for his
ZFS test case.

PR: 255523
Tested by: asomers
Reviewed by: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30076

3 years agosbin/ipfw: Fix null pointer deference when printing counters
Lutz Donnerhacke [Fri, 30 Apr 2021 14:12:47 +0000 (16:12 +0200)]
sbin/ipfw: Fix null pointer deference when printing counters

ipfw -[tT] prints statistics of the last access. If the rule was never
used, the counter might be not exist.  This happens unconditionally on
inserting a new rule.  Avoid printing statistics in this case.

PR: 255491
Reported by: Haisheng Zhouz
Reviewed by: ae
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30046

3 years agousr.bin/netstat: use roundup2 when rounding up to power of 2.
Xin LI [Sun, 2 May 2021 16:30:22 +0000 (09:30 -0700)]
usr.bin/netstat: use roundup2 when rounding up to power of 2.

MFC after:  2 weeks

3 years agousr.bin/patch: remove unneeded header.
Xin LI [Sun, 2 May 2021 16:27:32 +0000 (09:27 -0700)]
usr.bin/patch: remove unneeded header.

MFC after: 2 weeks

3 years agoAdd myself (vishwin) as a ports committer
Charlie Li [Sun, 2 May 2021 05:15:14 +0000 (01:15 -0400)]
Add myself (vishwin) as a ports committer

Following section 7.1 in Committer's Guide.

Approved by: arrowd (mentor)
Differential Revision: https://reviews.freebsd.org/D30078

3 years agoEnable IPIs on CPU 0 on arm and arm64
Andrew Turner [Sun, 2 May 2021 07:43:34 +0000 (07:43 +0000)]
Enable IPIs on CPU 0 on arm and arm64

Not all interrupt controllers enable IPIs by default as the Arm
GIC specs make it an implementation defined option. As at least two
hypervisors have also previously masked the IPIs on boot.

As we already enable these IPIs on the non-boot CPUs it is expected
this is a safe operation.

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

3 years agoImplement bus_map_resource on arm64
Andrew Turner [Sat, 10 Apr 2021 10:25:39 +0000 (10:25 +0000)]
Implement bus_map_resource on arm64

This will allow us to allocate an unmapped memory resource, then
later map it with a specific memory attribute.

This is also needed for virtio with the modern PCI attachment.

Reviewed by: kib (via D29723)
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D29694

3 years agoless: upgrade to v581.2.
Xin LI [Sun, 2 May 2021 06:16:08 +0000 (23:16 -0700)]
less: upgrade to v581.2.

MFC after: 1 week

3 years agoVendor import of less v581.2.
Xin LI [Sun, 2 May 2021 06:13:19 +0000 (23:13 -0700)]
Vendor import of less v581.2.

3 years agopowerpc/xive: Remove POWER9 DD1 IRQ bits
Justin Hibbits [Mon, 26 Apr 2021 18:04:42 +0000 (13:04 -0500)]
powerpc/xive: Remove POWER9 DD1 IRQ bits

The OPAL_XIVE_*_VIA_IFW flags are used only for POWER9 DD1, which we
don't support.

Noticed while perusing Linux and skiboot git logs.

3 years agoFix building sysctl(8) after c78ad20
Andrew Turner [Sat, 1 May 2021 11:10:03 +0000 (11:10 +0000)]
Fix building sysctl(8) after c78ad20

In sysctl we parse an efi header on amd64. Fix this after changing the
virtual memory type from a void * to a uint64_t in c78ad20.

3 years agoSwitch the EFI virtual address to a uint64_t
Andrew Turner [Wed, 14 Apr 2021 08:22:06 +0000 (08:22 +0000)]
Switch the EFI virtual address to a uint64_t

It is defined as a uint64_t in the UEFI spec. As it's not used as a
pointer by the kernel follow this and define it as the same in the
kernel.

Reviewed by: kib, manu, imp
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D29759

3 years agoAdd a way to map arm64 non-posted device memory
Andrew Turner [Thu, 8 Apr 2021 11:54:20 +0000 (11:54 +0000)]
Add a way to map arm64 non-posted device memory

On arm64 we currently use a non-posted write for device memory, however
we should move to use posted writes. This is expected to work on most
hardware, however we will need to support a non-posted option for some
broken hardware.

Reviewed by: imp, manu, bcr (manpage)
Differential Revision: https://reviews.freebsd.org/D29722

3 years agopowerpc64: Optimize radix trap handling a little more
Justin Hibbits [Sat, 1 May 2021 00:58:11 +0000 (19:58 -0500)]
powerpc64: Optimize radix trap handling a little more

Summary:
Since PCPU can live in a GPR for a while longer, let it, rather than
re-getting it in yet another register.  MFSPR is an expensive operation,
12 clock latency on POWER9, so the fewer operations we need, the better.

Since the check is tightly coupled to the fetch, by reducing the number
of fetch+check, we reduce the stalls, and improve the performance
marginally.  Buildworld was measured at a ~5-7% improvement on a single
run.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D30003

3 years agogicv3_its: Flush cache after allocating ITT memory
Marcin Wojtas [Thu, 29 Apr 2021 09:39:09 +0000 (11:39 +0200)]
gicv3_its: Flush cache after allocating ITT memory

It has to be zeroed before committing it to device.
We do that by allocating it with M_ZERO, but there was no
memory barrier or cache flush to ensure its sees it zeroed.
This fixes MSIX on LS1028A SoC.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: andrew
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30033

3 years agoWait longer for a previous IPI to be sent
Eric van Gyzen [Mon, 26 Apr 2021 15:01:17 +0000 (10:01 -0500)]
Wait longer for a previous IPI to be sent

When sending an IPI, if a previous IPI is still pending delivery,
native_lapic_ipi_vectored() waits for the previous IPI to be sent.
We've seen a few inexplicable panics with the current timeout of 50 ms.
Increase the timeout to 1 second and make it tunable.

No hardware specification mentions a timeout in this case; I checked
the Intel SDM, Intel MP spec, and Intel x2APIC spec.  Linux and illumos
wait forever.  In Linux, see __default_send_IPI_shortcut() in
arch/x86/kernel/apic/ipi.c.  In illumos, see apic_send_ipi() in
usr/src/uts/i86pc/io/pcplusmp/apic_common.c.  However, misbehaving hardware
could hang the system if we wait forever.

Reviewed by: mav kib
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D29942

3 years agoEFI secure boot VECTX related changes
Eric van Gyzen [Fri, 30 Apr 2021 17:53:45 +0000 (12:53 -0500)]
EFI secure boot VECTX related changes

When VECTX is enabled as a kernel option and non-EFI loaders are
built, many reads will fail due to the mis-match of whether
LOADER_VERIEXEC_VECTX or not in readin.h.  Source that includes
bootstrap.h must ensure the kernel option agrees with the compile
time CFLAGS in the various make related files.

Submitted by: bret_ketchum@dell.com (original revision)
Reviewed by: sjg, bdrewery, dab, bret_ketchum@dell.com
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D29993

3 years agoioccom: define ioctl cmd value that can never be valid
Konstantin Belousov [Thu, 22 Apr 2021 19:40:08 +0000 (22:40 +0300)]
ioccom: define ioctl cmd value that can never be valid

Its use is for cases where some filler is needed for cmd, or we need an
indication that there were no cmd supplied, and so on.

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

3 years agoconnectat(2): clarify that the s argument is socket
Konstantin Belousov [Wed, 28 Apr 2021 15:47:31 +0000 (18:47 +0300)]
connectat(2): clarify that the s argument is socket

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agoO_PATH: disable kqfilter for fifos
Konstantin Belousov [Wed, 28 Apr 2021 15:45:36 +0000 (18:45 +0300)]
O_PATH: disable kqfilter for fifos

Filter on fifos is real filter for the object, and not a filesystem
events filter like EVFILT_VNODE.

Reported by: markj using syzkaller
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agoamd64: disable LA57 by default for now
Konstantin Belousov [Wed, 28 Apr 2021 15:50:16 +0000 (18:50 +0300)]
amd64: disable LA57 by default for now

A testing on the real hardware uncovered an issue, and since I do not have
access to the machine, disable until the bug can be fixed.

Reported by: "Pieper, Jeffrey E" <jeffrey.e.pieper@intel.com>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

3 years agoamd64: invalidate TLB between page table update and access
Konstantin Belousov [Fri, 16 Apr 2021 18:28:08 +0000 (21:28 +0300)]
amd64: invalidate TLB between page table update and access

When setting up trampoline mapping for LA57 switcher, it is possible
that TLB still has some random mapping at that address.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoAdd myself(oh) as src committer and mentor(manu).
Oskar Holmlund [Fri, 30 Apr 2021 12:49:20 +0000 (14:49 +0200)]
Add myself(oh) as src committer and mentor(manu).

Step 7.1.5 in committers guide.

Reviewed by: manu
Approved by: manu (mentor)
Differential Revision: https://reviews.freebsd.org/D29890

3 years agosctp: update the vtag for INIT and INIT-ACK chunks
Michael Tuexen [Fri, 30 Apr 2021 11:31:38 +0000 (13:31 +0200)]
sctp: update the vtag for INIT and INIT-ACK chunks

This is needed in case of responding with an ABORT to an INIT-ACK.

3 years agoiflib: Take iri_pad into account when processing small frames
Marcin Wojtas [Tue, 27 Apr 2021 09:00:15 +0000 (11:00 +0200)]
iflib: Take iri_pad into account when processing small frames

Drivers can specify padding of received frames with iri_pad field.
This can be used to enforce ip alignment by hardware.
Iflib ignored that padding when processing small frames,
which rendered this feature inoperable.
I found it while writing a driver for a NIC that can ip align
received packets. Note that this doesn't change behavior of existing
drivers as they all set iri_pad to 0.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: gallatin
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30009

3 years agosctp: fix SCTP_PEER_ADDR_PARAMS socket option
Michael Tuexen [Fri, 30 Apr 2021 10:27:47 +0000 (12:27 +0200)]
sctp: fix SCTP_PEER_ADDR_PARAMS socket option

Ignore spp_pathmtu if it is 0, when setting the IPPROTO_SCTP level
socket option SCTP_PEER_ADDR_PARAMS as required by RFC 6458.

MFC after: 1 week

3 years agopf tests: Test scrub fragment reassemble on interfaces with different MTU
Kristof Provost [Tue, 27 Apr 2021 16:46:03 +0000 (18:46 +0200)]
pf tests: Test scrub fragment reassemble on interfaces with different MTU

There's a problem with pf's reassembly code where it produces incorrect
checksums when reassembling across interfaces with different MTUs.
Test this.

PR: 255432
Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30013

3 years agopf: Fix IP checksum on reassembly
Kristof Provost [Wed, 28 Apr 2021 10:56:06 +0000 (12:56 +0200)]
pf: Fix IP checksum on reassembly

If we reassemble a packet we modify the IP header (to set the length and
remove the fragment offset information), but we failed to update the
checksum. On certain setups (mostly where we did not re-fragment again
afterwards) this could lead to us sending out packets with incorrect
checksums.

PR: 255432
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30026

3 years agosctp: use RTO.Initial of 1 second as specified in RFC 4960bis
Michael Tuexen [Thu, 29 Apr 2021 22:45:56 +0000 (00:45 +0200)]
sctp: use RTO.Initial of 1 second as specified in RFC 4960bis

3 years agosctp: improve consistency in handling chunks with wrong size
Michael Tuexen [Wed, 28 Apr 2021 16:09:11 +0000 (18:09 +0200)]
sctp: improve consistency in handling chunks with wrong size

Just skip the chunk, if no other handling is required by the
specification.

3 years agokasan.9: A couple of fixups
Mark Johnston [Thu, 29 Apr 2021 16:26:03 +0000 (12:26 -0400)]
kasan.9: A couple of fixups

- Mention GENERIC-KASAN.
- Note that the runtime was ported from NetBSD.

Sponsored by: The FreeBSD Foundation

3 years agokasan: Use vm_offset_t for the first parameter to kasan_shadow_map()
Mark Johnston [Thu, 29 Apr 2021 15:39:02 +0000 (11:39 -0400)]
kasan: Use vm_offset_t for the first parameter to kasan_shadow_map()

No functional change intended.

Sponsored by: The FreeBSD Foundation

3 years agoipmi: support getting address from EFI
Yinlong Lu [Thu, 29 Apr 2021 10:04:36 +0000 (05:04 -0500)]
ipmi: support getting address from EFI

The original implementation only supports getting the address from legacy
BIOS (by searching for the SMBIOS_SIG pattern in a fixed address space).

Try to get the SMBIOS table from EFI through efirt (EFI Runtime Services)
firstly.  Continue to search in the legacy BIOS if a NULL address is
returned from EFI.

By this way the ipmi function supports both legacy BIOS and UEFI systems.

Reviewed by: dab, vangyzen
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D30007

3 years agosrc.libnames.mk: Remove redundant am-utils library definition
Cy Schubert [Thu, 22 Apr 2021 06:17:08 +0000 (23:17 -0700)]
src.libnames.mk: Remove redundant am-utils library definition

r358821 (13f7dbe822d5f447c6137dc0d4ff838fb7050dbe) retired amd(8).
This commit cleans up an artifact left in src.libnames.mk.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29914

3 years agopf: Trivial typo fix
Kristof Provost [Thu, 29 Apr 2021 08:34:00 +0000 (10:34 +0200)]
pf: Trivial typo fix

PV -> PF

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoarm: add a release conf for distribution files
Mitchell Horne [Thu, 29 Apr 2021 13:10:08 +0000 (10:10 -0300)]
arm: add a release conf for distribution files

We do not currently generate armv7 distribution sets, because we don't
build any installer images. However, having such sets available can be
useful for quickly installing a base system, particularly in the case
of creating an armv7 poudriere jail on arm64.

Add a configuration file for the generation of these distribution sets.

Reviewed by: manu, imp, gjb
MFC after: 3 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D29923

3 years agoSynch index of contrib/bc with what is in workdir after cloning.
Michael Gmelin [Thu, 29 Apr 2021 12:29:04 +0000 (14:29 +0200)]
Synch index of contrib/bc with what is in workdir after cloning.

From a workdir perspective this should be a no-op.
See also:
https://lists.freebsd.org/pipermail/freebsd-current/2021-April/079569.html

3 years agopci_vendors: update to 2021.04.26
Baptiste Daroussin [Thu, 29 Apr 2021 04:46:26 +0000 (06:46 +0200)]
pci_vendors: update to 2021.04.26

3 years agopkg(7): replace usage of sbuf(9) with open_memstream(3)
Baptiste Daroussin [Tue, 27 Apr 2021 02:38:55 +0000 (04:38 +0200)]
pkg(7): replace usage of sbuf(9) with open_memstream(3)

open_memstream(3) is a standard way to obtain the same feature we do get
by using sbuf(9) (aka dynamic size buffer), switching to using it makes
pkg(7) more portable, and reduces its number of dependencies.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D30005

3 years agopkg(7): indentation fixes
Baptiste Daroussin [Tue, 27 Apr 2021 02:07:05 +0000 (04:07 +0200)]
pkg(7): indentation fixes

Non functional changes

3 years agocxgbe(4): Do not panic when tx is called with invalid checksum requests.
Navdeep Parhar [Wed, 28 Apr 2021 20:45:58 +0000 (13:45 -0700)]
cxgbe(4): Do not panic when tx is called with invalid checksum requests.

There is no need to panic in if_transmit if the checksums requested are
inconsistent with the frame being transmitted.  This typically indicates
that the kernel and driver were built with different INET/INET6 options,
or there is some other kernel bug.  The driver should just throw away
the requests that it doesn't understand and move on.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 years ago[fib algo] Update fib_gen counter under FIB_MOD_LOCK.
Alexander V. Chernikov [Wed, 28 Apr 2021 20:21:58 +0000 (20:21 +0000)]
[fib algo] Update fib_gen counter under FIB_MOD_LOCK.

MFC after: 3 days

3 years agocache: remove incomplete lockless lockout support during resize
Mateusz Guzik [Sat, 10 Apr 2021 17:20:28 +0000 (19:20 +0200)]
cache: remove incomplete lockless lockout support during resize

This is already properly handled thanks to 2 step hash replacement.

3 years agoCorrect the link of external mirrors
Li-Wen Hsu [Wed, 28 Apr 2021 19:39:18 +0000 (03:39 +0800)]
Correct the link of external mirrors

Reported by: 0mp
Fixes: 8ef03ce6db33
MFC after: 1 day

3 years agoixgbe: Improve device name strings
Kevin Bowling [Wed, 21 Apr 2021 02:35:14 +0000 (19:35 -0700)]
ixgbe: Improve device name strings

This is just clerical work to ease bug triage and may be used to set
expectations around the ability for anyone in the community to perform
testing and development on older parts.

Approved by: erj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29876

3 years agopf: Error tracing SDTs
Kristof Provost [Tue, 20 Apr 2021 09:18:26 +0000 (11:18 +0200)]
pf: Error tracing SDTs

Add additional DTrace static trace points to facilitate debugging
failing pf ioctl calls.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoBump __FreeBSD_version for commits efe7f12 and 9781105
Neel Chauhan [Wed, 28 Apr 2021 15:07:05 +0000 (08:07 -0700)]
Bump __FreeBSD_version for commits efe7f12 and 9781105

These commits have added new APIs to linuxkpi.

3 years agolinuxkpi: Introduce tasklet_disable_nosync()
Neel Chauhan [Wed, 28 Apr 2021 15:05:57 +0000 (08:05 -0700)]
linuxkpi: Introduce tasklet_disable_nosync()

This is needed for the drm-kmod 5.5 update.

Reviewed by: hselasky (src)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D30024

3 years agolinuxkpi: Implement rcu_replace_pointer() macro
Neel Chauhan [Wed, 28 Apr 2021 15:04:52 +0000 (08:04 -0700)]
linuxkpi: Implement rcu_replace_pointer() macro

This is needed for the drm-kmod 5.5 update.

Reviewed by: hselasky (src)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D30025

3 years agopipe: Avoid calling selrecord() on a closing pipe
Mark Johnston [Wed, 28 Apr 2021 14:42:59 +0000 (10:42 -0400)]
pipe: Avoid calling selrecord() on a closing pipe

pipe_poll() may add the calling thread to the selinfo lists of both ends
of a pipe.  It is ok to do this for the local end, since we know we hold
a reference on the file and so the local end is not closed.  It is not
ok to do this for the remote end, which may already be closed and have
called seldrain().  In this scenario, when the polling thread wakes up,
it may end up referencing a freed selinfo.

Guard the selrecord() call appropriately.

Reviewed by: kib
Reported by: syzkaller+KASAN
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30016

3 years agobuild(7): fix references to svn(1) and svnlite(1)
Fernando Apesteguía [Fri, 23 Apr 2021 16:59:19 +0000 (18:59 +0200)]
build(7): fix references to svn(1) and svnlite(1)

Replace them with references to Git.

PR: 254937
Reported by: m.bueker@berlin.de
Approved by: 0mp (mentor)
Differential Revision: https://reviews.freebsd.org/D29949

3 years agocap_sysctl.3: Fix bugs in the example
Mark Johnston [Wed, 28 Apr 2021 14:38:52 +0000 (10:38 -0400)]
cap_sysctl.3: Fix bugs in the example

- Correct the type of the sysctl value.
- Initialize the oldsize parameter to cap_sysctlbyname()

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agotcp: stop spurious rescue retransmissions and potential asserts
Richard Scheffenegger [Wed, 28 Apr 2021 12:56:14 +0000 (14:56 +0200)]
tcp: stop spurious rescue retransmissions and potential asserts

Reported by: pho@
MFC after: 3 days
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29970

3 years agoUpdate tools/regression/poll/sockpoll.c for POLLRDPOLL.
Thomas Munro [Wed, 28 Apr 2021 11:08:27 +0000 (23:08 +1200)]
Update tools/regression/poll/sockpoll.c for POLLRDPOLL.

Add a POLLRDHUP example to this tool, for comparison with other
operating systems.  Also record current output on FreeBSD and Linux.

Reviewed by:    kib
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D29757

3 years agopoll(2): Add POLLRDHUP.
Thomas Munro [Wed, 28 Apr 2021 09:31:38 +0000 (21:31 +1200)]
poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested.  Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29757

3 years agoopen_memstream(3): fix typo
Yuri Pankov [Wed, 28 Apr 2021 09:18:25 +0000 (12:18 +0300)]
open_memstream(3): fix typo

While here, pet mandoc: .Tn -> .Vt

3 years agoAdd rib_walk_from() wrapper for selective rib tree traversal.
Alexander V. Chernikov [Sun, 25 Apr 2021 11:59:40 +0000 (11:59 +0000)]
Add rib_walk_from() wrapper for selective rib tree traversal.

Provide wrapper for the rnh_walktree_from() rib callback.
As currently `struct rib_head` is considered internal to the
 routing subsystem, this wrapper is necessary to maintain isolation
 from the external code.

Differential Revision: https://reviews.freebsd.org/D29971
MFC after: 1 week

3 years agocxgbe(4): Add support for NIC suspend/resume and live reset.
Navdeep Parhar [Wed, 28 Apr 2021 04:33:10 +0000 (21:33 -0700)]
cxgbe(4): Add support for NIC suspend/resume and live reset.

Add suspend/resume callbacks to the driver and a live reset built around
them.  This commit covers the basic NIC and future commits will expand
this functionality to other stateful parts of the chip.  Suspend and
resume operate on the chip (the t?nex nexus device) and affect all its
ports.  It is not possible to suspend/resume or reset individual ports.
All these operations can be performed on a running NIC.  A reset will
look like a link bounce to the networking stack.

Here are some ways to exercise this functionality:

 /* Manual suspend and resume. */
 # devctl suspend t6nex0
 # devctl resume t6nex0

 /* Manual reset. */
 # devctl reset t6nex0

 /* Manual reset with driver sysctl. */
 # sysctl dev.t6nex.0.reset=1

 /* Automatic adapter reset on any fatal error. */
 # hw.cxgbe.reset_on_fatal_err=1

Suspend disables the adapter (DMA, interrupts, and the port PHYs) and
marks the hardware as unavailable to the driver.  All ifnets associated
with the adapter are still visible to the kernel but operations that
require hardware interaction will fail with ENXIO.  All ifnets report
link-down while the adapter is suspended.

Resume will reattach to the card, reconfigure it as before, and recreate
the queues servicing the existing ifnets.  The ifnets are able to send
and receive traffic as soon as the link comes back up.

Reset is roughly the same as a suspend and a resume with at least one of
these events in between: D0->D3Hot->D0, FLR, PCIe link retrain.

MFC after: 1 month
Relnotes: yes
Sponsored by: Chelsio Communications

3 years agogeom_uzip(4): fix a typo
Ceri Davies [Wed, 28 Apr 2021 04:55:32 +0000 (00:55 -0400)]
geom_uzip(4): fix a typo

While I was there, also fixed a whitespace issue reported by mandoc
-Tlint.

PR: 254338
MFC after: 3 days

3 years agonfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()
Rick Macklem [Wed, 28 Apr 2021 00:30:16 +0000 (17:30 -0700)]
nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()

Commit aad780464fad added a function called nfscl_delegreturnvp()
to return delegations during the NFS VOP_RECLAIM().
The function erroneously assumed that nm_clp would
be non-NULL. It will be NULL for NFSV4.0 mounts until
a regular file is opened. It will also be NULL during
vflush() in nfs_unmount() for a forced dismount.

This patch adds a check for clp == NULL to fix this.

Also, since it makes no sense to call nfscl_delegreturnvp()
during a forced dismount, the patch adds a check for that
case and does not do the call during forced dismounts.

PR: 255436
Reported by: ish@amail.plala.or.jp
MFC after: 2 weeks

3 years agonfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT
Rick Macklem [Tue, 27 Apr 2021 22:32:35 +0000 (15:32 -0700)]
nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT

It was reported that a NFSv4.1 Linux client mount against
a FreeBSD12 server was hung, with the TCP connection in
CLOSE_WAIT state on the server.
When a NFSv4.1/4.2 mount is done and the back channel is
bound to the TCP connection, the soclose() is delayed until
a new TCP connection is bound to the back channel, due to
a reference count being held on the SVCXPRT structure in
the krpc for the socket. Without the soclose() call, the socket
will remain in CLOSE_WAIT and this somehow caused the Linux
client to hang.

This patch adds calls to soshutdown(.., SHUT_WR) that
are performed when the server side krpc sees that the
socket is no longer usable.  Since this can be done
before the back channel is bound to a new TCP connection,
it allows the TCP connection to proceed to CLOSED state.

PR: 254590
Reported by: jbreitman@tildenparkcapital.com
Reviewed by: tuexen
Comments by: kevans
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29526

3 years agoe1000: Rework em_msi_link interrupt filter
Kevin Bowling [Sun, 25 Apr 2021 08:22:23 +0000 (01:22 -0700)]
e1000: Rework em_msi_link interrupt filter

* Fix 82574 Link Status Changes, carrying the OTHER mask bit around as
  needed.
* Move igb-class LSC re-arming out of FAST back into the handler.
* Clarify spurious/other interrupt re-arms in FAST.

In MSI-X mode, 82574 and igb-class devices use an interrupt filter to
handle Link Status Changes. We want to do LSC re-arms in the handler
to take advantage of autoclear (EIAC) single shot behavior.

82574 uses 'Other' in ICR and IMS for LSC interrupt types when in MSI-X
mode, so we need to set and re-arm the 'Other' bit during attach and
after ICR reads in the FAST handler if not an LSC or after handling on
LSC due to autoclearing.

This work was primarily done to address the referenced PR, but inspired
some clarification and improvement for igb-class devices once the
intentions of previous bug fix attempts became clearer.

PR: 211219
Reported by: Alexey <aserp3@gmail.com>
Tested by: kbowling (I210 lagg), markj (I210)
Approved by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29943

3 years ago[fib algo] Delay algo init at fib growth to to allow to reliably use rib KPI.
Alexander V. Chernikov [Sun, 25 Apr 2021 10:22:45 +0000 (10:22 +0000)]
[fib algo] Delay algo init at fib growth to to allow to reliably use rib KPI.

Currently, most of the rib(9) KPI does not use rnh pointers, using
 fibnum and family parameters to determine the rib pointer instead.
This works well except for the case when we initialize new rib pointers
 during fib growth.
In that case, there is no mapping between fib/family and the new rib,
 as an entirely new rib pointer array is populated.

Address this by delaying fib algo initialization till after switching
 to the new pointer array and updating the number of fibs.
Set datapath pointer to the dummy function, so the potential callers
 won't crash the kernel in the brief moment when the rib exists, but
 no fib algo is attached.

This change allows to avoid creating duplicates of existing rib functions,
 with altered signature.

Differential Revision: https://reviews.freebsd.org/D29969
MFC after: 1 week

3 years agoriscv: Remove old qemu compatibility code
Brandon Bergren [Tue, 27 Apr 2021 16:07:34 +0000 (11:07 -0500)]
riscv: Remove old qemu compatibility code

During early qemu development, the /soc node was marked as compatible
with "riscv-virtio-soc" instead of "simple-bus".

This was changed in qemu 53f54508dae6 in Sep 2018, and predates the
baseline required qemu version (5.0) for riscv by a wide margin.

The generic simplebus code handles attachment in all cases nowadays.

Sponsored by: Tag1 Consulting, Inc.
Reviewed by: jrtc27, mhorne
Differential Revision: https://reviews.freebsd.org/D30011

3 years agoMerge llvm commits for kernel address and memory sanitizer support
Dimitry Andric [Tue, 27 Apr 2021 19:18:13 +0000 (21:18 +0200)]
Merge llvm commits for kernel address and memory sanitizer support

Merge commit 99eca1bd9c7a from llvm git (by Mark Johnston):

  [Driver] Enable kernel address and memory sanitizers on FreeBSD

  Test Plan: using kernel ASAN and MSAN implementations in FreeBSD

  Reviewed By: emaste, dim, arichardson

  Differential Revision: https://reviews.llvm.org/D98286

Merge commit f511dc75e4c1 from llvm git (by Mark Johnston):

  [asan] Add an offset for the kernel address sanitizer on FreeBSD

  This is based on a port of the sanitizer runtime to the FreeBSD kernel
  that has been commited as https://cgit.freebsd.org/src/commit/?id=38da497a4dfcf1979c8c2b0e9f3fa0564035c147
  and the following commits.

  Reviewed By: emaste, dim
  Differential Revision: https://reviews.llvm.org/D98285

Requested by: markj
MFC after: 3 days

3 years agoMove IOMMU code to a separate pmap module and switch ARM System MMU
Ruslan Bukin [Tue, 27 Apr 2021 17:59:15 +0000 (18:59 +0100)]
Move IOMMU code to a separate pmap module and switch ARM System MMU
driver to use it.

Add ARM Mali Txxx (Midgard), Gxx (Bifrost) GPU page management code.

Sponsored by: UKRI

3 years agodwc: Use mii_fdt function
Emmanuel Vadot [Sun, 11 Apr 2021 19:34:57 +0000 (21:34 +0200)]
dwc: Use mii_fdt function

Use the helper function to get phy mode and configure dwc accordingly.

Reviewed by: ian

3 years agommccam: probe*: Style(9)
Emmanuel Vadot [Fri, 23 Apr 2021 12:51:13 +0000 (14:51 +0200)]
mmccam: probe*: Style(9)

3 years agommcprobe_done: Style(9)
Emmanuel Vadot [Fri, 23 Apr 2021 12:50:04 +0000 (14:50 +0200)]
mmcprobe_done: Style(9)

3 years agodwmmc: Add \n to a debug printf
Emmanuel Vadot [Thu, 22 Apr 2021 19:41:56 +0000 (21:41 +0200)]
dwmmc: Add \n to a debug printf

3 years agommc: dwmmc: Convert driver to use the mmc_sim interface
Emmanuel Vadot [Wed, 21 Apr 2021 11:56:27 +0000 (13:56 +0200)]
mmc: dwmmc: Convert driver to use the mmc_sim interface

A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

Differential Revision: https://reviews.freebsd.org/D27487
Reviewed by: kibab

3 years agoallwinner: aw_mmc: Convert driver to use the mmc_sim interface
Emmanuel Vadot [Wed, 21 Apr 2021 11:54:25 +0000 (13:54 +0200)]
allwinner: aw_mmc: Convert driver to use the mmc_sim interface

A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

Differential Revision: https://reviews.freebsd.org/D27486
Reviewed by: imp