]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agoRevert "tools/build: Unbreak bmake bootstrap on Linux"
Jessica Clarke [Sun, 29 Jan 2023 23:17:39 +0000 (23:17 +0000)]
Revert "tools/build: Unbreak bmake bootstrap on Linux"

Now that make.py no longer has the described hack on Linux we can drop
this ugly workaround.

This reverts commit fba998a3d897e6297baca74068e4ec1db7adaeec.

17 months agotools/build/make.py: Drop problematic Linux hack for bmake bootstrap
Jessica Clarke [Sun, 29 Jan 2023 23:07:25 +0000 (23:07 +0000)]
tools/build/make.py: Drop problematic Linux hack for bmake bootstrap

Since e2eeea75eb8b ("Merge bmake-20201117") missing/sys/cdefs.h has
been present in bmake, and _GNU_SOURCE seems to have been defined by
config.h for much longer than that, possibly for the entire time OS
cross-build support has been in-tree, so these are obsolete. Moreover,
since 79e02149fcb4 ("Fix dtrace tools bootstrap on non-FreeBSD after
OpenZFS import"), HAVE_STRLCAT and HAVE_STRLCPY have been defined by our
cross-build headers in order to placate DTrace tools (which is not the
right way to solve that problem, but motivates fixing this one). Commit
4fde40d9b540 ("Merge/update to bmake-20230126") changed the strlcpy.c in
bmake from including config.h directly to including make.h, which means
it includes string.h and thus sees these bogus definitions, causing it
to not define the strlcpy compat function on Linux even though it needs
to and thus failing to link. Thus, fix this whole mess by removing the
hack we no longer need.

17 months agosbin/ping6: Remove remains of ping6.
Xin LI [Sun, 29 Jan 2023 23:21:25 +0000 (15:21 -0800)]
sbin/ping6: Remove remains of ping6.

MFC after: 2 weeks

17 months agoFix for getmntpoint(3) when checking for NFS mount points.
Kirk McKusick [Sun, 29 Jan 2023 23:12:48 +0000 (15:12 -0800)]
Fix for getmntpoint(3) when checking for NFS mount points.

Only attempt to add /dev/ to f_mntfromname names that result in a
valid character device.

MFC after:    1 week
Reported by:  Bjoern A. Zeeb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907

17 months agorescue: Add fetch(1) to the rescue tool.
John Grafton [Sun, 29 Jan 2023 23:05:15 +0000 (15:05 -0800)]
rescue: Add fetch(1) to the rescue tool.

After a failed upgrade, having fetch(1) on a system that is
physically unnreachable would be very useful to download files
required to get the OS back up and functional.

On my system this adds 589,824 bytes (3.8%) to the binary size.

PR: 266224
Reported by: Dan Mahoney
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38193

17 months agousr.bin/stat: Fix error message formatting.
Jamie Landeg-Jones [Sun, 29 Jan 2023 22:37:25 +0000 (14:37 -0800)]
usr.bin/stat: Fix error message formatting.

PR: bin/261657
MFC after: 3 days

17 months agoOnly call SMCCC init on arm64
Andrew Turner [Sun, 29 Jan 2023 19:32:11 +0000 (19:32 +0000)]
Only call SMCCC init on arm64

We don't build the smccc code on arm so don't call into it there.

17 months agonetstat: export weight for single-path routes.
Alexander V. Chernikov [Sun, 29 Jan 2023 16:27:31 +0000 (16:27 +0000)]
netstat: export weight for single-path routes.

* Parse and export newly-added NL_RTA_WEIGHT attribute, providing path
 weight for a non-multipath route. This fixes a number of tests in
 sys/net/routing which rely on this data.
* Remove handling of NL_RTA_KNH_ID in multipath routes, as it is
 not provided.
* Improve kernel/user nexthop index export. As a result,
 for multipath routes:
  * nhg-kidx attribute represents kernel nhg index (always provided)
  * nhg-uidx attribute represents user-provided nhg index (if set)
 for non-multipath routes:
  * nhop-kidx attribute represents kernel nhop index (always provided)
  * nhop-udx attribute represents user-provided nexthop index (if set)

17 months agonetlink: allow path weight manipulations for single-path routes.
Alexander V. Chernikov [Sun, 29 Jan 2023 15:53:34 +0000 (15:53 +0000)]
netlink: allow path weight manipulations for single-path routes.

Add support for the scenario when user adds/deletes paths for a single
 prefix one-by-one, all with different weights.
This change adds a new FreeBSD-specific RTA attribute, NL_RTA_WEIGHT.
When dumping non-multipath routes, this attribute is added if the
 route weight is not RT_DEFAULT_WEIGHT.
When adding a new route, this attribute is parsed as a relative path
 weight.

MFC after: 2 weeks

17 months agoMake SMCCC usable by device drivers
Andrew Turner [Sat, 4 Jun 2022 11:13:51 +0000 (12:13 +0100)]
Make SMCCC usable by device drivers

To allow device drivers to call into SMCCC we need to initialise it
earlier. As it depends on PSCI, and that is detected via ACPI or FDT
move the call to smccc_init to the PSCI driver.

Add a function for drivers to read the smccc version, or 0 if smccc
is not present.

17 months agoDisable the arm physical timer when an irq exists
Andrew Turner [Sat, 28 Jan 2023 17:36:24 +0000 (17:36 +0000)]
Disable the arm physical timer when an irq exists

Some firmware leaves the timers enabled. Ensure they are disabled if
there are any physical timer interrupt resources to ensure we don't
receive any unexpected interrupts from them.

17 months agomp_x86: Trim trailing whitespaces.
Dmitry Chagin [Sun, 29 Jan 2023 13:18:39 +0000 (16:18 +0300)]
mp_x86: Trim trailing whitespaces.

MFC after: 1 week

17 months agosubr_smp: Trim trailing whitespaces.
Dmitry Chagin [Sun, 29 Jan 2023 13:18:17 +0000 (16:18 +0300)]
subr_smp: Trim trailing whitespaces.

MFC after: 1 week

17 months agocpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.
Dmitry Chagin [Sun, 29 Jan 2023 13:17:33 +0000 (16:17 +0300)]
cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.

Under Linux to sched_[g|s]etaffinity() functions the value returned from a call
to gettid(2) (thread id) can be passed in the argument pid. Specifying pid as 0
will set the attribute for the calling thread, and passing the value returned
from a call to getpid(2) (process id) will set the attribute for the main thread
of the thread group.

Native cpuset(2) family of system calls has "which" argument to determine how
the value of id argument is interpreted, i.e., CPU_WHICH_TID is used to pass
a thread id and CPU_WHICH_PID - to pass a process id.

For now native sched_[g|s]etaffinity() implementation is wrong as uses "which"
CPU_WHICH_PID to pass both (process and thread id) to the kernel. To fix this
adding a new "which" CPU_WHICH_TIDPID intended to handle both id's.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38209
MFC after: 1 week

17 months agolibthr: Trim trailing whitespaces in pthread_attr_affinity.
Dmitry Chagin [Sun, 29 Jan 2023 12:38:04 +0000 (15:38 +0300)]
libthr: Trim trailing whitespaces in pthread_attr_affinity.

MFC after: 1 week

17 months agolibthr: Fix pthread_attr_[g|s]etaffinity_np manual.
Dmitry Chagin [Sun, 29 Jan 2023 12:37:18 +0000 (15:37 +0300)]
libthr: Fix pthread_attr_[g|s]etaffinity_np manual.

Fix my fault in f35093f8.

MFC after: 1 week

17 months agolibthr: Fix pthread_[g|s]etaffinity_np manual.
Dmitry Chagin [Sun, 29 Jan 2023 12:36:25 +0000 (15:36 +0300)]
libthr: Fix pthread_[g|s]etaffinity_np manual.

Since f35093f8 semantics of a thread affinity functions is changed to be a
compatible with Linux:
In case of getaffinity(), the minimum cpuset_t size that the kernel permits is
the maximum CPU id, present in the system, / NBBY bytes, the maximum size is not
limited.
In case of setaffinity(), the kernel does not limit the size of the user-provided
cpuset_t, internally using only the meaningful part of the set, where the upper
bound is the maximum CPU id, present in the system, no larger than the size of
the kernel cpuset_t.

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

17 months agolibthr: Fix pthread_attr_[g|s]etaffinity_np to match it's manual and the kernel.
Dmitry Chagin [Sun, 29 Jan 2023 12:35:18 +0000 (15:35 +0300)]
libthr: Fix pthread_attr_[g|s]etaffinity_np to match it's manual and the kernel.

Since f35093f8 semantics of a thread affinity functions is changed to be a
compatible with Linux:

In case of getaffinity(), the minimum cpuset_t size that the kernel permits is
the maximum CPU id, present in the system, / NBBY bytes, the maximum size is not
limited.
In case of setaffinity(), the kernel does not limit the size of the user-provided
cpuset_t, internally using only the meaningful part of the set, where the upper
bound is the maximum CPU id, present in the system, no larger than the size of
the kernel cpuset_t.

To match pthread_attr_[g|s]etaffinity_np checks of the user-provided cpusets to
the kernel behavior export the minimum cpuset_t size allowed by running kernel
via new sysctl kern.sched.cpusetsizemin and use it in checks.

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

17 months agosched.h: Fix _S macros for better compatibility with glibc.
Dmitry Chagin [Sun, 29 Jan 2023 12:34:10 +0000 (15:34 +0300)]
sched.h: Fix _S macros for better compatibility with glibc.

In e2650af157 was added "_S" macros for compatibility with glibc, but it's still
incompatible as under glibc the macros whose names end with "_S" operate on the
dynamically allocated CPU set(s) whose size is in bytes, not in bits.

While here remove limiting ifdef to non-kernel case.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38110
MFC after: 1 week

17 months agosmp: Drop confusing braces and return statement as panic() is never returns.
Dmitry Chagin [Sun, 29 Jan 2023 12:33:16 +0000 (15:33 +0300)]
smp: Drop confusing braces and return statement as panic() is never returns.

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

17 months agoAdd extended attributes
Fedor Uporov [Mon, 5 Dec 2022 17:04:42 +0000 (20:04 +0300)]
Add extended attributes

The extattrs follows semantic of ufs, mean it cannot
be set to char/block devices and fifos. The attributes
are allocated using regular malloc with M_WAITOK
allocation with the own malloc tag M_TMPFSEA. The memory
consumed by extended attributes is limited to avoid OOM
triggereing by tmpfs_mount variable tm_ea_memory_max,
which is set initialy to 16 MB. The extended attributes
entries are stored as linked list in the tmpfs node.
The mount point lock is required only under setextattr
and deleteextattr to update extended attributes
memory-inuse counter, all other operations are doing
under vnode lock.

Reviewed by:    kib
MFC after:      2 week
Differential revision:  https://reviews.freebsd.org/D38052

17 months agoFix pjfstest issue tests/rename/23.t
Fedor Uporov [Thu, 26 Jan 2023 10:23:22 +0000 (13:23 +0300)]
Fix pjfstest issue tests/rename/23.t

This test creates two files like file0 and file1,
then creates link to file1 and checks ctime on it.
Then renames file0 to file1. Then checks ctime on
link again. It is expected, that second ctime will
be higher then first ctime, because rename happen.
Add ctime updating for directory entry,
which will be deleted on rename.

Reviewed by:    kib
MFC after:      2 week
Differential revision:  https://reviews.freebsd.org/D38051

17 months agoFix pjfstest issue tests/rename/19.t
Fedor Uporov [Thu, 26 Jan 2023 10:17:48 +0000 (13:17 +0300)]
Fix pjfstest issue tests/rename/19.t

The rename call with args like:
"./dir0/dir1/.." "./dir2" will cause MPASS failure.
The tmpfs_dir_lookup() does not accept names like
'.' and '..' for lookup. Move the '.' and '..' entry
check before tmpfs_dir_lookup() call.

Reviewed by:    kib
MFC after:      2 week
Differential revision:  https://reviews.freebsd.org/D38051

17 months agoFix block bitmap end position computation
Fedor Uporov [Thu, 26 Jan 2023 10:06:25 +0000 (13:06 +0300)]
Fix block bitmap end position computation

PR:                     261850
Reported by:            chenguang.wang
MFC after:              2 weeks

17 months agoFix developer second name.
Fedor Uporov [Thu, 26 Jan 2023 09:57:00 +0000 (12:57 +0300)]
Fix developer second name.

17 months agousr.bin/gh-bc: update Makefiles for version 6.2.2
Stefan Eßer [Sat, 28 Jan 2023 22:48:34 +0000 (23:48 +0100)]
usr.bin/gh-bc: update Makefiles for version 6.2.2

The sources of this program are in contrib/bc, but built using the
Makefiles touched in this commit, which had to be adapted to comply
with changed made to the build system of this software, which is
not used when building in the base system.

17 months agocontrib/bc: merge from vendor release 6.2.2
Stefan Eßer [Sat, 28 Jan 2023 21:26:22 +0000 (22:26 +0100)]
contrib/bc: merge from vendor release 6.2.2

This update fixes a few issues in history editing and the processing
of the "quit" function. The "quit" function will no longer cause bc
to exit when encountered in a script file (before any command from
the script has been executed).

New functions is_number(), is_string return 1 if the passed argument
is a number resp. a string. The asciify() function has been extended
to support the conversion of an array of numbers into a string.

Merge commit '1a63323d17fedb05b6962853e821c9d7c6b9853e'

17 months agovendor/bc: import version 6.2.2
Stefan Eßer [Sat, 28 Jan 2023 20:08:43 +0000 (21:08 +0100)]
vendor/bc: import version 6.2.2

This is a production release that fixes a bug.

The bug was that if an array element was used as a parameter, and then
a later parameter had the same name as the array whose element was
used, bc would grab the element from the new array parameter, not the
actual element from before the function call.

17 months agovendor/bc: import version 6.2.1
Stefan Eßer [Sat, 28 Jan 2023 20:06:20 +0000 (21:06 +0100)]
vendor/bc: import version 6.2.1

This fixes one bug  in the history editing functions.

17 months agovendor/bc: import version 6.2.0
Stefan Eßer [Sat, 28 Jan 2023 20:02:27 +0000 (21:02 +0100)]
vendor/bc: import version 6.2.0

This is a production release with a new feature and a few bug fixes.

The bug fixes include:

 - A crash when bc and dc are built using editline, but history is not
   activated.
 - A missing local in the uint*() family of functions in the extended
   math library.
 - A failure to clear the tail call list in dc on error.
 - A crash when attempting to swap characters in command-line history
   when no characters exist.
 - SIGWINCH was activated even when history was not.

The new feature is that stack traces are now given for runtime errors.
In debug mode, the C source file and line of errors are given as well.

17 months agovendor/bc: import version 6.1.0
Stefan Eßer [Sat, 28 Jan 2023 19:59:18 +0000 (20:59 +0100)]
vendor/bc: import version 6.1.0

This is a production release that fixes a discrepancy from the bc
standard, a couple of memory bugs, and adds new features.

The discrepancy from the bc standard was with regards to the behavior
of the quit command. This bc used to quit whenever it encountered quit
during parsing, even if it was parsing a full file. Now, bc only quits
when encountering quit after it has executed all executable statements
up to that point.

This behavior is slightly different from GNU bc, but users will only
notice the difference if they put quit on the same line as other
statements.

The first memory bug could be reproduced by assigning a string to a
non-local variable in a function, then redefining the function with
use of the same non-local variable, which would still refer to a
string in the previous version of the function.

The second memory bug was caused by passing an array argument to the
asciify() built-in function. In certain cases, that was wrongly
allowed, and the interpreter just assumed everything was correct and
accessed memory. Now that arrays are allowed as arguments (see below),
this is not an issue.

The first feature was the addition of the is_number() built-in
function (u in dc) that returns 1 if the runtime argument is a number
and 0 otherwise.

The second feature was the addition of the is_string() built-in
function (t in dc) that returns 1 if the runtime argument is a string
and 0 otherwise.

These features were added because I realized that type-checking is
necessary now that strings can be assigned to variables in bc and
because they've always been assignable to variables in dc.

The last added feature is the ability of the asciify() built-in
function in bc to convert a full array of numbers into a string. This
means that character-by-character printing will not be necessary, and
more strings than just single-character ones will be able to be
created.

17 months agovendor/bc: import version 6.0.4
Stefan Eßer [Sat, 28 Jan 2023 19:54:39 +0000 (20:54 +0100)]
vendor/bc: import version 6.0.4

This version fixes a bug in the BC library that only affected
OpenBSD.

17 months agoDisable sandboxing when building with WITHOUT_CAPSICUM.
Xin LI [Sat, 28 Jan 2023 18:53:47 +0000 (10:53 -0800)]
Disable sandboxing when building with WITHOUT_CAPSICUM.

PR: bin/269185
MFC after: 3 days

17 months agostat(1): Do not pass S_IFBLK to devname unconditionally
Alexander Naumochkin [Sat, 28 Jan 2023 13:31:39 +0000 (15:31 +0200)]
stat(1): Do not pass S_IFBLK to devname unconditionally

PR: 269190
Reviewed by: kib
MFC after: 1 week

17 months agodevname(3): apply S_ISBLK() to type, not dev_t
Alexander Naumochkin [Sat, 28 Jan 2023 13:22:50 +0000 (15:22 +0200)]
devname(3): apply S_ISBLK() to type, not dev_t

PR: 269190
Reviewed by: kib
MFC after: 1 week

17 months agolinux_common: Fixup .PATH.
Dmitry Chagin [Sat, 28 Jan 2023 17:31:38 +0000 (20:31 +0300)]
linux_common: Fixup .PATH.

Since we have arm64, and awaiting ppc64 Linuxulator, do not include x86 specific
path to the module build for non x86 architectures.

MFC after: 1 week

17 months agonetlink: export nextop group kernel index when dumping multipath route.
Alexander V. Chernikov [Sat, 28 Jan 2023 15:37:58 +0000 (15:37 +0000)]
netlink: export nextop group kernel index when dumping multipath route.

MFC after: 2 weeks

17 months agoLinuxKPI: skbuff: implement skb_free_frag()
Bjoern A. Zeeb [Sat, 28 Jan 2023 15:33:12 +0000 (15:33 +0000)]
LinuxKPI: skbuff: implement skb_free_frag()

Using the work from 55038a6306a570c9f2df89f5ad076de0f7d98152 implement
skb_free_frag() calling page_frag_free().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

17 months agoumcs(4): Fix a typo in a kernel message
Gordon Bergling [Sat, 28 Jan 2023 14:45:52 +0000 (15:45 +0100)]
umcs(4): Fix a typo in a kernel message

- s/confguration/configuration/
- s/nornal/normal/

Obtained from: NetBSD
MFC after: 5 days

17 months agolinux(4): Convert mount exported flags for statfs system calls.
Dmitry Chagin [Sat, 28 Jan 2023 10:20:27 +0000 (13:20 +0300)]
linux(4): Convert mount exported flags for statfs system calls.

MFC after: 1 week

17 months agolinux(4): Rework statfs conversion routine.
Dmitry Chagin [Sat, 28 Jan 2023 10:19:41 +0000 (13:19 +0300)]
linux(4): Rework statfs conversion routine.

Rework the routines to convert a native statfs structure (with fixed-size 64-bit
counters) to a Linux statfs structure (with long-sized counters) for 32-bit apps.

Instead of following Linux and return an EOVERFLOW error from statfs() family of
syscalls when actual fs stat value(s) are large enough to not fit into 32 bits,
apply scale logics used by FreeBSD to convert a 5.x statfs structure to a 4.x
statfs structure.

For more details see cc479dda.

Tested by: glebius
MFC after: 1 week

17 months agolinuxkpi: Use a proper declaration for pm_suspend_via_firmware.
John Baldwin [Sat, 28 Jan 2023 03:29:39 +0000 (19:29 -0800)]
linuxkpi: Use a proper declaration for pm_suspend_via_firmware.

Reported by: GCC -Wstrict-prototypes

17 months agoMerge/update to bmake-20230126
Simon J. Gerraty [Sat, 28 Jan 2023 00:33:01 +0000 (16:33 -0800)]
Merge/update to bmake-20230126

17 months agoImport bmake-20230126
Simon J. Gerraty [Sat, 28 Jan 2023 00:23:54 +0000 (16:23 -0800)]
Import bmake-20230126

Relevant/interesting changes (see ChangeLog for more):

o variables like .newline and .MAKE.{GID,PID,PPID,UID}
should be read-only.
o .[NO]READONLY: for control of read-only variables
o .SYSPATH: for controlling the path searched for makefiles
o allow for white-space between command specifiers @+-
o add more details to warning 'Extra targets ignored'
o make.1: sync list of built-in variables with reality
sort list of built-in variables
o cond.c: add more details to error message for numeric comparison
o job.c: fix handling of null bytes in output
o Allow .break to terminate a .for loop early
o var.c: fix out-of-bounds errors when parsing
o fix exit status for '-q' (since 1994)

17 months agortalloc.9: remove obsolete man page
Mitchell Horne [Fri, 27 Jan 2023 22:00:07 +0000 (18:00 -0400)]
rtalloc.9: remove obsolete man page

This KPI was removed in d22337254564. Note that there are a handful of
references remaining in the src tree to these rtalloc functions that
could be cleaned up by someone with more domain knowledge.

Reviewed by: pauamma (manpages), glebius, melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38188

17 months agoPCBGROUP.9: remove obsolete man page
Mitchell Horne [Fri, 27 Jan 2023 21:59:07 +0000 (17:59 -0400)]
PCBGROUP.9: remove obsolete man page

The PCBGROUP option and KPI were removed entirely in 93c67567e015.

Reviewed by: pauamma (manpages), glebius, melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38187

17 months agouniverse: Switch GCC toolchains to GCC 12.
John Baldwin [Fri, 27 Jan 2023 21:35:13 +0000 (13:35 -0800)]
universe: Switch GCC toolchains to GCC 12.

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

17 months agolinuxkpi: Add `pin_user_pages*()` functions
Jean-Sébastien Pédron [Tue, 10 Jan 2023 10:09:56 +0000 (11:09 +0100)]
linuxkpi: Add `pin_user_pages*()` functions

They were defined in the i915 DRM driver. I move the code in linuxkpi so
it can benefit other drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38078

17 months agolinuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux
Jean-Sébastien Pédron [Tue, 10 Jan 2023 10:10:30 +0000 (11:10 +0100)]
linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux

It now returns a `struct scatterlist *` pointer instead of an error
code only.

The implementation is incomplete because it doesn't use the `prv`
argument.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38077

17 months agolinuxkpi: Include `linux/sched/mm.h` from `linux/sched.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:52:54 +0000 (10:52 +0100)]
linuxkpi: Include `linux/sched/mm.h` from `linux/sched.h`

At least one file in the DRM drivers benefits from some namespace
pollution to use `fs_reclaim_acquire()`/`fs_reclaim_release()`. They are
defined in `linux/sched/mm.h` and this header must be included
indirectly into the DRM drivers' source file.

I couldn't find how it was included. Therefore this commit includes
`linux/sched/mm.h` from `linux/sched.h`. This is not the case in Linux
but fixes the issue with the DRM drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37912

17 months agoCirrus-CI: switch GCC job to GCC 12
Ed Maste [Fri, 27 Jan 2023 17:15:01 +0000 (12:15 -0500)]
Cirrus-CI: switch GCC job to GCC 12

We need a C++20 or later compiler.

Sponsored by: The FreeBSD Foundation

17 months agorelease.7: Correct a variable name
Mark Johnston [Fri, 27 Jan 2023 19:00:23 +0000 (14:00 -0500)]
release.7: Correct a variable name

MFC after: 1 week

17 months agoloader: md: Use default func for fmtdev and parsedev
Emmanuel Vadot [Fri, 27 Jan 2023 06:34:02 +0000 (07:34 +0100)]
loader: md: Use default func for fmtdev and parsedev

The default function are enough for md so use them instead of the
disks ones that doesn't work for it anymore.

Reviewed by: imp
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: now
Differential Revision: https://reviews.freebsd.org/D38218

17 months agonetstat: fix format string on 32-bit archs
Alexander V. Chernikov [Fri, 27 Jan 2023 17:45:19 +0000 (17:45 +0000)]
netstat: fix format string on 32-bit archs

17 months agoamd64: do not enable PKRU if user disabled saving PKRU register in xsave mask
Konstantin Belousov [Fri, 27 Jan 2023 10:45:02 +0000 (12:45 +0200)]
amd64: do not enable PKRU if user disabled saving PKRU register in xsave mask

This is done by reverting CR4_PKE bit, because we perform %CR4
initialization in initializecpu(), and the function is called before
xsave_mask is read.  To not redo the whole early initialization
sequence for the corner case, this should be good enough.

Reported by: jhb
Reviewed by: jhb, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38219

17 months agox86: add more definitions for XCR0 bits
Konstantin Belousov [Fri, 27 Jan 2023 10:43:56 +0000 (12:43 +0200)]
x86: add more definitions for XCR0 bits

This covers all currently defined bits, adding PKRU and TILE.

Reviewed by: jhb, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38219

17 months agoRevert "Don't omit bsd.compiler.mk for the nested delete-old in buildworld."
John Baldwin [Fri, 27 Jan 2023 17:41:47 +0000 (09:41 -0800)]
Revert "Don't omit bsd.compiler.mk for the nested delete-old in buildworld."

The original motivation (src.opts.mk needing bsd.comppiler.mk to
determine if CXX is supported) is no longer relevant now that CXX is
non-optional.

This reverts commit b9cb80883bce6dc992cf05ae2e59089a60d311ec.

17 months agoMFV: zstd 1.5.2
Allan Jude [Fri, 27 Jan 2023 17:22:31 +0000 (17:22 +0000)]
MFV: zstd 1.5.2

Merge commit 'b3392d84da5bf2162baf937c77e0557f3fd8a52b' into zstd_1.5.2

full changelog: https://github.com/facebook/zstd/compare/v1.4.8...v1.5.2

Updated sys/kern/subr_compressor.c to new API

MFC after: 3 days
Relnotes: yes
Sponsored by: Klara, Inc.

17 months agonetstat: make netstat -rn use netlink instead of rtsock
Alexander V. Chernikov [Fri, 27 Jan 2023 15:14:39 +0000 (15:14 +0000)]
netstat: make netstat -rn use netlink instead of rtsock

This change switches route listing in netstat to netlink, with fallback to rtsock.
The outputs are mostly identical, with an exception of not showing kernel
 nexthop indexes for multipath routes.

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

17 months agoLinuxKPI: linux_pci.c: fix whitespace
Bjoern A. Zeeb [Fri, 27 Jan 2023 15:18:44 +0000 (15:18 +0000)]
LinuxKPI: linux_pci.c: fix whitespace

Properly indent a line.  No functional change.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

17 months agosysctl: use correct types and names in sysctl_*sec_to_sbintime
Gleb Smirnoff [Fri, 27 Jan 2023 15:09:22 +0000 (07:09 -0800)]
sysctl: use correct types and names in sysctl_*sec_to_sbintime

The functions are intended to report kernel variables that are
stored as sbintime_t (pointed to by arg1) as human readable
nanoseconds or milliseconds (reported via sysctl_handle_64).
The variable types and names were reversed.  I guess there is
no functional change here, as all types flipped around were
signed 64.  Note that these function aren't used yet anywhere
in the kernel.

Reviewed by: mav
Differential revision: https://reviews.freebsd.org/D38217

17 months agoRevert "rc.d: Put growfs script in FreeBSD-ufs"
Emmanuel Vadot [Fri, 27 Jan 2023 10:30:24 +0000 (11:30 +0100)]
Revert "rc.d: Put growfs script in FreeBSD-ufs"

The growfs script also support zfs.

This reverts commit 36a7fa1e16a0b4446f2cb618fc84a6bc1a2cbf86.

Reported by: emaste, Mina Galić

17 months agorc.d: Put resolv script in FreeBSD-resolvconf
Emmanuel Vadot [Fri, 28 Oct 2022 07:33:38 +0000 (09:33 +0200)]
rc.d: Put resolv script in FreeBSD-resolvconf

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

17 months agorc.d: Put growfs script in FreeBSD-ufs
Emmanuel Vadot [Fri, 28 Oct 2022 07:33:20 +0000 (09:33 +0200)]
rc.d: Put growfs script in FreeBSD-ufs

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

17 months agorc.d: Put ggated script in FreeBSD-ggate
Emmanuel Vadot [Fri, 28 Oct 2022 07:33:02 +0000 (09:33 +0200)]
rc.d: Put ggated script in FreeBSD-ggate

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

17 months agorc.d: Put dhclient script in FreeBSD-dhclient
Emmanuel Vadot [Fri, 28 Oct 2022 07:32:27 +0000 (09:32 +0200)]
rc.d: Put dhclient script in FreeBSD-dhclient

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

17 months agorc.d: Put devmatch script in FreeBSD-devmatch
Emmanuel Vadot [Fri, 28 Oct 2022 07:31:59 +0000 (09:31 +0200)]
rc.d: Put devmatch script in FreeBSD-devmatch

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

17 months agorc.d: Put devd script in FreeBSD-devd package
Emmanuel Vadot [Fri, 28 Oct 2022 07:31:17 +0000 (09:31 +0200)]
rc.d: Put devd script in FreeBSD-devd package

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

17 months agoRetire WITHOUT_CXX option
Ed Maste [Wed, 16 Nov 2022 14:20:39 +0000 (09:20 -0500)]
Retire WITHOUT_CXX option

Several important base system components are written in C++, and the
WITHOUT_CXX option produced a system that was not fully functional.
Just accept this, and remove the option to build without C++ support.

This reverts commit adc3c128c6603054586a993d117e5dd808deac17.

Reviewed by: brooks, kevans, jhb (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33108

17 months ago<sys/cdefs.h>: Decay expression passed to fallback version of __generic()
John Baldwin [Fri, 27 Jan 2023 00:28:22 +0000 (16:28 -0800)]
<sys/cdefs.h>: Decay expression passed to fallback version of __generic()

This ensures that __generic() more closely matches _Generic() when
using the fallback version when _Generic() is not available (such as
GCC).

Co-authored by: jrtc27
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D38215

17 months agoRevert "stdlib.h: Fix qsort_r compatibility with GCC 12."
John Baldwin [Fri, 27 Jan 2023 00:28:03 +0000 (16:28 -0800)]
Revert "stdlib.h: Fix qsort_r compatibility with GCC 12."

This reverts commit 43703bc489ec504b947b869045c492ed38c1a69c.

Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D38216

17 months agotcp: improve error handling of net.inet.tcp.udp_tunneling_port
Michael Tuexen [Thu, 26 Jan 2023 21:55:22 +0000 (22:55 +0100)]
tcp: improve error handling of net.inet.tcp.udp_tunneling_port

In case the new port can't be set, set the port to 0.

MFC after: 3 days
Sponsored by: Netflix, Inc.

17 months agotcp: protect TCP over UDP configuration with a lock
Gleb Smirnoff [Thu, 26 Jan 2023 18:16:32 +0000 (10:16 -0800)]
tcp: protect TCP over UDP configuration with a lock

The sysctl modifies global sockets without any locks.  The removed
comment suggests that previously it relied on a lock that doesn't
exist today.

17 months agoudp: don't forget to initialize udpcb for UDPv6
Gleb Smirnoff [Thu, 26 Jan 2023 18:16:32 +0000 (10:16 -0800)]
udp: don't forget to initialize udpcb for UDPv6

Reported by: tuexen
Fixes: 483fe96511ec02a3f077f9a59f1a96acb3640dea

17 months agolua: reduce diffs between luaconf.h copies
Ed Maste [Wed, 25 Jan 2023 22:01:00 +0000 (17:01 -0500)]
lua: reduce diffs between luaconf.h copies

Upstream luaconf.h is contrib/lua/src/luaconf.h.dist, while userland lua
and loader lua have copies in lib/liblua/luaconf.h and
stand/liblua/luaconf.h.

Adjust whitespace, VCS tags, etc. to match upstream's version, for ease
of comparison.

Reviewed By: imp
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38206

17 months agotcp: reduce the size of t_rttupdated in tcpcb
Richard Scheffenegger [Thu, 26 Jan 2023 17:07:11 +0000 (18:07 +0100)]
tcp: reduce the size of t_rttupdated in tcpcb

During tcp session start, various mechanisms need to
track a few initial RTTs before becoming active.
Prevent overflows of the corresponding tracking counter
and reduce the size of tcpcb simultaneously.

Reviewed By: #transport, tuexen, guest-ccui
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D21117

17 months agonetlink: Zero-initialize writer structures allocated on the stack
Mark Johnston [Thu, 26 Jan 2023 15:46:19 +0000 (10:46 -0500)]
netlink: Zero-initialize writer structures allocated on the stack

The prevailing pattern seems to be to simply initialize all fields to
zero.  Without this, it's possible to trigger a branch on uninitialized
memory, specifically, when testing nw->ignore_limit in
nlmsg_refill_buffer().

Initialize the writer structure in a couple of functions where this is
necessary.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38213

17 months agoLinuxKPI: pci.h move function declaration to top of file.
Bjoern A. Zeeb [Thu, 26 Jan 2023 14:31:26 +0000 (14:31 +0000)]
LinuxKPI: pci.h move function declaration to top of file.

No functional changes.

X-MFC-with: 49b6d5ed142d6c59b7a517ff5660165d8647bd01
Sponsored by: The FreeBSD Foundation

17 months agoRewrite to avoid Coverity false positive.
Kirk McKusick [Thu, 26 Jan 2023 00:57:26 +0000 (16:57 -0800)]
Rewrite to avoid Coverity false positive.

MFC after:    1 week
Reported by:  Coverity (CID 1502669)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907

17 months agolindebugfs: Add `debugfs_create_file_size()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:57:49 +0000 (10:57 +0100)]
lindebugfs: Add `debugfs_create_file_size()`

