freebsd.git
19 months agoMFV: Restore the ability to process files from stdin immediately.
Xin LI [Thu, 27 Oct 2022 07:12:53 +0000 (00:12 -0700)]
MFV: Restore the ability to process files from stdin immediately.

PR: bin/267221
MFC after: 3 days

19 months agoUse the -n flag to produce immediate results and kill the short-lived -I.
Christos Zoulas [Wed, 26 Oct 2022 16:56:14 +0000 (16:56 +0000)]
Use the -n flag to produce immediate results and kill the short-lived -I.

(cherry picked from commit 425f9897f0ed791a6c216c24375bd9b3a42330a2)

19 months agoIn immediate mode, print with the current width.
Christos Zoulas [Mon, 24 Oct 2022 20:21:54 +0000 (20:21 +0000)]
In immediate mode, print with the current width.

(cherry picked from commit 7d489233e5f27decdbcfb0e8ecba0b0b5fdc6066)

19 months agoPR/397: dadv: Restore the ability of processing filenames from stdin
Christos Zoulas [Sun, 23 Oct 2022 14:22:53 +0000 (14:22 +0000)]
PR/397: dadv: Restore the ability of processing filenames from stdin
immediately, using the -I flag.

(cherry picked from commit ae5c1ff8df0d6e00cbf5e31875d777edbb88d60a)

19 months agopsci: set psci_present as early as possible
Kyle Evans [Thu, 27 Oct 2022 03:46:45 +0000 (22:46 -0500)]
psci: set psci_present as early as possible

psci_attach is way too late to provide the intended semantics for
psci_present.  psci calls can be made immediately after psci_init(),
called way earlier at SI_SUB_CPU + SI_ORDER_FIRST, and we need it to
be valid as early as we can possibly call a psci function.

This fixes booting RPi3+4 with the in-review spintable patch;
rpi3-psci-monitor patches the FDT to add a PSCI node, but it doesn't
patch each cpus' enable-method.  Because of this, we would stall the
boot while enabling CPU 1 as we saw a valid looking enable-method and
"no" functional PSCI and attempted to use the spintable rather than
simply not starting secondary APs.

Fixes: 2218070b2c3c32 ("psci: finish psci_present implementation")
Reported by: karels

19 months agoffs validate_sblock(): avoid 32bit mul overflow
Konstantin Belousov [Mon, 24 Oct 2022 21:34:15 +0000 (00:34 +0300)]
ffs validate_sblock(): avoid 32bit mul overflow

Reported by: soralx@cydem.org
Tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

19 months agovfs_lookup(): Minor performance optimizations
Jason A. Harmening [Thu, 20 Oct 2022 03:33:19 +0000 (22:33 -0500)]
vfs_lookup(): Minor performance optimizations

Refactor the symlink and mountpoint traversal logic to avoid
repeatedly checking the vnode type; a symlink cannot be a mountpoint
and vice versa.  Avoid repeatedly checking cn_flags for NOCROSSMOUNT
and simplify the check which determines whether the vnode is a
mountpoint.

Suggested by: mjg
Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D35054

19 months agovfs_busy(): fix wording in comment
Jason A. Harmening [Thu, 20 Oct 2022 03:31:44 +0000 (22:31 -0500)]
vfs_busy(): fix wording in comment

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35054

19 months agoRemove witness directives from crossmp locking VOPs
Jason A. Harmening [Fri, 5 Aug 2022 05:39:04 +0000 (00:39 -0500)]
Remove witness directives from crossmp locking VOPs

These are of limited use since the crossmp vnode locking ops have not
actually used a lock since commit
a2d35545429117e68fbcbc68e14ad55e84265d69.  We in fact require that
these operations are always issued with LK_SHARED.  Additionally,
these directives can produce a false positive in certain VV_CROSSLOCK
cases which require upgrading of the covered vnode lock from shared
to exclusive.

While here, replace the runtime check of LK_SHARED with a KASSERT and
expand the check to include LK_NOWAIT, which all callers pass.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D35054

19 months agoAdd VV_CROSSLOCK vnode flag to avoid cross-mount lookup LOR
Jason A. Harmening [Fri, 5 Aug 2022 05:32:49 +0000 (00:32 -0500)]
Add VV_CROSSLOCK vnode flag to avoid cross-mount lookup LOR

When a lookup operation crosses into a new mountpoint, the mountpoint
must first be busied before the root vnode can be locked. When a
filesystem is unmounted, the vnode covered by the mountpoint must
first be locked, and then the busy count for the mountpoint drained.
Ordinarily, these two operations work fine if executed concurrently,
but with a stacked filesystem the root vnode may in fact use the
same lock as the covered vnode. By design, this will always be
the case for unionfs (with either the upper or lower root vnode
depending on mount options), and can also be the case for nullfs
if the target and mount point are the same (which admittedly is
very unlikely in practice).

In this case, we have LOR. The lookup path holds the mountpoint
busy while waiting on what is effectively the covered vnode lock,
while a concurrent unmount holds the covered vnode lock and waits
for the mountpoint's busy count to drain.

