]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
13 months agoe1000: Corrections for lem(4)/em(4) txcsum offload
Kevin Bowling [Thu, 27 Jul 2023 22:50:32 +0000 (15:50 -0700)]
e1000: Corrections for lem(4)/em(4) txcsum offload

Explicitly set ipcss/ipcse/ipcso for IPv6 per intel SDM as indicated in
inline comments.

Fix and consolidate 82543/82547 hwcsum exemption.

While here rearrange and expand some commentary.

(cherry picked from commit cbcab907f8ad1a4ac38dbc574c747ac2901faa54)

13 months agoe1000: add missing parens in csum setup
Kevin Bowling [Sun, 23 Jul 2023 00:03:26 +0000 (17:03 -0700)]
e1000: add missing parens in csum setup

Reported by: rscheff
Fixes: 4f9a44a215f8 e1000: Fix/enable IPv6 transmit checksum offload

(cherry picked from commit 92fd2f39e5b1fd588fdc49a07d626273eb8f7539)

13 months agoe1000: Fix/enable IPv6 transmit checksum offload
Kevin Bowling [Sat, 22 Jul 2023 22:58:34 +0000 (15:58 -0700)]
e1000: Fix/enable IPv6 transmit checksum offload

Fixes and enables txcsum6 offload for lem(4) and em(4).

MFC after: 2 weeks

(cherry picked from commit 4f9a44a215f873c6842a693f2e81e0abbe1531cf)

13 months agoe1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes
Kevin Bowling [Sat, 22 Jul 2023 18:33:27 +0000 (11:33 -0700)]
e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes

* em(4) obey administrative ifcaps for using hwcsum offload
* em(4) obey administrative ifcaps for hw vlan receive tagging
* em(4) add additional TSO6 ifcap, but disabled by default as is TSO4
* lem(4) obey administrative ifcaps for using hwcsum offload
* lem(4) add support for hw vlan receive tagging
* lem(4) Add ifcaps for TSO offload experimentation, but disabled by
  default due to errata and possibly missing txrx code.
* lem(4) disable HWCSUM ifcaps by default on 82547 due to errata around
  full duplex links.  It may still be administratively enabled.

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D30072

(cherry picked from commit 918c25677d882a901696672bd4d39b62faa56dfa)

13 months agoRevert "e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes"
Kevin Bowling [Fri, 4 Aug 2023 01:21:00 +0000 (18:21 -0700)]
Revert "e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes"

This reverts commit bd07d5c451995353cbf1d86f97c5264232ea401b.

13 months agoe1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes
Kevin Bowling [Fri, 21 Jul 2023 03:30:00 +0000 (20:30 -0700)]
e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes

* em(4) obey administrative ifcaps for using hwcsum offload
* em(4) obey administrative ifcaps for hw vlan receive tagging
* em(4) add additional TSO6 ifcap, but disabled by default as is TSO4
* lem(4) obey administrative ifcaps for using hwcsum offload
* lem(4) add support for hw vlan receive tagging
* lem(4) Add ifcaps for TSO offload experimentation, but disabled by
  default due to errata and possibly missing txrx code.
* lem(4) disable HWCSUM ifcaps by default on 82547 due to errata around
  full duplex links.  It may still be administratively enabled.

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D30072

(cherry picked from commit 95f7b36e8fac45092b9a4eea5e32732e979989f0)

13 months agoe1000: Some fixes for em(4) TSO setup
Kevin Bowling [Fri, 21 Jul 2023 01:51:02 +0000 (18:51 -0700)]
e1000: Some fixes for em(4) TSO setup

Always set TXD_CMD_IP for 82544
Otherwise set TXD_CMD_IP for IPv4, not IPv6

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D30072

(cherry picked from commit 201c4b7c29da44500ccb9e47b854dc1207df8b0a)

13 months agoem(4): remove reference to CNVi
Kevin Bowling [Thu, 3 Aug 2023 20:26:28 +0000 (13:26 -0700)]
em(4): remove reference to CNVi

I misread the newer PCH datasheet, these are still refered to as PCH.

(cherry picked from commit 1b01772f0185bb6476ec76d1d66c26373cebc391)

13 months agoem(4): Update and expand on hardware support
Kevin Bowling [Thu, 3 Aug 2023 19:49:42 +0000 (12:49 -0700)]
em(4): Update and expand on hardware support

(cherry picked from commit 42ce724d8021132b5ebcf8cc944f14e19c1c439f)

13 months agoem(4): add link to lem(4)
Kevin Bowling [Thu, 3 Aug 2023 19:49:12 +0000 (12:49 -0700)]
em(4): add link to lem(4)

(cherry picked from commit 7bcdbacf8437ea710f2e7526f225ffa36e504d29)

13 months agonetstat -i: compute most field widths dynamically
Mike Karels [Wed, 26 Jul 2023 15:56:52 +0000 (10:56 -0500)]
netstat -i: compute most field widths dynamically

The network and address fields were sometimes truncated for netstat -i
without -W, and often much too wide for netstat -i with the -W option.
Fields such as normal packet counts often overflowed.  As a result,
columns didn't line up, and large white spaces made it harder to
follow a line across the display.  Change the code to compute the
required field sizes for network, address, and various packet counts.
Hoist the code to format network and address into a subroutine that
can be called twice, once to measure the required field widths,
and once to emit the values.  Use separate field widths for input
and output packets, byte counts, and error and drop counters.
These are left at defaults (the preceding values) with the -h
option, in which case the fields have a limited total width.
An extra space is included between the Network and Address, which
otherwise seemed too close.

Change the mention of -W with -i in the man page to say that most
field widths are computed dynamically in this case.

Reviewed by: sjg, glebius
Differential Revision: https://reviews.freebsd.org/D41160

(cherry picked from commit 372e3d561d82aba7a66fcd4ecb49a4d0a9f69345)

13 months agolibpfct: ensure the initial allocation is large enough
Kristof Provost [Wed, 26 Jul 2023 08:30:22 +0000 (10:30 +0200)]
libpfct: ensure the initial allocation is large enough

Ensure that we allocate enough memory for the packed nvlist, no matter
what size hint was provided.

MFC after: 1 week
Reported by: R. Christian McDonald <rcm@rcm.sh>
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6422599e74db4bb8b47cead46760d96601d8396a)

13 months agortld_malloc: add cp2op() helper
Konstantin Belousov [Sat, 22 Jul 2023 04:24:03 +0000 (07:24 +0300)]
rtld_malloc: add cp2op() helper

(cherry picked from commit 86c7368f2bcefeb257f7dc40e4296261b295a674)

13 months agortld_malloc: only include internal rtld headers when building for rtld
Konstantin Belousov [Sat, 22 Jul 2023 04:39:20 +0000 (07:39 +0300)]
rtld_malloc: only include internal rtld headers when building for rtld

(cherry picked from commit bc7e86106d428c7da328ad7fc9d4cb5f7f303e0e)

13 months agortld: remove dup __crt_malloc prototypes
Konstantin Belousov [Sat, 22 Jul 2023 04:37:50 +0000 (07:37 +0300)]
rtld: remove dup __crt_malloc prototypes

(cherry picked from commit cf6dbdd135072fc2b74e0a10c22474b0282ca122)

13 months agortld_malloc: remove outdated comments
Konstantin Belousov [Sat, 22 Jul 2023 04:13:58 +0000 (07:13 +0300)]
rtld_malloc: remove outdated comments

(cherry picked from commit a24726a6f3b43473093267e2b4e81d186817dc7d)

13 months agobsd.linker.mk: Use :C not :S for regex
Jessica Clarke [Mon, 24 Jul 2023 00:50:55 +0000 (01:50 +0100)]
bsd.linker.mk: Use :C not :S for regex

Whilst ^ and $ are supported with C, those are special cases, and
general regex syntax like groups and alternations are not. Use the
correct modifier so we get a version number out that's not 0 (which is
what happens when it can't be parsed by the later code).

