]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agoktls: Post receive errors on partially closed sockets.
John Baldwin [Wed, 28 Dec 2022 00:00:17 +0000 (16:00 -0800)]
ktls: Post receive errors on partially closed sockets.

If an error such as an invalid record or one whose decryption fails is
detected on a socket that has received a RST then ktls_drop() could
ignore the error since INP_DROPPED could already be set.  In this case
soreceive_generic hangs since it does not return from a KTLS socket
with pending encrypted data unless there is an error (so_error) (this
behavior is to ensure that soreceive_generic doesn't return a
premature EOF when there is pending data still being decrypted).

Note that this was a bug prior to
69542f26820b7edb8351398b36edda5299c1db56 as tcp_usr_abort would also
have ignored the error in this case.

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

(cherry picked from commit 07be7517270e7cc8f51612efce9e6375ad1fc12e)

17 months agoktls: Close a race with setting so_error when dropping a connection.
John Baldwin [Thu, 15 Dec 2022 20:06:26 +0000 (12:06 -0800)]
ktls: Close a race with setting so_error when dropping a connection.

pr_abort calls tcp_usr_abort which calls tcp_drop with ECONNABORTED.
After pr_abort returns, the so_error is then set to a more specific
error.  However, a reader can observe and return the ECONNABORTED
error before so_error is set to the desired error value.  This is
resulting in spurious test failures of recently added tests for
invalid conditions such as invalid headers.

To fix, refactor the code to abort a connection to call tcp_drop
directly with the desired error value.  ktls_reset_send_tag already
calls tcp_drop directly when it aborts a connection due to an error.

Reviewed by: gallatin
Reported by: CI (jenkins), gallatin, olivier
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37692

(cherry picked from commit 69542f26820b7edb8351398b36edda5299c1db56)

17 months agowg: Re-add basic if_wg(4) tests.
John Baldwin [Fri, 16 Dec 2022 20:01:26 +0000 (12:01 -0800)]
wg: Re-add basic if_wg(4) tests.

These were originally added in commit
74ae3f3e33b810248da19004c58b3581cd367843 but have been updated to use
wg(8).

Reviewed by: kevans, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37400

(cherry picked from commit 8fb9739615da8922fbd8988ccd77093d4ca335ba)

17 months agosrc.opts.mk: Disable all of LLVM if C++ support is disabled.
John Baldwin [Wed, 16 Nov 2022 03:21:20 +0000 (19:21 -0800)]
src.opts.mk: Disable all of LLVM if C++ support is disabled.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D36891

(cherry picked from commit f53dc31bb3ef387338a7678581e8c7d587da8d2c)

17 months agobhyve: Use XHCI_PORTREG_PTR in one place that open-coded it.
John Baldwin [Wed, 16 Nov 2022 03:19:35 +0000 (19:19 -0800)]
bhyve: Use XHCI_PORTREG_PTR in one place that open-coded it.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D36888

(cherry picked from commit fd104a6ebc35cfc9cadeb981b23200e805a88b3f)

17 months agolibfetch: Pass a zeroed digest to DigestCalcResponse.
John Baldwin [Wed, 16 Nov 2022 03:18:58 +0000 (19:18 -0800)]
libfetch: Pass a zeroed digest to DigestCalcResponse.

GCC 12 warns that passing "" (a constant of char[1]) to a parameter of
type char[33] could potentially overread.  It is not clear from the
context that c->qops can never be "auth-int" (and if it can't, then
the "auth-int" handling in DigestCalcResponse is dead code that should
be removed since this is the only place the function is called).

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

(cherry picked from commit 57fbafb8deac75b924faf1fa6c2222a7719fdfec)

17 months agodiff: Don't (ab)use sprintf() as a kind of strcat().
John Baldwin [Wed, 16 Nov 2022 03:17:36 +0000 (19:17 -0800)]
diff: Don't (ab)use sprintf() as a kind of strcat().

Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows.  This
raised -Wformat-truncation and -Wrestrict warnings in GCC.  Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string.  While here, use sizeof(buf) with
strftime() rather than a magic number.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D36814

(cherry picked from commit 6100374ccf2644d3fd233bde8b8f4e73d9953c30)

17 months agodiff: Don't treat null characters like carriage returns in readhash().
John Baldwin [Wed, 16 Nov 2022 03:16:50 +0000 (19:16 -0800)]
diff: Don't treat null characters like carriage returns in readhash().

The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.

Reported by: GCC -Wimplicit-fallthrough
Reviewed by: bapt
Fixes:   3cbf98e2bee9 diff: read whole files to determine if they are ASCII text
Differential Revision: https://reviews.freebsd.org/D36813

(cherry picked from commit 4e0771714d6192119dcf7553b921bf88866d8925)

17 months agocxgbe: Various whitespace fixes.
John Baldwin [Tue, 15 Nov 2022 20:03:57 +0000 (12:03 -0800)]
cxgbe: Various whitespace fixes.

Mostly trailing whitespace and spaces before tabs.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37350

(cherry picked from commit 21186bdb2d6a14dbfff7b4366425285b8612cc22)

17 months agoktls_ocf: Reject encrypted TLS records using AEAD that are too small.
John Baldwin [Tue, 15 Nov 2022 20:02:57 +0000 (12:02 -0800)]
ktls_ocf: Reject encrypted TLS records using AEAD that are too small.

If a TLS record is too small to contain the required explicit IV,
record_type (TLS 1.3), and MAC, reject attempts to decrypt it with
EMSGSIZE without submitting it to OCF.  OCF drivers may not properly
detect that regions in the crypto request are outside the bounds of
the mbuf chain.  The caller isn't supposed to submit such requests.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37372

(cherry picked from commit 4e47414648894943413091984124d93bd43e5da1)

17 months agoktls: Don't leak ktls session objects for certain errors.
John Baldwin [Sat, 12 Nov 2022 00:00:37 +0000 (16:00 -0800)]
ktls: Don't leak ktls session objects for certain errors.

ktls_cleanup() does not free ktls session objects, it merely
cleans (and frees) members of the object.

Change callers to use ktls_free() instead.

Reviewed by: gallatin, markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37352

(cherry picked from commit d01db2b83705eb3557a32ea13143997cdb8135a3)

