]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
16 months agovm_fault: Fix a race in vm_fault_soft_fast()
Mark Johnston [Mon, 13 Feb 2023 21:24:40 +0000 (16:24 -0500)]
vm_fault: Fix a race in vm_fault_soft_fast()

When vm_fault_soft_fast() creates a mapping, it release the VM map lock
before unbusying the top-level object.  Without the map lock, however,
nothing prevents the VM object from being deallocated while still busy.

Fix the problem by unbusying the object before releasing the VM map
lock.  If vm_fault_soft_fast() fails to create a mapping, the VM map
lock is not released, so those cases don't need to change.

Reported by: syzkaller
Reviewed by: kib (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38527

(cherry picked from commit d0991948182a1a149ee84f1b9c4d3e30450c8f0b)

16 months agonetlink: fix NOINET6 build.
Alexander V. Chernikov [Fri, 24 Feb 2023 10:19:12 +0000 (10:19 +0000)]
netlink: fix NOINET6 build.

Reported by: Michael Paepcke <bugs.fbsd@paepcke.de>
PR: 269787
MFC after: 3 days

(cherry picked from commit efeb8003117073d29bf82c8a69e036b8dbd78352)

16 months agonetlink: fix addition of blackhole/reject routes.
Alexander V. Chernikov [Thu, 23 Feb 2023 17:38:18 +0000 (17:38 +0000)]
netlink: fix addition of blackhole/reject routes.

* Make nhop_set_blackhole() set all necessary properties for the
 nexthop
* Make nexthops blackhole/reject based on the rtm_type netlink
 property instead of using rtflags.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit d2deebe21b591336fbd8915b37d409b25da54d4d)

16 months agoUpdate leap-seconds to latest leap-seconds.3676924800 (expires 2023-12-28)
Dimitry Andric [Fri, 24 Feb 2023 12:17:16 +0000 (13:17 +0100)]
Update leap-seconds to latest leap-seconds.3676924800 (expires 2023-12-28)

Obtained from: ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
MFC after: 3 days

(cherry picked from commit df2fbbfa71b8ecc9e9e75ce85a635aade9c691cb)

16 months agoarm ti: Fix a typo in a kernel message
Gordon Bergling [Wed, 22 Feb 2023 08:43:49 +0000 (09:43 +0100)]
arm ti: Fix a typo in a kernel message

- s/adress/address/

(cherry picked from commit 49bf65be44adc3fbcc64a672530e52afb5cf5555)

16 months agoctf: Remove unused function prototype for getpname()
Zhenlei Huang [Sun, 26 Feb 2023 04:18:25 +0000 (12:18 +0800)]
ctf: Remove unused function prototype for getpname()

This function prototype should have been removed along with the
implementation.

Fixes: 3dd552426409 ctfdump: Use getprogname()
MFC after: 1 day

(cherry picked from commit f8e1aa85fed08d5f689cb36d65a76d191f6500dd)

16 months agoMFC: ARM release build: enable IPv6 SLAAC by default
Joerg Wunsch [Sun, 12 Feb 2023 21:26:52 +0000 (22:26 +0100)]
MFC: ARM release build: enable IPv6 SLAAC by default

When building ARM release images, enable IPv6 SLAAC by default in
addition to IPv4 DHCP.

Unlike amd64 (and other desktop/server) releases, ARM releases on SoC
setups are usually deployed by just using the installation image, so
there is no interactive network configuration. Not having IPv6
included by default is kind of an anachronism these days, given that
FreeBSD with the KAME project once pioneered IPv6 technology.

(cherry picked from commit 57228a49333505aebbc992f3799819667630f255)

16 months agolinux(4): Fixup the interface name translation in netlink
Dmitry Chagin [Thu, 23 Feb 2023 08:01:18 +0000 (11:01 +0300)]
linux(4): Fixup the interface name translation in netlink

Netlink should translate a FreeBSD interface name to a Linux
interface name.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38715
MFC after: 3 days

(cherry picked from commit e55e4a6ba3f4cd31d47b74574ea7370d5ab14b48)

16 months agolinux(4): Consolidate a FreeBSD interface names translation code
Dmitry Chagin [Thu, 23 Feb 2023 08:00:29 +0000 (11:00 +0300)]
linux(4): Consolidate a FreeBSD interface names translation code

We have some amount of interface names translation functions which are
differs by bugs implementation. Consolidates it in a one place.

Fixup loopback interface names translation and use ifnet methods and
accessors, where possible.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38714
MFC after: 3 days
X-MFC with: 32fdc75fe7

(cherry picked from commit 3ab3c9c29cf0e5df8dbbaaf2003456445534bad8)

16 months agolinux(4): Use predefined constant instead of hardcoded value
Dmitry Chagin [Thu, 23 Feb 2023 07:59:34 +0000 (10:59 +0300)]
linux(4): Use predefined constant instead of hardcoded value

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38713
MFC after: 3 days

(cherry picked from commit 200fe6e3a0c8f2fc4fb8f48abd6528418a8a370c)

16 months agolinux(4): Move use_real_names knob to the linux.c
Dmitry Chagin [Tue, 14 Feb 2023 14:46:32 +0000 (17:46 +0300)]
linux(4): Move use_real_names knob to the linux.c

MI linux.[c|h] are the module independent in terms of the Linux emulation
layer (ie, intended for both ISA - 32 & 64 bit), analogue of MD linux.h.
There must be a code here that cannot be placed into the corresponding by
common sense MI source and header files, i.e., code is machine independent,
but ISA dependent.
For the use_real_names knob, the code must be placed into the
linux_socket.[c|h], however linux_socket is ISA dependent.

MFC after: 2 weeks

(cherry picked from commit 32fdc75fe7276083d446964055b0de0e29970b7c)

16 months agolinux(4): Get rid of the opt_compat.h include.
Dmitry Chagin [Sun, 12 Feb 2023 17:24:32 +0000 (20:24 +0300)]
linux(4): Get rid of the opt_compat.h include.

Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed,
so include of opt_compat.h is no more needed.

MFC after: 2 weeks

(cherry picked from commit 10d16789a383a5b9e007dfd4c2e7844e044eaf7d)

16 months agomodules: Add missing opt_*.h files for stand-alone compile
Warner Losh [Sat, 29 Oct 2022 14:49:20 +0000 (08:49 -0600)]
modules: Add missing opt_*.h files for stand-alone compile

