]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agomixer(3): Add symbol versioning.
Hans Petter Selasky [Fri, 1 Oct 2021 12:14:38 +0000 (14:14 +0200)]
mixer(3): Add symbol versioning.

Suggested by: kib
Differential Revision: https://reviews.freebsd.org/D32254
Sponsored by: NVIDIA Networking

2 years agoFix bsnmpd(1) crash with ill-formed Discovery message
Shteryana Shopova [Fri, 1 Oct 2021 11:10:39 +0000 (14:10 +0300)]
Fix bsnmpd(1) crash with ill-formed Discovery message

RFC 3414 Section 4. Discovery specifies that a discovery request message has a
varBindList left empty. Nonetheless, bsnmpd(1) should not crash when receiving
a non-zero var-bindings list in a Discovery Request message.

PR: 255214
MFC after: 2 weeks

2 years agoAdd a gic interface to allocate MSI interrupts
Andrew Turner [Wed, 29 Sep 2021 13:33:18 +0000 (14:33 +0100)]
Add a gic interface to allocate MSI interrupts

The previous update to handle the gicv2m as a child of the gicv3 driver
assumed there was only a single gicv2m child. On some hardware there
are multiple children. Support this by removing the mbi ivars and
adding a new interface to handle MSI allocation in a given range.

Tested by: mw, trasz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32224

2 years agoAllow ddb and dtrace use the DMAP region on arm64
Andrew Turner [Tue, 21 Sep 2021 17:10:57 +0000 (17:10 +0000)]
Allow ddb and dtrace use the DMAP region on arm64

When writing to memory on arm64 we may be trying to be accessing a
read-only page. In this case try to access via the DMAP region to
get a writable location.

While here simplify writing data in DDB and stop trashing the size as
it is passed into the cache handling functions.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32053

2 years agoAlso print symbols when printing arm64 registers
Andrew Turner [Thu, 23 Sep 2021 10:32:16 +0000 (10:32 +0000)]
Also print symbols when printing arm64 registers

When printing arm64 registers because of an exception in the kernel
also print the symbol and offset. This can be used to track down why
the exception occured without needing external tools.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32077

2 years agoenetc_mdio: Fix devclass name
Kornel Duleba [Thu, 5 Aug 2021 10:31:33 +0000 (12:31 +0200)]
enetc_mdio: Fix devclass name

Use correct devclass name, due to the mismatch miibus would attach
to the wrong thing causing mii_attach to silently fail.

Fixes: dfcaa2c18bf9 (enetc_mdio: Support building the driver ...)
2 years agomodules: felix: Remove etherswitch_if.c from Makefile
Kornel Duleba [Thu, 30 Sep 2021 11:06:34 +0000 (13:06 +0200)]
modules: felix: Remove etherswitch_if.c from Makefile

Having it included confuses KOBJOPLOOKUP resulting in kobj_error_method
being called instead of a devmethod from the switch driver.
That in turn returns ENXIO which was treated as a pointer and
dereferenced by etherswitch ioctl logic causing the kernel to panic.

Fixes: b542c9e42ba4 (modules: felix: Add needed dependencies)
2 years agoarm64: std.nxp Add enetc NIC driver
Kornel Duleba [Thu, 30 Sep 2021 07:34:52 +0000 (09:34 +0200)]
arm64: std.nxp Add enetc NIC driver

It was missed during the conversion of kernel configs.
Although the driver is already built as a kernel module we might
want to have it built-in for diskless booting and such.

2 years agotcp_wrappers: get rid of duplicate fgets declarations
Kyle Evans [Thu, 30 Sep 2021 04:21:24 +0000 (23:21 -0500)]
tcp_wrappers: get rid of duplicate fgets declarations

This is declared in stdio.h, no need for this one.

2 years agolibc: ssp: sprinkle around some __dead2
Kyle Evans [Wed, 29 Sep 2021 21:48:20 +0000 (16:48 -0500)]
libc: ssp: sprinkle around some __dead2

This is consistent with, e.g., NetBSD's implementation, which declares
these as noreturn in ssp/ssp.h.

2 years agobootp: remove the USE_BFUNCS knob
Kyle Evans [Thu, 30 Sep 2021 03:01:34 +0000 (22:01 -0500)]
bootp: remove the USE_BFUNCS knob

We'd likely be better served by converting these to the equivalent mem*
calls, but just kill the knob for now. The b* macros being defined get
in the way of _FORTIFY_SOURCE.

Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D32235

2 years agokqueue: clean up some igor and mandoc -Tlint warnings
Kyle Evans [Thu, 30 Sep 2021 18:22:01 +0000 (13:22 -0500)]
kqueue: clean up some igor and mandoc -Tlint warnings

2 years agokqueue: document how timers with low/past timeouts are handled
Kyle Evans [Thu, 30 Sep 2021 18:19:05 +0000 (13:19 -0500)]
kqueue: document how timers with low/past timeouts are handled

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D32237

2 years agokqueue: don't arbitrarily restrict long-past values for NOTE_ABSTIME
Kyle Evans [Wed, 29 Sep 2021 19:55:59 +0000 (14:55 -0500)]
kqueue: don't arbitrarily restrict long-past values for NOTE_ABSTIME

NOTE_ABSTIME values are converted to values relative to boottime in
filt_timervalidate(), and negative values are currently rejected.  We
don't reject times in the past in general, so clamp this up to 0 as
needed such that the timer fires immediately rather than imposing what
looks like an arbitrary restriction.

Another possible scenario is that the system clock had to be adjusted
by ~minutes or ~hours and we have less than that in terms of uptime,
making a reasonable short-timeout suddenly invalid. Firing it is still
a valid choice in this scenario so that applications can at least
expect a consistent behavior.