17 months agowg: Drop the compat shim for sbcreatecontrol().
John Baldwin [Fri, 11 Nov 2022 22:18:48 +0000 (14:18 -0800)]
wg: Drop the compat shim for sbcreatecontrol().

I had to make a few other changes when merging the driver to stable/13
anyway, so adjusting this as well isn't really a big deal.

MFC after: 3 days

(cherry picked from commit 573bd1fcf532eae35ac30d6aa2c6ff4985a60fe8)

17 months agowg.4: Update first appeared release to 13.2.
John Baldwin [Fri, 11 Nov 2022 22:11:33 +0000 (14:11 -0800)]
wg.4: Update first appeared release to 13.2.

MFC after: 3 days

(cherry picked from commit 001830ea7aaf2f7de7afe85741f9662d9571e1ee)

17 months agopsm: Swap the unit member in the softc for a device_t.
John Baldwin [Thu, 21 Apr 2022 20:52:48 +0000 (13:52 -0700)]
psm: Swap the unit member in the softc for a device_t.

This entails various changes to make this driver more "modern"
(new-bus vs pre-new-bus) using device_log() and device_printf() rather
than psm%d.  It also fixes the device_busy/unbusy calls to use sc->dev
directly rather than looking the device_t up via the devclass and
unit.

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

(cherry picked from commit a6c09f20e8e00bec7d9eb088b4f32dd38bf7f490)

17 months agoAdd device and ifnet logging methods, similar to device_printf / if_printf
Adrian Chadd [Sun, 21 Mar 2021 18:49:05 +0000 (18:49 +0000)]
Add device and ifnet logging methods, similar to device_printf / if_printf

* device_printf() is effectively a printf
* if_printf() is effectively a LOG_INFO

This allows subsystems to log device/netif stuff using different log levels,
rather than having to invent their own way to prefix unit/netif  names.

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

(cherry picked from commit 25bfa448602cac74723115d0b0bd145ac795b685)

17 months agosmc: Rename constants for control register from CTR* to CTRL*.
John Baldwin [Wed, 13 Apr 2022 00:11:28 +0000 (17:11 -0700)]
smc: Rename constants for control register from CTR* to CTRL*.

This avoids a conflict with the recently-added CTR macro in
<sys/ktr.h>.

(cherry picked from commit 613e07c07f3b069eae08d9c5f5642713621c4a43)

17 months agoiwlwifi: Disable -Wformat when building with GCC.
John Baldwin [Thu, 3 Feb 2022 18:48:18 +0000 (10:48 -0800)]
iwlwifi: Disable -Wformat when building with GCC.

GCC's -Wformat complains about NULL format strings passed to
iwl_fw_dbg_collect_trig (though the function handles NULL format
strings).  Curious that upstream iwlwifi in Linux is built with GCC
and explicitly opts into this warning via the __printf() attribute.

Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D34146

(cherry picked from commit 87c5d39f77bc8c38738a6dc200f711f4418c5018)

17 months agonhop: hash ifnet pointer instead of if_index
Gleb Smirnoff [Sat, 4 Dec 2021 18:05:46 +0000 (10:05 -0800)]
nhop: hash ifnet pointer instead of if_index

Yet another problem created by VIMAGE/if_vmove/epair design that
relocates ifnet between vnets and changes if_index.  Since if_index
changes, nhop hash values also changes, unlink_nhop() isn't able to
find entry in hash and leaks the nhop.  Since nhop references ifnet,
the latter is also leaked.  As result running network tests leaks
memory on every single test that creates vnet jail.

While here, rewrite whole hash_priv() to use static initializer,
per Alexander's suggestion.

Reviewed by: melifaro

(cherry picked from commit ad2a0aec295478e750158b8985422f15deee0e54)

17 months agoif_clone: rework cloning KPI
Alexander V. Chernikov [Thu, 22 Sep 2022 09:37:37 +0000 (09:37 +0000)]
if_clone: rework cloning KPI

The current cloning KPI does not provide a way of creating interfaces
 with parameres from within kernel. The reason is that those parameters
 are passed as an opaque pointer and it is not possible to specify whether
 this pointer references kernel-space or user-space.
Instead of just adding a flag, generalise the KPI to simplify the
 extension process. Unify current notion of `SIMPLE` and `ADVANCED` users
 by leveraging newly-added IFC_C_AUTOUNIT flag to automatically pick
 unit number, which is a primary feature of the "SIMPLE" KPI.
Use extendable structures everywhere instead of passing function
 pointers or parameters.
Isolate all parts of the oldKPI under `CLONE_COMPAT_13` so it can be safely
 merged back to 13. Old KPI will be removed after the merge.

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

(cherry picked from commit 09ee0fc023c0c7ef90cb277afbb473abe4d95a9a)

17 months agonet: add if_allocdescr() to permit updating iface description from the kernel
Alexander V. Chernikov [Wed, 30 Nov 2022 13:49:07 +0000 (13:49 +0000)]
net: add if_allocdescr() to permit updating iface description from the kernel

Reviewed by: kp,zlei
Differential Revision: https://reviews.freebsd.org/D37566
MFC after: 2 weeks

(cherry picked from commit 984b27d879e14d88834ddfb7b9f9a4c40a84c492)

17 months agoifp: add if_setdescr() / if_freedesrt() methods
Alexander V. Chernikov [Sat, 24 Sep 2022 19:37:29 +0000 (19:37 +0000)]
ifp: add if_setdescr() / if_freedesrt() methods

Add methods for setting and removing the description from the interface,
 so the external users can manage it without using ioctl API.

MFC after:      2 weeks

(cherry picked from commit 9a7c520a7811a036a8140effb352f44ad5640c0e)

17 months agonetlink: allow creating sockets with SOCK_DGRAM.
Alexander V. Chernikov [Sat, 21 Jan 2023 14:36:23 +0000 (14:36 +0000)]
netlink: allow creating sockets with SOCK_DGRAM.

Some existing applications setup Netlink socket with
SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify
that the default way of creating the socket should be with
SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38075

(cherry picked from commit 0079d177ab69168df5e103128a2b15bd8e74d4eb)

17 months agonetlink: fix OOB write when creating attribute bitmask.
Alexander V. Chernikov [Sat, 21 Jan 2023 18:03:47 +0000 (18:03 +0000)]
netlink: fix OOB write when creating attribute bitmask.

Fix wrong arithmetics by moving to the standard bitset(9) functions.