Fixes: c4177f5b41d4 ("bsd.linker.mk: Handle Xcode 15 linker identification")
MFC after: 1 week

(cherry picked from commit 7f9318a022ef0e5104fd429dc2d9ac37b9916353)

13 months agobsd.linker.mk: Handle Xcode 15 linker identification
Jessica Clarke [Mon, 24 Jul 2023 00:34:17 +0000 (01:34 +0100)]
bsd.linker.mk: Handle Xcode 15 linker identification

The upcoming Xcode 15 introduces a new linker (called ld-prime or ld-new
in some documentation) to replace the classic ld64, which we need to
handle.

Previously, the linker would identify itself as:

  @(#)PROGRAM:ld  PROJECT:ld64-<version>

Now, there are two cases. When the classic ld64 is in use, it identifies
itself as:

  @(#)PROGRAM:ld-classic  PROJECT:ld64-<version>

When the new linker is in use, it identifies itself as:

  @(#)PROGRAM:ld  PROJECT:dyld-<version>

Thus, tweak the detection to allow a -classic suffix in the PROGRAM
string and to allow a dyld- prefix instead of an ld64- prefix on the
version number in the PROJECT string.

MFC after: 1 week

(cherry picked from commit c4177f5b41d45f3c83a0ef329a50e4ae05da3878)

13 months agokmod.mk: Use portable printf '%s' over non-portable echo -n
Jessica Clarke [Tue, 11 Jul 2023 20:30:06 +0000 (21:30 +0100)]
kmod.mk: Use portable printf '%s' over non-portable echo -n

Whilst /bin/echo on macOS and Linux implement -n, as do the builtin
echos in bash and zsh, the builtin echo in dash does not, causing the
first line of the output to be -n foo rather than just foo, and there to
be an extra newline in the output and thus blank line, both of which
result in "Symbol ... is not present in *.kld" warnings appearing in the
build output (once for -n foo and once for the empty string for each
module where EXPORT_SYMS is a list of symbols).

MFC after: 1 week

(cherry picked from commit d1e44bc94494448de196948d698b637b6e1df4bf)

13 months agogetlocalbase.3: Fix AUTHORS formatting
Jessica Clarke [Tue, 11 Jul 2023 17:50:32 +0000 (18:50 +0100)]
getlocalbase.3: Fix AUTHORS formatting

MFC after: 1 week

(cherry picked from commit bfc47586acee94ade461f2210c700abca93647af)

13 months agoresizewin: Stop printing bogus NUL to TTY
Jessica Clarke [Wed, 14 Jun 2023 22:58:36 +0000 (23:58 +0100)]
resizewin: Stop printing bogus NUL to TTY

A char array has an implicit NUL terminating it, which sizeof will
include, so we need to subtract 1 here. Printing a NUL can cause issues
for things like CI environments that aren't expecting it, especially
with recent Jenkins being stricter about not putting NUL in XML files.

Fixes: 3d222369acbe ("Add a small tool, resizewin(1), to query terminal for window size")
MFC after: 1 week

(cherry picked from commit 456c1199d3b3ee477463c6469940c0370de2b2ea)

13 months agolibpmc: Handle PMCALLOCATE log with PMC code on PMU event system
Jessica Clarke [Wed, 7 Jun 2023 14:21:18 +0000 (15:21 +0100)]
libpmc: Handle PMCALLOCATE log with PMC code on PMU event system

On an arm64 system that reports as a Cortex A72 r0p3, running

  pmcstat -P CPU_CYCLES command

works, but

  pmcstat -P cpu-cycles command

does not. This is because the former uses the PMU event from the JSON
source, resulting in pl_event in the log event being a small index
(here, 5) into the generated events table, whilst the latter does not
match any of the JSON events and falls back on PMC's own tables, mapping
it to the PMC event 0x14111, i.e. PMC_EV_ARMV8_EVENT_11H. Then, when
libpmc gets the PMCALLOCATE event, it tries to use the event as an index
into the JSON-derived table, but doing so only makes sense for the
former, whilst for the latter it will go way out of bounds and either
read junk (which may trigger the != NULL assertion) or segfault. As far
as I can tell we don't have anything lying around to tell us which of
the two cases we're in, but we can exploit the fact that the first
0x1000 PMC event codes are reserved, and that none of our PMU events
tables reach that number of entries yet.

PR: 268857
Reviewed by: mhorne
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D39592

(cherry picked from commit 21f7397a61f7bff61a1221cc6340cd980a922540)

13 months agoriscv: Add pass(4) to GENERIC kernel
Jessica Clarke [Wed, 3 May 2023 04:14:57 +0000 (05:14 +0100)]
riscv: Add pass(4) to GENERIC kernel

Whilst we don't have ahci(4) currently, we do have umass(4), and need
pass(4) for smartctl(8) to be able to talk to such devices.

Reported by: David Gilbert <dgilbert@daveg.ca>
MFC after: 1 week

(cherry picked from commit f78cc42f10cbfb5811276bc6827732ca32eb5485)

13 months agoMakefile.inc1: Support building with macOS Ventura's AMFI Launch Constraints
Jessica Clarke [Fri, 3 Mar 2023 02:15:30 +0000 (02:15 +0000)]
Makefile.inc1: Support building with macOS Ventura's AMFI Launch Constraints

As of macOS Ventura, Apple-signed binaries cannot be run if copied away from
their system location. This security feature doesn't really make sense for
boring things like sh(1), more so for applications with special entitlements,
but it's universally present, and results in the following error:

  >>> Install check world
  bmake[2]: "/Users/Jess/cheri/freebsd/Makefile.inc1" line 572: warning: "MAKEFLAGS= CPUTYPE=dummy /Users/Jess/cheri/build/freebsd-riscv64-build/bmake-install/bin/bmake -f /dev/null  -m /Users/Jess/cheri/freebsd/share/mk MK_AUTO_OBJ=no -V CPUTYPE" exited on a signal
  bmake[2]: "/Users/Jess/cheri/freebsd/Makefile.inc1" line 575: CPUTYPE global should be set with ?=.

As with host-symlinks, we don't actually need to copy the files on macOS, since
we're not updating the current machine, so copy its approach and just symlink
them instead.

MFC after: 1 week

(cherry picked from commit dda4d97289f17aa8b2bbfd8d63a746b3a7836fd5)

13 months agoriscv: Add da9063_pmic and da9063_rtc to GENERIC and NOTES
Jessica Clarke [Tue, 13 Sep 2022 16:46:28 +0000 (17:46 +0100)]
riscv: Add da9063_pmic and da9063_rtc to GENERIC and NOTES

This is the PMIC on SiFive's HiFive Unmatched; add it and the RTC child
device driver so we have a working RTC.

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

(cherry picked from commit 100f79569dbcee9a7c66f8fe543fa04e8bfb04bd)

13 months agoda9063_rtc: Add new driver for the Dialog Semiconductor DA9063 RTC
Jessica Clarke [Tue, 13 Sep 2022 16:46:21 +0000 (17:46 +0100)]
da9063_rtc: Add new driver for the Dialog Semiconductor DA9063 RTC

This is a simple RTC present in the PMIC, supporting 1s precision.

This is the PMIC on SiFive's HiFive Unmatched.

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

(cherry picked from commit 129028c79c6c287c3c028714e3e7993299357b6c)

13 months agoda9063_iic: Add new driver for the Dialog Semiconductor DA9063 PMIC
Jessica Clarke [Tue, 13 Sep 2022 16:46:09 +0000 (17:46 +0100)]
da9063_iic: Add new driver for the Dialog Semiconductor DA9063 PMIC

This is an MFD with regulators, an RTC and a watchdog, among other
things. This adds the necessary infrastructure for specific children to
be added.

Note that the PMIC can also be attached via SPI, not just I2C, and so
the interface is abstracted. No SPI implementation is added, however.

This is the PMIC on SiFive's HiFive Unmatched.

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

(cherry picked from commit 80466455adcab3952f7b1727c6332832540a8d14)

13 months agorelease: Set loader_menu_multi_user_prompt to "Installer" for installer
Jessica Clarke [Fri, 2 Sep 2022 19:30:50 +0000 (20:30 +0100)]
release: Set loader_menu_multi_user_prompt to "Installer" for installer

This makes it more obvious that the media being booted is an installer
rather than an installed system, which is otherwise hard to distinguish.
It also provides a more user-friendly, and more accurate, prompt.

Reviewed by: gjb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36419

(cherry picked from commit 2a90c47af158625b3e28390801639c21d6d0ed2a)

13 months agoMakefile.inc1: Fix -DNO_ROOT distributeworld certctl usage
Jessica Clarke [Thu, 14 Jul 2022 00:25:50 +0000 (01:25 +0100)]
Makefile.inc1: Fix -DNO_ROOT distributeworld certctl usage

Currently for distributeworld we pass DESTDIR to certctl.sh as an
environment variable, which sets the default value in the script.
However, for -DNO_ROOT builds, CERTCTLFLAGS has METALOG_INSTALLFLAGS
which includes -D ${DESTDIR}, overriding the custom DESTDIR pointing at
the base dist directory.

Moreover, in order to ensure that the METALOG includes the base/ prefix
for all the files, we need to have certctl call install with -D set to
DESTDIR/DISTDIR without the /base suffix but also ensure the files get
installed to DESTDIR/DISTDIR/base.

Fix these by passing the custom DESTDIR to certctl via -D rather than in
the environment and to pass the /base suffix in the distributeworld case
via the newly-added -d option.

We also need to run certctl rehash before we generate the .meta files
from the METALOG, not after, otherwise they won't include the METALOG
additions, so move the certctl rehash call.

Finally, add a missing semicolon that results in no message being
printed in the missing openssl case. By not including the semicolon,
else echo "..." is treated as extra arguments to certctl, which is lax
in its argument parsing and ignores additional arguments, and the
semicolon and fi after the intended echo terminate the if statement as
normal so there's no syntax error at the shell level. This is harmless
as we weren't trying to do anything other than echo anyway, all that
happens is the echo doesn't actually get run.

Reported by: markj (missing semicolon)
Reviewed by: brooks, kevans
Obtained from: CheriBSD
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35809

(cherry picked from commit 7e45839aca7157a73b0309e8cf4cb811d2cb5512)

13 months agocertctl: Introduce a new -d <distbase> option
Jessica Clarke [Thu, 14 Jul 2022 00:23:42 +0000 (01:23 +0100)]
certctl: Introduce a new -d <distbase> option

This will be used by Makefile.inc1 to fix -DNO_ROOT distributeworld,
which needs to split out DESTDIR from DISTBASE so the METALOG file
includes the base/ prefix.

Reviewed by: kevans
Obtained from: CheriBSD
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35808

(cherry picked from commit 232cf6be4bc493412f1c8b80a4cdc00fe53075c6)

13 months agofrag6: Avoid a possible integer overflow in fragment handling
Jonathan T. Looney [Tue, 1 Aug 2023 14:58:34 +0000 (10:58 -0400)]
frag6: Avoid a possible integer overflow in fragment handling

Reviewed by: kp, markj, bz
Approved by: so
Security: FreeBSD-SA-23:06.ipv6
Security: CVE-2023-3107

(cherry picked from commit ff3d1a3f9d71e706f320f51bae258e4e1a51b388)

13 months agobhyve: Fully reset the fwctl state machine if the guest requests a reset.
John Baldwin [Thu, 29 Jun 2023 18:27:12 +0000 (11:27 -0700)]
bhyve: Fully reset the fwctl state machine if the guest requests a reset.

If a guest tries to reset the fwctl device while a pending request was
in flight, the fwctl state machine can be left in an incomplete state.
Specifically, rinfo is not cleared.

Normally the state machine for fwctl alternates between REQ (receiving
request) and RESP (sending response) and ignores port writes while in
RESP or port reads while in REQ.  Once a guest completes the writes to
the port to send a request, the state machine transitions to RESP and
ignores future writes.

However, if a guest writes a full request and then resets the fwctl
device, the state would transition to REQ without draining the pending
response or discarding the received request.  Instead, additional
port writes after the reset were treated as new payload bytes, but
were appended to the previously-received request and could overflow
the fget_str buffer.

To fix, fully reset the fwctl state machine if the guest requests a
reset.

admbugs: 998
Approved by: so
Reviewed by: markj
Reported by: Omri Ben Bassat <t-benbassato@microsoft.com>
Security: FreeBSD-SA-23:07.bhyve
Security: CVE-2023-3494

(cherry picked from commit bed3ae1d7863ac1e0b1e82ae7bf952937e921efe)

13 months agotcp_lro: Fix for undefined behaviour.
Hans Petter Selasky [Mon, 28 Nov 2022 22:56:16 +0000 (23:56 +0100)]
tcp_lro: Fix for undefined behaviour.

Make sure the size of the raw[] array in the lro_address union is
correctly set at compile time, so that static code analysis tools
do not report undefined behaviour.

PR: 265664
Sponsored by: NVIDIA Networking

(cherry picked from commit e0d8add4af0be1d37ede9a16f46424dc08f0d95e)

13 months agoOpenSSL: Regen manual pages for OpenSSL 1.1.1v
Jung-uk Kim [Tue, 1 Aug 2023 16:48:23 +0000 (12:48 -0400)]
OpenSSL: Regen manual pages for OpenSSL 1.1.1v

13 months agoOpenSSL: Import OpenSSL 1.1.1v
Jung-uk Kim [Tue, 1 Aug 2023 14:48:37 +0000 (10:48 -0400)]
OpenSSL: Import OpenSSL 1.1.1v

(cherry picked from commit cc0d356166e39da7f956c39f874e6dee67fd5d60)

13 months agobuf: Make the number of pbufs slightly more dynamic
Mark Johnston [Tue, 30 May 2023 19:11:32 +0000 (15:11 -0400)]
buf: Make the number of pbufs slightly more dynamic

Various subsystems pre-allocate a set of pbufs, allocated to implement
I/O operations.  pbuf allocations are transient, unlike most buf
allocations.

Most subsystems preallocate nswbuf or nswbuf/2 pbufs each.  The
preallocation ensures that pbuf allocation will succeed in low memory
conditions, which might help avoid deadlocks.  Currently we initialize
nswbuf = min(nbuf / 4, 256).

nbuf/4 > 256 on anything but the smallest systems.  For example,
nswbuf is 256 in a VM with 128MB of memory.  In this configuration, a
firecracker VM with one CPU preallocates over 900 pbufs.  This consumes
2MB of RAM and adds several milliseconds to the kernel's (very small)
boot time.

Scale nswbuf by ncpu in the common case.  I think this makes more sense
than scaling by the amount of RAM, since pbuf allocations are transient
and aren't used for caching.  With the change, we get nswbuf=256 with 8
CPUs.  With fewer than 8 CPUs we'll preallocate fewer pbufs than before,
and with more we'll preallocate more.

Event: BSDCan 2023
Reported by: cperciva
Reviewed by: glebius, kib
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D40216

(cherry picked from commit 4e78addbeff902aabaa87fdaafbd962f90720d69)

13 months agobhyve: Stop calling pci_lintr_request() in the NVMe device model
Mark Johnston [Wed, 28 Jun 2023 20:06:21 +0000 (16:06 -0400)]
bhyve: Stop calling pci_lintr_request() in the NVMe device model

The device model effectively assumes that MSI-X is enabled (it never
asserts the legacy interrupt), so any guest which relies on being able
to use the legacy PCI interrupt will fail.

The WIP arm64 port does not implement legacy PCI interrupts, but NVMe
emulation is potentially useful there.  Simply remove the call.

Reviewed by: corvink, chuck, jhb
Tested by: chuck
MFC after: 1 month
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40731

(cherry picked from commit 13013d266e7781022fde04509670d0ce5f2ac25f)

13 months agoarm64/disassem.c: add extended register instruction definitions
Mykola Hohsadze [Mon, 24 Jul 2023 20:49:24 +0000 (17:49 -0300)]
arm64/disassem.c: add extended register instruction definitions

Add disassembly support for the following extended register
instructions: add, adds, sub, subs, cmp, cmn.

Reviewed by: mhorne
MFC after: 1 week
Pull Request: https://reviews.freebsd.org/D40967

(cherry picked from commit 4a07c778632bddb86a82f3e1fe144d889dae69c5)

13 months agoarm64/disassem.c: remove redundant OP_RN_SP for TYPE_02
Mykola Hohsadze [Mon, 24 Jul 2023 20:47:17 +0000 (17:47 -0300)]
arm64/disassem.c: remove redundant OP_RN_SP for TYPE_02

Removed redundant OP_RN_SP for TYPE_02, since these addressing modes
always use the SP register, never XZR.

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

(cherry picked from commit e57b86266b80e1eed266a8287ae51c941c591b9d)

13 months agosys_getrandom: fix a function reference in a comment
Mitchell Horne [Mon, 24 Jul 2023 13:48:38 +0000 (10:48 -0300)]
sys_getrandom: fix a function reference in a comment

MFC after: 3 days
Sponsored by: FreeBSD Foundation

(cherry picked from commit a4e4ea738b738a355f5042b02ca9d8bbb78af236)

13 months agopuc: fix man page reference
Mitchell Horne [Mon, 24 Jul 2023 12:52:19 +0000 (09:52 -0300)]
puc: fix man page reference

The reference to puc(9) is wrong; the page does not exist, and drivers
belong to section 4. Change the reference to puc(4), which does exist.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 09e5d91069d13000d1d93b0e6a26731926d500e1)

13 months agonetinet6 tests: test for loss of Solicited-node multicast groups
Kristof Provost [Wed, 19 Jul 2023 14:37:28 +0000 (16:37 +0200)]
netinet6 tests: test for loss of Solicited-node multicast groups

The multicast code has an issue where it can lose the Solicited-node
multicast group subscription if the same address is added twice.

Test for this.

PR: 233683
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41123

(cherry picked from commit b03012d0b600793d7501b4cc56757ec6150ec87f)

13 months agomld: always commit state changes on leaving
Kristof Provost [Thu, 20 Jul 2023 07:41:45 +0000 (09:41 +0200)]
mld: always commit state changes on leaving

Resolve a race condition where we'd lose the Solicited-node multicast
group subscription if we assigned the same IPv6 address twice.

PR: 233683
Reviewed by: ae
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41124

(cherry picked from commit 9c9a76dc6873427b14f6c84397dd60ea8e529d8d)

13 months agoena: Update driver version to v2.6.3
Arthur Kiyanovski [Sun, 28 May 2023 08:42:05 +0000 (08:42 +0000)]
ena: Update driver version to v2.6.3

Bug Fixes:
* Initialize statistics before the interface is available
* Fix driver unload crash

Minor Changes:
* Mechanically convert ena(4) to DrvAPI
* Remove usage of IFF_KNOWSEPOCH

MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit ac40021c935d77d86e68d28c6d33187ce9638ec6)

13 months agoena: Fix driver unload crash
Arthur Kiyanovski [Sun, 21 May 2023 12:31:54 +0000 (12:31 +0000)]
ena: Fix driver unload crash

When ena_detach is called, we first call ether_ifdetach(),
which destroys internal addresses of ifp. One such address
is ifp->if_addr->ifa_addr. Then during ena_destroy_device(),
if_link_state_change() is called, eventually trying to access
ifp->if_addr->ifa_addr->sa_family. This causes an access
to garbage memory and crashes the kernel.

Ticket [1] was opened to the FreeBSD community to add null
check in the code of if_link_state_change().
A fix was submitted in commit [2], however it was noted
that it is our driver's responsibilty to not call
if_link_state_change() after calling ether_ifdetach().

This commit makes sure if_link_state_change() is not called
after ether_ifdetach().

[1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813
[2]: https://reviews.freebsd.org/D39614

Fixes: 32f63fa7f975 ("Split ENA reset routine into restore and destroy stages")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit c59a5fbd8a2ef68ed0842cbb1df4450edd654129)

13 months agoena: Initialize statistics before the interface is available
Osama Abboud [Wed, 18 Jan 2023 13:19:07 +0000 (13:19 +0000)]
ena: Initialize statistics before the interface is available

In [1], the FBSD community exposed a bug in the fbsd/ena driver.

Bug description:
----------------
Current function call order is as follows:

1. ena_attach()
1.1. ena_setup_ifnet()
1.1.1. Registration of ena_get_counter()
1.1.2. ether_ifattach(ifp, adapter->mac_addr);
1.2. Statistics allocation and initialization.

At point 1.1.2, when ether_ifattach() returns, the interface is available,
and stats can be read before they are allocated, leading to kernel panic.

Also fixed a potential memory leak by freeing the stats since they were
not freed in case the following calls failed.

Fix:
----
This commit moves the statistics allocation and initialization to happen
before ena_setup_ifnet()

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934

Fixes: 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
Fixes: 30217e2dff10 ("Rework counting of hardware statistics in ENA driver")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit b9e80b5280b75f2c641d680245df44b8ff26a7b0)

