]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
13 months agommc(4): Don't call bridge driver for timings not requiring tuning
Marius Strobl [Wed, 12 Apr 2023 21:46:02 +0000 (23:46 +0200)]
mmc(4): Don't call bridge driver for timings not requiring tuning

The original idea behind calling into the bridge driver was to have the
logic deciding whether tuning is actually required for a particular bus
timing in a given slot as well as doing the sanity checking only on the
controller layer which also generally is better suited for these due to
say SDHCI_SDR50_NEEDS_TUNING. On another thought, not every such driver
should need to check whether tuning is required at all, though, and not
everything is SDHCI in the first place.
Adjust sdhci(4) accordingly keeping sdhci_generic_tune() a bit cautious
still.

(cherry picked from commit bd15d31cef50060d90356384ba7b878d398fc9f3)

13 months agoman: Remove obsolete meteor.4
Marius Strobl [Sat, 18 Dec 2021 13:56:16 +0000 (14:56 +0100)]
man: Remove obsolete meteor.4

The corresponding interface has been deorbited as part of
daba5ace03e83a930c128ae644afd186e1fe4341.

(cherry picked from commit 7ed5694dd9b9d91e6afd7442b04b602041650354)

13 months agoRemove bt.4 man page.
Cy Schubert [Mon, 29 Mar 2021 05:14:36 +0000 (22:14 -0700)]
Remove bt.4 man page.

r339568 (a1db7455b75d7557fd171a537e2d95aceb20846e) removed bt(4).
This revision removes the man page

(cherry picked from commit e2b247fac21e3b82f84cc56c7caf94f6ec3e78b0)

13 months agoUFS/FFS: Migrate to modern uintXX_t from u_intXX_t.
Kirk McKusick [Thu, 27 Jul 2023 22:26:01 +0000 (15:26 -0700)]
UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.

As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
move to the modern uintXX_t. While here also migrate u_char to uint8_t.
Where other kernel interfaces allow, migrate u_long to uint64_t.

No functional changes intended.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit 831b1ff7913fb0b317a258a43dce5abefee03a31)

13 months agoAdd diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
Kirk McKusick [Wed, 26 Jul 2023 21:49:07 +0000 (14:49 -0700)]
Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit 6f0ca273a393bad293cc3ae12b3816ab1582bbc2)

13 months agoAdd quitclean command to fsdb(8) to request a filesystem not be marked dirty.
Kirk McKusick [Wed, 26 Jul 2023 02:42:41 +0000 (19:42 -0700)]
Add quitclean command to fsdb(8) to request a filesystem not be marked dirty.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit d059e44b800a308822ad920c28f948a1afcc0fa3)

13 months agoHave fsdb(8) only mark a filesystem dirty when it is modified.
Kirk McKusick [Wed, 26 Jul 2023 02:27:59 +0000 (19:27 -0700)]
Have fsdb(8) only mark a filesystem dirty when it is modified.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit d51bdf327d9381807cbeffead1ed3cc466bdb87b)

13 months agoComment cleanup.
Kirk McKusick [Tue, 25 Jul 2023 21:07:31 +0000 (14:07 -0700)]
Comment cleanup.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit 4a3444428de5e74f8e847f656eb25ad559902a74)

13 months agoDebugging output additions. No functional changes intended.
Kirk McKusick [Tue, 25 Jul 2023 21:02:33 +0000 (14:02 -0700)]
Debugging output additions. No functional changes intended.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit 4d512b07357f6a4feff8ac266f90d34939a57be4)

13 months agoText format cleanups. No functional changes intended.
Kirk McKusick [Tue, 18 Jul 2023 00:28:07 +0000 (17:28 -0700)]
Text format cleanups. No functional changes intended.

Sponsored-by: The FreeBSD Foundation
(cherry picked from commit 239597e0309d4d8e84c35929513aa4a2470735ad)

13 months agonfsserver: Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 09:27:30 +0000 (11:27 +0200)]
nfsserver: Fix a typo in a source code comment

- s/restared/restarted/

(cherry picked from commit 11892bc710a741a03735b164dc089d40d7d80374)

13 months agonetpfil: Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 07:41:29 +0000 (09:41 +0200)]
netpfil: Fix a typo in a source code comment

- s/interprted/interpreted/

(cherry picked from commit cfd05de1946799c6353b07da5d351027d8471203)

13 months agoaic7xxx: Fix two typos in source code comments
Gordon Bergling [Wed, 2 Aug 2023 07:20:17 +0000 (09:20 +0200)]
aic7xxx: Fix two typos in source code comments

- s/reslection/reselection/

(cherry picked from commit 3514686b344da607515decb500018d25aadacd33)

13 months agoisp(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 09:48:46 +0000 (11:48 +0200)]
isp(4): Fix a typo in a source code comment

- s/Constatns/Constants/

Obtained from: NetBSD

(cherry picked from commit d3367c35cb12d4acde62ffbb72740801352cd3fc)

13 months agocam(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 09:14:53 +0000 (11:14 +0200)]
cam(4): Fix a typo in a source code comment

