]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
13 months agoLinuxKPI: skbuff.h: fix -Warray-bounds warnings
Bjoern A. Zeeb [Wed, 19 Apr 2023 21:37:01 +0000 (21:37 +0000)]
LinuxKPI: skbuff.h: fix -Warray-bounds warnings

Harmonize sk_buff_head and sk_buff further and fix -Warray-bounds
warnings reports by gcc.  At the same time simplify some code by
re-using other functions or factoring some code out.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b2dcb848688e1e8346762531208dd7d468ff3854)

13 months agoLinuxKPI: 802.11: fix a -Wenum-compare warning
Bjoern A. Zeeb [Wed, 19 Apr 2023 21:40:18 +0000 (21:40 +0000)]
LinuxKPI: 802.11: fix a -Wenum-compare warning

We are asserting that two values from different enums are the same.
gcc warns about these.  Cast the values to (int) to avoid the warning.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f369f10dd8122b1cd1282a378fb16ba81a712a74)

13 months agoiwlwifi: quieten more compiler warnings
Bjoern A. Zeeb [Thu, 20 Apr 2023 15:57:14 +0000 (15:57 +0000)]
iwlwifi: quieten more compiler warnings

Quieten some more (valid) gcc warnings and disable dead code.
There are more warnings, some probably a compiler problem, the
other related to firmware structs which I do not want to adjust
just locally.  Leave a comment to revisit after a next driver
update.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7db7bfe1a7b95c1acfc7861e05ee8808d448715f)

13 months agoiwlwifi: rtw88: rtw89: fix gcc warnings
Bjoern A. Zeeb [Tue, 18 Apr 2023 19:51:09 +0000 (19:51 +0000)]
iwlwifi: rtw88: rtw89: fix gcc warnings

Fix -Wno-format and unused variables warnings with gcc by adopting
(to|the) FreeBSD-specific code.

Reported by: jhb
Sponsored by: The FreeBSD Foundation
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D39673

(cherry picked from commit f621b087c00776de713944ae6561e44f83e7b541)

13 months agortw89: fix -Wunused-but-set-variable
Bjoern A. Zeeb [Thu, 23 Mar 2023 00:29:38 +0000 (00:29 +0000)]
rtw89: fix -Wunused-but-set-variable

Fix a -Wunused-but-set-variable warning by adding the field to the
debug logging as is done for other versions handler functions.

(cherry picked from commit 700acdc7b53213c1d9f35c05a1c1f58f285cd14d)

13 months agoKASAN: add bus_space*read*_8 for aarch64
Bjoern A. Zeeb [Sat, 15 Apr 2023 15:35:50 +0000 (15:35 +0000)]
KASAN: add bus_space*read*_8 for aarch64

Add the remaining bus_space*read*_8 functions conditionally for
only arm64 in order to not break KASAN builds with new code using
one of them.

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

(cherry picked from commit 42742fe725102a73b09800f4d041ad69b5d81edb)

13 months agoman4: fix some mandoc lint for iwlwifi.4 and rtw88.4
Bjoern A. Zeeb [Sun, 23 Apr 2023 13:21:46 +0000 (13:21 +0000)]
man4: fix some mandoc lint for iwlwifi.4 and rtw88.4

Address warnings (but one) from mandoc -T lint for these man pages.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b95fa4203d698063b02b03647cd00906cd94687a)

13 months agoifconfig: improve trimming off interface number at end
Bjoern A. Zeeb [Wed, 17 May 2023 20:40:47 +0000 (20:40 +0000)]
ifconfig: improve trimming off interface number at end

When trying to auto-load a module, we trim the interface number off
the end.  Currently we stop at the first digit.  For interfaces which
have numbers in the driver name this does not work well.
In the current example ifconfig ath10k0 would load ath(4) instead of
ath10k(4).  For module/interface names like rtw88[0] we never guess
correctly.
To improve for the case we can, start trimming off digits from the
end rather than the front.

Sponsored by: The FreeBSD Foundation
Reported by: thierry
Reviewed by: melifaro, thierry
Differential Revision: https://reviews.freebsd.org/D40137

(cherry picked from commit 2e6756b752e07878ae5f5e3e9b74934231f9fd17)

13 months agonetwork.subr: adjust regex for wlans_xxxxx rc.conf entries
Bjoern A. Zeeb [Tue, 18 Apr 2023 14:40:13 +0000 (14:40 +0000)]
network.subr: adjust regex for wlans_xxxxx rc.conf entries

Drivers like ath1[012]k will not match the current wlans_*-regex as
they have digits followed by letters.  Adjust the regex to allow
this combination in order to be able to configure interfaces with
names like wlans_ath11k0="..."

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

(cherry picked from commit de1dde5dfea4407119955a6f94528396b258db3f)

13 months agorc/WPA: driver_bsd.c: backout upstream IFF_ change and add logging
Bjoern A. Zeeb [Thu, 23 Mar 2023 22:37:12 +0000 (22:37 +0000)]
rc/WPA: driver_bsd.c: backout upstream IFF_ change and add logging

This reverts the state to our old supplicant logic setting or clearing
IFF_UP if needed.  In addition this adds logging for the cases in which
we do (not) change the interface state.

Depending on testing this seems to help bringing WiFi up or not log
any needed changes (which would be the expected wpa_supplicant logic
now).  People should look out for ``(changed)`` log entries (at least
if debugging the issue; this way we will at least have data points).

There is a hypothesis still pondered that the entire IFF_UP toggling
only exploits a race in net80211 (see further discssussions for more
debugging and alternative solutions see D38508 and D38753).
That may also explain why the changes to the rc startup script [1]
only helped partially for some people to no longer see the
continuous CTRL-EVENT-SCAN-FAILED.

It is highly likely that we will want further changes and until
we know for sure that people are seeing ''(changed)'' events
this should stay local.  Should we need to upstream this we'll
likely need #ifdef __FreeBSD__ around this code.

Remove ifconfig down/up workaround (bfb202c4554a) in
rc.d/wpa_supplicant as it is no longer needed.

[1] 5fcdc19a81115d975e238270754e28557a2fcfc5 and
    d06d7eb09131edea666bf049d6c0c55672726f76

Sponsored by: The FreeBSD Foundation
Reviewed by: cy, enweiwu (earlier)
Differential Revision: https://reviews.freebsd.org/D38807

(cherry picked from commit bfb202c4554a72383202a1a401d80721935b8c95)

Reviewed by: bz (for wireless)
Differential Revision: https://reviews.freebsd.org/D39257

(cherry picked from commit 052211e08c0e227277d0c4dc603bba2253eb3d73)

13 months agoifconfig: ifieee80211: print bssid name
Bjoern A. Zeeb [Tue, 21 Mar 2023 21:25:28 +0000 (21:25 +0000)]
ifconfig: ifieee80211: print bssid name

In certain setups (e.g., autonomous APs) it is extremly helpful to have
a way to map the BSSIDs to names for both normal status output as well
as the scan list.  This often allows a quicker overview than remembering
(or manually looking up) BSSIDs.
Call ether_ntohost() on the bssid and consult /etc/ethers
and print "(name)" after the bssid for the status output and "(name)"
at the end of the line after the IE list.