13 months agortld: fix dlopen() for an object that is already mapped but not yet initialized
Konstantin Belousov [Fri, 14 Jul 2023 13:38:03 +0000 (16:38 +0300)]
rtld: fix dlopen() for an object that is already mapped but not yet initialized

(cherry picked from commit 1005d3d05362de368b1ea7aeb8eb20cee993e122)

13 months agohwpmc(4): instead of manual edition, use sysrc(8)
Graham Perrin [Sat, 8 Jul 2023 06:24:18 +0000 (07:24 +0100)]
hwpmc(4): instead of manual edition, use sysrc(8)

Exemplifying safe use of sysrc(8) has become commonplace in
documentation such as the FreeBSD Handbook. Encourage its use.

Consistency: 'the driver' (not 'this driver').

Co-authored-by: Mina Galić <me+github@igalic.co>
Reviewed-by: imp, Mina Galić <me+github@igalic.co>
Approved by:    imp
MFC after:      3 days
Pull-request:   https://github.com/freebsd/freebsd-src/pull/785

(cherry picked from commit 666c54d12ec941e1fa3741f28ba19223ec4d2c81)

13 months agogpart(8): slices are out of context for GPT
Graham Perrin [Fri, 7 Jul 2023 22:05:46 +0000 (23:05 +0100)]
gpart(8): slices are out of context for GPT