- s/uppper/upper/

(cherry picked from commit 586eda6b244632d28d740e417133227b14324e3d)

13 months agoelf(3): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 09:51:56 +0000 (11:51 +0200)]
elf(3): Fix a typo in a source code comment

- s/speciaal/special/

(cherry picked from commit 2f0e0bd50633eafdfda503ec388151911e7383af)

13 months agolinux(4): Fix two typos in source code comments
Gordon Bergling [Wed, 2 Aug 2023 09:55:30 +0000 (11:55 +0200)]
linux(4): Fix two typos in source code comments

- s/decriptors/descriptors/

(cherry picked from commit 29eab3e4e0c9a6e954b0ee858e3d4c2a9f283ea4)

13 months agopsm(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 07:14:04 +0000 (09:14 +0200)]
psm(4): Fix a typo in a source code comment

- s/diable/disable/

(cherry picked from commit 7eb8fbfb0421d38ec83a73f9b8ea13e7c52d3314)

13 months agovnic: Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 07:33:35 +0000 (09:33 +0200)]
vnic: Fix a typo in a source code comment

- s/Enabele/Enable/

(cherry picked from commit b73763fc10d8000ec5c5682abccf6c8489eee8e3)

13 months agousb(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 09:04:24 +0000 (11:04 +0200)]
usb(4): Fix a typo in a source code comment

- s/determin/determine/

(cherry picked from commit a924b48579c7a0c794431fbd3f540ce56c4cd662)

13 months agoet(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 2 Aug 2023 07:09:56 +0000 (09:09 +0200)]
et(4): Fix a typo in a source code comment

- s/diabled/disabled/

(cherry picked from commit 734c9698d9ae83206a47daa40031a4de3bce9c28)

13 months agopf: test rules evaluation in the face of multiple IPv6 fragment headers
Kristof Provost [Thu, 13 Jul 2023 06:34:54 +0000 (08:34 +0200)]
pf: test rules evaluation in the face of multiple IPv6 fragment headers

Send an ICMPv6 echo request packet with multiple IPv6 fragment headers.
Set rules to pass all packets, except for ICMPv6 echo requests.

pf ought to drop the echo request, but doesn't because it reassembles
the packet, and then doesn't handle the second fragment header. In other
words: it fails to detect the ICMPv6 echo header.

Reported by: Enrico Bassetti bassetti@di.uniroma1.it (NetSecurityLab @ Sapienza University of Rome)
MFC after: instant
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit b23dbabb7f3edb3f323a64f03e37be2c9a8b2a45)

13 months agopf: handle multiple IPv6 fragment headers
Kristof Provost [Thu, 13 Jul 2023 08:25:49 +0000 (10:25 +0200)]
pf: handle multiple IPv6 fragment headers

With 'scrub fragment reassemble' if a packet contains multiple IPv6
fragment headers we would reassemble the packet and immediately
continue processing it.

That is, we'd remove the first fragment header and expect the next
header to be a final header (i.e. TCP, UDP, ICMPv6, ...). However, if
it's another fragment header we'd not treat the packet correctly.
That is, we'd fail to recognise the payload and treat it as if it were
an IPv6 fragment rather than as its actual payload.

Fix this by restarting the normalisation on the reassembled packet.
If there are multiple fragment headers drop the packet.

Reported by: Enrico Bassetti bassetti@di.uniroma1.it (NetSecurityLab @ Sapienza University of Rome)
MFC after: instant
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 76afcbb52492f9b3e72ee7d4c4ed0a54c25e1c48)

13 months agoatf_pytest_wrapper: fix use with pytest-7.4
Kristof Provost [Tue, 18 Jul 2023 14:20:47 +0000 (16:20 +0200)]
atf_pytest_wrapper: fix use with pytest-7.4

As of pytest 7.4 it no longer walks all the way to the root directory
of the file system to find conftest files. As a result we don't find /
usr/tests/conftest.py, and don't load atf_python. That in turn causes
atf_python tests to fail.

Explicitly set the confcutdir, as advised by the pytest changelog.

See also: https://github.com/pytest-dev/pytest/pull/11043
MFC after: 3 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D41064

(cherry picked from commit 9f23cbd6cae82fd77edfad7173432fa8dccd0a95)

13 months agosk(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 1 Aug 2023 05:50:45 +0000 (07:50 +0200)]
sk(4): Fix a typo in a source code comment

- s/nomral/normal/

(cherry picked from commit 135c2b71562f6a6b8e918cc66d5468342c198d02)

13 months agoe1000: HWCSUM excemption fixes
Kevin Bowling [Sat, 29 Jul 2023 01:14:29 +0000 (18:14 -0700)]
e1000: HWCSUM excemption fixes

Also disable IPV6 checksum offload.

Spell hw->mac.type < e1000_82543 as e1000_82542.  Confusingly, chips
like 82540 and 82541 come later and do not have these issues.  There
is no functional change here, as the enum was defined in such a way
it worked correctly.  But this reads literally.

(cherry picked from commit 38588749af45d738e6f548f15beb415c46ba8658)

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)