Reviewed by: kib, markj
Discussed with: allanjude
Differential Revision: https://reviews.freebsd.org/D32230

2 years agoImport ACPICA 20210930
Jung-uk Kim [Thu, 30 Sep 2021 20:23:21 +0000 (16:23 -0400)]
Import ACPICA 20210930

(cherry picked from commit c509b6ab0d7e5bafc5348b08653b8738bd40716e)

2 years agoEFI loader: Don't free bcache for DEVT_DISK devs
Colin Percival [Thu, 30 Sep 2021 21:48:14 +0000 (14:48 -0700)]
EFI loader: Don't free bcache for DEVT_DISK devs

Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os
performed from 609 to 432, reduces the total number of blocks read
from 61963 to 60797, and reduces the time spent in the loader by 39 ms.

Note that b4cb3fe0e39a allowed the bcache to be retained for most of
the boot process, but relies on mounting filesystems; this commit
allows the bcache to be retained at the start of the boot process,
before the root filesystem has been located.

Reviewed by: imp, tsoome
MFC after: 1 week
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32239

2 years agojail(3lua): add jail.attach()/jail.remove() methods
Kyle Evans [Fri, 23 Oct 2020 17:52:31 +0000 (12:52 -0500)]
jail(3lua): add jail.attach()/jail.remove() methods

These aren't a part of or use libjail(3), but rather are direct
syscalls.  Still, they seem like good additions, allowing us to attach
to already-running jails.

Reviewed by: freqlabs
Differential Revision: https://reviews.freebsd.org/D26927

2 years agojail(3lua): add a jail.list() method
Kyle Evans [Tue, 13 Oct 2020 02:11:14 +0000 (21:11 -0500)]
jail(3lua): add a jail.list() method

This is implemented as an iterator, reusing parts of the earlier logic
to populate jailparams from a passed in table.

The user may request any number of parameters to pull in while we're
searching, but we'll force jid and name to appear at a minimum.

Reviewed by: freqlabs
Differential Revision: https://reviews.freebsd.org/D26756

2 years agouart: Match simple comm
Warner Losh [Thu, 30 Sep 2021 20:16:19 +0000 (14:16 -0600)]
uart: Match simple comm

Match the PCI simple comm devices (or try to). Be conservative and use
legacy interrupts rather than msi messages by default for this 'catch
all' since it matches what Linux does (it has opt-in generally for MSI,
but also matches more devices because it does a catch-all like
implemented in this commit).

Sponsored by: Netflix
Reviewed by: kbowling
Differential Revision: https://reviews.freebsd.org/D32228

2 years agouart: Allow PCI quirk for not using MSI interrupts
Warner Losh [Thu, 30 Sep 2021 20:15:32 +0000 (14:15 -0600)]
uart: Allow PCI quirk for not using MSI interrupts

Some setups claim to have one MSI, but they don't actually work. Allow
these to be flagged.

Sponsored by: Netflix
Reviewed by: kbowling
Differential Revision: https://reviews.freebsd.org/D32229

2 years agomgb: Fix nop admin interrupt handling
Ed Maste [Wed, 29 Sep 2021 21:24:39 +0000 (17:24 -0400)]
mgb: Fix nop admin interrupt handling

Previously mgb_admin_intr printed a diagnostic message if no interrupt
status bits were set, but it's not valid to call device_printf() from a
filter.  Just drop the message as it has no user-facing value.

Also return FILTER_STRAY in this case - there is nothing further for
the driver to do.

Reviewed by: kbowling
MFC after: 1 week
Fixes: 8890ab7758b8 ("Introduce if_mgb driver...")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32231

2 years agonet80211: prevent plaintext injection by A-MSDU RFC1042/EAPOL frames
Mathy Vanhoef [Sun, 6 Jun 2021 22:10:56 +0000 (22:10 +0000)]
net80211: prevent plaintext injection by A-MSDU RFC1042/EAPOL frames

No longer accept plaintext A-MSDU frames that start with an RFC1042
header with EtherType EAPOL.  This is done by only accepting EAPOL
packets that are included in non-aggregated 802.11 frames.

Note that before this patch, FreeBSD also only accepted EAPOL frames
that are sent in a non-aggregated 802.11 frame due to bugs in
processing EAPOL packets inside A-MSDUs. In other words,
compatibility with legitimate devices remains the same.

This relates to section 6.5 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by: Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security: CVE-2020-26144
PR: 256120
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D30665

2 years agonet80211: mitigation against A-MSDU design flaw
Mathy Vanhoef [Sun, 6 Jun 2021 22:10:52 +0000 (22:10 +0000)]
net80211: mitigation against A-MSDU design flaw

Mitigate A-MSDU injection attacks by detecting if the destination address
of a subframe equals an RFC1042 (i.e., LLC/SNAP) header, and if so
dropping the complete A-MSDU frame.  This mitigates known attacks,
although new (unknown) aggregation-based attacks may remain possible.

This defense works because in A-MSDU aggregation injection attacks, a
normal encrypted Wi-Fi frame is turned into an A-MSDU frame. This means
the first 6 bytes of the first A-MSDU subframe correspond to an RFC1042
header. In other words, the destination MAC address of the first A-MSDU
subframe contains the start of an RFC1042 header during an aggregation
attack. We can detect this and thereby prevent this specific attack.

This relates to section 7.2 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by: Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security: CVE-2020-24588
PR: 256119
Differential Revision: https://reviews.freebsd.org/D30664

