]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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.

17 months agodomains: allow pre-defined domains to be unloaded
Alexander V. Chernikov [Fri, 12 Aug 2022 13:36:53 +0000 (13:36 +0000)]
domains: allow pre-defined domains to be unloaded

Add domain_remove() SYSUNINT callback that removes the domain
 from the domain list. This change is required to support Netlink.
This version is different from HEAD: it uses fixed family check,
 instead of the DOMF_UNLOADABLE flag. The dom_flag field appeared
 in HEAD and was not merged back, as there are no spare fields in
 'struct domain'.

Original commit message:

Add domain_remove() SYSUNINT callback that removes the domain
 from the domain list if it has DOMF_UNLOADABLE flag set.
This change is required to support netlink ( D36002 ).

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D36173

(cherry picked from commit 9b967bd65de6647aed68a141dc34f9b223a2593c)

17 months agopf tests: properly destroy renamed interfaces
Kajetan Staszkiewicz [Mon, 16 Jan 2023 06:19:41 +0000 (07:19 +0100)]
pf tests: properly destroy renamed interfaces

The pfsync:pbr tests leaves  lot of interfaces when they finish, making
other tests slower due to long time of loading scapy from pft_ping.py
when more interfaces are present. When both sides of epair are assigned
to jails, they are both removed from created_interfaces.lst and thus
won't be removed during cleanup from this file. An interface assigned to
jail is stored in created_jails.lst but if it is renamed, it won't be
cleaned up either. Furthermore this test uses identical names for
multiple interfaces across multiple jails which after destroying those
jails adds to overall confusion.

To address this issue a new function is provided for renaming interfaces
in jails and storing their new names in created_jails.lst for deletion
during cleanup.

MFC after: 1 week
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D38024

(cherry picked from commit ddcdb534b7669f186184baf164e7647d544f7bd6)

17 months agoAdd initial DPAA2 support
Dmitry Salychev [Tue, 20 Sep 2022 09:47:41 +0000 (11:47 +0200)]
Add initial DPAA2 support

DPAA2 is a hardware-level networking architecture found in some NXP
SoCs which contain hardware blocks including Management Complex
(MC, a command interface to manipulate DPAA2 objects), Wire Rate I/O
processor (WRIOP, packets distribution, queuing, drop decisions),
Queues and Buffers Manager (QBMan, Rx/Tx queues control, Rx buffer
pools) and the others.

The Management Complex runs NXP-supplied firmware which provides DPAA2
objects as an abstraction layer over those blocks to simplify an
access to the underlying hardware. Each DPAA2 object has its own
driver (to perform an initialization at least) and will be visible
as a separate device in the device tree.

Two new drivers (dpaa2_mc and dpaa2_rc) act like firmware buses in
order to form a hierarchy of the DPAA2 devices:

acpiX (or simplebusX)
  dpaa2_mcX
    dpaa2_rcX
      dpaa2_mcp0
      ...
      dpaa2_mcpN
      dpaa2_bpX
      dpaa2_macX
      dpaa2_io0
      ...
      dpaa2_ioM
      dpaa2_niX

dpaa2_mc is suppossed to be a root of the hierarchy, comes in ACPI
and FDT flavours and implements helper interfaces to allocate and
assign bus resources, MSI and "managed" DPAA2 devices (NXP treats some
of the objects as resources for the other DPAA2 objects to let them
function properly). Almost all of the DPAA2 objects are assigned to
the resource containers (dpaa2_rc) to implement isolation.

The initial implementation focuses on the DPAA2 network interface
to be operational. It is the most complex object in terms of
dependencies which uses I/O objects to transmit/receive packets.

Approved by: bz (mentor)
Tested by: manu, bz
Differential Revision: https://reviews.freebsd.org/D36638

(cherry picked from commit ba7319e9091b4f6ef15a9c4be3d3d076f3047f72)
(cherry picked from commit 7fb975c8fb970b35fc34561ed30a0fe220346cb6)
(cherry picked from commit 2782ed8f6cd3d7f59219a783bc7fa7bbfb1fe26f)
(cherry picked from commit d6eabdac2ef444b62aba186c793fbd5d4226b157)
(cherry picked from commit 16295b0a5a577aa70f47d3b3314277e631caee63)
(cherry picked from commit ff270fce1631cdfbf8d3d76b9a9f5342b78972c9)