This is the same as `debugfs_create_file()` but takes the initial size
of the file. In FreeBSD, the given size is ignored and
`debugfs_create_file()` is called.

Reviewed by: emaste, manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37914

17 months agolinuxkpi: Define `PCI_STD_NUM_BARS` in <linux/pci.h>
Jean-Sébastien Pédron [Sun, 22 Jan 2023 13:46:14 +0000 (14:46 +0100)]
linuxkpi: Define `PCI_STD_NUM_BARS` in <linux/pci.h>

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38162

17 months agolinuxkpi: Define `pm_suspend_target_state` in <linux/suspend.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 20:13:32 +0000 (21:13 +0100)]
linuxkpi: Define `pm_suspend_target_state` in <linux/suspend.h>

It is set to `PM_SUSPEND_ON`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38161

17 months agolinuxkpi: Add `msix_cap` to `struct pci_dev`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:23:59 +0000 (20:23 +0100)]
linuxkpi: Add `msix_cap` to `struct pci_dev`

At the same time, define `PCI_MSIX_FLAGS`and `PCI_MSIX_FLAGS_ENABLE`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38160

17 months agolinuxkpi: Add `sysfs_emit_at()` in <linux/sysfs.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:23:17 +0000 (20:23 +0100)]
linuxkpi: Add `sysfs_emit_at()` in <linux/sysfs.h>

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38159