Correct the GPT example. Creation of a partition leaves free the rest
of the device (not the slice).

Approved-by: imp
Fixes: ae1b731b5df0 Rewrite the GPT and MBR examples. For GPT, ensure that the boot partition is large enough for gptzfsboot, which has doubled in size since 10.
MFC after:    1 week
Pull-request: https://github.com/freebsd/freebsd-src/pull/795

(cherry picked from commit 3541d90836c0dde9734ea776f2b2b6c4ed8fd7f4)

13 months agoip output: ensure that mbufs are mapped if ipsec is enabled
Konstantin Belousov [Thu, 20 Jul 2023 12:08:24 +0000 (15:08 +0300)]
ip output: ensure that mbufs are mapped if ipsec is enabled

PR: 272616

(cherry picked from commit bc310a95c58a3c570ed7e5103371453881e36ba1)

13 months agothr_mutex.c: style
Konstantin Belousov [Sat, 22 Jul 2023 17:59:26 +0000 (20:59 +0300)]
thr_mutex.c: style

(cherry picked from commit 0a5c29a6ee0a4c2732977d6d832e7193dbddaf26)

13 months agoixl(4): Add link state polling
Krzysztof Galazka [Thu, 20 Jul 2023 22:33:52 +0000 (15:33 -0700)]
ixl(4): Add link state polling

In some cases driver may ask FW about link state before FW finishes
configuration of a (Q)SFP+ transceiver. If first attempt of using Get Link
Status AQC after loading driver or handling a reset fails, then re-try
periodically for 5 seconds.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Tested by: jeffrey.e.pieper@intel.com
Approved by: erj@
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D40899