Standalone compile that we at least create these opt_*.h files.

Sponsored by: Netflix

(cherry picked from commit 010175a76d0676ff8d9b8d54276aff093abbc3f2)

16 months agoctfdump: Use getprogname()
Zhenlei Huang [Thu, 23 Feb 2023 16:28:35 +0000 (00:28 +0800)]
ctfdump: Use getprogname()

Also remove no longer used function `getpname()`.

Reviewed by: markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38740

(cherry picked from commit 3dd5524264095ed8612c28908e13f80668eff2f9)

16 months agokern/sysv_ipc.c: use ANSI C function definition
Konstantin Belousov [Tue, 21 Feb 2023 14:00:22 +0000 (16:00 +0200)]
kern/sysv_ipc.c: use ANSI C function definition

(cherry picked from commit 836e4b371b6eacc8a7e14cdf30fbced59c343455)

16 months agonetlink: clear IPv6 embedded scope when dumping route gateways.
Alexander V. Chernikov [Tue, 21 Feb 2023 12:25:58 +0000 (12:25 +0000)]
netlink: clear IPv6 embedded scope when dumping route gateways.

Reported by: zarychtam@plan-b.pwste.edu.pl
MFC after: 3 days

(cherry picked from commit b9b2184322da85e1f4d52e3b0a6322dd214210ec)

16 months agonetlink: fix IPv6 route addition with link-local gateway
Alexander V. Chernikov [Mon, 20 Feb 2023 14:24:01 +0000 (14:24 +0000)]
netlink: fix IPv6 route addition with link-local gateway

Currently kernel assumes that IPv6 gateway address is in "embedded"
 form - that is, for the link-local IPv6 addresses, interface index
 is embedded in bytes 2 and 3 of the address.
Fix address embedding in netlink by wrapping nhop_set_gw() in the
 netlink-specific nl_set_nexthop_gw(), which does such embedding
 automatically.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit c7c348162101a70b1f99299578dabe1d3b100e48)

16 months agotesting: handling non-root users with VNETs in pytest-based tests.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:31:34 +0000 (14:31 +0000)]
testing: handling non-root users with VNETs in pytest-based tests.

Currently isolation and resource requirements are handled directly
 by the kyua runner, based on the requirements specified by the test.
It works well for simple tests, but may cause discrepancy with tests
 doing complex pre-setups. For example, all tests that perform
 VNET setups require root access to properly function.

This change adds additional handling of the "require_user" property
 within the python testing framework. Specifically, it requests
 root access if the test class signals its root requirements and
 drops privileges to the desired user after performing the pre-setup.

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

(cherry picked from commit 6332ef8941999b0c074d1ece0e1e108447c70b98)

16 months agonetlink: fix style(9) after c3d3f3594fdf.
Alexander V. Chernikov [Fri, 24 Feb 2023 10:37:51 +0000 (10:37 +0000)]
netlink: fix style(9) after c3d3f3594fdf.

No functional changes.

Reported by: karels

16 months agonetlink: Fix "version introduced" documentation.
Tom Hukins [Fri, 24 Feb 2023 10:25:35 +0000 (10:25 +0000)]
netlink: Fix "version introduced" documentation.

netlink(4) and associated features will exist in FreeBSD 14.0 but they
will also exist in 13.2, an older version, from commits such as 02b958b
and b309249.

Pull Request: #651
MFC after: 1 day

16 months agonproc: denote an incompatiblity with Linux
Mateusz Guzik [Wed, 15 Feb 2023 20:17:27 +0000 (20:17 +0000)]
nproc: denote an incompatiblity with Linux

On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel,
while it does not on FreeBSD.

Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting
the same value, it will automagically unbreak should someone change the
above.

(cherry picked from commit 059320b8c8de73a90514879cd1e2da397584cfde)

16 months agoAdd nproc(1)
Mateusz Guzik [Sat, 4 Feb 2023 23:33:48 +0000 (23:33 +0000)]
Add nproc(1)

This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by: des
Reviewed by: pstef
Differential Revision: https://reviews.freebsd.org/D38386

(cherry picked from commit 48bfd3597654490cdc43bf0f591a539d3a28b590)

16 months agovmm: Fix AP startup compatibility for old bhyve executables
Mark Johnston [Thu, 9 Feb 2023 20:52:35 +0000 (15:52 -0500)]
vmm: Fix AP startup compatibility for old bhyve executables

These changes unbreak AP startup when using a 13.1-RELEASE bhyve
executable with a newer kernel:
- Correct the destination mask for the VM_EXITCODE_IPI message generated
  by an INIT or STARTUP IPI in vlapic_icrlo_write_handler().
- Only initialize vlapics on active vCPUs.  13.1-RELEASE bhyve activates
  AP vCPUs only after the BSP starts them with an IPI, and vmm now
  allocates vcpu structures lazily, so the STARTUP handling in
  vm_handle_ipi() could trigger a page fault.
- Fix an off-by-one setting the vcpuid in a VM_EXITCODE_SPINUP_AP
  message.

Fixes: 7c326ab5bb9a ("vmm: don't lock a mtx in the icr_low write handler")
Reviewed by: jhb, corvink
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38446

(cherry picked from commit b265a2e0d76422f4007e96dd7295ed0aeb846e2d)

16 months agoMFV: zlib 1.2.13.
Xin LI [Fri, 17 Feb 2023 07:57:24 +0000 (23:57 -0800)]
MFV: zlib 1.2.13.

Relnotes: yes

(cherry picked from commit e37bb444aa945ed0725766e986698a09bd61b1b2)

16 months agohastd and hastctl: use zlib's crc32 implementation.
Xin LI [Fri, 3 Feb 2023 07:14:21 +0000 (23:14 -0800)]
hastd and hastctl: use zlib's crc32 implementation.

(cherry picked from commit 6998572a74a98721781ecd5b6829435259f9825a)
(cherry picked from commit fdbfaefefa585537273955fc88d7daf5e86c6f2d)

16 months agoe1000: Fix packet loss on 11th gen and later
Kevin Bowling [Thu, 9 Feb 2023 00:32:54 +0000 (17:32 -0700)]
e1000: Fix packet loss on 11th gen and later