2 years agonet80211: reject mixed plaintext/encrypted fragments
Mathy Vanhoef [Sun, 6 Jun 2021 22:10:41 +0000 (22:10 +0000)]
net80211: reject mixed plaintext/encrypted fragments

ieee80211_defrag() accepts fragmented 802.11 frames in a protected Wi-Fi
network even when some of the fragments are not encrypted.
Track whether the fragments are encrypted or not and only accept
successive ones if they match the state of the first fragment.

This relates to section 6.3 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by: Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security: CVE-2020-26147
PR: 256118
Differential Revision: https://reviews.freebsd.org/D30663

2 years agolibpmc: add some AMD pmu counter aliases
Mitchell Horne [Thu, 30 Sep 2021 14:13:37 +0000 (11:13 -0300)]
libpmc: add some AMD pmu counter aliases

Make it mostly compatible with what's defined for Intel. Except where
noted, these are defined for all of amdzen(1|2|3).

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

2 years agolibpmc: fix the 'cycles' event alias on x86
Mitchell Horne [Thu, 30 Sep 2021 14:11:36 +0000 (11:11 -0300)]
libpmc: fix the 'cycles' event alias on x86

Looking for "tsc-tsc" in the pmu tables will fail every time. Instead,
make this an alias for the static TSC event defined in pmc_events.h.
This fixes 'pmcstat -s cycles' on Intel and AMD.

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

2 years agolinprocfs: find cwd and root handling
Mateusz Guzik [Thu, 30 Sep 2021 10:50:18 +0000 (12:50 +0200)]
linprocfs: find cwd and root handling

The code would incorrectly use curthread instead of the target proc to
resolve vnodes.

Fixes: 8d03b99b9dafe928 ("fd: move vnodes out of filedesc into a dedicated structure")
PR: 258729
Noted by:  Damjan Jovanovic <damjan.jov@gmail.com>

2 years agofd: add pwd_hold_proc
Mateusz Guzik [Thu, 30 Sep 2021 10:49:51 +0000 (12:49 +0200)]
fd: add pwd_hold_proc

2 years agoocs_fc: Fix device lost timer where device is not getting deleted.
Ram Kishore Vegesna [Fri, 24 Sep 2021 09:35:30 +0000 (15:05 +0530)]
ocs_fc: Fix device lost timer where device is not getting deleted.

Issue: Devices wont go away after the link down.

Device lost timer functionality in ocs_fc is broken,
`is_target` flag is not set in the target database and target delete is skipped.

Fix: Remove unused flags and delete the device when timer expires.

Reported by: ken@kdm.org
Reviewed by: mav, ken

2 years agoocs_fc: When commands complete with an error, freeze the device queue.
Ram Kishore Vegesna [Fri, 24 Sep 2021 09:32:09 +0000 (15:02 +0530)]
ocs_fc: When commands complete with an error, freeze the device queue.

Proper error recovery depends on freezing the device queue when an
error occurs, so we can recover from an error before sending
additional commands.

The ocs_fc(4) driver was not freezing the device queue for most
SCSI errors, and that broke error recovery.

sys/dev/ocs_fc/ocs_cam.c:
In ocs_scsi_initiator_io_cb(), freeze the device queue if
        we're passing back status other than CAM_REQ_CMP.

Submitted by: ken@kdm.org
Reviewed by: mav, ken

2 years agoocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned.
Ram Kishore Vegesna [Fri, 24 Sep 2021 09:19:49 +0000 (14:49 +0530)]
ocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned.

        In ocs_scsi_initiator_io_cb(), if the SCSI command that is
        getting completed had a residual equal to the transfer length,
        it was setting the CCB status to CAM_REQ_CMP.

        That breaks the expected behavior for commands like READ ATTRIBUTE.
        For READ ATTRIBUTE, if the first attribute requested doesn't exist,
        the command is supposed to return an error (Illegal Request,
        Invalid Field in CDB).  The broken behavior for READ ATTRIBUTE
        caused LTFS tape formatting to fail.  It looks for attribute
        0x1623, and expects to see an error if the attribute isn't present.

        In addition, if the residual is negative (indicating an overrun),
        only set the CCB status to CAM_DATA_RUN_ERR if we have not already
        reported an error.  The SCSI sense data will have more detail about
        what went wrong.

        sys/dev/ocs_fc/ocs_cam.c:
                In ocs_scsi_initiator_io_cb(), don't set the status to
                CAM_REQ_CMP if the residual is equal to the transfer length.

                Also, only set CAM_DATA_RUN_ERR if we didn't get SCSI
                status.

Submitted by: ken@kdm.org
Reviewed by: mav, ken

2 years agoocs_fc: Increase maximum supported SG elements to support larger transfer sizes.
Ram Kishore Vegesna [Fri, 24 Sep 2021 09:05:03 +0000 (14:35 +0530)]
ocs_fc: Increase maximum supported SG elements to support larger transfer sizes.

Reported by: ken@kdm.org
Reviewed by: mav, ken

2 years agoocs_fc: Emulex Gen 7 HBA support.
Ram Kishore Vegesna [Thu, 23 Sep 2021 06:51:26 +0000 (12:21 +0530)]
ocs_fc: Emulex Gen 7 HBA support.

Emulex Gen7 adapter support in ocs_fc driver.

Reviewed by: mav, ken

2 years agomodules: iichid: needs opt_acpi.h
Kyle Evans [Thu, 30 Sep 2021 03:47:15 +0000 (22:47 -0500)]
modules: iichid: needs opt_acpi.h

This fixes the standalone build.