Reported by: markj, KASAN

(cherry picked from commit 10f2a38769c7b2fa210a3ea077d3185448479013)

17 months agonetlink: add snl(3) manpage to the build
Alexander V. Chernikov [Mon, 16 Jan 2023 20:24:49 +0000 (20:24 +0000)]
netlink: add snl(3) manpage to the build

(cherry picked from commit 7f2109f240c2cdb916ca0047422ccfb2a697cee7)

17 months agonetlink: fix compatibility with older netlink applications.
Alexander V. Chernikov [Mon, 16 Jan 2023 12:14:35 +0000 (12:14 +0000)]
netlink: fix compatibility with older netlink applications.

Some apps try to provide only the non-zero part of the required message
 header instead of the full one. It happens when fetching routes or
 interface addresses, where the first header byte is the family.
This behavior is "illegal" under the "strict" Netlink socket option,
 however there are many applications out there doing things in the
 "old" way.

Support this usecase by copying the provided bytes into the temporary
 zero-filled header and running the parser on this header instead.

Reported by: Goran Mekić <meka@tilda.center>

(cherry picked from commit 228c632ab3f6245df4a08d8692d49c8e12aacc27)

17 months agonetlink: fix typo in netlink(4)
Alexander V. Chernikov [Mon, 16 Jan 2023 10:56:10 +0000 (10:56 +0000)]
netlink: fix typo in netlink(4)

Reported by: Ihor Antonov <ihor@antonovs.family>

(cherry picked from commit a8633361ab71fda3860f6b4ed1a602f9b52b36b8)

17 months agoman: add Netlink reference to socket(2)
Alexander V. Chernikov [Sat, 14 Jan 2023 17:35:43 +0000 (17:35 +0000)]
man: add Netlink reference to socket(2)

Reviewed by: lwhsu, pauamma, gbe
Differential Revision: https://reviews.freebsd.org/D38054

(cherry picked from commit b0286ee504c605027c747e061591535c67032cf5)

17 months agotesting: fix skipping netlink tests if netlink module is not loaded.
Alexander V. Chernikov [Sun, 8 Jan 2023 19:51:26 +0000 (19:51 +0000)]
testing: fix skipping netlink tests if netlink module is not loaded.

(cherry picked from commit 9408f36627b74a472dc82f7a43320235c0c9055a)

17 months agonetlink: improve RTM_GETADDR handling.
Alexander V. Chernikov [Sat, 7 Jan 2023 16:18:39 +0000 (16:18 +0000)]
netlink: improve RTM_GETADDR handling.

* Allow filtering by ifa_family & ifa_index.
* Add common RTM_<NEW|DEL|GET>ADDR parser
* Add tests verifying RTM_GETADDR filtering behaviour & output
* Factor out common netlink socket test methods into NetlinkTestTemplate
* Add NLMSG_DONE message handler

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D37970

(cherry picked from commit c1871a3372e382bfcd46452d1d8d4f06561508cc)

17 months agonetlink: fix ifaddr reporting.
Alexander V. Chernikov [Fri, 6 Jan 2023 19:13:42 +0000 (19:13 +0000)]
netlink: fix ifaddr reporting.

Output the proper attributes for IPv4/IPvv6 ifaddrs:
* IFA_ADDRESS contains local address in every case except p2p,
   in that case it contains the peer address
* IFA_LOCAL contains local address. It is always present in IPv4,
   or in IPv6/p2p.
* IFA_BROADCAST contains the network broadcast address (if any)

Reported by: Adam Wood <aswood@gmail.com>
Tested by: Adam Wood <aswood@gmail.com>

(cherry picked from commit 13214c601a49d733bd17d42b927788bb9feea536)

17 months agotesting: add python test examples
Alexander V. Chernikov [Sun, 1 Jan 2023 14:35:41 +0000 (14:35 +0000)]
testing: add python test examples

Simplify the adoption of python tests by proving some examples,
 utilising commonly-used patterns.

Differential Revision: https://reviews.freebsd.org/D37902
Reviewed by: asomers
MFC after: 2 weeks

(cherry picked from commit 8161b823d77f9d89ffabd47444a83d693f74c515)

17 months agotesting: fix tests without cleanup in pytest.
Alexander V. Chernikov [Sun, 1 Jan 2023 14:11:18 +0000 (14:11 +0000)]
testing: fix tests without cleanup in pytest.

It was broken by 89ffac3b01fb3f6749799ac67b7d94056a36778e,
which added "cleanup" method to the base test class,
 resulting in reporting cleanup for all of the tests.

(cherry picked from commit bb60d265c9825d71cce84a42f66a435f05a6c5f7)

17 months agotesting: allow custom test cleanup handlers in pytest
Alexander V. Chernikov [Sat, 31 Dec 2022 16:22:30 +0000 (16:22 +0000)]
testing: allow custom test cleanup handlers in pytest

In order to provide more flexibility for the test writers,
add per-test-method cleanups in addition to the per-class cleanups.

Now the test 'test_one' can perform cleanup by either defining
per-class 'cleanup' method (typically used in VNET classes) and
per-test method 'cleanup_test_one'. The latter has preference.
In order to handle paramatrization, testid is passed as a single
 argument to both of the methods.

MFC after: 2 weeks

(cherry picked from commit 89ffac3b01fb3f6749799ac67b7d94056a36778e)

17 months agotesting: improve python vnet wrapper.
Alexander V. Chernikov [Thu, 29 Dec 2022 19:07:34 +0000 (19:07 +0000)]
testing: improve python vnet wrapper.

* Derive jail name from class name and method name, instead of just
method name. This change reduces the chances of different tests
clashing.
 Old: 'jail_test_one'. New: 'pytest:TestExampleSimplest:test_one'
* Simplify vnetX_handler() method signature by skipping obj_map (unused)
 and pipe. The latter can be accessed as the vnet property.
* Add `send_object()` method as a pair to the `wait_object` inside the
 VnetTestTemplate class.
* Add `test_id` property to the BaseTest method. Previously it was
 provided only for the VnetTestTemplate class. This change makes
 the identifier easily accessible for all users.

MFC after: 2 weeks

(cherry picked from commit f63825ff21a3bee2630ea8b0ed27a4583cc4242b)