Ungate DMA clock on TGP and later to avoid packet loss.

A similar fix appears in Linux 639e298f432fb058a9496ea16863f53b1ce935fe

This may be needed as far back as SPT but no confirmation from intel or
other OS yet.

Obtained from: OpenBSD (if_em_hw.c 1.116)
Sponsored by: BBOX.io

(cherry picked from commit 56365902147791994157c3a8f75784dafd46dbd8)

16 months agoe1000: Add support for future client platforms
Kevin Bowling [Thu, 9 Feb 2023 01:14:41 +0000 (18:14 -0700)]
e1000: Add support for future client platforms

Sponsored by: BBOX.io

(cherry picked from commit 905ae5881bdc1b9742e08d660d787204c08d6022)

16 months agoe1000: Remove redundant disable_ulp for ich8lan
Kevin Bowling [Wed, 8 Feb 2023 23:17:03 +0000 (16:17 -0700)]
e1000: Remove redundant disable_ulp for ich8lan

This call only makes sense for ich8lan, and the shared code does it in
e1000_setup_init_funcs() above this deletion.

Obtained from: DPDK
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/539

(cherry picked from commit d36fbdb08ff567393a698aaf16f726275901ec96)

16 months ago.github: Attempt to fix and increase robustness of macOS action
Jessica Clarke [Thu, 30 Jun 2022 20:03:26 +0000 (21:03 +0100)]
.github: Attempt to fix and increase robustness of macOS action

Homebrew has added LLVM 14 and made that the default version, but GitHub
continues to install LLVM 13 for now, so it ends up only accessible via
the versioned name and not the unversioned one. We also add an explicit
installation of llvm@13 so that, if GitHub updates the image to using
LLVM 14, the action continues to work, albeit slightly more slowly. This
also ensures the compiler label remains correct rather than outdated, as
has occurred in the past, and that we don't get new versions of LLVM
before we're ready for them, which is especially relevant for stable
branches. This all mirrors how the Ubuntu jobs are configured.

(cherry picked from commit 22f731486e80fdbf679712b2a99605ba97a50264)

16 months ago.github: Restrict permissions on cross-build jobs.
Alex [Thu, 9 Feb 2023 20:12:17 +0000 (12:12 -0800)]
.github: Restrict permissions on cross-build jobs.

(cherry picked from commit aca7ff471acffb59f0f9e2cc4de6363872444fcc)

16 months agoccr,ccp: Fix argument order to sglist_append_vmpages.
John Baldwin [Mon, 6 Feb 2023 21:51:57 +0000 (13:51 -0800)]
ccr,ccp: Fix argument order to sglist_append_vmpages.

The offset comes before the byte count.

Reported by: br
Reviewed by: asomers, markj
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D38375

(cherry picked from commit 70efe1a2fe13642732e56c7f040fe63f62bc6a6b)

16 months ago.github: Switch to v3 of actions/checkout.
John Baldwin [Wed, 21 Dec 2022 00:27:17 +0000 (16:27 -0800)]
.github: Switch to v3 of actions/checkout.

GitHub is emitting a warning that v2 is deprecated due to using
Node.js 12.

Reported by: GitHub
Reviewed by: arichardson, emaste
Differential Revision: https://reviews.freebsd.org/D37769

(cherry picked from commit 54f3a781a2ff980034dfe13ff6323c96fc587f1b)

16 months agoptrace.2: Fix warnings from igor.
John Baldwin [Thu, 15 Dec 2022 19:25:27 +0000 (11:25 -0800)]
ptrace.2: Fix warnings from igor.

Reviewed by: pauamma, imp
Differential Revision: https://reviews.freebsd.org/D37689

(cherry picked from commit 120eff994aeb31671c144a1835c62d9d8789a5a0)