Reviewed by: adrian, cy
Differential Revision: https://reviews.freebsd.org/D39192

(cherry picked from commit e091be417add7e9130653462012a9ab2f4fb5269)

13 months agonet80211: define mask for ss_flags rather than using hardcoded 0xfff
Bjoern A. Zeeb [Tue, 14 Mar 2023 21:00:48 +0000 (21:00 +0000)]
net80211: define mask for ss_flags rather than using hardcoded 0xfff

scan state ss_flags in two places cut off the "internal" GOTPICK
options.  Replace the hardcoded 0xfff with a defined mask.
Note that "internal" flags is confusing as we also supplement the
the 16bit by another 16bit of "internal flags" passed around but
comaparing to GOTPICK never stored to my understanding.

No functional change.

Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D38832

(cherry picked from commit 3346164ce844f8995311c3988ab193bd6ddda0c9)

13 months agonet80211: make ieee80211_scan_dump_channels private
Bjoern A. Zeeb [Tue, 14 Mar 2023 21:01:19 +0000 (21:01 +0000)]
net80211: make ieee80211_scan_dump_channels private

ieee80211_scan_dump_channels() is only used locally and only when
IEEE80211_DEBUG is compiled.  Stop exporting it, make it file local
and hide under the #ifdef to reduce the footprint for production
kernels a tiny bit.

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

(cherry picked from commit d7fb679dc96b07c38eedfa8c91817b44b214c799)

13 months agodpaa2: add console support for FDT based systems
Bjoern A. Zeeb [Tue, 14 Feb 2023 15:53:13 +0000 (15:53 +0000)]
dpaa2: add console support for FDT based systems

Add DPAA2 console support for MC and AIOP (latter untested) for FDT
systems.  ACPI systems are prepared but need some proper bus function
in order to get the address from MC (and likely a file splitup then).
This will come at a later stage once other ACPI/FDT bus parts are
cleared up.
The work was originally done in July 2022 and finally switched to
bus_space[1] lately to be ready for main.

Suggested by: andrew [1]
Reviewed by: dsl
Differential Revision: https://reviews.freebsd.org/D38592

(cherry picked from commit 72ef722b2a34b8f94fd639b05881242686480f05)

13 months agomotd: MFC: unbreak for source upgrade
Eugene Grosbein [Mon, 19 Jun 2023 07:49:35 +0000 (14:49 +0700)]
motd: MFC: unbreak for source upgrade

In case of source upgrade path from 12.x proper merge of new /etc
installs /etc/motd.template. Becase of that, the system is left
without symlink /etc/motd -> /var/run/motd but with stale /etc/motd contents.

Fix it creating symlink despite of presence of /etc/motd.template.

(cherry picked from commit 79a96e294c1acb4a2d17447a35f08647a6d09978)

13 months agosctp: only start shutdown guard timer when sending SHUTDOWN chunk
Michael Tuexen [Wed, 3 May 2023 18:28:46 +0000 (20:28 +0200)]
sctp: only start shutdown guard timer when sending SHUTDOWN chunk

The intention is to protect a malicious peer not following the
shutdown procedures.

(cherry picked from commit 04ede3675e44847c3e9e4a9bd44509cdf42ed60a)

13 months agosctp: improve shutdown(..., SHUT_WR) handling
Michael Tuexen [Wed, 3 May 2023 15:30:50 +0000 (17:30 +0200)]
sctp: improve shutdown(..., SHUT_WR) handling

When shutdown(..., SHUT_WR) is called in the front states, send a
SHUTDOWN chunk when a COOKIE ACK chunk is received and there is
no outstanding data.

(cherry picked from commit d9ae4adff2715cfab4a941037ec15aa07108efa1)

13 months agosctp: improve handling of stale cookie error causes
Michael Tuexen [Sun, 30 Apr 2023 09:39:32 +0000 (11:39 +0200)]
sctp: improve handling of stale cookie error causes

* If a measure of staleness of 0 is reported, use the RTT instead.
* Ensure that we always send a cookie preservative parameter by
  rounding up during the calculation.
* If allowed, perform a round trip time measurement.
* Clear the overall error counter, since the error cause also
  acts like an ACK.

(cherry picked from commit 1f0e13449beef3a983d9ed2faf4734075e4120d1)

13 months agosctp: use constants from RFC 8260 to improve compliance
Michael Tuexen [Sun, 23 Apr 2023 15:48:05 +0000 (17:48 +0200)]
sctp: use constants from RFC 8260 to improve compliance

Keep the old constants for backwards compatibility.

(cherry picked from commit 66d6fd532282fda0cda0ca31d93ff09044f1386a)

13 months agosctp: enforce Kahn's rule during the handshake
Michael Tuexen [Thu, 16 Mar 2023 16:40:40 +0000 (17:40 +0100)]
sctp: enforce Kahn's rule during the handshake

Don't take RTT measurements on packets containing INIT or COOKIE-ECHO
chunks, when they were retransmitted.

(cherry picked from commit 8ed1e2c88012cfca9fc4131a2637452cc9106b81)

13 months agosctp: don't do RTT measurements with cookies
Michael Tuexen [Thu, 16 Mar 2023 09:45:13 +0000 (10:45 +0100)]
sctp: don't do RTT measurements with cookies

When receiving a cookie, the receiver does not know whether the
peer retransmitted the COOKIE-ECHO chunk or not. Therefore, don't
do an RTT measurement. It might be much too long.
To overcome this limitation, one could do at least two things:
1. Bundle the INIT-ACK chunk with a HEARTBEAT chunk for doing the
   RTT measurement. But this is not allowed.
2. Add a flag to the COOKIE-ECHO chunk, which indicates that it
   is the initial transmission, and not a retransmission. But
   this requires an RFC.

(cherry picked from commit c91ae48a25edd426efc49ade14fb675e07a0f5ed)

13 months agotcp: fix TCP MD5 computation for the BBR and RACK stack
Michael Tuexen [Wed, 21 Jun 2023 20:54:33 +0000 (22:54 +0200)]
tcp: fix TCP MD5 computation for the BBR and RACK stack

PR: 253096
Reviewed by: cc, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40597

(cherry picked from commit 02b885b09d1e90574162a1442b9ede06cef2b13a)

13 months agotcp: fix TCP MD5 digest computation for TCP over UDP
Michael Tuexen [Wed, 21 Jun 2023 20:48:12 +0000 (22:48 +0200)]
tcp: fix TCP MD5 digest computation for TCP over UDP

Skip the UDP header for the computation. This is similar to
skipping IPv6 extension headers.

Reviewed by: cc, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40596

(cherry picked from commit 0fb0711dba76a32a2202d2f41d64aa1247b5e51d)

13 months agosctp: fix man page for socket option controlling delayed acks
Michael Tuexen [Wed, 21 Jun 2023 07:03:30 +0000 (09:03 +0200)]
sctp: fix man page for socket option controlling delayed acks