17 months agonetlink: fix test-includes broken by f2c8381fce9b
Alexander V. Chernikov [Fri, 23 Dec 2022 17:57:09 +0000 (17:57 +0000)]
netlink: fix test-includes broken by f2c8381fce9b

Reported by: many

(cherry picked from commit c89209c674f2c867a2a3a4cccd4760311399d7e4)

17 months agonetlink: make snl(3) headers self-contained.
Alexander V. Chernikov [Fri, 23 Dec 2022 15:52:33 +0000 (15:52 +0000)]
netlink: make snl(3) headers self-contained.

(cherry picked from commit 3e3875413128ff01f43b7ae8e0ca8db8d8d5efca)

17 months agonetlink: fix netlink_snl_route.h header includes
Alexander V. Chernikov [Fri, 23 Dec 2022 15:24:21 +0000 (15:24 +0000)]
netlink: fix netlink_snl_route.h header includes

(cherry picked from commit f6f4ba0b05ab090f2bcc8865a63dfc378a8d8421)

17 months agonetlink: add snl(3) - simple netlink library
Alexander V. Chernikov [Sun, 18 Dec 2022 17:34:41 +0000 (17:34 +0000)]
netlink: add snl(3) - simple netlink library

Reviewed by: bapt, pauamma
Differential Revision: https://reviews.freebsd.org/D37736

(cherry picked from commit f2c8381fce9b87695ea448591e4412cbed38aa77)

17 months agonetlink: connect netlink tests to the build
Alexander V. Chernikov [Fri, 16 Dec 2022 12:02:17 +0000 (12:02 +0000)]
netlink: connect netlink tests to the build

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D37708

(cherry picked from commit 3873bdc2f28f6aab6b426ccb6c85ab2a41483264)

17 months agonetlink: Use NET_EPOCH_[CALL|WAIT] macros
Zhenlei Huang [Wed, 21 Dec 2022 01:40:05 +0000 (09:40 +0800)]
netlink: Use NET_EPOCH_[CALL|WAIT] macros

Reviewed by: melifaro, kp
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D37730

(cherry picked from commit ab591c874b68512170750a7a54e41fd508249814)

17 months agonetlink: improve interface handling
Alexander V. Chernikov [Wed, 14 Dec 2022 19:45:01 +0000 (19:45 +0000)]
netlink: improve interface handling

* Separate interface creation from interface modification code
* Support setting some interface attributes (ifdescr, mtu, up/down, promisc)
* Improve interaction with the cloners requiring to parse/write custom
 interface attributes
* Add bitmask-based way of checking if the attribute is present in the
message
* Don't use multipart RTM_GETLINK replies when searching for the
specific interface names
* Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search
* Add python netlink test helpers
* Add some netlink interface tests

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

(cherry picked from commit 80f03e63d67ede8fedbed4bd6bf6b12ec2ab2cfb)

17 months agonetlink: add interface notification on link status / flags change.
Alexander V. Chernikov [Sat, 3 Dec 2022 17:10:50 +0000 (17:10 +0000)]
netlink: add interface notification on link status / flags change.

* Add link-state change notifications by subscribing to ifnet_link_event.
 In the Linux netlink model, link state is reported in 2 places: first is
 the IFLA_OPERSTATE, which stores state per RFC2863.
 The second is an IFF_LOWER_UP interface flag. As many applications rely
 on the latter, reserve 1 bit from if_flags, named as IFF_NETLINK_1.
 This flag is mapped to IFF_LOWER_UP in the netlink headers. This is done
 to avoid making applications think this flag is actually
 supported / presented in non-netlink outputs.
* Add flag change notifications, by hooking into rt_ifmsg().
 In the netlink model, notification should include the bitmask for the
 change flags. Update rt_ifmsg() to include such bitmask.

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

(cherry picked from commit 1bcd230f9508b3c917f26be4b905e4b5141decea)

17 months agonetlink: fix non-multipath build
Alexander V. Chernikov [Fri, 2 Dec 2022 22:20:42 +0000 (22:20 +0000)]
netlink: fix non-multipath build

(cherry picked from commit 6ab87ec483e9578823cbc30458f49ab07f51acf8)

17 months agonetlink: store user-provided rtm_protocol
Alexander V. Chernikov [Fri, 2 Dec 2022 19:26:34 +0000 (19:26 +0000)]
netlink: store user-provided rtm_protocol

Store user-supplied source protocol in the nexthops and nexthop groups.
Protocol specification help routing daemons like bird to quickly
identify self-originated routes after the crash or restart.

Example:
```
10.2.0.0/24 via 10.0.0.2 dev vtnet0 proto bird
10.3.0.0/24 proto bird
nexthop via 10.0.0.2 dev vtnet0 weight 3
nexthop via 10.0.0.3 dev vtnet0 weight 4
```

(cherry picked from commit cc2be311772d368541157dcf8bf989f216a5b994)

17 months agonetlink: suppress sending NLMSG_ERROR if NLMSG_DONE is already sent
Alexander V. Chernikov [Wed, 30 Nov 2022 12:15:23 +0000 (12:15 +0000)]
netlink: suppress sending NLMSG_ERROR if NLMSG_DONE is already sent

Netlink has a confirmation/error reporting mechanism for the sent
messages. Kernel explicitly acks each messages if requested (NLM_F_ACK)
 or if message processing results in an error.
Similarly, for multipart messages - typically dumps, where each message
 represents a single object like an interface or a route - another
 message, NLMSG_DONE is used to indicate the end of dump and the
 resulting status.
As a result, successfull dump ends with both NLMSG_DONE and NLMSG_ERROR
 messages.
RFC 3549 does not say anything specific about such case.
Linux adopted an optimisation which suppresses NLMSG_ERROR message
 when NLMSG_DONE is already sent. Certain libraries/applications like
 libnl depends on such behavior.

Suppress sending NLMSG_ERROR if NLMSG_DONE is already sent, by
 setting newly-added 'suppress_ack' flag in the writer and checking
 this flag when generating ack.

This change restores libnl compatibility.