16 months agorc.d/*: Use startmsg instead of echo on start messages
Jose Luis Duran [Sun, 13 Mar 2022 17:54:39 +0000 (18:54 +0100)]
rc.d/*: Use startmsg instead of echo on start messages

By rc.conf(5), setting rc_startmsgs="NO" should silence start messages.

Fix a few rc scripts by using startmsg.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

(cherry picked from commit 19a6267d61a0c3bd6cd56f19ca3f8a67a54f675c)

16 months agoIntroduce startmsg and use it in rc scripts
Jose Luis Duran [Sun, 13 Mar 2022 17:48:06 +0000 (18:48 +0100)]
Introduce startmsg and use it in rc scripts

startmsg is a new rc.subr(8) function function to be used instead of
echo(1) when for boot messages. It replaces the often forgotten

    check_startmsgs && echo ...

with

    startmsg ...

No functional change intended.

I adjusted the commit message and did some final clean-ups of the patch
before committing.

PR: 255207
Reported by: Jose Luis Duran <jlduran@gmail.com>
Reviewed by: imp, 0mp
Approved by: imp (src)
Differential Revision: https://reviews.freebsd.org/D34514

(cherry picked from commit 325ebf37d8efc6488754051fcc2b1aaa40cefd8b)

16 months agoe1000: bump driver version
Kevin Bowling [Wed, 8 Feb 2023 19:25:58 +0000 (12:25 -0700)]
e1000: bump driver version

Incrementing these to avoid confusion in users; we are on par with these
out of tree versions.

Reviewed by: erj
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit 647f2d2bc0cb9357ac083bf2aae4b669167dd66b)

16 months agoe1000: fix I219 hang on reset
Kevin Bowling [Wed, 8 Feb 2023 19:21:45 +0000 (12:21 -0700)]
e1000: fix I219 hang on reset

Clear the rings before reset to avoid a HW hang.

Inspired by em-7.7.8 and DPDK (1fc9701238edcf0541289b9ae15565b6d9d7ab30)

Reviewed by: erj
Sponsored by: BBOX.io
Pull Request: https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit ae1dca798e0f826de46f4ec11914ba4c91928d7a)

16 months agonfscl: Fix interaction between mmap'd and VOP_WRITE file updates
Rick Macklem [Wed, 8 Feb 2023 22:25:01 +0000 (14:25 -0800)]
nfscl: Fix interaction between mmap'd and VOP_WRITE file updates

asomers@ found a problem with the NFS client, where a write to
an NFS mounted file done via mmap(2) was lost when fspacectl(2)
was done before it.  This turned out to be caused by clearing the
dirty bit on pages when the client was doing commit RPCs,
due to the second argument to vfs_busy_pages() being set to 1.
Commit RPCs tell the server to commit previously written data to
stable storage.  However, Commit RPCs do not write data from the
client to the server.  As such, if the dirty bit on the page has
been set by a mmap'd write to an address in the page, it should
not be cleared.  Clearing it causes the mmap'd write to by lost.

This patch fixes the problem by changing the 2nd argument to
vfs_busy_pages() to 0 for this case.

I doubt this bug has affected many, since it was inherited from
the old NFS client and was in 4.3 FreeBSD twenty years ago.
Although fspacectl(2) is FreeBSD 14 specific, a write(2) would
cause the same failure.

PR: 269328

(cherry picked from commit 847967bc4e198a258b030a5864e64e029e7452e5)

16 months agoFix per-jail zfs.mount_snapshot setting
Allan Jude [Sat, 18 Feb 2023 01:44:34 +0000 (01:44 +0000)]
Fix per-jail zfs.mount_snapshot setting

When jail.conf set the nopersist flag during startup, it was
incorrectly destroying the per-jail ZFS settings.

PR: 260160
Reported by: imp (previous version), mm (upstream), freqlabs (upstream)
MFC after: immediately
Sponsored by: Modirum MDPay
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38662

(cherry picked from commit 8b04c1cbfc1cb71a1ce53b3a7855f1d45866fcfb)

16 months agoixl(4): Fix MAC/VLAN filters accounting
Krzysztof Galazka [Wed, 15 Feb 2023 22:28:01 +0000 (14:28 -0800)]
ixl(4): Fix MAC/VLAN filters accounting

- Account for a filter required to enable reception of untagged frames
while registering and unregistering VLANs to avoid trying to add more
filters than HW supports

- While adding MAC/VLAN filters, pre-set matching method field in the
Admin Queue Command response buffer to expected error value to work
around an issue with some FW versions, which do not update that field if
operation fails, and be able correctly track which filters were
configured in HW.

- Remove unused IXL_MAX_FILTERS macro definition

- Update number of available MAC/VLAN filters as in newer FW versions it
was decreased by one.

- Simplify i40e_dma_mem structure

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D37457

(cherry picked from commit 1d02c6b1b859e9f611bc8fe27ca3d2c16ec128c1)

16 months agoixgbe(4): Filter out spurious link up indication
Krzysztof Galazka [Wed, 15 Feb 2023 22:35:40 +0000 (14:35 -0800)]
ixgbe(4): Filter out spurious link up indication

Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D38395

(cherry picked from commit 04a5e6d7cadd06b10169c3c3a560649e7dc7444c)

16 months agoBump __FreeBSD_version after linuxkpi changes.
Emmanuel Vadot [Tue, 21 Feb 2023 08:21:29 +0000 (09:21 +0100)]
Bump __FreeBSD_version after linuxkpi changes.

Needed to have graphics/drm-515-kmod working.

Sponsored by: Beckhoff Automation GmbH & Co. KG

16 months agolinuxkpi: Add more suspend defines
Emmanuel Vadot [Fri, 17 Feb 2023 13:49:52 +0000 (14:49 +0100)]
linuxkpi: Add more suspend defines

Needed by drm 5.15-lts

Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit a0fdaf9a7b34b6f8fdab747f7a198158e66b57ab)

16 months agollvm: make sure to use ELFv2 ABI on powerpc64
Piotr Kubaj [Thu, 16 Feb 2023 23:49:43 +0000 (00:49 +0100)]
llvm: make sure to use ELFv2 ABI on powerpc64

Currently LLVM is more or less set up to use ELFv2, but it still defaults to
ELFv1 in some places. This causes lld to generate broken binaries when used
with LTO.

PR: 269455
Approved by: dim
MFC after: 3 days

(cherry picked from commit a1ffc2fe9ce54a498c410dcab86495569dbaa7cc)

16 months agokern: physmem: improve region coalescing logic
Kyle Evans [Thu, 28 Oct 2021 04:40:08 +0000 (23:40 -0500)]
kern: physmem: improve region coalescing logic

The existing logic didn't take into account newly inserted mappings
wholly contained by an existing region (or vice versa), nor did it
account for weird overlap scenarios.  The latter is probably unlikely
to happen, but the former may happen in UEFI: BootServicesData allocated
within a large chunk of ConventionalMemory.  This situation blows up vm
initialization.

While we're here, remove the "exact match" logic as it's likely wrong;
if an exact match exists with conflicting flags, for instance, then we
should probably be doing something else.  The new logic takes into
account exact matches as part of the overlapping efforts.

Reviewed by: kib, mhorne (both earlier version)
Differential Revision: https://reviews.freebsd.org/D32701

(cherry picked from commit 7771f2a0c94fc2f7b9ce1565a49e52dba1e7381d)

16 months agocpuset: Adapt sched_affinity compat shims to the stable/13
Dmitry Chagin [Mon, 20 Feb 2023 17:28:36 +0000 (20:28 +0300)]
cpuset: Adapt sched_affinity compat shims to the stable/13

Use compat shims to run the stable/13 world on a kernels which
does not support CPU_WHICH_TIDPID.

This is direct commit to the stable/13.

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

16 months agopcb: Move an assignment into in_pcbdisconnect()
Mark Johnston [Fri, 3 Feb 2023 15:57:37 +0000 (10:57 -0500)]
pcb: Move an assignment into in_pcbdisconnect()

All callers of in_pcbdisconnect() clear the local address, so let's just
do that in the function itself.

Note that the inp's local address is not a parameter to the inp hash
functions.  No functional change intended.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D38362

(cherry picked from commit 2589ec0f365777faacf36bd1eb24706538836b17)

16 months agoman4: Add a manual page for kvmclock
Mark Johnston [Fri, 3 Feb 2023 15:54:50 +0000 (10:54 -0500)]
man4: Add a manual page for kvmclock

Reviewed by: pauamma, imp, kib
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38343

(cherry picked from commit a2286a1f4651f9369cacb82bb1777920f5a86fdc)

16 months agopvclock: Export a vDSO page even without rdtscp available
Mark Johnston [Fri, 3 Feb 2023 15:54:23 +0000 (10:54 -0500)]
pvclock: Export a vDSO page even without rdtscp available

When the cycle counter is "stable", i.e., synchronized across vCPUs by
the hypervisor, userspace can use a serialized rdtsc instead of relying
on rdtscp, just like the kernel timecounter does.  This can be useful
for performance in guests where the hypervisor hides rdtscp for some
reason.

To avoid breaking compatibility with older userspace which expects
rdtscp to be usable when pvclock exports timekeeping info, hide this
feature behind a sysctl.

Reviewed by: kib
Tested by: Shrikanth R Kamath <kshrikanth@juniper.net>
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38342

(cherry picked from commit 2bed14192cec1abcdc4e02ca7b18dafd868095ef)

16 months agolibc: Fall back to rdtsc when using pvclock and rdtscp is not available
Mark Johnston [Fri, 3 Feb 2023 15:53:20 +0000 (10:53 -0500)]
libc: Fall back to rdtsc when using pvclock and rdtscp is not available

In preparation for a follow-up revision wherein kvmclock may export
timekeeping info to userspace even in the absence of AMDID_RDTSCP, fall
back to using rdtsc when rdtscp isn't available.  This mimics
pvclock_read_time_info() in the kernel.

Reviewed by: kib
Tested by: Shrikanth R Kamath <kshrikanth@juniper.net>
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38341

(cherry picked from commit 26d105199ec89d6eaec8a9ca70e3b05ca65e3aac)

16 months agoshm: Document shm_create_largepage()
Mark Johnston [Fri, 3 Feb 2023 15:55:30 +0000 (10:55 -0500)]
shm: Document shm_create_largepage()

While here, move notes about FreeBSD-specific functionality to the
COMPATIBILITY section, and document the ECAPMODE error for shm_open().

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

(cherry picked from commit 5f03f96fbefbb5c68a5d7d06728ff5b4a05f87b0)

16 months agolua: reduce diffs between luaconf.h copies
Ed Maste [Mon, 20 Feb 2023 16:19:35 +0000 (09:19 -0700)]
lua: reduce diffs between luaconf.h copies

Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua
and loader lua have copies in lib/liblua/luaconf.h and
stand/liblua/luaconf.h.

Adjust whitespace, VCS tags, etc. to match upstream's version, for ease
of comparison.

Reviewed By: imp
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38206

(cherry picked from commit ec965063070e5753c166cf592c9336444b74720a)

16 months agostand: Update mfc notes
Warner Losh [Mon, 20 Feb 2023 16:09:07 +0000 (09:09 -0700)]
stand: Update mfc notes

Using some automation I found a few mistakes in my earlier list and also
a change merged without a cherry-pick -x (and evidentally changed as
well, since git log --cherry didn't know it had been merged). Fix them
so I can use this list with my experimental mfc script.

Sponsored by: Netflix

This is a direct commit to stable/13

16 months agond6: fix panic in lltable_drop_entry_queue()
Alexander V. Chernikov [Sun, 15 Jan 2023 15:10:48 +0000 (15:10 +0000)]
nd6: fix panic in lltable_drop_entry_queue()

nd6_resolve_slow() can be called without mbuf. If the LLE entry
 is not reachable, nd6_resolve_slow() will add this NULL mbuf to
 the holdchain via lltable_append_entry_queue, which will "append"
 NULL to the end of the queue (effectively no-op) and bump la_numhold
 value. When this entry gets freed, the kernel will panic due to the
 inconsistency between the amount of mbufs in the queue and the value
 of la_numhold.

Fix the panic by checking of mbuf is not NULL prior to inserting it
 into the holdchain.

Reported by: kib
MFC after: 3 days

(cherry picked from commit 6468b6b23e08d9bd02c8cb74ec0ff389ed74c3bb)

16 months agonetinet6: Fix mbuf leak in NDP
Arseny Smalyuk [Tue, 31 May 2022 20:04:51 +0000 (20:04 +0000)]
netinet6: Fix mbuf leak in NDP

Mbufs leak when manually removing incomplete NDP records with pending packet via ndp -d.
It happens because lltable_drop_entry_queue() rely on `la_numheld`
counter when dropping NDP entries (lles). It turned out NDP code never
increased `la_numheld`, so the actual free never happened.

Fix the issue by introducing unified lltable_append_entry_queue(),
common for both ARP and NDP code, properly addressing packet queue
maintenance.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35365
MFC after: 2 weeks

(cherry picked from commit d18b4bec98f1cf3c51103a22c0c041e6238c44c7)

16 months agonetlink: fix OOB read in genetlink
Alexander V. Chernikov [Sat, 18 Feb 2023 17:24:59 +0000 (17:24 +0000)]
netlink: fix OOB read in genetlink

CID: 1498863
MFC after: 1 day

(cherry picked from commit 8f7455a9265f4952f885b06c08c57fcce6f16e5c)

16 months agonetlink: simplify temporary address allocation in rtnl_handle_getlink().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:57:44 +0000 (17:57 +0000)]
netlink: simplify temporary address allocation in rtnl_handle_getlink().

MFC after: 3 days

(cherry picked from commit 45356a1864c79680c6911b48a18b14a88a7d07fa)

16 months agonetlink: fix interface dump.
Alexander V. Chernikov [Thu, 16 Feb 2023 13:17:58 +0000 (13:17 +0000)]
netlink: fix interface dump.

The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit 86fd0bdba540132ae298457e160b651f61d1db6b)

16 months agofibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.
Alexander V. Chernikov [Sat, 11 Feb 2023 15:43:23 +0000 (15:43 +0000)]
fibs: restrict jail_attach(2) if process fibnum >= numfibs in the jail.

Reported by: olivier
Tested by: olivier
Reviewed by: kp, glebius
Differential Revision: https://reviews.freebsd.org/D38505
MFC after: 1 week

(cherry picked from commit 69e7d9b7e6b369b760e1f189af2e25587b56a102)

16 months agonetlink: return optional metadata with the operation result.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:53:44 +0000 (14:53 +0000)]
netlink: return optional metadata with the operation result.

Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after: 1 week

(cherry picked from commit 25c2dd2f2c6c6144d59d463c95f0471301d6efaa)

16 months agonetlink: call genetlink notification handler upon successful family
Alexander V. Chernikov [Fri, 17 Feb 2023 17:58:53 +0000 (17:58 +0000)]
netlink: call genetlink notification handler upon successful family
search.

MFC after: 3 days

(cherry picked from commit 7cbe771f013f6cf3316910648f6d46641cad7f44)

16 months agocleanvar: Be more careful when cleaning up /var.
Xin LI [Mon, 13 Feb 2023 04:56:17 +0000 (20:56 -0800)]
cleanvar: Be more careful when cleaning up /var.

The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR: 269213

(cherry picked from commit 39e8c2a29a860bdb69ffcfbc06de4d4ad103b458)

16 months agofusefs: fix some resource leaks
Alan Somers [Sat, 11 Feb 2023 23:43:30 +0000 (16:43 -0700)]
fusefs: fix some resource leaks

fusefs would leak tickets in three cases:
* After FUSE_CREATE, if the server returned a bad inode number.
* After a FUSE_FALLOCATE operation during VOP_ALLOCATE
* After a FUSE_FALLOCATE operation during VOP_DEALLOCATE

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38526

(cherry picked from commit 1bdf879b97b686a8f36fdba050b68f9e7493f363)

MFC Note: changes to VOP_DEALLOCATE are not MFCed, because that VOP does
not exist in stable/13.

16 months agocpuset: Add compat shim to the sched_affinity functions
Dmitry Chagin [Wed, 15 Feb 2023 09:23:15 +0000 (12:23 +0300)]
cpuset: Add compat shim to the sched_affinity functions

To allow to run a newer world on a pre-1400079 kernel a compat shims to
the sched_affinity functions has beed added.

Reported by: antoine
Tested by: antoine
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D38555
MFC after: 3 days

(cherry picked from commit cbc32e4c5e8427e0f1032d9d3aa5863dd1538c11)

16 months agotmpfs: remove IFF macro
Konstantin Belousov [Mon, 13 Feb 2023 23:47:44 +0000 (01:47 +0200)]
tmpfs: remove IFF macro

(cherry picked from commit b918ee2ce4850253ddd884e39dabecd6e96bf474)

16 months agotmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts
Konstantin Belousov [Mon, 13 Feb 2023 23:23:24 +0000 (01:23 +0200)]
tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) asserts

(cherry picked from commit 9ff2fbdf2ded59e276fdbf7ef7d18c726386b6fb)

16 months agosys/param.h: Add _WANT_P_OSREL
Konstantin Belousov [Tue, 14 Feb 2023 08:52:14 +0000 (10:52 +0200)]
sys/param.h: Add _WANT_P_OSREL

(cherry picked from commit 5942b4b6fde3f4ce6d0295fbcf135f552f92c607)

16 months agomsdosfs deextend: validate pages of the partial buffer
Konstantin Belousov [Sat, 11 Feb 2023 18:09:30 +0000 (20:09 +0200)]
msdosfs deextend: validate pages of the partial buffer

PR: 269341

(cherry picked from commit 0152d453a08fa2bad694dc04a8184fce2b7faa10)

16 months agomsdosfs deextend(): memoize DETOV(dep)
Konstantin Belousov [Sat, 11 Feb 2023 18:05:14 +0000 (20:05 +0200)]
msdosfs deextend(): memoize DETOV(dep)

(cherry picked from commit 67dc1e7b0457ec014a1291c5874decdefe7bffdd)

16 months agomsdosfs: correct handling of vnode pager size on file extension error
Konstantin Belousov [Fri, 10 Feb 2023 04:58:43 +0000 (06:58 +0200)]
msdosfs: correct handling of vnode pager size on file extension error

(cherry picked from commit e59180ea09a1d1d1463f2a269e94efa0f0b677c5)

16 months agoallocbuf(): convert direct panic() calls to KASSERT()s
Konstantin Belousov [Sat, 11 Feb 2023 18:03:22 +0000 (20:03 +0200)]
allocbuf(): convert direct panic() calls to KASSERT()s

(cherry picked from commit 020e8a4d0609d56cb49a9f35258ff07815d5e478)

16 months agoefivar: Really look for labels for the provider with right efimedia
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Really look for labels for the provider with right efimedia

The prior code mistakently thought that the g_consumer that hung off the
provider we found were the right thing to use to find all the glabel
aliases for this node. However, the only way to find that is to iterate
through all the geoms that belong to the glabel geom class, looking for
those geoms with the same name as the provider with the right efimedia.
Do this in a way that caches glabel class, and allows for it to be
absent. Tighten the filter for mounted filesystems to only look
for the ones that are mounted on /dev/.. since the rest of the code
assumes that.

MFC After: 3 days
Sponsored by: Netflix
Reviewed by: corvink, asomers
Differential Revision: https://reviews.freebsd.org/D38619

(cherry picked from commit 2b460910326c4f39068fe2158a0726dc3d362f68)

16 months agoefibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file

"efibootmgr --efidev unix-path" will return the UEFI device-path to the
file or device specified by unix-path. It's useful for debugging, but
may also be useful for scripting.

Sponsored by: Netflix
Reviewed by: corvink, manu
Differential Revision: https://reviews.freebsd.org/D38617

(cherry picked from commit 9a7915299484a767fbffc7234b8dc45c29954cca)

16 months agoefivar: support device paths as well as mounted paths in path_to_dp
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: support device paths as well as mounted paths in path_to_dp

In path_to_dp, allow passing in either the actual device path "eg
/dev/foo/bar" or the path where the device is mounted (say
/mnt/baz/bing). In the former case we'll assume the path within the
device is nothing (the relpath). In the latter, we'll take from the
mount point on down as the relpath.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38616

(cherry picked from commit 57d5ca4eeba6192e91044aad86fca4429966cfac)

16 months agoefivar: Allow NULL paths in build_dp
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Allow NULL paths in build_dp

Allow there to be NULL paths in buildp. This lets us return the device
path to the partition, as well as to files on the partition.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38615

(cherry picked from commit 49fd6affdbfe6af53f119ebb27ff5e5e292e1f67)

16 months agoefivar: Try harder to find label's efimedia
Warner Losh [Thu, 16 Feb 2023 16:36:03 +0000 (09:36 -0700)]
efivar: Try harder to find label's efimedia

If there's no efimedia attribute on the provider, and the provider's a
glabel, then find the 'parent' geom. In this case, the provider's name
is label-type/name, but the geom's label will that of the underlying
device (eg ada0p1). If it is, recurisvely call find_geom_efimedia with
the geom's name, which shuold have the efimedia attribute.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38614

(cherry picked from commit ccf2121d59ac51e1a0287d75262d48018d09cad6)

16 months agonetlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:31:40 +0000 (17:31 +0000)]
netlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

(cherry picked from commit f2f7911c5513096e46422ad7756bc90c13c6e6d8)

16 months agorouting: always pass rtentry to add_route_flags().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:20:38 +0000 (17:20 +0000)]
routing: always pass rtentry to add_route_flags().

add_route_flags() uses `rt` prefix data to lookup the the current
 rtentry from the routing table. Update rib_add_route_px() to
 always pass rtentry regardless of the op_flags.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

(cherry picked from commit a0aa160b6d261f67b29a25c7cc5e04668fb6faf7)

16 months agonetlink: use ifmedia to provide vlan interface operstate.
Alexander V. Chernikov [Wed, 15 Feb 2023 20:22:47 +0000 (20:22 +0000)]
netlink: use ifmedia to provide vlan interface operstate.

Netlink customers rely on admin and operational state when
 working with interfaces. The current implementation retuns
 "unknown" operstate for all interface types except IFT_ETHER
 and IFT_LOOP.

This change updates the code to fetch vlan operstate in the same way
 as for the ether interfaces. For the rest of the interface types,
 operstate is now mapped to the admin state.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

(cherry picked from commit 5dd48f718433959c283a8a4d6e46512426f1e200)

16 months agonetlink: fix if_allocdescr() malloc options argument.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:35:28 +0000 (17:35 +0000)]
netlink: fix if_allocdescr() malloc options argument.

The current value was based on the initial revision of D37566 and
 was not updated afterwards.

MFC after: 1 day

(cherry picked from commit 6694cb1f5784d6ceacd684d29b3e3012e1e4e4d5)

16 months agonetlink: add forgotten pru_rcvd handler.
Alexander V. Chernikov [Sat, 18 Feb 2023 11:48:40 +0000 (11:48 +0000)]
netlink: add forgotten pru_rcvd handler.

There were changes in -HEAD domain/protosw setup logic and
 .pru_rcvd netlink handler was missed when performing the merge.
Lack of this handler resulted in userland being waiting forever
 when performing large dumps of data.

This change restores the handler as direct commit to stable/13.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>

16 months agonetlink: Zero-initialize writer structures allocated on the stack
Mark Johnston [Thu, 26 Jan 2023 15:46:19 +0000 (10:46 -0500)]
netlink: Zero-initialize writer structures allocated on the stack

The prevailing pattern seems to be to simply initialize all fields to
zero.  Without this, it's possible to trigger a branch on uninitialized
memory, specifically, when testing nw->ignore_limit in
nlmsg_refill_buffer().

Initialize the writer structure in a couple of functions where this is
necessary.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38213

(cherry picked from commit 7a78ae88659e0f6a901574d17672d1ccdc3e971b)

16 months agonetlink: Fix indentation in netlink_message_writer.c
Mark Johnston [Tue, 17 Jan 2023 14:37:33 +0000 (09:37 -0500)]
netlink: Fix indentation in netlink_message_writer.c

This file is indented with a mixture of tabs and spaces.  No functional
change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38100

(cherry picked from commit 35472cb60ab95b4d99981492a87443022181eac2)

16 months agonetlink: Make the writers function table static and const
Mark Johnston [Tue, 17 Jan 2023 14:37:21 +0000 (09:37 -0500)]
netlink: Make the writers function table static and const

No functional change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38099

(cherry picked from commit e262610007f01398630dc8ce7bf404dbcfd6350c)

16 months agonetlink: Zero-initialize mbuf messages
Mark Johnston [Tue, 17 Jan 2023 14:36:54 +0000 (09:36 -0500)]
netlink: Zero-initialize mbuf messages

Some users of nlmsg_reserve_object() and nlmsg_reserve_data() are not
careful to fully initialize pad and reserved fields, allowing
uninitialized bytes to leak to userspace.  For example, dump_nhgrp()
doesn't set nhm->resvd = 0.

Meanwhile, nlmsg_get_ns_buf() and nlmsg_get_ns_lbuf() zero-initialize
the buffer, so nlmsg_get_ns_mbuf() is inconsistent.  Let's just make
them all behave the same here.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38098

(cherry picked from commit d91be0f1211b0196a0087cdfa237a6a0d2a43b65)

16 months agousb: Remove unused member in struct mos_softc
Zhenlei Huang [Wed, 15 Feb 2023 05:07:19 +0000 (13:07 +0800)]
usb: Remove unused member in struct mos_softc

Spotted by jhibbits in D37812.

Reviewed by: #network, glebius
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38581

(cherry picked from commit 3bafe73affe37de3e94d91d4c1310f1272375970)

16 months agoBump __FreeBSD_version to 1302502 after LinuxKPI changes.
Bjoern A. Zeeb [Fri, 17 Feb 2023 23:40:29 +0000 (23:40 +0000)]
Bump __FreeBSD_version to 1302502 after LinuxKPI changes.

Help out-of-tree consumers detect changes to LinuxKPI pci and 802.11.

16 months agoLinuxKPI: dummy: remove files which have implementation
Bjoern A. Zeeb [Sun, 29 Jan 2023 17:52:15 +0000 (17:52 +0000)]
LinuxKPI: dummy: remove files which have implementation

Remove former dummy/ files which now have an actual implementation
in common/ .

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38269

(cherry picked from commit 78cab57ac6aad5c4c9334ca99ed89cbc3579ffff)

16 months agoLinuxKPI: return an address string in pci_name()
Val Packett [Mon, 6 Feb 2023 21:50:13 +0000 (21:50 +0000)]
LinuxKPI: return an address string in pci_name()

amdgpu's virtual display feature uses pci_name() to match a module parameter
string, and the documentation shows an example of `0000:26:00.0` for the name.
In our case the name was just `drmn`, which is not actually unique across
devices.

The other consumers are wireless drivers, which will benefit from this
change.

Generate the expected string for pci_name() to return.

Related to: https://github.com/freebsd/drm-kmod/issues/134
Sponsored by: https://www.patreon.com/valpackett
Reviewed by: bz, hselasky, manu (earlier)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34248

(cherry picked from commit 393b0ba25f1a54dcc3f94244933c665f1c471d1a)

16 months agoLinuxKPI: pci: add more functions
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:02:51 +0000 (15:02 +0000)]
LinuxKPI: pci: add more functions

Add a dummy pci_assign_resource() and an implementation of
pci_irq_vector() returning the irq for MSI-X, MSI, and legacy interrupt.
Both are needed by wirless drivers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38237

(cherry picked from commit fd1a2f3dfc0e8fb20d0d397d586000bb918aab47)

16 months agoLinuxKPI: PCI: implement support for more than 1 MSI vector
Bjoern A. Zeeb [Fri, 27 Jan 2023 15:34:42 +0000 (15:34 +0000)]
LinuxKPI: PCI: implement support for more than 1 MSI vector

Following e9715b1c4474333ff119aba3a9a74bff91f72372 and
4b56afaf7bf4fa37bae5b26fd93ee1ff5969c1bb, implement support
for up-to 32 MSI vectors.  This is used by wireless drivers.
This also switches msi_desc to an array in order to store
per-vector information.

Sponsored by: The FreeBSD Foundation
Discussed with: grehan (in Dec)
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38222

(cherry picked from commit b15491b4773af99ce2470144ef6bcd9146cc9a98)

16 months agoLinuxKPI: implement irq_get_msi_desc()
Bjoern A. Zeeb [Mon, 28 Nov 2022 18:27:03 +0000 (18:27 +0000)]
LinuxKPI: implement irq_get_msi_desc()

Add irq_get_msi_desc() as a wrapper around a PCI function which will
allocate a single cached value (see comment on struct) for the
msi_desc requested if it doesn't exist yet and handle freeing it
when the PCI device goes away.  We take the values from the ivars of
the native (FreeBSD) device.

While changing struct pci_dev also add the msi_cap field requested by
a wireless driver.

MFC after: 3 days
Reviewed by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37523

(cherry picked from commit 4b56afaf7bf4fa37bae5b26fd93ee1ff5969c1bb)

16 months agoLinuxKPI: 802.11: basic implementation of *queue(s)/*txq*
Bjoern A. Zeeb [Tue, 31 Jan 2023 16:17:14 +0000 (16:17 +0000)]
LinuxKPI: 802.11: basic implementation of *queue(s)/*txq*
LinuxKPI: 802.11: deal with stopped queues

Very basic implementations of ieee80211_{wake,stop}_queue[s],
as well as ieee80211_txq_schedule_start(), ieee80211_next_txq(),
and ieee80211_schedule_txq().
Various combinations of these are used by different wireless
drivers, incl. iwlwifi.

Following 5a9a0d7803382321b5f9fff1deae5fb08463cf1a initialize the
queue values explicitly and deal with a stopped queue in
ieee80211_tx_dequeue().

Sponsored by: The FreeBSD Foundation (parts of this work)
MFC after: 3 days

(cherry picked from commit 5a9a0d7803382321b5f9fff1deae5fb08463cf1a)
(cherry picked from commit 0cbcfa1964de89cd346ee6f79437c6ab83a3b716)

16 months agoLinuxKPI: 802.11: fix indent in lkpi_wake_tx_queues()
Bjoern A. Zeeb [Tue, 31 Jan 2023 23:12:30 +0000 (23:12 +0000)]
LinuxKPI: 802.11: fix indent in lkpi_wake_tx_queues()

Fix indentation in lkpi_wake_tx_queues().
No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit b0ddb44fd427d44b8153781ce9c461e393771aff)

16 months agoLinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT
Bjoern A. Zeeb [Tue, 31 Jan 2023 23:00:28 +0000 (23:00 +0000)]
LinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT

Add code (currently disabled by #ifdef) for HT and VHT to
lkpi_scan_ies_add().  Switch to a local variable for ic given
the new code also needs the value.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit 3dd980267f4e53df259eb6d322e7332a8bc5bb0a)

16 months agoLinuxKPI: 802.11: implement ieee80211_is_pspoll()
Bjoern A. Zeeb [Tue, 31 Jan 2023 16:36:24 +0000 (16:36 +0000)]
LinuxKPI: 802.11: implement ieee80211_is_pspoll()

Implement ieee80211_is_pspoll() and move it up to the set of implemented
ieee80211_is_*() functions.

There are no further changes (git diff just looks weird).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit ff76cbc81d57ffc4bbc9bc20fd22325b2a8c2028)
(cherry picked from commit 2336248a8ba9763ad38074db40f32e117edd86f5)

16 months agoLinuxKPI: 802.11: implement ieee80211_tx_status_ext()
Bjoern A. Zeeb [Tue, 31 Jan 2023 15:35:59 +0000 (15:35 +0000)]
LinuxKPI: 802.11: implement ieee80211_tx_status_ext()

Add an implementation of ieee80211_tx_status_ext() extending the
internal linuxkpi_ieee80211_tx_status() implementation.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit a839757109891573123d8777b539fafa2d2198bb)

16 months agoLinuxKPI: 802.11: extend linuxkpi_ieee80211_rx()
Bjoern A. Zeeb [Tue, 31 Jan 2023 15:05:30 +0000 (15:05 +0000)]
LinuxKPI: 802.11: extend linuxkpi_ieee80211_rx()

Extend linuxkpi_ieee80211_rx() by another argument for
the ieee80211_rx_list() implementation (even though the argument
is currently ignored).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit e30e05d3ab3979a148068235298e1a6f73b675f0)

16 months agoLinuxKPI: 802.11: fix types and whitespace
Bjoern A. Zeeb [Tue, 31 Jan 2023 13:39:04 +0000 (13:39 +0000)]
LinuxKPI: 802.11: fix types and whitespace

Correct struct member types, fix whitespace, and remove superfluous
return statements in void functions.

No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit a3baca22d0b7789a040a60f389e3c132b6e1755b)

16 months agoLinuxKPI: skbuff: implement skb_free_frag()
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:33:12 +0000 (15:33 +0000)]
LinuxKPI: skbuff: implement skb_free_frag()

Using the work from 55038a6306a570c9f2df89f5ad076de0f7d98152 implement
skb_free_frag() calling page_frag_free().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

(cherry picked from commit dbbf46ebba78770c2c3a1d7983e92e79ca67abc0)