2 years agomodules: a lot: need opt_kern_tls.h
Kyle Evans [Thu, 30 Sep 2021 04:07:17 +0000 (23:07 -0500)]
modules: a lot: need opt_kern_tls.h

This fixes the standalone build.

2 years agomodules: p2sb: need opt_platform.h
Kyle Evans [Thu, 30 Sep 2021 04:04:52 +0000 (23:04 -0500)]
modules: p2sb: need opt_platform.h

This fixes the standalone build.

2 years agomodules: netflow: need opt_inet.h
Kyle Evans [Thu, 30 Sep 2021 04:04:18 +0000 (23:04 -0500)]
modules: netflow: need opt_inet.h

This fixes the standalone build.

2 years agomodules: acpi_video: need opt_evdev.h
Kyle Evans [Thu, 30 Sep 2021 04:04:00 +0000 (23:04 -0500)]
modules: acpi_video: need opt_evdev.h

This fixes the standalone build.

2 years agobluetooth: Remove one more h4 reference.
Warner Losh [Thu, 30 Sep 2021 04:02:25 +0000 (22:02 -0600)]
bluetooth: Remove one more h4 reference.

Sponsored by: Netflix

2 years agobluetooth: Remove stray btccc references
Warner Losh [Thu, 30 Sep 2021 03:58:27 +0000 (21:58 -0600)]
bluetooth: Remove stray btccc references

The 3com bluetooth PC Card adapter was removed from the tree when PC
Card support was removed earlier this year. Remove stray references to
it still in the tree.

Sponsored by: Netflix

2 years agobluetooth: remove hcseriald
Warner Losh [Thu, 30 Sep 2021 03:08:30 +0000 (21:08 -0600)]
bluetooth: remove hcseriald

Without ng_h4 gone, there's no need for hcseriald.

Sponsored by: Netflix

2 years agobluetooth: Fix build after ng_h4 removal
Jung-uk Kim [Thu, 30 Sep 2021 03:10:56 +0000 (23:10 -0400)]
bluetooth: Fix build after ng_h4 removal

It was caused by 79a100e28e3c814773bb4c1826cfa25fbe31140e.

2 years agofd: Move from using device_busy to a refcount
Warner Losh [Thu, 30 Sep 2021 02:18:28 +0000 (20:18 -0600)]
fd: Move from using device_busy to a refcount

Use refcounting to delay the detach rather than device_busy and/or
device_unbusy. fd/fdc is one of the few consumers of device_busy in the
tree for that, and it's not a good fit. Also, nothing is waking 'fd' and
other drivers don't loop like this. Return EBUSY if we still have active
users.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D31830

2 years agoloader.efi: remove extra extern ST
Warner Losh [Thu, 30 Sep 2021 02:07:13 +0000 (20:07 -0600)]
loader.efi: remove extra extern ST

The definition for 'ST' is in efilib.h, so we don't need extern ST here.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D32225

2 years agobluetooth: complete removal of ng_h4
Warner Losh [Sun, 5 Sep 2021 18:41:16 +0000 (12:41 -0600)]
bluetooth: complete removal of ng_h4

The ng_h4 module was disconnected 13 years ago when the tty later was
locked by Ed. It completely fails to compile, and has a number of false
positives for Giant use. Remove it for lack of interest. Bluetooth has
largely (completely?) moved on from bluetooth over UART transport.

OK'd by: emax
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31846

2 years agoida: Use ida lock instead of Giant for bus_dma allocation
Warner Losh [Thu, 30 Sep 2021 01:05:39 +0000 (19:05 -0600)]
ida: Use ida lock instead of Giant for bus_dma allocation

It looks like a reference to Giant was overloooked when jhb made this
MPSAFE in 6b5b57ae9f8f.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31841

2 years agoipfilter: Save time and cycles swapping bucket table sizes
Cy Schubert [Tue, 28 Sep 2021 03:04:18 +0000 (20:04 -0700)]
ipfilter: Save time and cycles swapping bucket table sizes

NAT hash tables are inverted for inbound vs outbound. Rather than spend
the time and cycles swapping them, let's simply calculate the bucket
lengths inversely.

MFC after: 1 week

2 years agoloader_lua.8: Fix first version
Warner Losh [Wed, 29 Sep 2021 23:14:14 +0000 (17:14 -0600)]
loader_lua.8: Fix first version

Lua bindings appeared in FreeBSD 12.0. Delete the authors section of the
man page, since it's unclear who wrote different parts of the man
page.

Noted by: Trond Endrestol
Sponsored by: Netflix

2 years agoBump __FreeBSD_version to 1400034 for LinuxKPI changes
Vladimir Kondratyev [Wed, 29 Sep 2021 20:26:46 +0000 (23:26 +0300)]
Bump __FreeBSD_version to 1400034 for LinuxKPI changes

2 years agoLinuxKPI: Remove vma argument from fault method of vm_operations_struct
Vladimir Kondratyev [Wed, 29 Sep 2021 20:26:32 +0000 (23:26 +0300)]
LinuxKPI: Remove vma argument from fault method of vm_operations_struct

It is removed from Linux since 4.11.
In FreeBSD it results in several #ifdefs in drm-kmod.

Reviewed by: emaste, hselasky, manu
Differential revision: https://reviews.freebsd.org/D32169

2 years agoLinuxKPI: Hide some internal symbols in linux_interrupt.c
Vladimir Kondratyev [Wed, 29 Sep 2021 20:26:14 +0000 (23:26 +0300)]
LinuxKPI: Hide some internal symbols in linux_interrupt.c

Reviewed by: hselasky, manu
Differential revision: https://reviews.freebsd.org/D32168