The SCTP_DELAYED_ACK_TIME socket option was replaced by the
SCTP_DELAYED_SACK in the socket API specification in
draft-ietf-tsvwg-sctpsocket-14.
The code was updated in r170056, but the man page was not.

PR: 272124

(cherry picked from commit 133b132bc1b612abe591c8f54680c3da8491e194)

13 months agoipmi: add Block Transfer interface support
Andrey V. Elsukov [Wed, 7 Jun 2023 09:30:47 +0000 (12:30 +0300)]
ipmi: add Block Transfer interface support

Reviewed by: ambrisko
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D40421

(cherry picked from commit 1f166509895dd90fcaaa08b557f9bc106e3f7e71)

14 months agowpa: Enable receiving priority tagged (VID 0) frames
R. Christian McDonald [Sun, 11 Jun 2023 23:22:53 +0000 (16:22 -0700)]
wpa: Enable receiving priority tagged (VID 0) frames

Certain internet service providers transmit vlan 0 priority tagged
EAPOL frames from the ONT towards the residential gateway. VID 0
should be ignored, and the frame processed according to the priority
set in the 802.1P bits and the encapsulated EtherType (i.e. EAPOL).

The pcap filter utilized by l2_packet is inadquate for this use case.

Here we modify the pcap filter to accept both unencapsulated and
encapsulated (with VLAN 0) EAPOL EtherTypes. This preserves the
original filter behavior while also matching on encapsulated EAPOL.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D40442

(cherry picked from commit bb5d6d14d81b0789d2e73da03571603426afef56)

14 months agoarm64: Remove struct arm64_frame
Mark Johnston [Thu, 15 Jun 2023 16:10:44 +0000 (12:10 -0400)]
arm64: Remove struct arm64_frame

It was used in one place and was added specifically to support dtrace
stack unwinding code.  Write an equivalent expression using struct
unwind_state instead.  No functional change intended.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40538

(cherry picked from commit d3251842321e7a5ac8bbb2aec128328cd10f3a84)

14 months agodtrace/arm64: Fix user memory access routines
Mark Johnston [Thu, 15 Jun 2023 16:39:21 +0000 (12:39 -0400)]
dtrace/arm64: Fix user memory access routines

Use unprivileged loads to access user memory.  Without this, the
accesses trap and various dtrace actions such as ustack() fail.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40540

(cherry picked from commit 6281147a963b02bb5d7b4db15ee295d6d65d0fff)

14 months agoarm64: Make a debug print conditional on bootverbose
Mark Johnston [Thu, 15 Jun 2023 16:13:05 +0000 (12:13 -0400)]
arm64: Make a debug print conditional on bootverbose

It doesn't seem particularly useful to have it enabled by default, and
it spits several dozen lines into the dmesg on a test system.

Reviewed by: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40499

(cherry picked from commit 50e1cc94a138f8886588eabe0b849b487d9925a3)

14 months agomd: Get rid of the pbuf zone
Mark Johnston [Tue, 23 May 2023 14:14:06 +0000 (10:14 -0400)]
md: Get rid of the pbuf zone

The zone is used solely to provide KVA for mapping BIOs so that we can
pass mapped buffers to VOP_READ and VOP_WRITE.  Currently we preallocate
nswbuf/10 bufs for this purpose during boot.

The intent was to limit KVA usage on 32-bit systems, but the
preallocation means that we in fact consumed more KVA than needed unless
one has more than nswbuf/10 (typically 25) vnode-backed MD devices
in existence, which I would argue is the uncommon case.

Meanwhile, all I/O to an MD is handled by a dedicated thread, so we can
instead simply preallocate the KVA region at MD device creation time.

Event: BSDCan 2023
Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D40215

(cherry picked from commit 30038a8b4efc6d0b9f8f295e28bc205fe9728310)

14 months agokern_ntptime: Fix undefined behavior of the shift operator
Dmitriy Alexandrov [Thu, 8 Jun 2023 09:08:46 +0000 (12:08 +0300)]
kern_ntptime: Fix undefined behavior of the shift operator

L_LINT macro is used with negative numbers [i.e.
L_LINT(time_freq, -MAXFREQ)], it could cause undefined
behavior. It should be similar to the L_RSHIFT(v, n) macro.

MFC after: 2 weeks
Reviewed by: cy
Pull Request: https://github.com/freebsd/freebsd-src/pull/769
Signed-off-by: Dmitriy Alexandrov <d06alexandrov@gmail.com>
(cherry picked from commit af9ce4e9bb7d717279e02d46455e85ef6fb828f7)

14 months agomsun: Correct FreeBSD version in sincos() man page
Brad Smith [Fri, 9 Jun 2023 20:01:35 +0000 (22:01 +0200)]
msun: Correct FreeBSD version in sincos() man page

The sincos() man page notes the function was added to msun in FreeBSD
9.0 which must have been an oversight in the review as it was commited
to 12.0 and then backported to the 11 branch.

So I have provided a diff to correct this to the first FreeBSD version
it did ship with which was 11.2.

Reviewed by: dim, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D40308

(cherry picked from commit 2c01176a2802cb261d56a09c9faf9bff9dfb3536)

14 months agonameser: Fix a typo in a source code comment
Gordon Bergling [Mon, 19 Jun 2023 11:49:23 +0000 (13:49 +0200)]
nameser: Fix a typo in a source code comment

-s /unknwon/unknown/

(cherry picked from commit 8f79b07564df4deccf63478c2a87dafabeac95c3)

14 months agoEC2: Default to "uefi-preferred" boot mode
Colin Percival [Wed, 7 Jun 2023 22:17:12 +0000 (15:17 -0700)]
EC2: Default to "uefi-preferred" boot mode

In EC2, UEFI boots faster than BIOS, but not all amd64 instance types
support UEFI.  AMIs need to have their boot mode designated, which
created a dilemma: Faster boots, or wider compatibility?

The recently added "uefi-preferred" option solves this: AMIs can be
marked to use UEFI where it's available, but fall back to BIOS on
instance types which do not support UEFI.

This uses bsdec2-image-upload 1.4.6, which recently landed in the
ports tree.

PR: 265697
Reviewed by: delphij, imp
MFC after: 1 week
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D40470

(cherry picked from commit bcf9147144f3499976a623f92712ecd0aca71912)

14 months agopf: fix pf_nv##_array() size check
Kristof Provost [Mon, 15 May 2023 17:40:32 +0000 (19:40 +0200)]
pf: fix pf_nv##_array() size check

We want to set the maximum number of elements we'll accept, not the
exact number we need.

MFC after: 3 weeks
Sponsored by: Orange Business Services

(cherry picked from commit 76c8f202a4f6a3190e102a0bc1589bbfc179abf6)

14 months agofreebsd-update: Mention 13.2-RELEASE in usage.
Poul-Henning Kamp [Sun, 30 Apr 2023 05:06:56 +0000 (05:06 +0000)]
freebsd-update:  Mention 13.2-RELEASE in usage.

(cherry picked from commit e0e5bf4d62831090a23dd0e0ac374baa0a00ef98)

14 months agopam_krb5: Fix spoofing vulnerability
Cy Schubert [Wed, 31 May 2023 19:20:27 +0000 (12:20 -0700)]
pam_krb5: Fix spoofing vulnerability