(cherry picked from commit ba2f531f816a6bc1ef5f2cba4a329ff7bdbec0f3)

13 months agoixl: port ice's atomic API to ixl
Piotr Kubaj [Tue, 6 Jun 2023 15:30:18 +0000 (17:30 +0200)]
ixl: port ice's atomic API to ixl

Differential Revision: https://reviews.freebsd.org/D40532
Approved by: erj

(cherry picked from commit b8f51b8c5423af0795429836a00f2a968e791f6e)

13 months agoReally fix cross-builds from macOS
Jessica Clarke [Thu, 30 Jun 2022 21:08:31 +0000 (22:08 +0100)]
Really fix cross-builds from macOS

LINKER_TYPE is set to mac not macos on macOS.

Fixes: 7927452ac4e9 ("Add RELRO build knob, default to enabled")
(cherry picked from commit 4ca6ecf100733ecd61f32257452690c56a6b6a3e)

13 months agomsun: Fix typo in math_private.h comment
Steve Kargl [Wed, 26 Jul 2023 18:21:44 +0000 (02:21 +0800)]
msun: Fix typo in math_private.h comment

PR: 272738
MFC after: 3 days

(cherry picked from commit f2c94ddd0ad79d972b6a707978cc09f3a8a6dbbf)

13 months agoFix cross-builds from macOS
Ed Maste [Sun, 26 Jun 2022 17:23:39 +0000 (13:23 -0400)]
Fix cross-builds from macOS

The macOS linker does not support -zrelro/-znorelro.  Since it is only
used to for build tools that run on the host, and WITH_RELRO or
WITHOUT_RELRO does not matter there, just skip the option.

Reviewed by: markj
Fixes: 2f3a961487c9 ("Add RELRO build knob, default to enabled")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35589

(cherry picked from commit 7927452ac4e98309bd832d55526cc98438fba8a5)

13 months agomsun: Add copyright notices
Warner Losh [Sat, 23 Oct 2021 04:00:54 +0000 (22:00 -0600)]
msun: Add copyright notices

These files were copied from MUSL. Add the standard copyright notice and
SPDX-License-Identifier: MIT consistent with our new draft license
policy. It reads word for word the same as the MIT license on the SPDX
web site. Add a pointer to the MUSL COPYIRGHT file which contains a list
of all authors of MUSL.

Sponsored by: Netflix
Noticed by: Steve Kargl

(cherry picked from commit 3550a49f6814af38c21b0033ef8746953451dade)

13 months ago* lib/msun/Makefile b/lib/msun/Makefile:
Mark Murray [Tue, 14 Dec 2021 09:08:57 +0000 (09:08 +0000)]
* lib/msun/Makefile b/lib/msun/Makefile:
  . Disconnect imprecise.c from the build.  This file can be deleted.
  . Add b_tgammal.c to the build for ld80 and ld128 targets.  The ld128
    is a 'git mv' of imprecise.c to ld128/b_tgammal.c.

* lib/msun/ld80/b_expl.c:
  . New file.  Implement __exp__D for ld80 targets.  This is based on
    bsdsrc/b_exp.c.

* lib/msun/ld80/b_logl.c:
  . New file.  Implement __log__D for ld80 targets.  This is based on
    bsdsrc/b_log.c.

* lib/msun/ld80/b_tgammal.c b/lib/msun/ld80/b_tgammal.c
  . New file.  Implement tgammal(x) for ld80 targets.

Submitted by:           Steve Kargl
Differential Revision:  https://reviews.freebsd.org/D33444
Reviewed by:            pfg

(cherry picked from commit 03a88e3de9c68182d21df94b1c8c7ced930dbd1f)

13 months ago* lib/msun/Makefile:
Mark Murray [Tue, 14 Dec 2021 09:02:45 +0000 (09:02 +0000)]
* lib/msun/Makefile:
  . Disconnect b_exp.c and b_log.c from the build.

* lib/msun/bsdsrc/b_exp.c:
  . Replace scalb() usage with C99's ldexp().
  . Replace finite(x) usage with C99's isfinite().
  . Whitespace changes towards style(9).
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Remove #if 0 ... #endif code, which has been present since svn r93211
    (2002-03-26).
  . New minimax polynomial coefficients.
  . Add comments to explain origins of some constants.
  . Use ansi-C prototype.  Remove K&R prototype.  Add static to prototype.

* lib/msun/bsdsrc/b_log.c:
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Fix comments to actually describe the code.
  . Reduce minimax polynomial from degree 4 to degree 3.
    This uses newly computed coefficients.
  . Use ansi-C prototype.  Remove K&R prototype.  Add static to prototype.
  . Remove volatile in declaration of u1.
  . Alphabetize decalaration list.
  . Whitespace changes towards style(9).
  . In argument reduction of x to g and m, replace use of logb() and
    ldexp() with a single call to frexp().  Add code to get 1 <= g < 2.
  . Remove #if 0 ... #endif code, which has been present since svn r93211
    (2002-03-26).
  . The special case m == -1022, replace logb() with ilogb().

* lib/msun/bsdsrc/b_tgamma.c:
  . Update comments.  Fix comments where needed.
  . Add float.h to get LDBL_MANT_DIG for weak reference of tgammal to tgamma.
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Use "math.h" instead of <math.h>.
  . Add '#include math_private.h"
  . Add struct Double from mathimpl.h and include b_log.c and b_exp.c.
  . Remove forward declarations of neg_gam(), small_gam(), smaller_gam,
    large_gam() and ratfun_gam() by re-arranging the code to move these
    function above their first reference.
  . New minimax coefficients for polynomial in large_gam().
  . New splitting of a0 into a0hi nd a0lo, which include additional
    bits of precision.
  . Use ansi-C prototype.  Remove K&R prototype.
  . Replace the TRUNC() macro with a simple cast of a double entities
    to float before assignment (functional changes).
  . Replace sin(M_PI*z) with sinpi(z) and cos(M_PI*(0.5-z)) with cospi(0.5-z).

Submitted by: Steve Kargl
Differential Revision: https://reviews.freebsd.org/D33444
Reviewed by: pfg

(cherry picked from commit 455b2ccda3df35f31a167f8a35f11ec31fac89bc)

13 months agoFix powf().
Mark Murray [Mon, 6 Sep 2021 17:26:39 +0000 (18:26 +0100)]
Fix powf().

Summary:
From Steve Kargl:

Paul Zimmermann has identified a bug in Openlibm's powf(),
which is identical to FreeBSD's libm.  Both derived from
fdlibm. https://github.com/JuliaMath/openlibm/issues/212.

Consider

% cat h.c
int
main(void)
{
  float x, y, z;
  x =  0x1.ffffecp-1F;
  y = -0x1.000002p+27F;
  z =  0x1.557a86p115F;
  printf("%e %e %e <-- should be %e\n", x, y, powf(x,y), z);
  return 0;
}

% cc -o h -fno-builtin h.c -lm && ./h
9.999994e-01 -1.342177e+08 inf <-- should be 5.540807e+34

Reviewers: manu

Subscribers: imp, andrew, emaste

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

(cherry picked from commit 292815eac623035493854f133200a4b1041fa246)

13 months agoMove LIBADD lines from usr.bin/clang/*/Makefile one level up
Dimitry Andric [Sun, 23 Jul 2023 20:04:46 +0000 (22:04 +0200)]
Move LIBADD lines from usr.bin/clang/*/Makefile one level up

Some utilities under usr.bin/clang were only linked to libz, while most
others were linked to libz and libzstd. Make this consistent, and remove
repetition, by moving these LIBADD lines to usr.bin/clang/clang.prog.mk
and usr.bin/clang/clang.prog.mk.

MFC after: 3 days

(cherry picked from commit f576172682401984fcf5e422d31086499caaebcf)