2 years agoLinuxKPI: Import linux_page.c and some dependent code from drm-kmod
Vladimir Kondratyev [Wed, 29 Sep 2021 20:15:37 +0000 (23:15 +0300)]
LinuxKPI: Import linux_page.c and some dependent code from drm-kmod

No functional changes intended

Reviewed by: hselasky, manu, markj
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32167

2 years agoLinuxKPI: Update pte_fn_t definition to match Linux 5.3
Vladimir Kondratyev [Wed, 29 Sep 2021 20:15:27 +0000 (23:15 +0300)]
LinuxKPI: Update pte_fn_t definition to match Linux 5.3

Reviewed by: emaste, hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32166

2 years agoLinuxKPI: Implement backlight_enable and backlight_disable functions
Vladimir Kondratyev [Wed, 29 Sep 2021 20:15:12 +0000 (23:15 +0300)]
LinuxKPI: Implement backlight_enable and backlight_disable functions

For now, disable backlight if brightness level is set to 0.
In the future we may implement separate knob in backlight(8).

Required by drm-kmod v5.6

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32165

2 years agoLinuxKPI: Add dummy pgprot_decrypted() implementation
Vladimir Kondratyev [Wed, 29 Sep 2021 20:14:58 +0000 (23:14 +0300)]
LinuxKPI: Add dummy pgprot_decrypted() implementation

to reduce number of #ifdefs in drm-kmod

Reviewed by: hselasky
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32094

2 years agoLinuxKPI: Cast offset_in_page() parameter to unsigned long
Vladimir Kondratyev [Wed, 29 Sep 2021 20:14:47 +0000 (23:14 +0300)]
LinuxKPI: Cast offset_in_page() parameter to unsigned long

to reduce number of patches in drm-kmod

Reviewed by: hselasky
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32093

2 years agoLinuxKPI: Import linux/poison.h header
Vladimir Kondratyev [Wed, 29 Sep 2021 20:14:34 +0000 (23:14 +0300)]
LinuxKPI: Import linux/poison.h header

Required by drm-kmod 5.6

Reviewed by: hselasky, imp, manu
MFC after: 2 weeks
Obtained from: OpenBSD
Differential revision: https://reviews.freebsd.org/D32092

2 years agoLinuxKPI: Add helper functions to store integers to linux/xarray.h
Vladimir Kondratyev [Wed, 29 Sep 2021 20:14:23 +0000 (23:14 +0300)]
LinuxKPI: Add helper functions to store integers to linux/xarray.h

Required by drm-kmod.

Reviewed by: hselasky
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32091

2 years agoLinuxKPI: Allow cdev_pager prefault handler to steal pages
Vladimir Kondratyev [Wed, 29 Sep 2021 20:14:05 +0000 (23:14 +0300)]
LinuxKPI: Allow cdev_pager prefault handler to steal pages

from other vm_objects. This workarounds "Page already inserted" panic
in vm_page_insert routine triggered on attempt to mmap file created
with shmem_file_setup call. After introduction of "GTT mmap
interface v4" a.k.a. MMAP_OFFSET, vm_objects allocated by these calls
may try to own intersected sets of pages that leads to the assertion.

Reviewed by: kib
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32090

2 years agoLinuxKPI: stub anon_inode_getfile
Vladimir Kondratyev [Wed, 29 Sep 2021 20:13:53 +0000 (23:13 +0300)]
LinuxKPI: stub anon_inode_getfile

Although drm-kmod contains better implementation which is able to
allocate real entries on pseudofs, this feature has never been used.

Starting from drm-kmod v5.6 old implementation began to leak entries
on each drm device close(). Now just drop pseudofs support instead of
fixing it in drm-kmod and provide stub in base.

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32069

2 years agoLinuxKPI: Factor out vmf_insert_pfn_prot() routine
Vladimir Kondratyev [Wed, 29 Sep 2021 20:13:41 +0000 (23:13 +0300)]
LinuxKPI: Factor out vmf_insert_pfn_prot() routine

from GEM and TTM page fault handlers and move it in to base system. This
code is tightly integrated with LKPI mmap support to belong to drm-kmod.

As this routine requires associated vm_object to be locked, it got
additional _locked suffix.

Reviewed by: hselasky, markj
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32068

2 years agoLinuxKPI: Invoke release handler when file is destroyed by fput()
Vladimir Kondratyev [Wed, 29 Sep 2021 20:13:27 +0000 (23:13 +0300)]
LinuxKPI: Invoke release handler when file is destroyed by fput()

Required by drm_kmod 5.6

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32067

2 years agoLinuxKPI: allocate current before taking shrinkers lock
Vladimir Kondratyev [Wed, 29 Sep 2021 20:12:58 +0000 (23:12 +0300)]
LinuxKPI: allocate current before taking shrinkers lock

This fixes following warnings when shrinkers are invoked first time:

uma_zalloc_debug: zone "lkpicurr" with the following non-sleepable
locks held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)

uma_zalloc_debug: zone "lkpimm" with the following non-sleepable locks
held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32066

2 years agoLinuxKPI: implement _IOC_TYPE and _IOC_NR macros in linux/ioctl.h
Vladimir Kondratyev [Wed, 29 Sep 2021 20:12:47 +0000 (23:12 +0300)]
LinuxKPI: implement _IOC_TYPE and _IOC_NR macros in linux/ioctl.h

They are used by drm-kmod

Reviewed by: emaste, hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31674

2 years agoLinuxKPI: Remove FreeBSD struct resource from all LKPI headers
Vladimir Kondratyev [Wed, 29 Sep 2021 20:12:36 +0000 (23:12 +0300)]
LinuxKPI: Remove FreeBSD struct resource from all LKPI headers