17 months agounzip: Document optional member list
Yoshihiro Takahashi [Mon, 2 Jan 2023 04:17:27 +0000 (13:17 +0900)]
unzip: Document optional member list

Submitted by: Pat Maddox (man page)
PR: 267426

(cherry picked from commit a1f28ec729f7491da8607e8eeaee1b0f547c60d0)

17 months agokern_umtx.c do_wait(): correct confusing indent
Konstantin Belousov [Fri, 20 Jan 2023 21:32:27 +0000 (23:32 +0200)]
kern_umtx.c do_wait(): correct confusing indent

(cherry picked from commit 5657f49ef33b13934ccdc36e3990fdd71376baed)

17 months agovmstat: fix overflow of interrupt name buffer
Elliott Mitchell [Sat, 26 Nov 2022 16:21:33 +0000 (09:21 -0700)]
vmstat: fix overflow of interrupt name buffer

(cherry picked from commit e5c30ac93055e708e26e075937263608b3eeb17d)

17 months agovmstat: remove shadow variables
Elliott Mitchell [Wed, 21 Sep 2022 02:18:23 +0000 (19:18 -0700)]
vmstat: remove shadow variables

(cherry picked from commit d4d79718496753493f059cb8f2b2e87e0b7019b0)

17 months agomd.c: another style fix
Konstantin Belousov [Fri, 20 Jan 2023 02:39:36 +0000 (04:39 +0200)]
md.c: another style fix

(cherry picked from commit ad8feb1ed9996593df8b4b7259057c6e263aa130)

17 months agoHandle ERELOOKUP from VOP_FSYNC() in several other places
Konstantin Belousov [Wed, 18 Jan 2023 21:09:10 +0000 (23:09 +0200)]
Handle ERELOOKUP from VOP_FSYNC() in several other places

(cherry picked from commit 6189672e600814fec4cc165d25ae050fb2f3a999)

17 months agovm_object.c: minor style
Konstantin Belousov [Thu, 19 Jan 2023 18:32:16 +0000 (20:32 +0200)]
vm_object.c: minor style

(cherry picked from commit 70e1b11216c43e95118728f3684a1b8abc7034a1)

17 months agoif_ipsec(4): handle situations where there are no policy or SADB entry for if
Konstantin Belousov [Tue, 17 Jan 2023 01:59:56 +0000 (03:59 +0200)]
if_ipsec(4): handle situations where there are no policy or SADB entry for if

(cherry picked from commit b1d10b49e24a4fd3af80f8491cd95bd0766ca1f1)

17 months agoif_ipsec(4): protect against user supplying unknown address family
Konstantin Belousov [Tue, 17 Jan 2023 01:37:45 +0000 (03:37 +0200)]
if_ipsec(4): protect against user supplying unknown address family

(cherry picked from commit eac971545baa3857903e0107439f00d8438c5847)

17 months agoipsec.c: typos in the comment
Konstantin Belousov [Sat, 4 Sep 2021 13:42:33 +0000 (16:42 +0300)]
ipsec.c: typos in the comment

(cherry picked from commit 424f1296bd73f2661b556ddfdfb4bcc8f9df898a)

17 months agoRequire INVARIANTS and WITNESS if DEBUG_VFS_LOCKS is set
Konstantin Belousov [Sun, 15 Jan 2023 21:33:10 +0000 (23:33 +0200)]
Require INVARIANTS and WITNESS if DEBUG_VFS_LOCKS is set

Tested by: pho

(cherry picked from commit 0f80d5ebc898f487067a3f2232f9ab0a7b291277)

17 months agoffs_syncvnode(): avoid a LoR for SU
Konstantin Belousov [Sat, 7 Jan 2023 12:22:18 +0000 (14:22 +0200)]
ffs_syncvnode(): avoid a LoR for SU

Tested by: pho

(cherry picked from commit 6e1eabadcb1d554ab6c0ad8ce1d82f6748cc80b4)

17 months agomountd(8): Fix a typo in a source code comment
Gordon Bergling [Thu, 19 Jan 2023 13:23:51 +0000 (14:23 +0100)]
mountd(8): Fix a typo in a source code comment