An adversary on the network can log in via ssh as any user by spoofing
the KDC. When the machine has a keytab installed the keytab is used to
verify the service ticket. However, without a keytab there is no way
for pam_krb5 to verify the KDC's response and get a TGT with the
password.

If both the password _and_ the KDC are controlled by an adversary, the
adversary can provide a password that the adversary's spoofed KDC will
return a valid tgt for.  Currently, without a keytab, pam_krb5 is
vulnerable to this attack.

Reported by: Taylor R Campbell <riastradh@netbsd.org> via emaste@
Reviewed by: so
Approved by: so
Security: FreeBSD-SA-23:04.pam_krb5
Security: CVE-2023-3326

(cherry picked from commit 813847e49e35439ba5d7bf16034b0691312068a4)

14 months agocaroot: update the root bundle
Kyle Evans [Thu, 15 Jun 2023 04:26:23 +0000 (23:26 -0500)]
caroot: update the root bundle

Summary:
- Zero (0) newly trusted
- Five (5) modified
- Nine (9) distrusted

(cherry picked from commit f5e5dcdbeb699bda5a43c5600b522108cc612ac8)

14 months agolibc: locale: fix collation file size validation
Kyle Evans [Sun, 28 May 2023 17:52:51 +0000 (12:52 -0500)]
libc: locale: fix collation file size validation

At a minimum, we need enough for the colllation format version string +
locale definition version string and a full collate_info definition,
rather than just the first two and a pointer.

Sponsored by: Klara, Inc.

(cherry picked from commit e15da6b10a4971f43aa604fca3ea43effa096f4c)

14 months agoarm64: gicv3: setup PPIs on all APs after they're online
Kyle Evans [Mon, 15 May 2023 17:21:45 +0000 (12:21 -0500)]
arm64: gicv3: setup PPIs on all APs after they're online

For all PPIs setup earlier than SI_SUB_SMP, PIC_INIT_SECONDARY ends up
cleaning these up for each AP as it comes online.  Once they're online,
we don't currently do anything to make sure they're configured for other
APs.  Fix it by using smp_rendezvous for the meaty bits of configuring a
PPI, which will just do single-thread behavior before APs are online but
do the right thing for other CPUs after.

While we're here, make sure redistributor config is correct for other
APs as they come online in gic_v3_init_secondary.

Reported/Tested by: Souradeep Chakrabarti (Microsoft/Hyper-V)
Reviewed by: andrew (before slight refactor)

(cherry picked from commit 172af24449cd8d34339172d125832b7ecd274213)

14 months agoacl(3): improve discoverability of acl_get_perm_np(3)
Kyle Evans [Tue, 9 May 2023 03:45:12 +0000 (22:45 -0500)]
acl(3): improve discoverability of acl_get_perm_np(3)

- Mention it in acl(3) as an available function, xref
- Mention it in acl_get_permset(3), as acl_get_perm_np(3) is a natural
    follow-up to acl_get_permset(3)

Sponsored by: Klara, Inc.

(cherry picked from commit 20c61a7c518b9c2f451118913e10a1525ad0b578)

14 months agohifn(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 17 Jun 2023 08:51:23 +0000 (10:51 +0200)]
hifn(4): Fix a typo in a source code comment

- s/regesters/registers/

(cherry picked from commit 85b3169b78f763aa7102621c349485cd5509efd3)

14 months agoxdr(3): Fix a typo in a source code comment
Gordon Bergling [Sat, 17 Jun 2023 08:49:40 +0000 (10:49 +0200)]
xdr(3): Fix a typo in a source code comment

- s/curren/current/

(cherry picked from commit 85604f7008ee7c963bb6dc8417582f9c31bb4ad3)

14 months agogeli tests: Add a regression test for PR 271766
Mark Johnston [Mon, 12 Jun 2023 16:11:20 +0000 (12:11 -0400)]
geli tests: Add a regression test for PR 271766

This test case catches both of the bugs reported there.

PR: 271766
Reviewed by: imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40469

(cherry picked from commit 9c0467929abaab97f45fc07507b6f30c80211239)

14 months agocrypto: Advance the correct pointer in crypto_cursor_copydata()
Mark Johnston [Mon, 12 Jun 2023 16:09:54 +0000 (12:09 -0400)]
crypto: Advance the correct pointer in crypto_cursor_copydata()

PR: 271766
Reported by: Michael Laß <bevan@bi-co.net>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40468

(cherry picked from commit 9f7fdd8c1ab153104275e59b49b2d567cec95256)

14 months agoopencrypto: Handle end-of-cursor conditions in crypto_cursor_segment()
Mark Johnston [Mon, 12 Jun 2023 16:09:34 +0000 (12:09 -0400)]
opencrypto: Handle end-of-cursor conditions in crypto_cursor_segment()

Some consumers, e.g., swcr_encdec(), may call crypto_cursor_segment()
after having advanced the cursor to the end of the buffer.  In this case
I believe the right behaviour is to return NULL and a length of 0.

When this occurs with a CRYPTO_BUF_VMPAGE buffer, the cc_vmpage pointer
will point past the end of the page pointer array, so
crypto_cursor_segment() ends up dereferencing a random pointer before
the function returns a length of 0.  The uio-backed cursor has
a similar problem.

Address this by keeping track of the residual buffer length and
returning immediately once the length is zero.

PR: 271766
Reported by: Andrew "RhodiumToad" Gierth <andrew@tao11.riddles.org.uk>
Reviewed by: jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40428

(cherry picked from commit 718d4a1d5643c2faf409001320c3fd64aae57638)

14 months agovm_phys: Change the return type of vm_phys_unfree_page() to bool
Mark Johnston [Mon, 5 Jun 2023 14:40:15 +0000 (10:40 -0400)]
vm_phys: Change the return type of vm_phys_unfree_page() to bool

This is in keeping with the trend of removing uses of boolean_t, and the
sole caller was implicitly converting it to a "bool".

No functional change intended.

Reviewed by: dougm, alc, imp, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40401

(cherry picked from commit 6062d9faf23f11e0655f3a222c204725e3111fe8)

14 months agozfs: merge openzfs/zfs@86783d7d9 (zfs-2.1-release) into stable/13
Martin Matuska [Sat, 17 Jun 2023 07:14:08 +0000 (09:14 +0200)]
zfs: merge openzfs/zfs@86783d7d9 (zfs-2.1-release) into stable/13

OpenZFS release 2.1.12