13 months agoWork around VNET and DPCPU related panics on aarch64
Dimitry Andric [Sun, 23 Jul 2023 13:48:36 +0000 (15:48 +0200)]
Work around VNET and DPCPU related panics on aarch64

lld >= 14 and recent GNU ld can relax adrp+add and adrp+ldr
instructions, which breaks VNET and DPCPU when used in modules.

Until VNET and DPCPU can be fixed to deal with these relaxed
instructions, disable linker relaxation for now.

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

(cherry picked from commit 80e4ac2964a11edef456a15b77e43aadeaf273a2)

13 months agospdx: The BSD-3-Clause-FreeBSD identifier never was, drop -FreeBSD
Warner Losh [Wed, 10 May 2023 15:40:58 +0000 (09:40 -0600)]
spdx: The BSD-3-Clause-FreeBSD identifier never was, drop -FreeBSD

There never was a BSD-3-Clause-FreeBSD SPDX identifier. Replace it
with BSD-3-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

(cherry picked from commit eb8f887758f31f605829c995ce71a627dec0838a)

13 months agoSPDX: It's spelled 'SPDX-License-Identifier'
Warner Losh [Thu, 11 May 2023 16:03:59 +0000 (10:03 -0600)]
SPDX: It's spelled 'SPDX-License-Identifier'

Sponsored by: Netflix

(cherry picked from commit ecfb43cb419808a5e2f802f780cba66a49f473b7)

13 months agospdx: Simplify BSD-2-Clause AND BSD-2-Clause
Warner Losh [Wed, 10 May 2023 15:40:58 +0000 (09:40 -0600)]
spdx: Simplify BSD-2-Clause AND BSD-2-Clause

After removing the -FreeBSD and -NetBSD, we're left with a nuber of
BSD-2-Clause AND BSD-2-Clause, so tidy that up.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

(cherry picked from commit eebd9d53665e1b691ffada910b940b37b6f62cc4)

13 months agospdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
Warner Losh [Wed, 10 May 2023 15:40:58 +0000 (09:40 -0600)]
spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD

The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

(cherry picked from commit b61a573019428cbdc38ed03be9ecd2482011ea66)

13 months agospdx: Remove duplicate lines
Warner Losh [Wed, 10 May 2023 22:42:54 +0000 (16:42 -0600)]
spdx: Remove duplicate lines

Remove duplicated SPDX lines.

Sponsored by: Netflix

(cherry picked from commit c87658aa7d1fe09d3839b9ad1d6a9c0fef5afd94)

13 months agospdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
Warner Losh [Wed, 10 May 2023 15:40:58 +0000 (09:40 -0600)]
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

(cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)

13 months agoCirrus-CI: use llvm16 job by default and make llvm15 manual
Ed Maste [Thu, 22 Jun 2023 23:20:34 +0000 (19:20 -0400)]
Cirrus-CI: use llvm16 job by default and make llvm15 manual

With commit e048f78b2143 (head) / 2e7b90a28f69 (stable/13) the default
tool chain is Clang/LLVM 16, so follow along in the llvm pkg used by
Cirrus-CI.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 171f1c1b4f0e9ec5b77a2dabdd4fcbf9baaa02df)

13 months agoCirrus-CI: add a manually triggered aarch64-gcc12 task
Ed Maste [Fri, 9 Jun 2023 15:19:42 +0000 (11:19 -0400)]
Cirrus-CI: add a manually triggered aarch64-gcc12 task

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5ad6c907f99443ebbe9e152d4e68a18b7fa01fff)

13 months agoCirrus-CI: add amd64 and arm64 Clang/LLVM 16 jobs
Ed Maste [Fri, 26 May 2023 12:14:51 +0000 (08:14 -0400)]
Cirrus-CI: add amd64 and arm64 Clang/LLVM 16 jobs