17 months agolinuxkpi: Define `is_cow_mapping(flags)` as false
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:22:41 +0000 (20:22 +0100)]
linuxkpi: Define `is_cow_mapping(flags)` as false

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38158

17 months agolinuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:51:40 +0000 (18:51 +0100)]
linuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>

I'm not sure this is correct, but it gives access to the definition of
`PAGE_KERNEL` in `ttm_tt.c` in the DRM drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38154

17 months agolinuxkpi: Add `seqcount_ww_mutex_t` in <linux/seqlock.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:20:01 +0000 (18:20 +0100)]
linuxkpi: Add `seqcount_ww_mutex_t` in <linux/seqlock.h>

It is defined as a synonymous to `seqcount_mutex_t`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38152

17 months agolinuxkpi: Define `DEFINE_WD_CLASS(name)` in <linux/ww_mutex.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:19:01 +0000 (18:19 +0100)]
linuxkpi: Define `DEFINE_WD_CLASS(name)` in <linux/ww_mutex.h>

It is defined as a synonymous to `DEFINE_WW_CLASS(name)`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38151

17 months agolinuxkpi: Adds more `SZ_*` macros
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:17:37 +0000 (18:17 +0100)]
linuxkpi: Adds more `SZ_*` macros

`SZ_2K` and `SZ_1G` were defined in irdma. They are removed from this
driver.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38150