except linux/pci.h to avoid conflicts with Linux version.
This allows to #define resource in drm-kmod globally and strip some #ifdef-s

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31673

2 years agoLinuxKPI: Implement get_file_rcu()
Vladimir Kondratyev [Wed, 29 Sep 2021 20:12:25 +0000 (23:12 +0300)]
LinuxKPI: Implement get_file_rcu()

get_file_rcu() grabs a file if the file->f_count is not zero.

Required by drm-kmod 5.6

Reviewed by: hselasky, manu (previous version)
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31672

2 years agominidump: De-duplicate the progress bar
Mitchell Horne [Wed, 29 Sep 2021 17:44:27 +0000 (14:44 -0300)]
minidump: De-duplicate the progress bar

The implementation of the progress bar is simple, but duplicated for
most minidump implementations. Extract the common bits to kern_dump.c.
Ensure that the bar is reset with each subsequent dump; this was only
done on some platforms previously.

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31885

2 years agominidump: De-duplicate is_dumpable()
Mitchell Horne [Wed, 29 Sep 2021 17:30:11 +0000 (14:30 -0300)]
minidump: De-duplicate is_dumpable()

The function is identical in each minidump implementation, so move it to
vm_phys.c. The only slight exception is powerpc where the function was
public, for use in moea64_scan_pmap().

Reviewed by: kib, markj, imp (earlier version)
MFC after: 2 weeks
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31884

2 years agocmp: add -b, --print-bytes
Kyle Evans [Thu, 23 Sep 2021 05:46:30 +0000 (00:46 -0500)]
cmp: add -b, --print-bytes

This is compatible with GNU cmp.

Reviewed by: bapt, markj (earlier version)
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D32074

2 years agocmp: add -i, --ignore-initial, an alternative to skip1/skip2 args
Kyle Evans [Thu, 23 Sep 2021 05:43:32 +0000 (00:43 -0500)]
cmp: add -i, --ignore-initial, an alternative to skip1/skip2 args

This is compatible with GNU cmp.

Reviewed by: markj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D32073

2 years agocmp: add -n, --bytes to limit number of bytes to compare
Kyle Evans [Thu, 23 Sep 2021 05:26:52 +0000 (00:26 -0500)]
cmp: add -n, --bytes to limit number of bytes to compare

This is compatible with GNU cmp.

Reviewed by: markj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D32072

2 years agocmp: accept SI suffixes for skip1 and skip2
Kyle Evans [Thu, 23 Sep 2021 05:17:07 +0000 (00:17 -0500)]
cmp: accept SI suffixes for skip1 and skip2

This is compatible with GNU cmp.

Reviewed by: bapt (earlier version), markj, imp
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D32071