Before:
```
~ nl-link-list
Error: Unable to allocate link cache: Message sequence number mismatch
````

After:
```
~ nl-link-list
vtnet0 ether 52:54:00:14:e3:19 <broadcast,multicast,up,running>
lo0 ieee1394 <loopback,multicast,up,running>
```

Reviewed by: bapt,pauamma
Tested by: bapt
Differential Revision: https://reviews.freebsd.org/D37565

(cherry picked from commit f4d3aa74908496f1f5815caca94ebd86944b17cb)

17 months agonetlink: add netlink user documentation.
Alexander V. Chernikov [Tue, 1 Nov 2022 12:20:13 +0000 (12:20 +0000)]
netlink: add netlink user documentation.

Add netlink(4) as a "frontend" manpage describing netlink in general.
Add rtnelink(4) describing supported commands and attributes in
NETLINK_ROUTE family.
Add genetlink(4) describing generic netlink API.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D37011

(cherry picked from commit 7366c0a49c9a60d3eea7520d7ae4bc2b3ab172f3)

17 months agonetlink: unregister groups along with family
Baptiste Daroussin [Tue, 8 Nov 2022 08:02:43 +0000 (09:02 +0100)]
netlink: unregister groups along with family

Differential Revision: https://reviews.freebsd.org/D37308
Reviewed by: melifaro

(cherry picked from commit 1edc3b6e56932e423d778df484ffca3bd2af9e97)

17 months agonetlink: allow more than 64 groups per netlink socket.
Alexander V. Chernikov [Thu, 3 Nov 2022 16:44:07 +0000 (16:44 +0000)]
netlink: allow more than 64 groups per netlink socket.

(cherry picked from commit 4dfd380e06c515349c5cc55a1f05effbf3a44ba1)

17 months agonetlink: remove private netlink_var.h header from the non-netlink core files.
Alexander V. Chernikov [Thu, 3 Nov 2022 17:03:26 +0000 (17:03 +0000)]
netlink: remove private netlink_var.h header from the non-netlink core files.

(cherry picked from commit 669d63eb85066be6b53d1a6ee6d0441fd0f46595)

17 months agonetlink: fix CTRL_CMD_GETFAMILY lookup/dumps.
Alexander V. Chernikov [Mon, 31 Oct 2022 17:11:53 +0000 (17:11 +0000)]
netlink: fix CTRL_CMD_GETFAMILY lookup/dumps.

Reported by: bapt

(cherry picked from commit 728ca8506dff0f27e32a5994b68e9eea5c345e04)

17 months agonetlink: fix genetlink CTRL_ATTR_MCAST_GRP_MAX define.
Alexander V. Chernikov [Mon, 31 Oct 2022 15:03:27 +0000 (15:03 +0000)]
netlink: fix genetlink CTRL_ATTR_MCAST_GRP_MAX define.

Reported by: harti

(cherry picked from commit 830352ccca2386dde60e0590ad4e3a22532867a9)

17 months agonetlink: fix NLMSG_SPACE() macro.
Alexander V. Chernikov [Mon, 31 Oct 2022 15:02:12 +0000 (15:02 +0000)]
netlink: fix NLMSG_SPACE() macro.

Reported by: bapt

(cherry picked from commit 03de61aabb40dab3c7311e1664c85e41dafe29b4)

17 months agonetlink: fix generic netlink privilege check.
Alexander V. Chernikov [Mon, 31 Oct 2022 13:40:25 +0000 (13:40 +0000)]
netlink: fix generic netlink privilege check.

Reported by: bapt

(cherry picked from commit fc47afbfafca9c72ea8866e71a05ed7ee4c0fce6)

17 months agonetlink: use (void) for function definitions with no arguments
Ed Maste [Thu, 27 Oct 2022 14:49:51 +0000 (10:49 -0400)]
netlink: use (void) for function definitions with no arguments

For some of these Clang produced a warning that "a function declaration
without a prototype is deprecated in all versions of C".  In other cases
the function defintion used () which did not match the header
declaration, which used (void).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 43d0c2ddd2556841717a50925f713c9c70d3936e)

17 months agonetlink: make it working without INET6
Gleb Smirnoff [Tue, 4 Oct 2022 21:39:49 +0000 (14:39 -0700)]
netlink: make it working without INET6

(cherry picked from commit b958b862b1f43f5fef881c1f9aee6618d7d24197)

17 months agoFix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .
Hans Petter Selasky [Tue, 4 Oct 2022 14:08:20 +0000 (16:08 +0200)]
Fix kernel build after fcb3f813f379f544f9cd2a10d18045588da0e132 .

By adding missing ifdefs for INET and INET6 when building LINT-NOIP .

Differential Revision: https://reviews.freebsd.org/D36731
Sponsored by: NVIDIA Networking

(cherry picked from commit 1d41a055578704a28b34820e0aaf14a29f28f413)

17 months agonetlink: fix non-default builds (no INET, INET6, ROUTE_MPATH).
Alexander V. Chernikov [Sun, 2 Oct 2022 13:02:24 +0000 (13:02 +0000)]
netlink: fix non-default builds (no INET, INET6, ROUTE_MPATH).

(cherry picked from commit 356724fc931f4af1ed992a24f114070b14bb430a)

17 months agonetlink: Fix build without VIMAGE
Jung-uk Kim [Sun, 2 Oct 2022 01:38:55 +0000 (21:38 -0400)]
netlink: Fix build without VIMAGE

(cherry picked from commit fc083c3eb2bf9c2ea92914fab9e8fd090d1db710)

17 months agonetlink: fix build without INVARIANTS
Alexander V. Chernikov [Sat, 1 Oct 2022 21:20:50 +0000 (21:20 +0000)]
netlink: fix build without INVARIANTS

Reported by: cy

(cherry picked from commit 03994c24da957ffd6556096cdd6f6522eb968ba8)

17 months agonetlink: fix format strings on 32-bit platforms
Alexander V. Chernikov [Sat, 1 Oct 2022 21:16:31 +0000 (21:16 +0000)]
netlink: fix format strings on 32-bit platforms

(cherry picked from commit 8d9f3e05728ecef4e21672dd8a54066b17b62a50)

17 months agonetlink: fix debugging on 32-bit platforms
Alexander V. Chernikov [Sat, 1 Oct 2022 19:03:28 +0000 (19:03 +0000)]
netlink: fix debugging on 32-bit platforms

(cherry picked from commit c90bff3fa7c1c3ba3773759d243aad7b29b643a3)

17 months agonetlink: make test-includes happy by hiding most of the header
Alexander V. Chernikov [Sat, 1 Oct 2022 17:01:53 +0000 (17:01 +0000)]
netlink: make test-includes happy by hiding most of the header
 contents under _KERNEL.

(cherry picked from commit dddafa8d25c6ba57c64c0363d8a4791470d465e0)

17 months agonetlink: add netlink support
Alexander V. Chernikov [Thu, 20 Jan 2022 21:39:21 +0000 (21:39 +0000)]
netlink: add netlink support

Netlinks is a communication protocol currently used in Linux kernel to modify,
 read and subscribe for nearly all networking state. Interfaces, addresses, routes,
 firewall, fibs, vnets, etc are controlled via netlink.
It is async, TLV-based protocol, providing 1-1 and 1-many communications.

The current implementation supports the subset of NETLINK_ROUTE
family. To be more specific, the following is supported:
* Dumps:
 - routes
 - nexthops / nexthop groups
 - interfaces
 - interface addresses
 - neighbors (arp/ndp)
* Notifications:
 - interface arrival/departure
 - interface address arrival/departure
 - route addition/deletion
* Modifications:
 - adding/deleting routes
 - adding/deleting nexthops/nexthops groups
 - adding/deleting neghbors
 - adding/deleting interfaces (basic support only)
* Rtsock interaction
 - route events are bridged both ways

The implementation also supports the NETLINK_GENERIC family framework.

Implementation notes:
Netlink is implemented via loadable/unloadable kernel module,
 not touching many kernel parts.
Each netlink socket uses dedicated taskqueue to support async operations
 that can sleep, such as interface creation. All message processing is
 performed within these taskqueues.

Compatibility:
Most of the Netlink data models specified above maps to FreeBSD concepts
 nicely. Unmodified ip(8) binary correctly works with
interfaces, addresses, routes, nexthops and nexthop groups. Some
software such as net/bird require header-only modifications to compile
and work with FreeBSD netlink.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36002
MFC after: 2 months

(cherry picked from commit 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6)

17 months agodtrace: correct the aframes value for fbt provider
Mitchell Horne [Wed, 11 Jan 2023 18:06:24 +0000 (14:06 -0400)]
dtrace: correct the aframes value for fbt provider

Set the number of artificial frames to 5:
 1. cpu_exception_handler_supervisor()
 2. do_trap_supervisor()
 3. dtrace_invop_start()
 4. dtrace_invop()
 5. fbt_invop()

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

(cherry picked from commit 36a9ce874b5988dc8615a4b1b3fb41eb9e06051d)

17 months agodtrace: correct profile aframes value for riscv
Mitchell Horne [Wed, 11 Jan 2023 18:06:17 +0000 (14:06 -0400)]
dtrace: correct profile aframes value for riscv

Experimentation shows this is the correct value; the dtrace/interrupt
handler frames are omitted, while the backtrace of the active thread is
recorded in its entirety.

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

(cherry picked from commit 40fdda022a16ec1a5ec18e7111a8cb8c147aefaf)

17 months agodtrace: dtrace_getpcstack() tweaks for riscv
Mitchell Horne [Wed, 11 Jan 2023 18:06:02 +0000 (14:06 -0400)]
dtrace: dtrace_getpcstack() tweaks for riscv

Backtraces for fbt probes are missing the caller's frame. Despite what
the inherited comment claims, we do need to insert this manually on
riscv. In fbt_invop(), set cpu_dtrace_caller to be the return address,
not addr.

We should not increment aframes within this function, since we begin the
main loop by unwinding past the current frame.

Plus some very small comment/style tweaks.

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

(cherry picked from commit cdfa49f2584ac174648ced04d76a47ad6773f2f0)

17 months agodtrace: remove unused defines
Mitchell Horne [Wed, 11 Jan 2023 18:05:38 +0000 (14:05 -0400)]
dtrace: remove unused defines

Reviewed by: markj, emaste
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37659

(cherry picked from commit 2f2ec4bce96058c061f4c08fd62e67c37992dec3)

17 months agoriscv: always include frame pointer
Mitchell Horne [Wed, 11 Jan 2023 18:04:45 +0000 (14:04 -0400)]
riscv: always include frame pointer

Specifically it is missing in kernel modules, meaning a proper backtrace
can't be constructed.

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

(cherry picked from commit b926b6db37f3195e83f9fd2751b7e0c6dcf8aaef)

17 months agoClarify DTR_ENABLED make variable
Mitchell Horne [Tue, 3 Jan 2023 17:54:15 +0000 (13:54 -0400)]
Clarify DTR_ENABLED make variable

Rename it to DTRACE_ENABLED.

Suggested by: jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8372afd096ea24d45a573fce11024d143058cdab)

17 months agofuser: fix loop over kinfo_proc array
Gleb Smirnoff [Mon, 9 Jan 2023 16:40:20 +0000 (08:40 -0800)]
fuser: fix loop over kinfo_proc array

The previous code would skip as many entries at the end of the
array as there were zombies in the list.  While here fix type
of cnt.

Submitted by: Ali Abdallah <ali.abdallah suse.com>
PR: 232702

(cherry picked from commit dd2b23006caa2323a12749dfc0d831a26a79bc5b)

17 months agoatomic.9: Remove the stated dependency on types.h
Mark Johnston [Mon, 16 Jan 2023 13:04:01 +0000 (08:04 -0500)]
atomic.9: Remove the stated dependency on types.h

All machine/atomic.h necessarily include sys/atomic_common.h, which
brings in types.h.

Reviewed by: imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38040

(cherry picked from commit ccffe71ad4d9ac01f6bb4efa625ffcaf9fae739f)

17 months agoatomic: Remove cdefs.h includes from atomic_*.h
Mark Johnston [Mon, 16 Jan 2023 13:03:20 +0000 (08:03 -0500)]
atomic: Remove cdefs.h includes from atomic_*.h

Avoid including cdefs.h in system headers.  Both headers now include
types.h, and we can assume that that pulls in cdefs.h (required for
__typeof usage in some of the atomic macro expansions).

No functional change intended.

Reviewed by: imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38039

(cherry picked from commit f7e2f98bffdafff65012fb02ad838c30b7e3502f)

17 months agovm_object: Fix a kernel memory disclosure via the vm_object list sysctl
Mark Johnston [Mon, 16 Jan 2023 15:53:59 +0000 (10:53 -0500)]
vm_object: Fix a kernel memory disclosure via the vm_object list sysctl

Reported by: Chris J-D <chris@accessvector.net>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b050ee6c97e7f5b6f1e3adec69775fa41afc948f)

17 months agoatomic: Make atomic_san.h self-contained
Mark Johnston [Wed, 4 Jan 2023 02:47:52 +0000 (10:47 +0800)]
atomic: Make atomic_san.h self-contained

This file assumes that uint*_t and __typeof() are defined, so ensure
that consumers don't have to pull in the requisite includes themselves.
This is consistent with sys/atomic_common.h.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37939

(cherry picked from commit 6ebd8466af2a33d88f491799287035aa0477a5c8)

17 months agodebugnet: remove spurious message on boot
Franco Fichtner [Fri, 16 Dec 2022 15:27:18 +0000 (10:27 -0500)]
debugnet: remove spurious message on boot

In non-INVARIANTS kernels, hide the warning message printed by debugnet
when an interface MTU is configured or link state changes, and debugnet
cannot infer the number of mbuf clusters to reserve.  The warning isn't
really actionable and mostly serves to confuse users.

Reviewed by: vangyzen, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34393

(cherry picked from commit 346b8b25d90acbbbc829ddf2227ab978ffdaec7a)

17 months agoloader.efi: make sure kernel image is executable
Robert Clausecker [Mon, 2 Jan 2023 21:12:50 +0000 (22:12 +0100)]
loader.efi: make sure kernel image is executable

The Windows Dev Kit 2023 (Volterra) has an UEFI implementation that maps
EfiLoaderData pages as non-executable.  Map the kernel as EfiLoaderCode
to ensure that it can be executed.

With this change and another in review, FreeBSD boots to the mountroot
prompt if hw.pac.enable = 0 is set in loader.conf(5).

Reviewed by: andrew, imp, tsoome
Sponsored by: Berliner Linux User Group e.V.
Sponsored by: spline / FU-Berlin
Differential Revision: https://reviews.freebsd.org/D37931

(cherry picked from commit 95fa2e0aee5b7259cf4bcdea7396c4dff3241173)

17 months agoAdd Windows Dev Kit 2023 support to if_ure
Andrew Turner [Wed, 4 Jan 2023 13:23:59 +0000 (13:23 +0000)]
Add Windows Dev Kit 2023 support to if_ure

The Windows Dev Kit 2023 has an if_ure NIC with custom vendor and
procuct IDs. Add them to the driver.

Tested by: Robert Clausecker <fuz@fuz.su>
Obtained from: OpenBSD
Sponsored by: Arm Ltd

(cherry picked from commit e5b9b5ee8c3a4f3bff348cd94e3555e6b69585f6)

17 months agoCheck for more XHCI ACPI IDs
Andrew Turner [Wed, 4 Jan 2023 12:33:08 +0000 (12:33 +0000)]
Check for more XHCI ACPI IDs

The Windows Dev Kit 2023 uses the XHCI-compliant USB controller without
standard debug ID in its ACPI tables. Check for both ID values found
on [1] in the XHCI ACPI attachment.

[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/device-management-namespace-objects

Tested by: Robert Clausecker <fuz@fuz.su>
Sponsored by: Arm Ltd

(cherry picked from commit 8793196ca28f7b78f04ca479fe60b7d7af6b20e1)

17 months agoAdd support for the new Arm Generic UART _HID
Andrew Turner [Mon, 19 Dec 2022 13:42:44 +0000 (13:42 +0000)]
Add support for the new Arm Generic UART _HID

Historically the ACPI _HID for both the Arm PL011 and Generic UARTs
was ARMH0011. In the Arm Base Boot Requirements 2.0 the Generic UART
_HID is changed to ARMHB000. Use this new value in the PL011 driver
where we support both UART types.

This has been observed in some recent EDK2 builds.

Sponsored by: Arm Ltd

(cherry picked from commit f9ccec823a9f759ad6360c2a0c6336a3e2a6188a)

17 months agoUse hwreset_array in the Rockchip tsadc driver
Andrew Turner [Fri, 11 Nov 2022 08:58:34 +0000 (08:58 +0000)]
Use hwreset_array in the Rockchip tsadc driver

The order of asserting/deasserting the resets doesn't matter so use
the new hwreset_array to manage them all.

Reviewed by: manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37358

(cherry picked from commit 7ebc4c9bf76d1ea62e2ccd3020ff8e6e293b499c)

17 months agoAdd support for an array of hwresets
Andrew Turner [Fri, 11 Nov 2022 08:55:59 +0000 (08:55 +0000)]
Add support for an array of hwresets

In some drivers we need to assert and deassert a group of hardware
resets in any order. To support this add a new hwreset_array that
manages all hwresets defined for a device.

Reviewed by: bz, manu, mmel
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37357

(cherry picked from commit 969935b86b179b2b517ab5d35d943fcb761203c1)

17 months agoSplit out the arm64 EL2 exception vectors
Andrew Turner [Mon, 31 Oct 2022 15:08:26 +0000 (15:08 +0000)]
Split out the arm64 EL2 exception vectors

These were originally in locore.S as they are only needed so we have
a valid value to put into the vbar_el2 register. As these will soon
be used by bhyve so move them to a new file as we already have with
the EL1 exception vectors in exception.S.

Obtained from: https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8a2adde1e4b3fb4230cd39c151c79e73e26b575d)

17 months agoAdd more arm64 hypervisor registers
Andrew Turner [Mon, 14 Nov 2022 15:42:51 +0000 (15:42 +0000)]
Add more arm64 hypervisor registers

These will be used by bhyve.

Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2468c61958f5e50927775f0611b44402a461840d)

17 months agoPut the arm64 vttbr_el2 register into a state
Andrew Turner [Tue, 15 Nov 2022 12:53:28 +0000 (12:53 +0000)]
Put the arm64 vttbr_el2 register into a state

Zero the vttbr_el2 register on each CPU so we can tell if we are
running the host or guest kernel from a hypervisor.

Obtained from: https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ae43a817d33db3aa51f6dfce8dd940f06716e2a9)

17 months agoAdd the arch field to the arm64 MIDR macros
Andrew Turner [Mon, 14 Nov 2022 15:48:43 +0000 (15:48 +0000)]
Add the arch field to the arm64 MIDR macros

For completeness add accessors for the MIDR field. As the field is
always 0xf on arm64 it is unneeded in the current MICR handling, but
will be used in the vmm module for bhyve.

Obtained from: https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 80ba994bfacd8a843af4eb9cb7558b62e8de26ee)

17 months agoDisable superpage use for stage 2 arm64 mappings
Andrew Turner [Mon, 7 Nov 2022 11:21:42 +0000 (11:21 +0000)]
Disable superpage use for stage 2 arm64 mappings

When modifying a stage 2 mapping we may need to call into the
hypervisor to invalidate the TLB. Until it is known if the cost of
this operation is less than the performance gains superpages offers
disable their use.

Reviewed by: kib. markj
Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37299

(cherry picked from commit 0b976be033c2d7ad774da341e66aa69bfdb7f0ce)

17 months agoInclude sys/malloc.h directly in the qoriq clock
Andrew Turner [Thu, 3 Nov 2022 09:41:05 +0000 (09:41 +0000)]
Include sys/malloc.h directly in the qoriq clock

We depend on header pollution to include sys/malloc.h. Include it
directly to fix the no-FDT build.

(cherry picked from commit 81bdc9ebe3d55a4ee30ee123ada62e1fe1ea9b63)

17 months agoMake all options lower case in files.arm64
Andrew Turner [Wed, 2 Nov 2022 20:02:31 +0000 (20:02 +0000)]
Make all options lower case in files.arm64

Some of the SOC options were upper case. Make them lower to be
consistent with the rest of the file.

(cherry picked from commit cc72012d423c94ac45e3bd4fb5be68ae0844b6f7)

17 months agoSort the SOC options in the arm64 NOTES config
Andrew Turner [Wed, 2 Nov 2022 19:42:32 +0000 (19:42 +0000)]
Sort the SOC options in the arm64 NOTES config

(cherry picked from commit 2222b0e7133ebaa4588f98fa2213c30e45f6d283)

17 months agoInclude sys/systm.h in phy_usb.c for KASSERT
Andrew Turner [Fri, 28 Oct 2022 17:12:31 +0000 (18:12 +0100)]
Include sys/systm.h in phy_usb.c for KASSERT

Rather than depending on header pollution include systm.h directly.

Sponsored by: Innovate UK

(cherry picked from commit 754358108c1fa4e1818215c5ea085e13576ed798)

17 months agoRemove unneeded headers from clk_link.c
Andrew Turner [Fri, 28 Oct 2022 16:44:33 +0000 (17:44 +0100)]
Remove unneeded headers from clk_link.c

There is no OFW/FDT specific code in this file so the ofw headers can
be removed.

Sponsored by: Innovate UK

(cherry picked from commit 83de69579188488731e521df5d5c66697a321174)

17 months agoAdd more Arm CPUs to the arm64 cpu ident
Andrew Turner [Tue, 11 Oct 2022 11:53:45 +0000 (12:53 +0100)]
Add more Arm CPUs to the arm64 cpu ident

These are based on CPUs found in https://github.com/ARM-software/data

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 82860bcb64417d35e79504db2d2197769def28e7)

17 months agoMark 64-bit arm64 hypervisor registers with UL
Andrew Turner [Wed, 28 Sep 2022 13:39:45 +0000 (14:39 +0100)]
Mark 64-bit arm64 hypervisor registers with UL

These are 64-bit. Mark them as unsigned long so we don't rely on
undefined behaviour or shift a 32-bit value more than 32 bits.

Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 12c1c65d8a66e7fdd2b99a1bb03cdcf95df0a336)

17 months agoStop relying on header pollution in sdhci_xenon.c
Andrew Turner [Wed, 5 Oct 2022 13:52:02 +0000 (14:52 +0100)]
Stop relying on header pollution in sdhci_xenon.c

Include sys/malloc.h directly in sdhci_xenon.c to get the malloc(9)
definition rather than depend on header pollution.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 232323a531f42b7ecd60e8b67934c0225a1651ab)

17 months agoUse SYSCTL_FOREACH in drm2
Andrew Turner [Wed, 5 Oct 2022 09:24:13 +0000 (10:24 +0100)]
Use SYSCTL_FOREACH in drm2

This was added recently. Use it to get the correct _FOREACH macro.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e0853c9336616e4ca4ff41aab0f8ad91bb75fd42)

17 months agoClear the indirect flag in the GICv3 ITS driver
Andrew Turner [Tue, 4 Oct 2022 11:46:24 +0000 (12:46 +0100)]
Clear the indirect flag in the GICv3 ITS driver

Summary:
The indirect flag tells the hardware to use a flat or two level table.
As we only support using the flat table ensure the flag that marks
which is in use is set correctly.

We can't rely on this being set correctly as some firmware may set the
indirect flag, e.g. booting from LinuxBoot.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36873

(cherry picked from commit a0a4f5cf17236c7245250d1a9ec6fe39286f4a25)

17 months agoReduce the arm64 ID registers we print
Andrew Turner [Tue, 19 Jul 2022 08:47:23 +0000 (09:47 +0100)]
Reduce the arm64 ID registers we print

On systems with different CPUs we may print all the ID registers for
all CPUs. Reduce this to just print them when they change from the
previous CPU.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit a42206a7ca773fafad396cd89f77f3a369a75a17)

17 months agoMove the GICv3 bus_print_child function to the parent
Andrew Turner [Thu, 22 Sep 2022 10:50:15 +0000 (11:50 +0100)]
Move the GICv3 bus_print_child function to the parent

This should be common for both ACPI and FDT. Move this to the common
part of the driver.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit bdc9ece97b80c3a8b8c9161d95ef908172eb316a)

17 months agoAdd bus_get_resource_list functions to the GICv3 driver
Andrew Turner [Thu, 22 Sep 2022 10:17:45 +0000 (11:17 +0100)]
Add bus_get_resource_list functions to the GICv3 driver

This will be used to reduce code duplication between the ACPI and FDT
attachments.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6fc6896c474483b3cf34b83fb85f8e9f8cabc8a1)

17 months agoRevert "tcp: virtualise net.inet.tcp.msl sysctl."
Alexander V. Chernikov [Mon, 23 Jan 2023 11:37:58 +0000 (11:37 +0000)]
Revert "tcp: virtualise net.inet.tcp.msl sysctl."

This reverts commit 81a72d997e22f37ac15a009090a5a15a6c279900.