Attempt to resolve this LOR by allowing the stacked filesystem
to specify a new flag, VV_CROSSLOCK, on a covered vnode as necessary.
Upon observing this flag, the vfs_lookup() will leave the covered
vnode lock held while crossing into the mountpoint. Employ this flag
for unionfs with the caveat that it can't be used for '-o below' mounts
until other unionfs locking issues are resolved.

Reported by: pho
Tested by: pho
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D35054

19 months agovmm: Fix AP startup with old userspace binaries.
John Baldwin [Wed, 26 Oct 2022 21:22:56 +0000 (14:22 -0700)]
vmm: Fix AP startup with old userspace binaries.

Older binaries that do not request IPI exits to userspace do not
start user threads for other vCPUs until a STARTUP IPI triggers a
VM_EXITCODE_SPINUP_AP exit to userland.  This means that those vcpus
are not yet active (in terms of vm_active_cpus) when the INIT and
STARTUP IPIs are delivered to the vCPUs.

The changes in commit 0bda8d3e9f7a changed the INIT and STARTUP IPIs
to reuse the existing vlapic_calcdest() function.  This function
silently ignores IPIs sent to inactive vCPUs.  As a result, when using
an old bhyve binary, the INIT and STARTUP IPIs sent to wakeup APs were
ignored.

To fix, restructure the compat code for the INIT and STARTUP IPIs to
ignore the results of vlapic_calcdest() and manually parse the APIC ID
and resulting vcpuid.  As part of this, make the compat code always
conditonal on the ipi_exit capability being disabled.

Reviewed by: c.koehne_beckhoff.com, markj
Differential Revision: https://reviews.freebsd.org/D37093

19 months agoUPDATING: correct spearate typo
Ed Maste [Wed, 26 Oct 2022 18:25:12 +0000 (14:25 -0400)]
UPDATING: correct spearate typo

Reported by: manu
Fixes: 9c36300582ec ("UPDATING: add an introductory...")

19 months agoUPDATING: add an introductory sentence to 20221026's entry
Ed Maste [Wed, 26 Oct 2022 18:10:46 +0000 (14:10 -0400)]
UPDATING: add an introductory sentence to 20221026's entry

19 months agoUPDATING: Add note for pkgbase users after splitting packages.
Emmanuel Vadot [Wed, 26 Oct 2022 17:48:32 +0000 (19:48 +0200)]
UPDATING: Add note for pkgbase users after splitting packages.

19 months agopkgbase: Put less in FreeBSD-runtime
Emmanuel Vadot [Tue, 16 Aug 2022 19:25:38 +0000 (21:25 +0200)]
pkgbase: Put less in FreeBSD-runtime

Useful to have a pager in it.

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

19 months agopkgbase: Create a FreeBSD-games package
Emmanuel Vadot [Mon, 8 Aug 2022 17:56:50 +0000 (19:56 +0200)]
pkgbase: Create a FreeBSD-games package

And put :
- pom
- caesar
- grdc

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

19 months agopkgbase: Put devmatch in its own package
Emmanuel Vadot [Fri, 22 Jul 2022 20:30:11 +0000 (22:30 +0200)]
pkgbase: Put devmatch in its own package

devmatch is useful on standalone machine but not on jails.
Put devinfo(8) and libdevinfo there too.

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

19 months agopkgbase: Put devd in its own package
Emmanuel Vadot [Fri, 22 Jul 2022 12:46:30 +0000 (14:46 +0200)]
pkgbase: Put devd in its own package

It's not that useful in a jail or in a mdroot.

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

19 months agopkgbase: Put ufs related tools and lib in their own package
Emmanuel Vadot [Fri, 22 Jul 2022 11:22:29 +0000 (13:22 +0200)]
pkgbase: Put ufs related tools and lib in their own package

It's not really useful in a jail or in a mdroot or even if a users
wants to do a full zfs machine.

Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D36227

19 months agopkgbase: Put libwrap in FreeBSD-tcpd package
Emmanuel Vadot [Fri, 22 Jul 2022 09:06:05 +0000 (11:06 +0200)]
pkgbase: Put libwrap in FreeBSD-tcpd package

It belongs there with the tcp wrapper utilities

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

19 months agopkgbase: Put zfs utilities and lib in their own package
Emmanuel Vadot [Fri, 22 Jul 2022 08:43:39 +0000 (10:43 +0200)]
pkgbase: Put zfs utilities and lib in their own package

It is useful to have zfs utilities and lib in a separate package as
it allow users to create image that can support ZFS (i.e. not with
WITHOUT_ZFS in src.conf set) without bloating the default image with
all zfs tools (for example for jails).

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

19 months agopkgbase: Put geom utilities in their own package
Emmanuel Vadot [Fri, 22 Jul 2022 08:19:07 +0000 (10:19 +0200)]
pkgbase: Put geom utilities in their own package

For most users it's not needed to boot and they are also
available in the FreeBSD-rescue package in case an update
break and FreeBSD-geom package isn't updated correctly.

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