Notable upstream pull requeset merges:
  #14145 Storage device expansion "silently" fails on degraded vdev
  #14358 Wait for txg sync if the last DRR_FREEOBJECTS might result in
         a hole
  #14410 Improve resilver ETAs
  #14428 Resilver performance tuning
  #14501 FreeBSD: don't verify recycled vnode for zfs control directory
  #14524 Ignore too large stack in case of dsl_deadlist_merge
  #14659 Allow MMP to bypass waiting for other threads
  #14722 Fix "Detach spare vdev in case if resilvering does not happen"
  #14774 FreeBSD .zfs fixups
  #14776 FreeBSD: make zfs_vfs_held() definition consistent with
         declaration
  #14788 FreeBSD: add missing vop_fplookup assignments
  #14794 zpool import -m also removing spare and cache when log device
         is missing
  #14795 Fix positive ABD size assertion in abd_verify()
  #14798 Mark TX_COMMIT transaction with TXG_NOTHROTTLE
  #14811 Refine special_small_blocks property validation
  #14816 Fix two abd_gang_add_gang() issues
  #14819 Add dmu_tx_hold_append() interface
  #14823 Remove single parent assertion from zio_nowait()
  #14853 zil: Don't expect zio_shrink() to succeed
  #14861 Probe vdevs before marking removed
  #14873 Add the ability to uninitialize a zpool
  #14892 Fix concurrent resilvers initiated at same time
  #14903 Fix NULL pointer dereference when doing concurrent 'send'
         operations
  #14910 ZIL: Allow to replay blocks of any size

Obtained from: OpenZFS
OpenZFS tag: zfs-2.1.12
OpenZFS commit: 86783d7d92cf7a859464719a917fdff845b9a9e1
Relnotes: yes

14 months agokevent: Make references to filter definitions const
Mark Johnston [Fri, 2 Jun 2023 17:14:13 +0000 (13:14 -0400)]
kevent: Make references to filter definitions const

Follow-up revisions can make individual filter definitions const.  No
functional change intended.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35842

(cherry picked from commit 67f938c5ff1a4c90fcb9372132c8458ed67aba57)

14 months agoEC2: Chase awscli package rename
Colin Percival [Thu, 8 Jun 2023 04:22:25 +0000 (21:22 -0700)]
EC2: Chase awscli package rename

MFC after: 1 week

(cherry picked from commit 267411d164d4d38a701599e3afe8d9e9261f65dd)

14 months agolibvmmapi: Remove some unneeded includes
Mark Johnston [Thu, 8 Jun 2023 19:03:46 +0000 (15:03 -0400)]
libvmmapi: Remove some unneeded includes

These are amd64-specific and so can't be used when targetting arm64, but
they don't appear to be needed.

No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1320520ba488386251a7d02bd90842e031931133)

14 months agoBack out fb31ad53c471e01ba473b2fb038c0cff6253654b, which was committed
Marko Zec [Thu, 15 Jun 2023 05:18:23 +0000 (07:18 +0200)]
Back out fb31ad53c471e01ba473b2fb038c0cff6253654b, which was committed
in error directly to stable/13 instead to main.

14 months agolinuxkpi: #ifdef guard fpu_kern(9) usage
Mitchell Horne [Mon, 12 Jun 2023 13:51:16 +0000 (10:51 -0300)]
linuxkpi: #ifdef guard fpu_kern(9) usage

The recent revert of 8ca78eb03fd4 removed the guards around these calls.
As a result, LINT builds for architectures which do not implement this
API on the branch are failing -- armv7, powerpc, powerpc64, riscv.

This is a direct commit to stable/13.

Fixes: fa6603d4a725 (Revert "LinuxKPI: Make FPU sections thread-safe...")
Differential Revision: https://reviews.freebsd.org/D40497

14 months agoxargs: terminate if line replacement cannot be constructed
Tom Jones [Tue, 5 Jul 2022 15:03:51 +0000 (16:03 +0100)]
xargs: terminate if line replacement cannot be constructed

If the line with replacement cannot be constructed xargs should
terminate as documented in the man page

We encounter this error, but gnu/xargs doesn't because they have a much
larger limit for created outputs (~10000 lines).

Reviewed by: oshogbo
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35574

(cherry picked from commit f058359ba5e08c555d7e6f192217f890b83cd46c)

xargs: fix description of strnsubst return value

Reported by: oshogbo
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35574

(cherry picked from commit 1e692b938e37a9b43a43ace2739eb6b97379cac0)

xargs: improve foundeof check for -E