Reviewed by: lwhsu (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40286

(cherry picked from commit df042dcf268c7f5ab9ca5d090a682af76070b919)

13 months agomodules: fix freebsd32_modstat on big endian platforms
Ka Ho Ng [Fri, 7 Jul 2023 04:21:01 +0000 (00:21 -0400)]
modules: fix freebsd32_modstat on big endian platforms

The layout of modspecific_t on both little endian and big endian are as
follows:
|0|1|2|3|4|5|6|7|
+-------+-------+
|uintval|       |
+-------+-------+
|ulongval       |
+-------+-------+

For the following code snippet:
        CP(mod->data, data32, longval);
        CP(mod->data, data32, ulongval);
It only takes care of little endian platforms that it truncates the
highest 32bit automatically. However on big endian platforms it takes
the highest 32bit instead. This eventually returns a garbage syscall
number to the 32bit userland.

Since modspecific_t's usage currently is for the use of syscall modules,
we only initialize modspecific32_t with uintval. Now on both BE and LE
64-bit platforms it always pick up the first 4 bytes.

Sponsored by: Juniper Networks, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D40814
MFC after: 1 week

(cherry picked from commit 034c0856018ccf73c0f2d6140825f3edf43f47b2)

13 months agoApply build fix for powerpc64-specific llvm-ar and llvm-nm link error
Dimitry Andric [Sun, 23 Jul 2023 18:26:01 +0000 (20:26 +0200)]
Apply build fix for powerpc64-specific llvm-ar and llvm-nm link error

Only on powerpc64, llvm-ar and llvm-nm could fail to link due to a
"undefined symbol: ZSTD_compressBound" error. This does not happen on
-CURRENT, so directly apply a specific build fix on stable/13.

13 months agoMerge commit 2b0f5df7b4e0 from llvm-project (by Jessica Clarke):
Dimitry Andric [Sun, 23 Jul 2023 11:01:42 +0000 (13:01 +0200)]
Merge commit 2b0f5df7b4e0 from llvm-project (by Jessica Clarke):

  [builtins][Mips] Un-break FreeBSD build of __clear_cache

  Commit 674a17e9bbe8 ("MIPS/compiler_rt: use synci to flush icache on
  r6") completely removed the OS-specific guards under the guise of "For
  pre-r6, we can use cacheflush libc function, which is same on Linux and
  FreeBSD." However, the code in question had guards for Linux and
  OpenBSD, not Linux and FreeBSD, and FreeBSD does not have a cacheflush
  libc function as claimed, so this was neither the statement they
  intended to make nor was it sufficient justification for making the code
  completely unconditional. Whilst the upcoming FreeBSD 14 release has
  dropped support for MIPS, FreeBSD 13 has support for it.

  Fix this by only calling cacheflush on the OSes where it was previously
  called, and not on other OSes where it either definitely isn't available
  (FreeBSD) or is unknown (any other OS than the three mentioned in this
  commit).

This is only needed for MFC'ing, as mips has been removed from
14-CURRENT.

PR: 271047
MFC after: immediately

(cherry picked from commit b8f1c9dd9b3dd9b91e6999b28ab941a2af142702)

13 months agoMerge commit 9ca395b5ade1 from llvm-project (by Haojian Wu):
Dimitry Andric [Wed, 19 Jul 2023 09:18:50 +0000 (11:18 +0200)]
Merge commit 9ca395b5ade1 from llvm-project (by Haojian Wu):

  [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

  Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
  code), we propagate the contains-errors bit for C-code path.

  Fixes https://github.com/llvm/llvm-project/issues/50236
  Fixes https://github.com/llvm/llvm-project/issues/50243
  Fixes https://github.com/llvm/llvm-project/issues/48636
  Fixes https://github.com/llvm/llvm-project/issues/50320

  Differential Revision: https://reviews.llvm.org/D154861

This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors()
|| RHSExpr->containsErrors()) && "Should only occur in error-recovery
path."), function BuildBinOp') when building parts of dtrace in certain
scenarios.

Reported by: dstolfa
PR: 271047
MFC after: 1 month

(cherry picked from commit 8d0cab8800e19cddc56d4a532abdbe9f0ac6c620)

13 months agoMerge commit 8757ce490130 from llvm-project (by Simon Pilgrim):
Dimitry Andric [Sun, 16 Jul 2023 18:45:29 +0000 (20:45 +0200)]
Merge commit 8757ce490130 from llvm-project (by Simon Pilgrim):

    [PowerPC] Replace PPCISD::VABSD cases with generic ISD::ABDU(X,Y) node

    A move towards using the generic ISD::ABDU nodes on more backends

    Also support ISD::ABDS for v4i32 types using the existing signbit flip trick

    PowerPC has a select(icmp_ugt(x,y),sub(x,y),sub(y,x)) -> abdu(x,y) combine that I intend to move to DAGCombiner in a future patch.

    The ABS(SUB(X,Y)) -> PPCISD::VABSD(X,Y,1) v4i32 combine wasn't legal (https://alive2.llvm.org/ce/z/jc2hLU) - so I've removed it, having already added the legal sub nsw tests equivalent.

    Differential Revision: https://reviews.llvm.org/D142313

This fixes a "Wasn't expecting to be able to lower this!" fatal error
when compiling graphics/opencv for PowerPC.

Requested by: pkubaj
PR: 271047
MFC after: 1 month

(cherry picked from commit 881fc203567e85648f2f591a75c4674be2bee0ed)

13 months agoMerge commit fde5924dcc69 from llvm-project (by Serge Pavlov):
Dimitry Andric [Thu, 13 Jul 2023 18:57:22 +0000 (20:57 +0200)]
Merge commit fde5924dcc69 from llvm-project (by Serge Pavlov):

  [clang] Reset FP options before template instantiation

  AST nodes that may depend on FP options keep them as a difference
  relative to the options outside the AST node. At the moment of
  instantiation the FP options may be different from the default values,
  defined by command-line option. In such case FP attributes would have
  unexpected values. For example, the code:

      template <class C> void func_01(int last, C) {
        func_01(last, int());
      }
      void func_02() { func_01(0, 1); }
      #pragma STDC FENV_ACCESS ON

  caused compiler crash, because template instantiation takes place at the
  end of translation unit, where pragma STDC FENV_ACCESS is in effect. As
  a result, code in the template instantiation would use constrained
  intrinsics while the function does not have StrictFP attribute.

  To solve this problem, FP attributes in Sema must be set to default
  values, defined by command line options.

  This change resolves https://github.com/llvm/llvm-project/issues/63542.

  Differential Revision: https://reviews.llvm.org/D154359

Requested by: pkubaj
PR: 265755, 265758
MFC after: 1 month

(cherry picked from commit 1cd9788408aa9ea4fd0fbc3e06bd9a4eaf8d8d22)

13 months agoBump __FreeBSD_version for llvm 16.0.6 merge
Dimitry Andric [Thu, 22 Jun 2023 18:24:04 +0000 (20:24 +0200)]
Bump __FreeBSD_version for llvm 16.0.6 merge

PR: 271047
MFC after: 1 month

(cherry picked from commit a681cba16d8967651a2146385ce44a2bfeb1c4c3)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152
Dimitry Andric [Thu, 22 Jun 2023 17:47:54 +0000 (19:47 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.6-0-g7cbf1a259152 (aka 16.0.6 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit e048f78b21438144bab781f2ba9ee33a2aae6772)

13 months agoMerge commit 69d42eef4bec from llvm-project (by Dimitry Andric):
Dimitry Andric [Wed, 14 Jun 2023 18:49:59 +0000 (20:49 +0200)]
Merge commit 69d42eef4bec from llvm-project (by Dimitry Andric):

  [Clang] Show type in enum out of range diagnostic

  When the diagnostic for an out of range enum value is printed, it
  currently does not show the actual enum type in question, for example:

      v8/src/base/bit-field.h:43:29: error: integer value 7 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion]
        static constexpr T kMax = static_cast<T>(kNumValues - 1);
                                  ^

  This can make it cumbersome to find the cause for the problem. Add the
  enum type to the diagnostic message, to make it easier.

  Reviewed By: aaron.ballman

  Differential Revision: https://reviews.llvm.org/D152788

PR: 271047
MFC after: 1 month

(cherry picked from commit cf24393421ca807899c599a53ddc5dcedb7c71dc)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba
Dimitry Andric [Sun, 4 Jun 2023 19:01:35 +0000 (21:01 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.5-0-g185b81e034ba (aka 16.0.5 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit 2efbaac7a07fff163640a67873b3ac250794ec3f)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493
Dimitry Andric [Mon, 22 May 2023 17:29:55 +0000 (19:29 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.4-0-gae42196bc493 (aka 16.0.4 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit a324c34037ef2e1101962fca4ad0c021253288e1)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5
Dimitry Andric [Fri, 5 May 2023 17:37:33 +0000 (19:37 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.3-0-gda3cd333bea5 (aka 16.0.3 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit cbe9438cfe07adfbcdeafe8e363614f83b03a055)

13 months agoclang: re-downgrade implicit int/function declarations to warning only
Dimitry Andric [Tue, 25 Apr 2023 19:24:04 +0000 (21:24 +0200)]
clang: re-downgrade implicit int/function declarations to warning only

This reapplies upstream commit c0141f3c300f by Aaron Ballman:

  Downgrade implicit int and implicit function declaration to warning only

  The changes in Clang 15.0.0 which enabled these diagnostics as a
  warning which defaulted to an error caused disruption for people
  working on distributions such as Gentoo. There was an explicit request
  to downgrade these to be warning-only in Clang 15.0.1 with the
  expectation that Clang 16 will default the diagnostics to an error.

  See
  https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
  for more details on the discussion.

  See https://reviews.llvm.org/D133800 for the public review of these
  changes.

As noted in the upstream discussion, there are many programs that fail
to configure or build correctly, if these warnings are turned into
errors by default.

Note that most affected programs in ports are relatively old, and are
unlikely to be fixed by actually adjusting their declarations, but by
compiling with -std=gnu89, which downgrades the errors back to warning
again. Lots of tedious work for very little gain.

(cherry picked from commit c3450ad127e94d3fa67ae337310e59c002f51bfc)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9
Dimitry Andric [Sat, 22 Apr 2023 17:27:13 +0000 (19:27 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.2-0-g18ddebe1a1a9 (aka 16.0.2 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit 9e7101a856ad738879b0bde099bfb2ba08b7995c)

13 months agoMerge commit db492316399a from llvm-project (by Dimitry Andric):
Dimitry Andric [Thu, 20 Apr 2023 19:22:59 +0000 (21:22 +0200)]
Merge commit db492316399a from llvm-project (by Dimitry Andric):

  [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

  As of https://reviews.llvm.org/D79708, clang-tblgen generates `arm_neon.h`,
  `arm_sve.h` and `arm_bf16.h`, and all those generated files will contain a
  typedef of `bfloat16_t`. However, `arm_neon.h` and `arm_sve.h` include
  `arm_bf16.h` immediately before their own typedef:

      #include <arm_bf16.h>
      typedef __bf16 bfloat16_t;

  With a recent version of clang (I used 16.0.1) this results in warnings:

      /usr/lib/clang/16/include/arm_neon.h:38:16: error: redefinition of typedef 'bfloat16_t' is a C11 feature [-Werror,-Wtypedef-redefinition]

  Since `arm_bf16.h` is very likely supposed to be the one true place where
  `bfloat16_t` is defined, I propose to delete the duplicate typedefs from the
  generated `arm_neon.h` and `arm_sve.h`.

  Reviewed By: sdesmalen, simonbutcher

  Differential Revision: https://reviews.llvm.org/D148822

PR: 271047
MFC after: 1 month

(cherry picked from commit 1ac57eed95099f4d9da2ecab6000ad66d05c1018)

13 months agoMerge commit 16949c5c48ab from llvm-project (by Dimitry Andric):
Dimitry Andric [Thu, 20 Apr 2023 19:21:37 +0000 (21:21 +0200)]
Merge commit 16949c5c48ab from llvm-project (by Dimitry Andric):

  [compiler-rt] Include system headers before optionally defining HWCAP macros

  In https://reviews.llvm.org/D141285 the optional definitions of `HWCAP`
  macros were moved to before their usage. However, they were also moved
  to before the inclusion of system headers which can optionally define
  them. If any of those system headers then actually defined any of the
  `HWCAP` macros, it would result in a redefinition error.

  Move the system header includes to just before the optional definitions,
  to avoid this problem.

  Reviewed By: ilinpv

  Differential Revision: https://reviews.llvm.org/D148819

PR: 271047
MFC after: 1 month

(cherry picked from commit 482e0fcdf745981f2c2b12311405fe93563cefc4)

13 months agoMerge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979
Dimitry Andric [Mon, 17 Apr 2023 17:14:23 +0000 (19:14 +0200)]
Merge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.1-0-gcd89023f7979 (aka 16.0.1 release).

PR: 271047
MFC after: 1 month

(cherry picked from commit 1ac55f4cb0001fed92329746c730aa9a947c09a5)

13 months agoMerge llvm-project main llvmorg-16-init-18548-gb0daacf58f41
Dimitry Andric [Fri, 14 Apr 2023 21:41:27 +0000 (23:41 +0200)]
Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16-init-18548-gb0daacf58f41.

PR: 271047
MFC after: 1 month

(cherry picked from commit bdd1243df58e60e85101c09001d9812a789b6bc4)

13 months agolibarchive: make single bit bitfields unsigned to avoid clang 16 warning
Dimitry Andric [Mon, 17 Apr 2023 16:20:56 +0000 (18:20 +0200)]
libarchive: make single bit bitfields unsigned to avoid clang 16 warning

Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by various declarations in libarchive:

    contrib/libarchive/libarchive/archive_write_set_format_7zip.c:1541:13: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    file->dir = 1;
                              ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5127:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    isoent->dir = 1;
                                ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5213:14: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->dir = 1;
                        ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5214:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->virtual = 1;
                            ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7149:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->virtual = 1;
                            ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7435:32: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    iso9660->zisofs.detect_magic = 1;
                                                 ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7495:25: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            iso9660->zisofs.making = 1;
                                   ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7496:26: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            iso9660->zisofs.allzero = 1;
                                    ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7702:28: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                            iso9660->zisofs.allzero = 1;
                                                    ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7871:25: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    zisofs->header_passed = 1;
                                          ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7894:24: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                            zisofs->initialized = 1;
                                                ^ ~

Signed one-bit bitfields can only have values -1 and 0, but the intent
here is to use the fields as booleans, so make them unsigned.

This has also been sent upstream.

MFC after: 3 days

(cherry picked from commit 67ecab6f50ff29e9bda340be1e9d2acc963c9a2b)

13 months agolibm: correctly test for for NaN and Infinity in sinpi(), cospi(), and tanpi()
Steve Kargl [Mon, 17 Jul 2023 05:19:28 +0000 (08:19 +0300)]
libm: correctly test for for NaN and Infinity in sinpi(), cospi(), and tanpi()

PR: 272539

(cherry picked from commit be4c7f273508994638b68d2fae742be37d3cb117)

13 months agolibthr: trigger library initialization on rwlock calls
Konstantin Belousov [Thu, 13 Jul 2023 15:56:11 +0000 (18:56 +0300)]
libthr: trigger library initialization on rwlock calls

(cherry picked from commit ad056b5d35d9957b1bd023abeb6461601449b725)

13 months agodepend-cleanup.sh: handle 32-bit dependencies having no 64-bit equivalent
Dimitry Andric [Mon, 10 Jul 2023 22:50:09 +0000 (00:50 +0200)]
depend-cleanup.sh: handle 32-bit dependencies having no 64-bit equivalent

For example with the recent removal of ffs.S for 32-bit arm and i386,
the egrep in clean_dep() did not find any files to remove, even if you
added a "clean_dep lib/libc ffs S" line. This is because it will never
find the ffs.S filename in the 64-bit .depend files for libc.

Split the searching and removing of 32-bit dependencies and objects into
a separate part to cope with this. This can be used similarly later on,
for other bitnesses.

MFC after: 3 days

(cherry picked from commit 7ba8cc9b7b6bdea142d7ecb82c7d3a9b095e967d)

13 months agorelease: pass UNAME_r to fix building 14.x ports on 13.x
Glen Barber [Thu, 18 Feb 2021 23:52:39 +0000 (18:52 -0500)]
release: pass UNAME_r to fix building 14.x ports on 13.x

Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

(cherry picked from commit 80ab50e1de19ca125f05a13937c796d48c4edd4a)

13 months agorelease: Adjust where UNAME_r is defined for ports builds
Glen Barber [Tue, 2 Mar 2021 15:11:04 +0000 (10:11 -0500)]
release: Adjust where UNAME_r is defined for ports builds

In followup to 80ab50e1de19ca125f05a13937c796d48c4edd4a,
export UNAME_r in Makefile.inc1 instead of Makefile.vm.

Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

(cherry picked from commit 0be274d3737972532c042d06c53b5807e95aa845)

13 months agorelease: Include Makefile.inc1 in Makefile.vm
Glen Barber [Tue, 2 Mar 2021 15:19:59 +0000 (10:19 -0500)]
release: Include Makefile.inc1 in Makefile.vm

Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

(cherry picked from commit c883b6fd8ccd8d9c50b3f8fbb04da20ac0dec1c4)

13 months agorelease: sprinkle UNAME_r hacks following c883b6fd8ccd
Glen Barber [Thu, 4 Mar 2021 14:22:45 +0000 (09:22 -0500)]
release: sprinkle UNAME_r hacks following c883b6fd8ccd

Pass UNAME_r override to make(1) for ports builds when building
ports for another branch.

Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

(cherry picked from commit 63749bfe96b792b3a435f84ad81a47888cae1dea)

13 months agoWrite out corrected superblock when creating a UFS/FFS snapshot.
Kirk McKusick [Tue, 13 Jun 2023 07:21:43 +0000 (00:21 -0700)]
Write out corrected superblock when creating a UFS/FFS snapshot.

PR:           271352
Tested-by: Peter Holm
Sponsored-by: The FreeBSD Foundation
(cherry picked from commit f1549d7d522995bf5d821ae08cc2f500ba545285)

13 months agolibfido2: update to 1.10.0
Ed Maste [Fri, 5 May 2023 23:57:34 +0000 (19:57 -0400)]
libfido2: update to 1.10.0

Some highlights from NEWS:

 ** bio: fix CTAP2 canonical CBOR encoding in fido_bio_dev_enroll_*();
    gh#480.
 ** New API calls:
  - fido_dev_info_set;
  - fido_dev_io_handle;
  - fido_dev_new_with_info;
  - fido_dev_open_with_info.
 ** Documentation and reliability fixes.
 ** Support for TPM 2.0 attestation of COSE_ES256 credentials.

Relnotes:       Yes
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 3e696dfb7009cd8ffa12e36f48f4339bb7a2048d)

13 months agolibfido2: update to 1.9.0
Ed Maste [Fri, 5 May 2023 23:11:52 +0000 (19:11 -0400)]
libfido2: update to 1.9.0

Some highlights from NEWS:

 ** Added OpenSSL 3.0 compatibility.
 ** Removed OpenSSL 1.0 compatibility.
 ** Support for FIDO 2.1 "minPinLength" extension.
 ** Support for COSE_EDDSA, COSE_ES256, and COSE_RS1 attestation.
 ** Support for TPM 2.0 attestation.
 ** Support for device timeouts; see fido_dev_set_timeout().
 ** New API calls:
  - es256_pk_from_EVP_PKEY;
  - fido_cred_attstmt_len;
  - fido_cred_attstmt_ptr;
  - fido_cred_pin_minlen;
  - fido_cred_set_attstmt;
  - fido_cred_set_pin_minlen;
  - fido_dev_set_pin_minlen_rpid;
  - fido_dev_set_timeout;
  - rs256_pk_from_EVP_PKEY.
 ** Reliability and portability fixes.
 ** Better handling of HID devices without identification strings; gh#381.

Relnotes:       Yes
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit f540a43052c12c76d3453ead881248d5467a1ab0)