- s/ingore/ignore/

(cherry picked from commit afc55510b1178ba94d2bdcef0eb666b10abcfc42)

17 months agoamd64: Fix a common typo in source code comments
Gordon Bergling [Thu, 19 Jan 2023 13:27:18 +0000 (14:27 +0100)]
amd64: Fix a common typo in source code comments

- s/comparision/comparison/

(cherry picked from commit 05187f2ffc79e5959762ab8ce7067b7b8a1cdfd9)

17 months agobsnmpget.1: Fix a typo in the man page
Gordon Bergling [Thu, 19 Jan 2023 13:18:52 +0000 (14:18 +0100)]
bsnmpget.1: Fix a typo in the man page

- s/ingore/ignore/

(cherry picked from commit 7a184a41c6a31a1dcf82c2e35446f96dde78dbce)

17 months agonfs: Fix a common typo in source code comments
Gordon Bergling [Thu, 19 Jan 2023 13:26:06 +0000 (14:26 +0100)]
nfs: Fix a common typo in source code comments

- s/ingore/ignore/

(cherry picked from commit 72e709040f3691911c7b58d5a14b4d19b276f478)

17 months agoextra_tcp_stacks: Fix a common typo in source code comments
Gordon Bergling [Thu, 19 Jan 2023 13:11:00 +0000 (14:11 +0100)]
extra_tcp_stacks: Fix a common typo in source code comments

- s/orginal/original/

(cherry picked from commit 73e994a99810edf519d85e96dcb4a56e57be25cc)

17 months agoip_gre: Fix a common typo in source code comments
Gordon Bergling [Thu, 19 Jan 2023 13:13:02 +0000 (14:13 +0100)]
ip_gre: Fix a common typo in source code comments

- s/addres/address/

(cherry picked from commit fa7de6dcb9b7314d4736f1fc21b3fdceefe34173)

17 months agong_hci: handle NG_HCI_M_PULLUP failure in le_advertizing_report
Ed Maste [Tue, 1 Nov 2022 13:55:22 +0000 (09:55 -0400)]
ng_hci: handle NG_HCI_M_PULLUP failure in le_advertizing_report

PR: 267396
Reported by: Robert Morris <rtm@lcs.mit.edu>
Reviewed by: takawata
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37228

(cherry picked from commit 05c0c99ea37f2558155f346769a00b4180cb59ed)

17 months agong_bt: Remove an unused variable.
John Baldwin [Fri, 8 Apr 2022 00:01:26 +0000 (17:01 -0700)]
ng_bt: Remove an unused variable.

Leave a comment describing the field in the packet it represented.

(cherry picked from commit 9f566782e0ba9973a78fd2405427b5de887ac213)

17 months agobhyve nvme: Fix uninitialized pointer
Chuck Tuffli [Thu, 9 Jun 2022 20:05:46 +0000 (13:05 -0700)]
bhyve nvme: Fix uninitialized pointer

The Dataset Management code could free an uninitialized pointer if the
device doesn't support the Dataset Management command.

PR: 264548
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 7376c08cc67e65ee660d51873129e34745ef5dd4)

17 months agoopenssh: remove mention of now-unused svn:keywords
Ed Maste [Mon, 16 Jan 2023 14:52:00 +0000 (09:52 -0500)]
openssh: remove mention of now-unused svn:keywords

Reported by: gshapiro

(cherry picked from commit 9b7eddfeed465d4062dbad178261b806e97d6b62)

17 months agotests/sys/posixshm/posixshm_test.c: Fix build for real
Konstantin Belousov [Fri, 20 Jan 2023 13:02:12 +0000 (15:02 +0200)]
tests/sys/posixshm/posixshm_test.c: Fix build for real

Remove unused variables.  This is a direct commit to stable/13.

17 months agoRemove merge conflict leftovers
Konstantin Belousov [Fri, 20 Jan 2023 11:21:08 +0000 (13:21 +0200)]
Remove merge conflict leftovers

This is a direct commit to stable/13.

Reported by: Stefan Grundmann via https://github.com/freebsd/freebsd-src/pull/639

17 months agoStop cleaning MNT_LOCAL on unmount
Konstantin Belousov [Fri, 6 Jan 2023 16:38:44 +0000 (18:38 +0200)]
Stop cleaning MNT_LOCAL on unmount