4aeb63826e0f got it almost correct (we can't use strcmp() here as
current argument isn't guaranteed to be NUL-terminated), but we also
need to check that current argument length is equal to that of eofstr.

PR: 270867
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D39583

(cherry picked from commit 21ef48af5c0f4ed85a5f42855b5a8d58b5431103)

xargs: Fix typo in error message.

MFC after: 1 week
Sponsored by: Klara, Inc.

(cherry picked from commit 6d777389e19d3bebde515e88e8405de45d8af7bd)

xargs: Consistently use strtonum() to parse arguments.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D40425

(cherry picked from commit fbc445addf9183d180bb8b488281617bb19d9242)

14 months agoctags: Support writing to stdout instead of a file.
Dag-Erling Smørgrav [Thu, 25 May 2023 11:55:56 +0000 (11:55 +0000)]
ctags: Support writing to stdout instead of a file.

* Understand "-" to mean stdout as per convention.
* Check that the output is a regular file and ignore -u if not, otherwise we might try to rm /dev/stdout.
* As a bonus, if -u was specified but the output file does not exist, proceed as if -u had not been specified instead of erroring out.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: cracauer, debdrup
Differential Revision: https://reviews.freebsd.org/D40237

(cherry picked from commit 430d064ba5b0cb2e91a26af34c15df48d290e417)

ctags: Recognize __attribute__ in function declarations.

MFC after: 1 week
Obtained from: NetBSD
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D40264

(cherry picked from commit 9f35eb8f96a55aac92fc0c7d08f4b6ab0ae9bc39)

ctags: Don't undercount lines when handling // comments.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D40374

(cherry picked from commit 7ba6119e22b54c2104b1948f0e8a4157d4112958)

14 months agotsort: Error out if writing to stdout failed.
Dag-Erling Smørgrav [Thu, 4 May 2023 17:26:59 +0000 (17:26 +0000)]
tsort: Error out if writing to stdout failed.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D39959

(cherry picked from commit cb46f47c7969b619d1b2547d06a75ad5b375eda9)

tsort: Replace bcopy() with memcpy().

Also fix an indentation error I introduced in the previous commit.

Fixes: cb46f47c7969
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40042

(cherry picked from commit b55bc49e8694d9226a82041ff23ad61a5c7a6a76)

tsort: Add unit tests.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40043

(cherry picked from commit 09aee570980b7eca6e3c902a66f6db129b8c7376)

14 months agoncal: Error out if writing to stdout failed.
Dag-Erling Smørgrav [Thu, 4 May 2023 17:26:54 +0000 (17:26 +0000)]
ncal: Error out if writing to stdout failed.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D39958

(cherry picked from commit 5903d9c00b75f17f09404d1001ee5aaae7603a61)

14 months agolocal-unbound-setup: Disable the libc subscriber.
Dag-Erling Smørgrav [Fri, 24 Mar 2023 20:45:24 +0000 (21:45 +0100)]
local-unbound-setup: Disable the libc subscriber.

This is the correct way to prevent resolvconf from updating resolv.conf.

Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D39262

(cherry picked from commit 9b20ab1e1ef7d3de672ec20a62f26a605db8d3d0)

14 months agoAllow a comma-separated list in login class capabilities,
Sean Eric Fagan [Sat, 14 Jan 2023 18:37:31 +0000 (10:37 -0800)]
Allow a comma-separated list in login class capabilities,
by adding a version of strcspn that allows quoting.

PR: 236204
Differential Revision: https://reviews.freebsd.org/D25368

(cherry picked from commit f32db406504ece1b28f43dc816736e081fe22826)

14 months agoriscv timer: use stimecmp CSR when available
Mitchell Horne [Thu, 25 May 2023 17:07:49 +0000 (14:07 -0300)]
riscv timer: use stimecmp CSR when available

The Sstc extension defines a new stimecmp CSR, allowing supervisor
software to set the timer, rather than just read it. When supported,
using this avoids the frequent trips through the SBI every time the
CPU's timer expires.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40241

(cherry picked from commit cadaabcc720bb20d6d604c4792acb29072d2882d)

14 months agoriscv: S-mode extension parsing
Mitchell Horne [Thu, 25 May 2023 17:07:26 +0000 (14:07 -0300)]
riscv: S-mode extension parsing

There are now several Supervisor-mode extensions that have entered the
'ratified' status, so begin parsing and reporting a few of these.

Recognize the following extensions:
 - Sstc: stimecmp/vstimecmp CSR
 - Svnapot: NAPOT* translation contiguity
 - Svpbmt: page-based memory types
 - Svinval: fine-grained TLB invalidation instructions
 - Sscofpmf: performance counter overflow

*i.e. "naturally aligned power-of-2" page granularity

For now, provide globals for Sstc and Sscofpmf, as we will make use of
these in the near future.

Plus, update the copyright statement after my recent work on this file.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40240

(cherry picked from commit 8bebb786820f634d47522711b8cd56a66db3785d)

14 months agoriscv: Print less CPU info
Mitchell Horne [Mon, 22 May 2023 23:54:36 +0000 (20:54 -0300)]
riscv: Print less CPU info

Change the reporting strategy to more closely follow what arm64
implements:
 - Always print the one-line CPU summary when a core comes online
 - Only print the additional fields (e.g. ISA) when they differ from the
   CPU before it

In the common case of identical CPUs this results in informative but
non-repetitive output. For example, in QEMU:

  CPU 0  : Vendor=Unspecified Core=Unknown (Hart 0)
    marchid=0x80032, mimpid=0x80032
    MMU: 0x7<Sv39,Sv48,Sv57>
    ISA: 0x112d<Atomic,Compressed,Double,Float,Mult/Div>
  real memory  = 8589934592 (8192 MB)
  avail memory = 8332300288 (7946 MB)
  FreeBSD/SMP: Multiprocessor System Detected: 6 CPUs
  CPU 1  : Vendor=Unspecified Core=Unknown (Hart 1)
  CPU 2  : Vendor=Unspecified Core=Unknown (Hart 2)
  CPU 3  : Vendor=Unspecified Core=Unknown (Hart 3)

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40024

(cherry picked from commit 940e6d36de1ef010f731e290c9b2b08535fff424)

14 months agoriscv: MMU detection
Mitchell Horne [Mon, 22 May 2023 23:53:43 +0000 (20:53 -0300)]
riscv: MMU detection

Detect and report the supported MMU for each CPU. Export the
capabilities to the rest of the kernel and use it in pmap_bootstrap() to
check for Sv48 support.

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39814

(cherry picked from commit 7245ffd10eda4ff604840350943d762f70657983)

14 months agoriscv: Print ISA extensions
Mitchell Horne [Mon, 22 May 2023 23:52:28 +0000 (20:52 -0300)]
riscv: Print ISA extensions

Report the CPU's single-letter ISA extensions in printcpuinfo().

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39813

(cherry picked from commit 78a3420c20e075ca8c44a4670ab5ca5afe6bbdf5)

14 months agoriscv: Rework CPU identification (second part)
Mitchell Horne [Mon, 22 May 2023 23:51:44 +0000 (20:51 -0300)]
riscv: Rework CPU identification (second part)

Modify when and how we perform parsing and reporting. Most notably,
everything now executes on CPU 0.

The de-facto standard way to enumerate CPU features (ISA extensions) on
RISC-V is by parsing each CPU's ISA string. We currently obtain this
information from the device tree, and in the future will be able to pull
it from ACPI tables.

Eliminate the SYSINIT from identcpu.c. We still need to walk the /cpus
list in the device tree, but now do this one CPU at a time, as a step in
the identify_cpu() procedure. This is slightly less error prone, and
allows us to parse ISA features for CPU 0 much earlier.

Make use of the SMP hooks cpu_mp_start() and cpu_mp_announce() to
identify and print secondary CPU info, respectively. This causes
secondary processor identification to be printed much earlier in boot;
everything is done by SI_SUB_CPU, SI_ORDER_THIRD. Adjust some other
printf() calls so that we get enough useful info to debug under
bootverbose.

Reviewed by: markj (slightly earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39811

(cherry picked from commit b37dc0903332c4e3b593f1c92df986e8d367d697)

14 months agoriscv: Call identify_cpu() earlier for CPU 0
Mitchell Horne [Mon, 22 May 2023 23:50:09 +0000 (20:50 -0300)]
riscv: Call identify_cpu() earlier for CPU 0

It is advantageous to have knowledge of ISA features as early as
possible. For example, the presence of newer virtual memory extensions
may be useful to pmap_bootstrap().

To achieve this, split out the printf() parts of identify_cpu() into a
separate function, printcpuinfo(). This latter function will be called
later in boot after the console has been initialized.

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39810

(cherry picked from commit b0d45b023e8c9af50312c7b56c4be9c39657afcb)

14 months agoriscv: Rework CPU identification (first part)
Mitchell Horne [Mon, 22 May 2023 23:48:41 +0000 (20:48 -0300)]
riscv: Rework CPU identification (first part)

Make better use of the RISC-V identification CSRs: mvendorid, marchid,
and mimpid. This code was written before these registers were
well-specified, or even available to the kernel. It currently fails to
recognize any CPU or platform.

Per the privileged specification, mvendorid contains the JEDEC vendor ID,
or zero.

The marchid register denotes the CPU microarchitecture. This is either
one of the globally allocated open-source implementation IDs, or the
field has a custom encoding. Therefore, for known vendors (SiFive) we
can also maintain a list of known marchid values. If we can not give a
name to the CPU but marchid is non-zero, then just print its value in
the report.

The mimpid (implementation ID) could be used in the future to more
uniquely identify the micro-architecture, but it really remains to be
seen how it gets used. For now we just print its value.

Thank you to Danjel Qyteza <danq1222@gmail.com> who submitted an early
version of this change to me, although it has been almost entirely
rewritten.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39809

(cherry picked from commit 88b4d124efc5a2d45660551fe0750acc0be6d3cd)

14 months agolib/csu: do not compile the body of handle_static_init() for PIC build at all
Konstantin Belousov [Sun, 12 Mar 2023 01:45:37 +0000 (03:45 +0200)]
lib/csu: do not compile the body of handle_static_init() for PIC build at all

(cherry picked from commit c383f4857f1696c4beb782db36323f46f0c4f6de)

14 months agolibc/csu: add powerpcspe
Konstantin Belousov [Sun, 12 Mar 2023 09:59:16 +0000 (11:59 +0200)]
libc/csu: add powerpcspe

(cherry picked from commit 94e3409e2d02ce3e4817d1a94051dc798e520745)

14 months agolibc/csu: rename ignore_init.c to libc_start1.c
Konstantin Belousov [Sat, 11 Mar 2023 22:56:46 +0000 (00:56 +0200)]
libc/csu: rename ignore_init.c to libc_start1.c

(cherry picked from commit c5c9d980c4b0ca3866cb2ad67ec3f7111f5c4285)

14 months agolibc: move declaration of 'char **environ' to common private header
Konstantin Belousov [Sun, 6 Nov 2022 04:08:36 +0000 (06:08 +0200)]
libc: move declaration of 'char **environ' to common private header

(cherry picked from commit 0c6f0c0db75ea5a1e89a68a163fc555bdd7d00f5)

14 months agox86: microoptimize static PIE startup
Konstantin Belousov [Tue, 1 Nov 2022 01:42:50 +0000 (03:42 +0200)]
x86: microoptimize static PIE startup

(cherry picked from commit 0303938539f3f12da65128fc67f883efe82dc125)

14 months agocsu: move common code to libc
Konstantin Belousov [Sun, 30 Oct 2022 23:47:44 +0000 (01:47 +0200)]
csu: move common code to libc

For MFC purposes, keep lib/csu code intact, only add lib/libc/csu bits.
This allows stable/13 to run simple binaries compiled on 14.

(cherry picked from commit 51015e6d0f570239b0c2088dc6cf2b018928375d)

14 months agolib/csu: Get rid of unused fptr typedef on amd64.
Gleb Popov [Thu, 22 Jul 2021 15:28:21 +0000 (18:28 +0300)]
lib/csu: Get rid of unused fptr typedef on amd64.

(cherry picked from commit feac06569a381dd7fec92c7d490fc34ef0bbdda5)

14 months agonfsuserd: Improve failure message when running in a jail
Rick Macklem [Mon, 29 May 2023 20:38:07 +0000 (13:38 -0700)]
nfsuserd: Improve failure message when running in a jail

If a jail is not correctly configured to run nfsd(8)
in the jail, nfsuserd(8) cannot run.
This patch improves the failure message for this case.

(cherry picked from commit a94018e2003b83c10e8fb814f7a8d47e2513da95)

14 months agortld: fix typo in comment
Konstantin Belousov [Sat, 10 Jun 2023 01:35:14 +0000 (04:35 +0300)]
rtld: fix typo in comment

(cherry picked from commit a254f671025f3da313e1d02646b6402f54006e14)

14 months agortld: fix allocate_module_tls() variant I fallback to static allocation
Konstantin Belousov [Fri, 9 Jun 2023 00:51:32 +0000 (03:51 +0300)]
rtld: fix allocate_module_tls() variant I fallback to static allocation

(cherry picked from commit e9a38ed2fa61fd264a80f24ceb35f39b0ac6463d)

14 months agortld: do not allow both dynamic DTV index and static TLS offset
Konstantin Belousov [Mon, 5 Jun 2023 00:54:46 +0000 (03:54 +0300)]
rtld: do not allow both dynamic DTV index and static TLS offset

(cherry picked from commit 91880e07f605edb90339685bc934699a4344de3b)

14 months agortld: rename tls_done to tls_static
Konstantin Belousov [Mon, 5 Jun 2023 00:43:55 +0000 (03:43 +0300)]
rtld: rename tls_done to tls_static

(cherry picked from commit 283a4f409731ba3a4eb1be41e151c20e8a960c03)

14 months agortld_tls.h: style
Konstantin Belousov [Mon, 5 Jun 2023 01:15:31 +0000 (04:15 +0300)]
rtld_tls.h: style

(cherry picked from commit a7bca6949252f32bb39440cb2914ba23e1c01551)

14 months agogssd: Improve failure message when running in a jail
Rick Macklem [Sun, 28 May 2023 18:06:27 +0000 (11:06 -0700)]
gssd: Improve failure message when running in a jail

If a jail is not correctly configured to run nfsd(8)
in the jail, gssd(8) cannot run.
This patch improves the failure message for this case.

(cherry picked from commit 697727110b68e483c320d834bcbcdf01c01142a1)

14 months agorc(8): document how to reload rc's configuration
Mina Galić [Fri, 2 Jun 2023 18:01:03 +0000 (19:01 +0100)]
rc(8): document how to reload rc's configuration

The fact that rc(8) only reads its configuration once is in the man
page, but how to trigger a reload is only in the code.

Discovered while trying to make cloud-init disable and stop syslogd.

Thanks to RhodiumToad for providing the words.

Reviewed by:           debdrup, grahamperrin
Approved by:           grahamperrin, imp
Sponsored by:          The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D40329

(cherry picked from commit 0981275c75d5678172eb9dd8fbc89ef61c05c979)

14 months agolibpmc: expand PMC_OP* defines
Mitchell Horne [Thu, 1 Jun 2023 18:19:22 +0000 (15:19 -0300)]
libpmc: expand PMC_OP* defines

When performing the syscall, specify the full name of the desired
operation. This improves grep-ability.

No functional change.

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

(cherry picked from commit be75e578549fcc1da3754a29fc0e7b63672e7b44)

14 months agobcm2835_gpio: Handle BCM2711 pin configuration
Tetsuya Uemura [Sun, 28 May 2023 12:56:21 +0000 (09:56 -0300)]
bcm2835_gpio: Handle BCM2711 pin configuration

Add support for GPIO internal pull up/down configuration on RPi4 family.

BCM2711 SoC on 4th generation Raspberry Pi changed the way to configure
its GPIO pins' internal pull up/down resistors. NetBSD already have
support for this change, and port it to FreeBSD is trivial.

This patch, based on the NetBSD commit adds the appropriate method for
BCM2711 and now we can properly configure the GPIO pins' pull status.

PR: 256372
Reviewed by: mhorne
Obtained from: NetBSD bb88cfa64ad8
Pull Request: https://github.com/freebsd/freebsd-src/pull/746

(cherry picked from commit 9d35469e9a6892b3845f66d3513f5c528fe68a77)

14 months agohier(7): fix a couple mandoc warnings
Mitchell Horne [Wed, 10 May 2023 13:26:35 +0000 (10:26 -0300)]
hier(7): fix a couple mandoc warnings

These references are rendered correctly without the zero-width space.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 031049cf3262ec5981cebc35d9b70623177a84bd)

14 months agohier(7): document /home/ and /usr/home/
Mitchell Horne [Wed, 10 May 2023 12:53:56 +0000 (09:53 -0300)]
hier(7): document /home/ and /usr/home/

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

(cherry picked from commit 36db6b04962a01ff7b21592def02d4c570dac939)

14 months agohier(7): drop list of /usr/share/doc subdirectories
Mitchell Horne [Wed, 10 May 2023 12:53:40 +0000 (09:53 -0300)]
hier(7): drop list of /usr/share/doc subdirectories

Several entries are outdated, several new ones are missing. I do not
think there is much value added in maintaining this.

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

(cherry picked from commit 1bc55f58393ffd9714ebfd1ad4e9555cff76e8f6)

14 months agohier(7): drop list of /usr/include subdirectories
Mitchell Horne [Wed, 10 May 2023 12:52:47 +0000 (09:52 -0300)]
hier(7): drop list of /usr/include subdirectories

It is nice to have, however, the location of this information means that
it will naturally be missed by developers adding or removing directories
to the layout, so it trends out-of-date and it is out-of-date.

The target audience for hier(7) is users and administrators. It is not
expected to be a place that programmers should go to learn about the
purposes of the different C headers provided by FreeBSD.

Program authors needing FreeBSD-specific interfaces or libraries
(#include <sys/queue.h>, for instance) will either be following a more
detailed man page, or consulting the header contents directly. Folks
targeting standardized headers (#include <sys/time.h>) will not need
hier(7) to tell them where those headers are under /usr/include.

In other words, this is more detail than necessary for this document.
I'd go as far as to say that many of the existing entries in this list
do little more than parrot the name of the directory.

With all this in mind, let's drop the maintenance burden.

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

(cherry picked from commit c3b611e153e0480a354559f82fe5dc4c455bad4e)

14 months agoriscv: Use PMAP_MAPDEV_EARLY_SIZE in locore and pmap_bootstrap
Alfredo Mazzinghi [Thu, 25 May 2023 15:33:12 +0000 (16:33 +0100)]
riscv: Use PMAP_MAPDEV_EARLY_SIZE in locore and pmap_bootstrap

Use PMAP_MAPDEV_EARLY_SIZE instead of assuming that its value is always
L2_SIZE. Add compile-time assertions to check that the size matches the
expectations in locore.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40110

(cherry picked from commit ef0a711fd5d0d389205c18c869c78b9a4d639ddb)

14 months agoarm64/disassem.c: Add shifted register instruction definitions
Mykola Hohsadze [Thu, 25 May 2023 14:41:55 +0000 (11:41 -0300)]
arm64/disassem.c: Add shifted register instruction definitions

Add disassembly support for the following shifted register instructions:
 * adds
 * subs
 * sub
 * neg
 * negs
 * cmp
 * cmn

The 'Mandatory Tokens' checks are relaxed to allow for the alias
instructions (e.g. cmp) which hard-code one or more registers as xzr.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40006

(cherry picked from commit ffa75b573f043951c7958c200c1e0e1b1f703740)

14 months agoarm64/disassem.c: Make output lowercase
Mykola Hohsadze [Thu, 25 May 2023 14:40:38 +0000 (11:40 -0300)]
arm64/disassem.c: Make output lowercase

Update the few uppercase fields fields to be consistent with others.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39820

(cherry picked from commit 8a852d3e9ff7c4d6f93b65beba8d674127109fc4)

14 months agoarm64/disassem.c: Add detection of xzr and sp
Mykola Hohsadze [Mon, 8 May 2023 13:39:09 +0000 (10:39 -0300)]
arm64/disassem.c: Add detection of xzr and sp

Added support to distinguish between XZR/WZR and SP/WSP registers.

Add new OP_ flags to indicate if the instruction allows the use of SP
for a given register field. "wSP" and "SP" are removed from w_reg and
x_reg, and helper functions are introduced for this purpose of detecting
the correct name of the x31 register.

mhorne: While here, adjust some whitespace issues from a previous
commit.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39862

(cherry picked from commit 9f60b8ce6085049c3886c3e2eb8d4034cef56627)

14 months agoofw_cpu: quiet secondary CPU devices
Mitchell Horne [Wed, 24 May 2023 13:27:55 +0000 (10:27 -0300)]
ofw_cpu: quiet secondary CPU devices

We already do plenty to announce the different CPUs in dmesg. Follow the
ACPI CPU strategy of reporting the first CPU device, but quieting the
rest for non-verbose boot. This cuts down slightly on dmesg output.

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

(cherry picked from commit 08637d5d1580af743f4ed6504104d038e017f918)

14 months agoofw_cpu: whitespace cleanup
Mitchell Horne [Wed, 24 May 2023 13:27:34 +0000 (10:27 -0300)]
ofw_cpu: whitespace cleanup

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

(cherry picked from commit 5edffecc4b4ec6c3e1f09174f155a3abdd928d01)

14 months agohwpmc: remove stub pmd_switch_{in,out} methods
Mitchell Horne [Fri, 5 May 2023 21:59:41 +0000 (18:59 -0300)]
hwpmc: remove stub pmd_switch_{in,out} methods

Most platforms (non-x86) don't require these methods and implement stub
versions. If we initialize the pmc_mdep structure to always point to the
generic versions, then we can purge the duplicate stubs.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39913

(cherry picked from commit fa88954fd8f16ef60084a73d446a23e791ed22e5)

14 months agohwpmc: remove pmd_pcpu_{init,fini} callbacks
Mitchell Horne [Fri, 5 May 2023 21:59:33 +0000 (18:59 -0300)]
hwpmc: remove pmd_pcpu_{init,fini} callbacks

These are unused on all platforms.

Reviewed by: jkoshy, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39912

(cherry picked from commit 772b2dc3abc5072743e7598d35e0a8ad621e7b0d)

14 months agohwpmc: pass pmc pointer to more class methods
Mitchell Horne [Fri, 5 May 2023 22:00:02 +0000 (19:00 -0300)]
hwpmc: pass pmc pointer to more class methods

In many cases this avoids an extra lookup, since the callers always have
pm at hand. We can also eliminate several assertions, mostly for pm !=
NULL. The class methods are an internal interface, and the callers
already handle such a scenario. No functional change intended.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39915

(cherry picked from commit 39f92a76a99a2ceb747250da4f2d627b9c317f8c)

14 months agohwpmc: unused/diagused annotations in tsc class
Mitchell Horne [Fri, 5 May 2023 21:59:53 +0000 (18:59 -0300)]
hwpmc: unused/diagused annotations in tsc class

These are preferred over casts to void. No functional change.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39914

(cherry picked from commit a35453b9c7644f11df83d0c7e73da488f521e56e)

14 months agopmcstat: augment an error message
Mitchell Horne [Fri, 5 May 2023 21:58:23 +0000 (18:58 -0300)]
pmcstat: augment an error message

It also applies to the -t argument.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39907

(cherry picked from commit bf66159342e86b1dba02f1c463b47dd96fb09969)

14 months agohwpmc: use kstack_contains()
Mitchell Horne [Fri, 5 May 2023 21:59:01 +0000 (18:59 -0300)]
hwpmc: use kstack_contains()

This existing helper function is preferable to the hand-rolled
calculation of the kstack bounds.

Make some small style improvements while here. Notably, rename every
instance of "r", the return address, to "ra". Tidy the includes in the
affected files.

Reviewed by: jkoshy
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39909

(cherry picked from commit aba91805aa92a47b2f3f01741a55ff9f07c42d04)