17 months agolinuxkpi: Define ENOKEY to 126.
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:14:25 +0000 (18:14 +0100)]
linuxkpi: Define ENOKEY to 126.

This is the same error code as Linux. This value is unused on FreeBSD.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38149

17 months agolinuxkpi: Add `pci_device_is_present()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 17:46:37 +0000 (18:46 +0100)]
linuxkpi: Add `pci_device_is_present()`

This calls bus_child_present(9) internally.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38148

17 months agolinuxkpi: Define `dev_dbg_ratelimited()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 00:15:03 +0000 (01:15 +0100)]
linuxkpi: Define `dev_dbg_ratelimited()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38145

17 months agovt(4): Return errors from `vt_{,de}allocate()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 18:22:56 +0000 (19:22 +0100)]
vt(4): Return errors from `vt_{,de}allocate()`

This is useful to the DRM drivers to let them know if a device is
effectively used by the console.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38089

17 months agolinuxkpi: Fix `atomic_long_sub()` overflow
Jean-Sébastien Pédron [Sun, 15 Jan 2023 14:56:48 +0000 (15:56 +0100)]
linuxkpi: Fix `atomic_long_sub()` overflow

By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making
the atomic long overflow. Indeed the underlying FreeBSD atomic is based
on an unsigned long.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38090