Tested by: pho

(cherry picked from commit 1d9f3a37eb20305bfdd67788cfac5c51938226a4)

17 months agoi386: print trampoline disposition value for verbose boot
Konstantin Belousov [Fri, 6 Jan 2023 18:18:51 +0000 (20:18 +0200)]
i386: print trampoline disposition value for verbose boot

Tested by: pho

(cherry picked from commit 29bfaf1c6d8bc0a06aaa7e09363544769eade3c0)

17 months agoamd64 pmap.h: make it easier to use the header for other consumers
Konstantin Belousov [Wed, 4 Jan 2023 10:31:16 +0000 (12:31 +0200)]
amd64 pmap.h: make it easier to use the header for other consumers

Tested by: pho

(cherry picked from commit ad97b9bbfccdb36f17788033903b1dbf508fcb96)

17 months agoamd64: be more precise when enabling the AlderLake small core PCID workaround
Konstantin Belousov [Tue, 3 Jan 2023 10:13:07 +0000 (12:13 +0200)]
amd64: be more precise when enabling the AlderLake small core PCID workaround

Tested by: pho

(cherry picked from commit a2c08eba43a2c0ebeac7117f708fb9392022a300)

17 months agoMove INVLPG to pmap_quick_enter_page() from pmap_quick_remove_page().
Konstantin Belousov [Thu, 29 Dec 2022 20:48:51 +0000 (22:48 +0200)]
Move INVLPG to pmap_quick_enter_page() from pmap_quick_remove_page().

Tested by: pho

(cherry picked from commit 231d75568f169fe6adc30373c12512b992c5c672)

17 months agoamd64: for small cores, use (big hammer) INVPCID_CTXGLOB instead of INVLPG
Konstantin Belousov [Mon, 10 Oct 2022 23:08:55 +0000 (02:08 +0300)]
amd64: for small cores, use (big hammer) INVPCID_CTXGLOB instead of INVLPG

PR: 261169, 266145
Tested by: pho

(cherry picked from commit cde70e312c3fde5b37a29be1dacb7fde9a45b94a)

17 months agoamd64: identify small cores
Konstantin Belousov [Wed, 21 Dec 2022 11:04:14 +0000 (13:04 +0200)]
amd64: identify small cores

Tested by: pho

(cherry picked from commit 45ac7755a7c5d8508176b3d015bb27ff58485c80)

17 months agoUFSSUSPEND: unbusy mp in EDADLK case
Konstantin Belousov [Thu, 29 Dec 2022 22:09:57 +0000 (00:09 +0200)]
UFSSUSPEND: unbusy mp in EDADLK case

Tested by: pho

(cherry picked from commit a5ff86646ee4602a141a24eee95c1c60bb375030)

17 months agoufs/suspend: deny suspension if the calling process has a file from mp opened for...
Konstantin Belousov [Wed, 28 Dec 2022 18:14:52 +0000 (20:14 +0200)]
ufs/suspend: deny suspension if the calling process has a file from mp opened for write

PR: 267628, 267630
Tested by: pho

(cherry picked from commit 701b36961cbd2084c36eb828402d0ef89211d929)

17 months agoffs_suspend.c: clean up includes
Konstantin Belousov [Wed, 28 Dec 2022 18:17:53 +0000 (20:17 +0200)]
ffs_suspend.c: clean up includes

Tested by: pho

(cherry picked from commit 68912701700ca3230f3e2d4b7858a038f884a327)

17 months agoAdd descrip_check_write_mp() helper
Konstantin Belousov [Wed, 28 Dec 2022 18:13:01 +0000 (20:13 +0200)]
Add descrip_check_write_mp() helper

Tested by: pho

(cherry picked from commit 37b9fb169686e867987c8a1a9868f81137b9df2b)

17 months agotools/test/ptrace: update scescx to do remote getpid(2) on each SCX event
Konstantin Belousov [Fri, 2 Dec 2022 01:26:13 +0000 (03:26 +0200)]
tools/test/ptrace: update scescx to do remote getpid(2) on each SCX event

Tested by: pho

(cherry picked from commit 6403a140243d4f5377f589f93aeb44fe75ea8d59)