2 years agoFix error return of kern.ipc.posix_shm_list, which caused it (and thus
Jamie Gritton [Wed, 29 Sep 2021 17:20:36 +0000 (10:20 -0700)]
Fix error return of kern.ipc.posix_shm_list, which caused it (and thus
"posixshmcontrol ls") to fail for all jails that didn't happen to own
the last shm object in the list.

2 years agoAdd the arm64 table attributes and use them
Andrew Turner [Thu, 23 Sep 2021 15:00:55 +0000 (15:00 +0000)]
Add the arm64 table attributes and use them

Add the table page table attributes on arm64 and use them to add
restrictions to the block and page entries below them. This ensures
we are unable to increase the permissions in these last level entries
without also changing them in the upper levels.

Use the attributes to ensure the kernel can't execute from userspace
memory and vice versa, userspace has no access to read or write kernel
memory, and that the DMAP region is non-executable.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32081

2 years agof00f: We don't need giant to create IDT for workaround.
Warner Losh [Wed, 29 Sep 2021 16:19:51 +0000 (10:19 -0600)]
f00f: We don't need giant to create IDT for workaround.

We don't need to assert we have Giant here. All machines that require
the F00F workaround are UP and interrupts are disabled. Since we are
single threaded, it's safe to allocate the IDT area with pmap_trm_alloc,
interact with the current idt table and replace the IDT table without
any Giant locking.

Sponsored by: Netflix
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D31839

2 years agoloader: create separate man pages for each of the loaders
Warner Losh [Wed, 29 Sep 2021 15:21:17 +0000 (09:21 -0600)]
loader: create separate man pages for each of the loaders

Create a man page per loader. Loader(8) will have information common to
all of them, while loader_${INTERP}(8) will have information relevant to
that specific loader. Rewrite loader(8) to give an overview and point to
the appropriate man page. Rewrite each of the loader_${INTER}(8) man
pages to contain only the relevant information to that loader. Put all
the common commands, environment variables, etc in loader_simp(8) and
refernce that from the loader_lua or loader_4th man pages. The
loader_lua(8) could use more details about the Lua
integration. Additional organization may be benefitial.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31340

2 years agoRevert "mgb: Use MGB_DEBUG instead of DEBUG"
Ed Maste [Wed, 29 Sep 2021 15:04:23 +0000 (11:04 -0400)]
Revert "mgb: Use MGB_DEBUG instead of DEBUG"

This reverts commit 5aa9f8dae3d40e1780a688ce01401e799b25e7c3.

We might as well get coverage of this code via LINT.

Reported by: mhorne

2 years agosdhci: add a missing newline
Mitchell Horne [Wed, 29 Sep 2021 00:10:26 +0000 (21:10 -0300)]
sdhci: add a missing newline

2 years agosdhci_xenon: add ACPI support
Bartlomiej Grzesik [Wed, 21 Jul 2021 14:36:11 +0000 (16:36 +0200)]
sdhci_xenon: add ACPI support

Add support for ACPI device probing for SDHCI controller found on Marvell chips.

Reviewed by: mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31600

2 years agosdhci_xenon: split driver file into generic file and fdt parts
Bartlomiej Grzesik [Thu, 15 Jul 2021 12:29:15 +0000 (14:29 +0200)]
sdhci_xenon: split driver file into generic file and fdt parts

This patch splits driver code into two seperate files sdhci_xenon.c
and sdhci_xenon_fdt.c. This will allow future implementation of ACPI
discovery of sdhci on Xenon chips.

Reviewed by: mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31599

2 years agomgb: Use MGB_DEBUG instead of DEBUG
Ed Maste [Wed, 29 Sep 2021 13:59:10 +0000 (09:59 -0400)]
mgb: Use MGB_DEBUG instead of DEBUG

The debug register dump routine is not hooked up and is really only
useful to driver developers, so put it under an mgb-specific MGB_DEBUG
rather than general DEBUG.

MFC after: 1 week
Fixes: 8890ab7758b8 ("Introduce if_mgb driver...")
Sponsored by: The FreeBSD Foundation

2 years agoLinuxKPI: fix build
Bjoern A. Zeeb [Wed, 29 Sep 2021 13:50:12 +0000 (13:50 +0000)]
LinuxKPI: fix build

Add a missing "static" for non-{i386,amd64,arm64} which was missed in
c39eefe715b3c835ce3d91a1c1932197c23c1f3c.   This should ifx the builds.

Sponsored by: The FreeBSD Foundation
MFC after: 7 days
X-MFC with: c39eefe715b3c835ce3d91a1c1932197c23c1f3c

2 years agosyslogd: Fix bug that caused -N to drop SecureMode if specified after -s
jfranklin13 [Tue, 28 Sep 2021 14:49:15 +0000 (16:49 +0200)]
syslogd: Fix bug that caused -N to drop SecureMode if specified after -s

MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/541

2 years agopf tests: Basic adaptive mode syncookie test
Kristof Provost [Sat, 25 Sep 2021 13:05:02 +0000 (15:05 +0200)]
pf tests: Basic adaptive mode syncookie test

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32139

2 years agopf tests: Basic syncookie test
Kristof Provost [Sat, 10 Jul 2021 11:20:44 +0000 (13:20 +0200)]
pf tests: Basic syncookie test

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32138

2 years agopf.conf: document syncookies
Kristof Provost [Sat, 14 Aug 2021 08:42:03 +0000 (10:42 +0200)]
pf.conf: document syncookies

Reviewed by: bcr
Obtained from: OpenBSD
MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32137

2 years agopfctl: userspace adaptive syncookies configration
Kristof Provost [Fri, 13 Aug 2021 11:42:59 +0000 (13:42 +0200)]
pfctl: userspace adaptive syncookies configration

Hook up the userspace bits to configure syncookies in adaptive mode.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32136

2 years agopf: hook up adaptive mode configuration
Kristof Provost [Sat, 24 Jul 2021 12:23:59 +0000 (14:23 +0200)]
pf: hook up adaptive mode configuration

The kernel side of pf syncookie adaptive mode configuration.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32135

2 years agopf: implement adaptive mode
Kristof Provost [Sat, 24 Jul 2021 11:59:34 +0000 (13:59 +0200)]
pf: implement adaptive mode

Use atomic counters to ensure that we correctly track the number of half
open states and syncookie responses in-flight.
This determines if we activate or deactivate syncookies in adaptive
mode.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D32134

2 years agommc: Fix regression in 8a8166e5bcfb breaking Stratix 10 boot
Jessica Clarke [Wed, 29 Sep 2021 12:59:13 +0000 (13:59 +0100)]
mmc: Fix regression in 8a8166e5bcfb breaking Stratix 10 boot

The refactoring in 8a8166e5bcfb introduced a functional change that
breaks booting on the Stratix 10, hanging when it should be attaching
da0. Previously OF_getencprop was called with a pointer to host->f_max,
so if it wasn't present then the existing value was left untouched, but
after that commit it will instead clobber the value with 0. The dwmmc
driver, as used on the Stratix 10, sets a default value before calling
mmc_fdt_parse and so was broken by this functional change. It appears
that aw_mmc also does the same thing, so was presumably also broken on
some boards.

Fixes: 8a8166e5bcfb ("mmc: switch mmc_helper to device_ api")
Reviewed by: manu, mw
Differential Revision: https://reviews.freebsd.org/D32209

2 years agoLinuxKPI: implement dma_set_coherent_mask()
Bjoern A. Zeeb [Mon, 27 Sep 2021 22:50:07 +0000 (22:50 +0000)]
LinuxKPI: implement dma_set_coherent_mask()

Coherent is lower 32bit only by default in Linux and our only default
dma mask is 64bit currently which violates expectations unless
dma_set_coherent_mask() was called explicitly with a different mask.

Implement coherent by creating a second tag, and storing the tags in the
objects and use the tag from the object wherever possible.
This currently does not update the scatterlist or pool (both could be
converted but S/G cannot be MFCed as easily).

There is a 2nd change embedded in the updated logic of
linux_dma_alloc_coherent() to always zero the allocation as
otherwise some drivers get cranky on uninialised garbage.

Sponsored by: The FreeBSD Foundation
MFC after: 7 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32164

2 years agoneta: cleanup warning
Bjoern A. Zeeb [Wed, 29 Sep 2021 12:37:16 +0000 (12:37 +0000)]
neta: cleanup warning

mvneta_find_ethernet_prop_switch() is file-local static to
if_mvneta_fdt.c.  Normally we would not need a function declararion
but in case MVNETA_DEBUG is set it becomes public.  Move the
function declaration from if_mvneta.c to if_mvneta_fdt.c to avoid
a warning during each compile.

2 years agomgb: Fix DEBUG (and LINT) build
Li-Wen Hsu [Wed, 29 Sep 2021 08:34:59 +0000 (16:34 +0800)]
mgb: Fix DEBUG (and LINT) build

Sponsored by: The FreeBSD Foundation

2 years agonvme: Sanity check completion id
Warner Losh [Wed, 29 Sep 2021 03:21:50 +0000 (21:21 -0600)]
nvme: Sanity check completion id

Make sure the completion ID is in the range of [0..num_trackers) since
the values past the end of the act_tr array are never going to be valid
trackers and will lead to pain and suffering if we try to dereference
them to get the tracker or to set the tracker back to NULL as we
complete the I/O.

Sponsored by: Netflix
Reviewed by: mav, chs, chuck
Differential Revision: https://reviews.freebsd.org/D32088

2 years agonvme: count number of ignored interrupts
Warner Losh [Wed, 29 Sep 2021 03:13:11 +0000 (21:13 -0600)]
nvme: count number of ignored interrupts

Count the number of times we're asked to process completions, but that
we ignore because the state of the qpair isn't in RECOVERY_NONE.

Sponsored by: Netflix
Reviewed by: mav, chuck
Differential Revision: https://reviews.freebsd.org/D32212

2 years agonvme: Add sanity check for phase on startup.
Warner Losh [Wed, 29 Sep 2021 03:11:17 +0000 (21:11 -0600)]
nvme: Add sanity check for phase on startup.

The proper phase for the qpiar right after reset in the first interrupt
is 1. For it, make sure that we're not still in phase 0. This is an
illegal state to be processing interrupts and indicates that we've
failed to properly protect against a race between initializing our state
and processing interrupts. Modify stat resetting code so it resets the
number of interrpts to 1 instead of 0 so we don't trigger a false
positive panic.

Sponsored by: Netflix
Reviewed by: cperciva, mav (prior version)
Differential Revision: https://reviews.freebsd.org/D32211

2 years agonvme: start qpair in state RECOVERY_WAITING
Warner Losh [Wed, 29 Sep 2021 03:09:45 +0000 (21:09 -0600)]
nvme: start qpair in state RECOVERY_WAITING

An interrupt happens on the admin queue right away after the reset, so
as soon as we enable interrupts, we'll get a call to our interrupt
handler. It is safe to ignore this interrupt if we're not yet
initialized, or to process it if we are. If we are initialized, we'll
see there's no completion records and return. If we're not, we'll
process no completion records and return. Either way, nothing is
processed and nothing is lost.

Until we've completely setup the qpair, we need to avoid processing
completion records. Start the qpair in the waiting recovery state so we
return immediately when we try to process completions. The code already
sets it to 'NONE' when we're initialization is complete. It's safe to
defer completion processing here because we don't send any commands
before the initialization of the software state of the qpair is
complete. And even if we were to somehow send a command prior to that
completing, the completion record for that command would be processed
when we send commands to the admin qpair after we've setup the software
state. There's no good central point to add an assert for this last
condition.

This fixes an KASSERT "received completion for unknown cmd" panic on
boot.

Fixes: 502dc84a8b6703e7c0626739179a3cdffdd22d81
Sponsored by: Netflix
Reviewed by: mav, cperciva, gallatin
Differential Revision: https://reviews.freebsd.org/D32210

2 years agomgb: Connect if_mgb module to the build
Ed Maste [Tue, 28 Sep 2021 16:58:40 +0000 (12:58 -0400)]
mgb: Connect if_mgb module to the build

It supports the following Microchip devices:

LAN7430 PCIe Gigabit Ethernet controller with PHY
LAN7431 PCIe Gigabit Ethernet controller with RGMII interface

The driver has a number of caveats and limitations, but is functional.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

2 years agosctp: provide a specific stream scheduler function for FCFS
Michael Tuexen [Wed, 29 Sep 2021 00:08:37 +0000 (02:08 +0200)]
sctp: provide a specific stream scheduler function for FCFS

A KASSERT in the genric routine does not apply and triggers
incorrectly.

Reported by: syzbot+8435af157238c6a11430@syzkaller.appspotmail.com
MFC after: 1 week

2 years agoloader: Set twiddle globaldiv to 16 by default
Colin Percival [Tue, 28 Sep 2021 18:39:59 +0000 (11:39 -0700)]
loader: Set twiddle globaldiv to 16 by default

Booting FreeBSD on an EC2 c5.xlarge instance, the loader "twiddles"
810 times over the course of 510 ms, a rate of 1.59 kHz. Even accepting
that many systems are slower than this particular VM and will take
longer to boot (especially if using spinning-rust disks), this seems
like an unhelpfully large amount of twiddling when compared to the
~60 Hz frame rate of many displays; printing the twiddles also consumes
roughly 10% of the boot time on the aforementioned VM.

Setting the default globaldiv to 16 dramatically reduces the time spent
printing twiddles to the console while still twiddling at roughly 100
Hz; this should be ample even for systems which take longer to boot and
consequently twiddle slower.

Note that this can adjusted via the twiddle_divisor variable in
loader.conf, but that file is not processed until nearly halfway
through the loader's runtime.

Reviewed by: allanjude, jrtc27, kevans
MFC after: 1 week
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: <https://reviews.freebsd.org/D32163>