19 months agopkgbase: Put resolvconf in its own package
Emmanuel Vadot [Fri, 22 Jul 2022 08:01:59 +0000 (10:01 +0200)]
pkgbase: Put resolvconf in its own package

It doesn't really make sense to have it in runtime and let's not
bloat utilities more.

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

19 months agopkgbase: Put dhclient in its own package
Emmanuel Vadot [Fri, 22 Jul 2022 08:00:03 +0000 (10:00 +0200)]
pkgbase: Put dhclient in its own package

It doesn't really make sense to have it in runtime and let's not
bloat utilities more.

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

19 months agopkgbase: Put nvmecontrol in its own package
Emmanuel Vadot [Fri, 22 Jul 2022 07:58:11 +0000 (09:58 +0200)]
pkgbase: Put nvmecontrol in its own package

It doesn't really make sense to have it in runtime and let's not
bloat utilities more.

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

19 months agosendmail: fix auth with cyrus-sasl-2.1.28
Ed Maste [Tue, 25 Oct 2022 15:53:07 +0000 (11:53 -0400)]
sendmail: fix auth with cyrus-sasl-2.1.28

Apply patch extracted from sendmail-8-17.1.9 snapshot by dinoex@.

PR: 262935
Reviewed by: gshapiro
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37119

19 months agow: Fix premature rounding.
Dag-Erling Smørgrav [Mon, 24 Oct 2022 14:02:11 +0000 (14:02 +0000)]
w: Fix premature rounding.

If the system has been up more longer than a minute, we add 30 seconds to
the uptime so that subsequent calculations will round to the nearest minute
rather than truncate.  However, since the introduction of libxo, we output
the raw value after performing the adjustment.  Rewrite so that we output
the raw value first, then perform the adjustment and recalculate before
outputting the humanized value.

While there, reduce stack usage and avoid needless allocations.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37128

19 months agovfs: use cache_assert_no_entries instead of open-coding it
Mateusz Guzik [Wed, 26 Oct 2022 15:33:47 +0000 (15:33 +0000)]
vfs: use cache_assert_no_entries instead of open-coding it

19 months agoqlnxe(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 26 Oct 2022 15:27:07 +0000 (17:27 +0200)]
qlnxe(4): Fix a typo in a source code comment

- s/defult/default/

MFC after: 3 days

19 months agonetinet*: add back necessary headers
Gleb Smirnoff [Tue, 25 Oct 2022 21:19:34 +0000 (14:19 -0700)]
netinet*: add back necessary headers

The LINT successful build was provided by the includes that SCTP
pulled in.

Fixes: 92e190f11fe872f7b1f1a1a22c1f10edeb3b7f8d

19 months agoHyper-V: Code refactor to avoid redundancy of MSR values on x86 and arm64
Souradeep Chakrabarti [Wed, 26 Oct 2022 03:29:01 +0000 (03:29 +0000)]
Hyper-V: Code refactor to avoid redundancy of MSR values on x86 and arm64

Refactor the code to put split the MSR values for x86 and arm64
Hyper-V. Code not yet built. This is one of several patches for
the arm64 Hyper-V enablement.

Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D37103

19 months agosplit: add word order fix
Kyle Evans [Tue, 25 Oct 2022 21:51:21 +0000 (16:51 -0500)]
split: add word order fix

This was meant to note that both pattern and line matching were
previously restricted, but words are difficult.  +line and rearrange.

Sponsored by: Klara, Inc.

19 months agostrfmon(3): Fix # explanation
Jose Luis Duran [Thu, 13 Oct 2022 16:11:31 +0000 (13:11 -0300)]
strfmon(3): Fix # explanation

There's only one value that specifies the number of digits after the
decimal point (oh, sorry, the "radix character") the other specifies the
number before...

While here, add a little more info on the effects of using the #n value.

Obtained from: https://github.com/NetBSD/src/commit/d1dd1a086400ae719bde1f2c45938d9bc1d29e8b
Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon(3): Remove repeated words
Jose Luis Duran [Thu, 13 Oct 2022 16:22:54 +0000 (13:22 -0300)]
strfmon(3): Remove repeated words

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Fix formatting of a second fixed-width value
Jose Luis Duran [Fri, 21 Oct 2022 19:34:09 +0000 (16:34 -0300)]
strfmon: Fix formatting of a second fixed-width value

There is a bug when formatting two consecutive values using fixed-widths
and the values need padding.  This was because the value of pad_size
was zeroed only every other time.

Format           Before                         After
[%8n] [%8n]      [ $123.45] [       $123.45]    [ $123.45] [ $123.45]

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Fix an edge case when sep_by_space is 2
Jose Luis Duran [Tue, 18 Oct 2022 02:24:03 +0000 (23:24 -0300)]
strfmon: Fix an edge case when sep_by_space is 2

Fix an edge case by printing the required space when, the currency
symbol succeeds the value, a space separates the sign from the value and
the sign position precedes the quantity and the currency symbol.

In other words:

    n_cs_precedes = 0
    n_sep_by_space = 2
    n_sign_posn = 1

From The Open Group's localeconv[1]:

> When {p,n,int_p,int_n}_sep_by_space is 2:
> If the currency symbol and sign string are adjacent, a space separates
> them; otherwise, a space separates the sign string from the value.

    Format    Before        After
    [%n]      [-123.45¤]    [- 123.45¤]

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html

Obtained from: Darwin
Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Fix alignment when enclosed by parentheses
Jose Luis Duran [Fri, 14 Oct 2022 23:26:32 +0000 (20:26 -0300)]
strfmon: Fix alignment when enclosed by parentheses

Take into consideration the possibility of quantities enclosed by
parentheses when aligning.

Matches the examples from The Open Group's:

Format  Before          After
%(#5n   [$   123.45]    [ $   123.45 ]  Use an alternative pos/neg style
        [($   123.45)]  [($   123.45)]
        [$ 3,456.78]    [ $ 3,456.78 ]

%!(#5n  [   123.45]     [    123.45 ]   Disable the currency symbol
        [(   123.45)]   [(   123.45)]
        [ 3,456.78]     [  3,456.78 ]

https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

SD5-XSH-ERN-29 is applied, updating the examples for %(#5n and %!(#5n.

Obtained from: Darwin
Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Trim the SPACE from international currency symbol
Jose Luis Duran [Fri, 21 Oct 2022 16:13:27 +0000 (13:13 -0300)]
strfmon: Trim the SPACE from international currency symbol

The international currency symbol (int_curr_symbol) has a mandatory
SPACE character as the last character.

Trim this space after reading it, otherwise this extra space will always
be printed when displaying the int_curr_symbol.

Fixes the output when the international currency format is selected
(%i).

    Locale         Format    Before           After
    en_US.UTF-8    [%i]      [USD 123.45]     [USD123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR ]    [123,45 EUR]

Note that the en_US.UTF-8 locale states that no space should be printed
between the currency symbol and the value (sep_by_space = 0).

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Avoid an out-of-bounds access
Jose Luis Duran [Thu, 13 Oct 2022 15:51:27 +0000 (12:51 -0300)]
strfmon: Avoid an out-of-bounds access

Avoid an out-of-bounds access when trying to set the space_char using an
international currency format (%i) and the C/POSIX locale.

The current code tries to read the SPACE from int_curr_symbol[3]:

    currency_symbol = strdup(lc->int_curr_symbol);
    space_char = *(currency_symbol+3);

But on C/POSIX locales, int_curr_symbol is empty.

Three implementations have been examined: NetBSD[1], Darwin[2], and
Illumos[3].  Only NetBSD has fixed it[4].

Darwin and NetBSD also trim the mandatory final SPACE character after
reading it.

    Locale         Format    Darwin/NetBSD    FreeBSD/Illumos
    en_US.UTF-8    [%i]      [USD123.45]      [USD 123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR]     [123,45 EUR ]

This commit only fixes the out-of-bounds access.

[1]: https://github.com/NetBSD/src/blob/trunk/lib/libc/stdlib/strfmon.c
[2]: https://opensource.apple.com/source/Libc/Libc-1439.141.1/stdlib/NetBSD/strfmon.c.auto.html
[3]: https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/locale/strfmon.c
[4]: https://github.com/NetBSD/src/commit/3d7b5d498aa9609f2bc9ece9c734c5f493a8e239

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Fix typos in source code comments
Jose Luis Duran [Thu, 13 Oct 2022 14:49:21 +0000 (11:49 -0300)]
strfmon: Fix typos in source code comments

s/defult/default
s/internaltion/international

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Fix typo in constant
Jose Luis Duran [Thu, 13 Oct 2022 14:36:46 +0000 (11:36 -0300)]
strfmon: Fix typo in constant

s/SUPRESS_CURR_SYMBOL/SUPPRESS_CURR_SYMBOL

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon: Code cleanup
Jose Luis Duran [Fri, 14 Oct 2022 17:05:22 +0000 (14:05 -0300)]
strfmon: Code cleanup

No functional change intended.
Not claiming full style(9) compliance.

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon_test: Add some tests
Jose Luis Duran [Sun, 16 Oct 2022 04:01:17 +0000 (01:01 -0300)]
strfmon_test: Add some tests

Attempt to test the correctness of strfmon(3).

Some of them were inspired from the examples section at:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

Items marked with XXX represent an invalid output.

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agostrfmon_test: Fix typo and remove extra space
Jose Luis Duran [Sun, 16 Oct 2022 03:04:44 +0000 (00:04 -0300)]
strfmon_test: Fix typo and remove extra space

Reviewed by: kib
PR: 267282
Github PR: #619
MFC after: 1 week

19 months agonetinet*: remove unneeded headers from files that just declare domains
Gleb Smirnoff [Tue, 25 Oct 2022 18:09:23 +0000 (11:09 -0700)]
netinet*: remove unneeded headers from files that just declare domains

19 months agotcp: remove useless today lock assertion in a middle of function
Gleb Smirnoff [Tue, 25 Oct 2022 18:09:22 +0000 (11:09 -0700)]
tcp: remove useless today lock assertion in a middle of function

It was added back in 7cfc6904408b, when there was a jump label
above and tcp_input() hadn't been locked all through.

19 months agotimes: Use modern function definitions
Warner Losh [Tue, 25 Oct 2022 05:03:11 +0000 (23:03 -0600)]
times: Use modern function definitions

Use the modern ANSI function defition syntax rather than the old K&R
syntax for times.

Sponsored by: Netflix

19 months agochio: Mark some arguments as unused.
Warner Losh [Tue, 25 Oct 2022 05:02:44 +0000 (23:02 -0600)]
chio: Mark some arguments as unused.

Sponsored by: Netflix

19 months agointrng: Remove from NOTES file
Warner Losh [Tue, 25 Oct 2022 16:52:44 +0000 (10:52 -0600)]
intrng: Remove from NOTES file

INTRNG is required on these platforms. Remove it from the NOTES file
since it is now in the DEFAULTS file.

Suggested by: mhorne
Sponsored by: Netflix

19 months agosubr_physmem: Fix userspace build
Warner Losh [Tue, 25 Oct 2022 05:05:07 +0000 (23:05 -0600)]
subr_physmem: Fix userspace build

Include stdbool.h in userspace configurations. For the kernel builds we
get it from sys/types.h, but bool isn't defined there for non-kernel
builds and this otherwise kernel-only file is used for the physmem test
suite.

Fixes: deb1e3b71998
Sponsored by: Netflix

19 months agovnic: work_done here only used for debug
Warner Losh [Tue, 25 Oct 2022 14:52:27 +0000 (08:52 -0600)]
vnic: work_done here only used for debug

Sponsored by: Netflix

19 months agogenet: cnt here is write only and can be removed
Warner Losh [Tue, 25 Oct 2022 14:52:53 +0000 (08:52 -0600)]
genet: cnt here is write only and can be removed

Sponsored by: Netflix

19 months agohccontrol.8: missed underscore fixed.
Maxim Konovalov [Tue, 25 Oct 2022 16:29:44 +0000 (16:29 +0000)]
hccontrol.8: missed underscore fixed.

PR: 267343

19 months agox86/include/elf.h: make inclusion blocks for elf32.h and elf64.h similar
Konstantin Belousov [Sat, 22 Oct 2022 20:05:59 +0000 (23:05 +0300)]
x86/include/elf.h: make inclusion blocks for elf32.h and elf64.h similar

They were copy-pasted when x86/include/elf.h file was merged from its
i386 and amd64 counterparts.  Having the text around inclusions
significantly different is somewhat confusing.

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

19 months agoi386: move hard-coded load address for PIE below default linker base
Konstantin Belousov [Sat, 22 Oct 2022 20:03:17 +0000 (23:03 +0300)]
i386: move hard-coded load address for PIE below default linker base

both for i386 native and compat32 amd64.  We know the ld-elf.so.1 size
in advance, it fits there.  Trying to push it up after the end of a
binary cannot work reliably and eventually fail for large binaries.

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

19 months agoarm, arm64: tweak hard-coded load addresses for PIE binaries
Konstantin Belousov [Sat, 22 Oct 2022 10:58:43 +0000 (13:58 +0300)]
arm, arm64: tweak hard-coded load addresses for PIE binaries

They are used when ASLR is not applied.
The need for adjusting is due to rtld direct exec mode puts ld-elf.so.1
at the PIE load address, and this address must not conflict with the
default linker' load address for non-PIE binaries.  Otherwise rtld in
direct mode cannot activate image.  Example of implicit failure is ldd(1)
refusing to run.

Reported by: kp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37085

19 months agophysmem: Add physmem_excluded to query if a region is excluded
Warner Losh [Thu, 6 Oct 2022 03:55:26 +0000 (21:55 -0600)]
physmem: Add physmem_excluded to query if a region is excluded

In order to safely reuse excluded memory when it's reserved for special
purpose, we need to test whether or not the memory has been reserved
early in boot. physmem_excluded will return true when the entire range
is excluded, false otherwise.

Sponsored by: Netflix

19 months agoefi: Add linux memory reserve table defniitions
Warner Losh [Thu, 6 Oct 2022 02:56:43 +0000 (20:56 -0600)]
efi: Add linux memory reserve table defniitions

There is some hardware which can't be completely reset to release the
memory it is using(so far only the GICv3 on arm has fit this
bill). Since that meory needs to be reserved by the OS for that
hardware's later use of it, create defines for code that will parse that
memory table. Otherise the system may allocate the memory for block I/O,
network packets, etc which will lead to memory corruption.

When booting via Linux's kexec protocol, it will add this table to the
EFI systbl's cfgtbl array. While the mechanism to pass 'configuration'
is standardized, these specific tables are not documented except in the
Linux source. Include comments gleened from its study.

Sponsored by: Netflix

19 months agobuild: Use `rm -fv` for BATCH_DELETE_OLD_FILES
Ed Maste [Mon, 24 Oct 2022 18:06:41 +0000 (14:06 -0400)]
build: Use `rm -fv` for BATCH_DELETE_OLD_FILES

It's possible to have files with odd permissions in the tmproot (or
sysroot), causing rm to prompt for each one during e.g. buildworld.
Add -f to forcibly delete these.

Reviewed by: brooks
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37111

19 months agobhyve: Address some signed/unsigned comparison warnings
Mark Johnston [Sun, 23 Oct 2022 14:32:45 +0000 (10:32 -0400)]
bhyve: Address some signed/unsigned comparison warnings

MFC after: 1 week

19 months agobhyve: Address signed/unsigned comparison warnings in the e1000 model
Mark Johnston [Tue, 25 Oct 2022 13:54:50 +0000 (09:54 -0400)]
bhyve: Address signed/unsigned comparison warnings in the e1000 model

No functional change intended.

MFC after: 1 week

19 months agobhyve: Address signed/unsigned comparison warnings in the AHCI model
Mark Johnston [Tue, 25 Oct 2022 13:39:07 +0000 (09:39 -0400)]
bhyve: Address signed/unsigned comparison warnings in the AHCI model

No functional change intended.

MFC after: 1 week

19 months agobhyve: Address warnings in blockif_proc()
Mark Johnston [Tue, 25 Oct 2022 13:16:23 +0000 (09:16 -0400)]
bhyve: Address warnings in blockif_proc()

- Use unsigned types for all arithmetic.  Use a new signed variable for
  holding the return value of pread() and pwrite().
- Handle short I/O from pwrite().

MFC after: 1 week

19 months agobhyve: Fix a typo in a function name
Mark Johnston [Tue, 25 Oct 2022 13:22:12 +0000 (09:22 -0400)]
bhyve: Fix a typo in a function name

MFC after: 1 week

19 months agobhyve: Avoid arithmetic on void pointers
Mark Johnston [Tue, 25 Oct 2022 13:07:14 +0000 (09:07 -0400)]
bhyve: Avoid arithmetic on void pointers

No functional change intended.

MFC after: 1 week

19 months agobhyve: Avoid shadowing global variables in bhyverun.c
Mark Johnston [Fri, 9 Sep 2022 00:40:02 +0000 (20:40 -0400)]
bhyve: Avoid shadowing global variables in bhyverun.c

- Rename the global cores/sockets/threads to cpu_cores/sockets/threads.
  This way, num_vcpus_allowed() doesn't shadow them.
- The global maxcpus is unused, remove it for the same reason.

MFC after: 1 week

19 months agosplit: add some tests
Kyle Evans [Tue, 23 Aug 2022 02:08:03 +0000 (21:08 -0500)]
split: add some tests

This should cover all of the basic functionality, as well as the recent
enhancement to use a dynamic buffer size rather than limiting patterns
and lines to MAXBSIZE.

Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36324

19 months agosplit: switch to getline() for line/pattern matching
Kyle Evans [Tue, 23 Aug 2022 02:05:58 +0000 (21:05 -0500)]
split: switch to getline() for line/pattern matching

Get rid of split's home-grown logic for growing the buffer; arbitrarily
breaking at LONG_MAX bytes instead of 65536 bytes gives us much more
wiggle room.  Additionally, we'll actually fail out entirely if we can't
fit a line, which makes noticing this class of problem much easier.

Reviewed by: bapt, emaste, pauamma
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36323

19 months agonetmap(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 25 Oct 2022 12:56:25 +0000 (14:56 +0200)]
netmap(4): Fix a typo in a source code comment

- s/microsconds/microseconds/

MFC after: 3 days

19 months agosmartpqi(4): Fix two typos in kernel error messages
Gordon Bergling [Tue, 25 Oct 2022 11:17:20 +0000 (13:17 +0200)]
smartpqi(4): Fix two typos in kernel error messages

- s/runnning/running/

MFC after: 2 weeks

19 months agodconschat(8): Fix a typo in an error message
Gordon Bergling [Tue, 25 Oct 2022 10:58:55 +0000 (12:58 +0200)]
dconschat(8): Fix a typo in an error message

- s/faild/failed/

MFC after: 1 week

19 months agoarcmsr(4): Fix a typo in a source code comment
Gordon Bergling [Tue, 25 Oct 2022 10:57:37 +0000 (12:57 +0200)]
arcmsr(4): Fix a typo in a source code comment

- s/faild/failed/

MFC after: 3 days

19 months agozfsd(8): Fix a typo in an error message
Gordon Bergling [Tue, 25 Oct 2022 10:55:42 +0000 (12:55 +0200)]
zfsd(8): Fix a typo in an error message

- s/faild/failed/

MFC after: 1 week

19 months agofirewire(4): Fix a typo in an error message
Gordon Bergling [Tue, 25 Oct 2022 10:54:15 +0000 (12:54 +0200)]
firewire(4): Fix a typo in an error message

- s/faild/failed/

MFC after: 5 days

19 months agoocs_fc(4): Fix a typo in an error message
Gordon Bergling [Tue, 25 Oct 2022 10:52:24 +0000 (12:52 +0200)]
ocs_fc(4): Fix a typo in an error message

- s/faild/failed/

MFC after: 5 days

19 months agoCMSG_DATA.3: Fix a typo in the EXAMPLES section
Gordon Bergling [Tue, 25 Oct 2022 10:49:21 +0000 (12:49 +0200)]
CMSG_DATA.3: Fix a typo in the EXAMPLES section

- s/faild/failed/

MFC after: 3 days

19 months agorun.4: Fix a typo in the DIAGNOSTICS section
Gordon Bergling [Tue, 25 Oct 2022 10:47:29 +0000 (12:47 +0200)]
run.4: Fix a typo in the DIAGNOSTICS section

- s/faild/failed/

MFC after: 3 days

19 months agoman: hook acpi_ged.4 to build.
Takanori Watanabe [Mon, 24 Oct 2022 23:11:49 +0000 (08:11 +0900)]
man: hook acpi_ged.4 to build.

Submittet by: yuri@astern.org

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

19 months agonetpfil: Fix two typos in source code comments
Gordon Bergling [Tue, 25 Oct 2022 02:32:59 +0000 (04:32 +0200)]
netpfil: Fix two typos in source code comments

- s/missmatch/mismatch/

MFC after: 3 days

19 months agonet8021: Fix a typo in a kernel error message
Gordon Bergling [Tue, 25 Oct 2022 02:31:51 +0000 (04:31 +0200)]
net8021: Fix a typo in a kernel error message

- s/missmatch/mismatch/

MFC after: 1 week

19 months agoopencrypto: fix null esp crypt
Konstantin Belousov [Mon, 24 Oct 2022 23:02:58 +0000 (02:02 +0300)]
opencrypto: fix null esp crypt

Fixes: 3e9470482a1357eef90d007b27ec5d9725ae1111
Reviewed by: jhb
Sponsored by: Nvidia networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37113

19 months agoLinuxKPI: seq_file add "private" versions.
Bjoern A. Zeeb [Sat, 22 Oct 2022 18:07:37 +0000 (18:07 +0000)]
LinuxKPI: seq_file add "private" versions.

Add __seq_open_private() and seq_release_private() needed by iwlwifi
debugfs support.

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

19 months agobhyve: Drop a bogus const qualifier
Mark Johnston [Mon, 24 Oct 2022 21:35:16 +0000 (17:35 -0400)]
bhyve: Drop a bogus const qualifier

No functional change intended.

MFC after: 1 week

19 months agobhyve: Use the new vm_limit_rights() interface
Mark Johnston [Mon, 24 Oct 2022 21:32:04 +0000 (17:32 -0400)]
bhyve: Use the new vm_limit_rights() interface

This addresses a compiler warning arising from the fact that bhyve
needs to cast away a const qualifier in order to call free().

No functional change intended.

Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37099

19 months agolibvmmapi: Provide an interface for limiting rights on the device fd
Mark Johnston [Mon, 24 Oct 2022 21:31:11 +0000 (17:31 -0400)]
libvmmapi: Provide an interface for limiting rights on the device fd

Currently libvmmapi provides a way to get a list of the allowed ioctls
on the vmm device file, so that bhyve can limit rights on the device
file fd.  The interface is rather strange: it allocates a copy of the
list but returns a const pointer, so the caller has to cast away the
const in order to free it without aggravating the compiler.

As far as I can see, there's no reason to make a copy of the array, but
changing vm_get_ioctls() to not do that would break compatibility.  So
this change just introduces a better interface: move all rights-limiting
logic into libvmmapi.

Any new operations on the fd should be wrapped by libvmmapi, so also
discourage use of vm_get_device_fd().  Currently bhyve uses it only when
limiting rights on the device fd.

No functional change intended.

Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37098

19 months agodpaa2: cleanup some include files
Bjoern A. Zeeb [Mon, 24 Oct 2022 20:54:20 +0000 (20:54 +0000)]
dpaa2: cleanup some include files

2782ed8f6cd3d7f59219a783bc7fa7bbfb1fe26f fixed the standalone module
build.  REmove the now duplicate includes for opt_acpi.h and
opt_platform.h.  Als remove the if_mdio.h again in both the Makefile
and the implementation file as it is not (currently) used.

X-MFC with: ba7319e9091b4f6ef15a9c4be3d3d076f3047f72
MFC after: 70 days

19 months agoRack and BBR broken with the new timewait state purge.
Randall Stewart [Mon, 24 Oct 2022 19:47:29 +0000 (15:47 -0400)]
Rack and BBR broken with the new timewait state purge.

We recently got rid of the explicit INP_TIMEWAIT state, this has caused some
minor breakage to both rack and bbr. Basically the timewait check that was
in tcp_lro.c is now gone. This means that compressed_ack and mbuf_queued
packets will arrive at TCP without going through tcp_input_with_port(). We need
to expand the check that was stripped to look at the tcp_state (t_state) and
not "LRO" packets that are in the TCPS_TIMEWAIT state.

Reviewed by: tuexen, gliebus
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D37080

19 months agoif_ovpn: avoid netisr_queue name conflicts
Kristof Provost [Mon, 24 Oct 2022 18:45:39 +0000 (20:45 +0200)]
if_ovpn: avoid netisr_queue name conflicts

Rename the netisr_queue variable in if_ovpn.c to avoid naming conflicts.

Sponsored by: Rubicon Communications, LLC ("Netgate")

19 months agoacpi_ged: Module build no longer needs to define INTRNG
Warner Losh [Mon, 24 Oct 2022 18:12:29 +0000 (12:12 -0600)]
acpi_ged: Module build no longer needs to define INTRNG

Now that we properly define INTRNG generically on all the platforms that
need it in opt_global.h, we don't need to define it here.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D37110

19 months agoconfig.mk: All options in DEFAULTS are now defined in opt_global.h
Warner Losh [Mon, 24 Oct 2022 18:12:17 +0000 (12:12 -0600)]
config.mk: All options in DEFAULTS are now defined in opt_global.h

To simplify management of all the options that should be enabled for the
different architectures, adopt the convention that all options listed in
DEFAULTS will be #defined to 1 in opt_global.h for untied builds. Except
for GEOM_* and ISAPNP, they are all in opt_global.h. ISAPNP is a
opt_dontuse.h, so only filter GEOM_*.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D37108

19 months agoconfig: Make ISAPNP be in opt_dontuse.h
Warner Losh [Mon, 24 Oct 2022 18:12:09 +0000 (12:12 -0600)]
config: Make ISAPNP be in opt_dontuse.h

Nothing uses ISAPNP today, apart from bringing in files or not. There's
really no need to ever do #ifdef ISAPNP in drivers and such. It means
use the ISA bus plug and play isolation protocol to enumerate the bus,
not the more useful 'you might have devices with isa pnp ids' which all
drivers hide behind DEV_ISA and/or an isa clause in the files files.

Sponsored by: Netflix
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D37109

19 months agoDEFAULTS: move intrng to DEFAULTS for its platforms.
Warner Losh [Mon, 24 Oct 2022 18:11:58 +0000 (12:11 -0600)]
DEFAULTS: move intrng to DEFAULTS for its platforms.

Sponsored by: Netflix
Reviewed by: manu, kevans
Differential Revision: https://reviews.freebsd.org/D37107

19 months agostand/efi: Simpler construct
Warner Losh [Mon, 24 Oct 2022 18:11:50 +0000 (12:11 -0600)]
stand/efi: Simpler construct

Use 'sizeof(long) == 8' for a compile time constant that can be used as
an initializer rather than #ifdefs.

Sponsored by: Netflix

19 months agoman4: Hook mac_ddb.4 up to the build
Mark Johnston [Tue, 18 Oct 2022 16:49:25 +0000 (12:49 -0400)]
man4: Hook mac_ddb.4 up to the build

Fixes: 287d467c5db5 ("mac: add new mac_ddb(4) policy")
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.

19 months agozfs: Fix a pair of bugs in zfs_fhtovp()
Mark Johnston [Mon, 24 Oct 2022 15:55:48 +0000 (11:55 -0400)]
zfs: Fix a pair of bugs in zfs_fhtovp()

This cherry-picks upstream ed566bf1cd0bdbf85e8c63c1c119e3d2ef5db1f6

    - Add a zfs_exit() call in an error path, otherwise a lock is
      leaked.
    - Remove the fid_gen > 1 check.  That appears to be Linux-specific:
      zfsctl_snapdir_fid() sets fid_gen to 0 or 1 depending on whether
      the snapshot directory is mounted.  On FreeBSD it fails, making
      snapshot dirs inaccessible via NFS.

PR: 266236
MFC after: 3 days

19 months agoacpi_ged: fix build with ACPI_DEBUG
Gleb Smirnoff [Mon, 24 Oct 2022 16:00:04 +0000 (09:00 -0700)]
acpi_ged: fix build with ACPI_DEBUG

19 months agoRELNOTES: Add an entry for if_bridge l3 filtering default change
Kristof Provost [Mon, 24 Oct 2022 15:58:00 +0000 (17:58 +0200)]
RELNOTES: Add an entry for if_bridge l3 filtering default change

19 months agocache: add cache_assert_no_entries
Mateusz Guzik [Mon, 24 Oct 2022 15:34:57 +0000 (15:34 +0000)]
cache: add cache_assert_no_entries

19 months agoacpi_ged: fix build, as module and non INTRNG case.
Takanori Watanabe [Mon, 24 Oct 2022 14:19:12 +0000 (23:19 +0900)]
acpi_ged: fix build, as module and non INTRNG case.

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

19 months agobsd-family-tree: OpenBSD 7.2 and DragonFly BSD 6.0.1
Sergey A. Osokin [Mon, 24 Oct 2022 14:12:31 +0000 (10:12 -0400)]
bsd-family-tree: OpenBSD 7.2 and DragonFly BSD 6.0.1

Add two releases to the tree.

While I'm here correct DragonFly BSD 6.2.1 position, it's
been released after FreeBSD 12.3.

MFC after: 3 days