17 months agolinuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 12:22:19 +0000 (13:22 +0100)]
linuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`

The code comes from the i915 DRM driver.

In Linux commits b739f125e4ebd73d10ed30a856574e13649119ed and
b12d691ea5e01db42ccf3b4207e57cb3ce7cfe91 (Linux 5.13), the i915 DRM
driver dropped specific implementations to use Linux generic functions.
Therefore I moved the FreeBSD code from that i915 driver to linuxkpi.

However, these commits were later reverted (also in Linux 5.13) so the
i915 driver doesn't use these functions. But perhaps it will help in the
future.

To sum up, the code comes from the i915 DRM driver but it doesn't use it
(i.e. it continues to use its internal implementation).

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38088

17 months agolinuxkpi: Add `sysfs_emit()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 23:23:33 +0000 (00:23 +0100)]
linuxkpi: Add `sysfs_emit()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38086

17 months agolinuxkpi: Add `complete` field to `struct dev_pm_ops`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:57 +0000 (23:23 +0100)]
linuxkpi: Add `complete` field to `struct dev_pm_ops`

This change breaks the KBI.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38085

17 months agolinuxkpi: Add `pm_suspend_via_firmware()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:35 +0000 (23:23 +0100)]
linuxkpi: Add `pm_suspend_via_firmware()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38084

17 months agolinuxkpi: Add `pm_runtime_suspended()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:14 +0000 (23:23 +0100)]
linuxkpi: Add `pm_runtime_suspended()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38083

17 months agolinuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 00:48:43 +0000 (01:48 +0100)]
linuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38080