]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
11 months agoamd64: Fix TLB invalidation routines in !SMP kernels
Mark Johnston [Sun, 30 Jul 2023 15:12:35 +0000 (11:12 -0400)]
amd64: Fix TLB invalidation routines in !SMP kernels

amd64 is special in that its implementation of zpcpu_offset_cpu() is not
the identity transformation, even in !SMP kernels.  Because the pm_pcidp
array of amd64's struct pmap is allocated from a pcpu UMA zone, this
means that accessing pm_pcidp directly, as is done in !SMP
implementations of pmap_invalidate_*, does not work.  Specifically, I
see occasional unexplicable crashes in userspace when PCIDs are enabled.

Apply a minimal patch to fix the problem.  While it would also make
sense to provide separate implementations of zpcpu_* for !SMP kernels,
fixing it this way makes the SMP and !SMP implementations of
pmap_invalidate_* more similar.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D41230

11 months agoradix_tree: redefine the clev field
Doug Moore [Sun, 30 Jul 2023 06:20:07 +0000 (01:20 -0500)]
radix_tree: redefine the clev field

The clev field in the node struct is almost always multiplied by
WIDTH; occasionally, it is incremented and then multiplied by
WIDTH. Instructions can be saved by storing it always multiplied by
WIDTH.

For the computation of slot(), this just eliminates a
multiplication. For trimkey(), where the caller always adds one to
clev before passing it as an argument, this change has the caller, not
the caller, do that. Trimkey() handles it not by adding WIDTH to the
input parameter, but by shifting COUNT, and not 1. That produces the
same result, and it relieves keybarr of the need to test to avoid
shifting by more than 63 bits, since level is always <= 63.

This takes 3 instrutions and 14 bytes out of the basic lookup loop on
amd64.

Reviewed by: kib
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D41226

11 months agolibarchive: merge from vendor branch
Martin Matuska [Sat, 29 Jul 2023 20:43:36 +0000 (22:43 +0200)]
libarchive: merge from vendor branch

Libarchive 3.7.1

Important changes (relevant to FreeBSD):
  ISSUE #1934: stack buffer overflow in cpio verbose mode
  ISSUE #1935: SEGV in cpio verbose mode
  PR #1731 tar: respect --strip-components and -s patterns in cru modes

MFC after: 1 week

11 months agousr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case
Stefan Eßer [Sat, 29 Jul 2023 18:52:53 +0000 (20:52 +0200)]
usr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case

Some macro definitions had been moved into a Makefile section
that depends on MK_NLS_CATALOGS != "no", leading to LTO and the
installation of tests being disabled in the WITHOUT_NLS_CATALOGS
case.

Reported by: Yuri <yuri@aetern.org>

11 months agoUpdate vendor/libarchive to libarchive/libarchive@0e1e2b926
Martin Matuska [Sat, 29 Jul 2023 18:13:53 +0000 (20:13 +0200)]
Update vendor/libarchive to libarchive/libarchive@0e1e2b926

Important bugfixes (relevant to FreeBSD):
  ISSUE #1934: stack buffer overflow in cpio verbose mode
  ISSUE #1935: SEGV in cpio verbose mode
  PR #1731 tar: respect --strip-components and -s patterns in cru modes

Obtained from: libarchive
Libarchive commit: 0e1e2b926aad81512a79a05c791b9dc7e0fa8715
Libarchive tag: v3.7.1

11 months agovfs: Deleting a doubled inclusion of sys/capsicum.h
Dmitry Chagin [Sat, 29 Jul 2023 08:21:58 +0000 (11:21 +0300)]
vfs: Deleting a doubled inclusion of sys/capsicum.h

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

11 months agolinux(4): Fix control message size calculation
Dmitry Chagin [Sat, 29 Jul 2023 08:21:35 +0000 (11:21 +0300)]
linux(4): Fix control message size calculation

To determine the size in bytes needed to hold a control message
and its contents of length len, CMSG_SPACE should be used.

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

11 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.

MFC after: 1 week

11 months agosctp: keep sb_acc and sb_ccc in sync
Michael Tuexen [Fri, 28 Jul 2023 13:16:23 +0000 (15:16 +0200)]
sctp: keep sb_acc and sb_ccc in sync

PR: 260116
MFC after: 1 week

11 months agosctp: improve consistency
Michael Tuexen [Fri, 28 Jul 2023 12:36:11 +0000 (14:36 +0200)]
sctp: improve consistency

This is simplifying a patch to address PR 260116.

PR: 260116
MFC after: 1 week

11 months agoamd64 pmap: Catch up with pctrie changes
Alan Cox [Fri, 28 Jul 2023 20:13:13 +0000 (15:13 -0500)]
amd64 pmap: Catch up with pctrie changes

Recent changes to the pctrie code make it necessary to initialize the
kernel pmap's rangeset for PKU.

11 months agocam: Log errors from passthru commands
Warner Losh [Fri, 28 Jul 2023 18:11:21 +0000 (12:11 -0600)]
cam: Log errors from passthru commands

Since a30ecd42b8e09 we've logged almost all unexpected errors from
commands. However, some passthru commands were not logged via devctl. To
fix this, pass all requests through passerror (which calls
cam_periph_error), but flag those requests that didn't want error
recovery as SF_NO_RECOVERY, like we do for device probing. By doing this
we get identical behavior to the current code, but log these errors.

We have had hangs on drives that seems to show no error. Vendor analysis
of the drive found an illegal command that happen to hang the drive. In
verifying their analysis, we discovered that the pass through commands
from things like smartctl that encountered errors or timeouts weren't
logged.

Sponsored by: Netflix
Reviewed by: ken, mav
Differential Revision: https://reviews.freebsd.org/D41167

11 months agomk: Install bsd.compat.pre.mk
Jessica Clarke [Fri, 28 Jul 2023 16:52:38 +0000 (17:52 +0100)]
mk: Install bsd.compat.pre.mk

Reported by: dchagin
Fixes: 5d6cb793d0d5 ("bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables")

11 months agoEvery path in a radix trie ends with a leaf or a NULL. By replacing
Doug Moore [Fri, 28 Jul 2023 16:39:52 +0000 (11:39 -0500)]
Every path in a radix trie ends with a leaf or a NULL. By replacing
NULL (non-leaf) pointers with NULL leaves, there is a NULL test
removed from every iteration of an index-based search loop.

This speeds up radix trie searches by few percent. If there are any
radix tries that are not initialized with the init() function, but
instead depend on zeroing everything being proper initialization, this
will break those tries.

Reviewed by: alc, kib
Tested by: pho (as part of a larger change)
Differential Revision: https://reviews.freebsd.org/D41171

11 months agoarm64: Add constants for decoding ISS fields for WF* exceptions
Mark Johnston [Fri, 28 Jul 2023 13:32:45 +0000 (09:32 -0400)]
arm64: Add constants for decoding ISS fields for WF* exceptions

WFI and WFIT trap to EL2 when executed in a vmm guest.  (Currently
WFE/WFET are not configured to trap.)  We only handle WFI at the moment,
so these constants are useful when handling the exception.

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

11 months agoarm64: Decode the ID_AA64PFR2_EL1 register
Andrew Turner [Thu, 6 Jul 2023 14:48:42 +0000 (15:48 +0100)]
arm64: Decode the ID_AA64PFR2_EL1 register

No fields have been defined, but it has been documented in the
Architecture Reference Manual.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40897

11 months agoarm64: Update the ID_AA64PFR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 14:40:01 +0000 (15:40 +0100)]
arm64: Update the ID_AA64PFR1_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40896

11 months agoarm64: Update the ID_AA64PFR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 14:02:35 +0000 (15:02 +0100)]
arm64: Update the ID_AA64PFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40895

11 months agoarm64: Decode the ID_AA64MMFR4_EL1 register
Andrew Turner [Thu, 6 Jul 2023 13:51:52 +0000 (14:51 +0100)]
arm64: Decode the ID_AA64MMFR4_EL1 register

No fields have been defined, but it has been documented in the
Architecture Reference Manual.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40894

11 months agoarm64: Decode the ID_AA64MMFR3_EL1 register
Andrew Turner [Thu, 6 Jul 2023 13:28:23 +0000 (14:28 +0100)]
arm64: Decode the ID_AA64MMFR3_EL1 register

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40893

11 months agoarm64: Don't use hex for ID_AA64MMFR2_EL1_op/CR*
Andrew Turner [Thu, 6 Jul 2023 13:15:12 +0000 (14:15 +0100)]
arm64: Don't use hex for ID_AA64MMFR2_EL1_op/CR*

It breaks a future macro that creates the alternative register name
for old compilers.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40892

11 months agoarm64: Update the ID_AA64MMFR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 13:11:29 +0000 (14:11 +0100)]
arm64: Update the ID_AA64MMFR1_EL1 fields

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40891

11 months agoarm64: Update the ID_AA64MMFR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 12:34:28 +0000 (13:34 +0100)]
arm64: Update the ID_AA64MMFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40890

11 months agoarm64: Update the ID_AA64ISAR1_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 10:01:11 +0000 (11:01 +0100)]
arm64: Update the ID_AA64ISAR1_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40889

11 months agoarm64: Update the ID_AA64ISAR0_EL1 fields
Andrew Turner [Thu, 6 Jul 2023 09:19:21 +0000 (10:19 +0100)]
arm64: Update the ID_AA64ISAR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40888

11 months agoarm64: Update the ID_AA64DFR0_EL1 fields
Andrew Turner [Mon, 13 Mar 2023 09:17:32 +0000 (09:17 +0000)]
arm64: Update the ID_AA64DFR0_EL1 fields

While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.

Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40887

11 months agomroute: avoid calling if_allmulti with the lock held
Kristof Provost [Thu, 27 Jul 2023 06:03:25 +0000 (08:03 +0200)]
mroute: avoid calling if_allmulti with the lock held

Avoid locking issues when if_allmulti() calls the driver's if_ioctl,
because that may acquire sleepable locks (while we hold a non-sleepable
rwlock).

Fortunately there's no pressing need to hold the mroute lock while we
do this, so we can postpone the call slightly, until after we've
released the lock.

This avoids the following WITNESS warning (with iflib drivers):

lock order reversal: (sleepable after non-sleepable)
 1st 0xffffffff82f64960 IPv4 multicast forwarding (IPv4 multicast forwarding, rw) @ /usr/src/sys/netinet/ip_mroute.c:1050
 2nd 0xfffff8000480f180 iflib ctx lock (iflib ctx lock, sx) @ /usr/src/sys/net/iflib.c:4525
lock order IPv4 multicast forwarding -> iflib ctx lock attempted at:
#0 0xffffffff80bbd6ce at witness_checkorder+0xbbe
#1 0xffffffff80b56d10 at _sx_xlock+0x60
#2 0xffffffff80c9ce5c at iflib_if_ioctl+0x2dc
#3 0xffffffff80c7c395 at if_setflag+0xe5
#4 0xffffffff82f60a0e at del_vif_locked+0x9e
#5 0xffffffff82f5f0d5 at X_ip_mrouter_set+0x265
#6 0xffffffff80bfd402 at sosetopt+0xc2
#7 0xffffffff80c02105 at kern_setsockopt+0xa5
#8 0xffffffff80c02054 at sys_setsockopt+0x24
#9 0xffffffff81046be8 at amd64_syscall+0x138
#10 0xffffffff8101930b at fast_syscall_common+0xf8

See also: https://redmine.pfsense.org/issues/12079
Reviewed by: mjg
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41209

11 months agotests: Test libexecinfo backtrace call througth signal trampoline
Dmitry Chagin [Fri, 28 Jul 2023 09:10:27 +0000 (12:10 +0300)]
tests: Test libexecinfo backtrace call througth signal trampoline

It should fails on Aarch64 until https://reviews.llvm.org/D155066
is not merged.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D41129

11 months agolinux(4): Add elf_hwcap2 to x86
Dmitry Chagin [Fri, 28 Jul 2023 08:56:59 +0000 (11:56 +0300)]
linux(4): Add elf_hwcap2 to x86

On x86 Linux via AT_HWCAP2 the user controlled (by tunables) processor
capabilities are exposed.

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

11 months agoi386: Don't use static DPCPU and VNET defines in i386 modules
Dmitry Chagin [Fri, 28 Jul 2023 08:55:31 +0000 (11:55 +0300)]
i386: Don't use static DPCPU and VNET defines in i386 modules

As of c84617e8 a similar to 4802a2cb and b6ea4c5a fix should be
applied to i386 too.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D41195

11 months agoman: Link _Fork(2) man page
Dmitry Chagin [Fri, 28 Jul 2023 08:54:20 +0000 (11:54 +0300)]
man: Link _Fork(2) man page

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

11 months agouniverse: Demote armv6 to an extra architecture.
Warner Losh [Fri, 28 Jul 2023 04:21:44 +0000 (22:21 -0600)]
universe: Demote armv6 to an extra architecture.

Per discussions over how to lighten the load of armv6, move it to an
extra arch. You can still build TARGET_ARCH=armv6 if you desire, but
it won't be built as part of 'make universe' without -DEXTRA_TARGETS.

Sponsored by: Netflix

11 months agocam: Fail 2/0 asc/ascq return code
Warner Losh [Thu, 27 Jul 2023 22:05:29 +0000 (16:05 -0600)]
cam: Fail 2/0 asc/ascq return code

This asc/ascq code 2/0 ("No seek complete") is a fatal error on modern
drives indicating a sensor failure. One of our vendors noticed we
retried 2/0 so many times in their failure analysis and asked why (no
other OS else does). They've indicated that this failures means the
track couldn't be located (something that's not going to change, except
if the environment changes significantly, which won't happen on a
timescale useful to retries).

Sponsored by: Netflix

11 months agoPre-quote macros passed to .incbin to avoid unwanted substitution
Jessica Clarke [Fri, 28 Jul 2023 04:08:43 +0000 (05:08 +0100)]
Pre-quote macros passed to .incbin to avoid unwanted substitution

Currently for the MFS, firmware and VDSO template assembly files we pass
the path to include with .incbin unquoted and use __XSTRING within the
assembly file to stringify it. However, __XSTRING doesn't just perform a
single level of expansion, it performs the normal full expansion of the
macro, and so if the path itself happens to tokenise to something that
includes a defined macro in it that will itself be substituted. For
example, with #define MACRO 1, a path like /path/containing/MACRO/in/it
will expand to /path/containing/1/in/it and then, when stringified, end
up as "/path/containing/1/in/it", not the intended string. Normally,
macros have names that start or end witih underscores and are unlikely
to appear in a tokenised path (even if technically they could), but now
that we've switched to GNU C as of commit ec41a96daaa6 ("sys: Switch the
kernel's C standard from C99 to GNU99.") there are a few new macros
defined which don't start or end with underscores: unix, which is always
defined to 1, and i386, which is defined to 1 on i386. The former
probably doesn't appear in user paths in practice, but the latter has
been seen to and is likely quite common in the wild.

Fix this by defining the macro pre-quoted instead of using __XSTRING.
Note that technically we don't need to do this for vdso_wrap.S today as
all the paths passed to it are safe file names with no user-controlled
prefix but we should do it anyway for consistency and robustness against
future changes.

This allows make tinderbox to pass when built with source and object
directories inside ~/path-with-unix, which would otherwise expand to
~/path-with-1 and break.

PR: 272744
Fixes: ec41a96daaa6 ("sys: Switch the kernel's C standard from C99 to GNU99.")

11 months agoMakefile.inc1: Fix list-old-libs by deleting stray pipe
Jessica Clarke [Thu, 27 Jul 2023 23:14:19 +0000 (00:14 +0100)]
Makefile.inc1: Fix list-old-libs by deleting stray pipe

Reported by: Yuri <yuri@aetern.org>
Fixes: 264594efbe69 ("Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats")

11 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.

11 months agoiflib: Fix panic during driver reload stress test
Przemyslaw Lewandowski [Thu, 27 Jul 2023 22:47:12 +0000 (15:47 -0700)]
iflib: Fix panic during driver reload stress test

During a driver reload stress test, after 50-300 reloads a panic occurs.
After adding sleeps in between loading and unloading the driver, the
issue does not occur.  It's possible that loading/unloading too fast may
cause the gt_taskqueue pointer to be freed earlier than expected;
checking for a null pointer first fixes it.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: jeffrey.e.pieper@intel.com
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D39457

11 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.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
11 months agomk: fix unnecessary library relinking with incremental builds
Val Packett [Thu, 27 Jul 2023 21:55:16 +0000 (14:55 -0700)]
mk: fix unnecessary library relinking with incremental builds

Initial libs such as csu are always built (.PHONY), and their
installation to WORLDTMP was causing all the subsequent libraries to
be considered out-of-date even when in reality they were not. Use
install -C more consistently everywhere to avoid unnecessarily
updating the mtimes in WORLDTMP, fixing this problem.

This cut down my no-change buildworld time from 30 to 15 seconds.

Fixes: https://lists.freebsd.org/pipermail/freebsd-current/2016-May/061481.html
TODO.1

Reviewed by: sjg
Sponsored by: https://www.patreon.com/valpackett
Differential Revision:  https://reviews.freebsd.org/D39980

11 months agodtrace: Add WITH_DTRACE_ASAN
Domagoj Stolfa [Thu, 27 Jul 2023 18:27:42 +0000 (20:27 +0200)]
dtrace: Add WITH_DTRACE_ASAN

This option is a blanket for all the DTrace-related software. The option
when enabled passes in -fsanitize=address -fsanitize=undeifned, enabling
ASAN and UBSAN in the following components:

 - libdtrace
 - dtrace(1)
 - lockstat(1)
 - plockstat(1)

The option defaults to "no" and is intended as a developer aid.

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

11 months agopcpu: Remove unused definitions of ALT_STACK_SIZE
Mark Johnston [Mon, 24 Jul 2023 15:26:08 +0000 (11:26 -0400)]
pcpu: Remove unused definitions of ALT_STACK_SIZE

This was added originally for the sparc64 port and apparently copied to
other platforms.  No functional change intended.

MFC after: 1 week

11 months agokmsan: Use the correct origin bytes in kmsan_check_arg()
Mark Johnston [Mon, 17 Jul 2023 13:34:57 +0000 (09:34 -0400)]
kmsan: Use the correct origin bytes in kmsan_check_arg()

Upon discovering a violation kmsan_check_arg() passes a pointer to
function parameter shadow state to kmsan_report_hook().
kmsan_report_hook() uses that address to find the origin cells, assuming
that the passed address belongs to the kernel map.  This has two
problems:
1) Function parameter origin state is also located in TLS, not in the
   origin map, but kmsan_report_hook() doesn't know this.
2) KMSAN TLS for thread0 is statically allocated and thus isn't shadowed
   (because the kernel itself is not shadowed).

These bugs could result in inaccuracies in KMSAN reports, or a page
fault when trying to report a KMSAN violation (which by default panics
the kernel anyway).

Fix the problem by making callers of kmsan_report_hook() provide a
pointer to origin cells.

Sponsored by: The FreeBSD Foundation

11 months agokmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
Mark Johnston [Sat, 15 Jul 2023 18:04:55 +0000 (14:04 -0400)]
kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE

Sponsored by: The FreeBSD Foundation

11 months agoopencrypto: Respect alignment constraints in xor_and_encrypt()
Mark Johnston [Thu, 27 Jul 2023 19:44:52 +0000 (15:44 -0400)]
opencrypto: Respect alignment constraints in xor_and_encrypt()

Copy operands to an aligned buffer before performing operations which
require alignment.  Otherwise it's possible for this code to trigger an
alignment fault on armv7.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D41211

11 months agoarm/unwind: Check stack pointer boundaries before dereferencing
Mark Johnston [Thu, 27 Jul 2023 19:44:00 +0000 (15:44 -0400)]
arm/unwind: Check stack pointer boundaries before dereferencing

If the unwinder somehow ends up with a stack pointer that lies outside
the stack, then an attempt to dereference can lead to a fault, which
causes the kernel to panic again and unwind the stack, which leads to a
fault...

Add kstack_contains() checks at points where we dereference the stack
pointer.  This avoids the aforementioned infinite loop in one case I hit
where some OpenSSL assembly code apparently confuses the unwinder.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D41210

11 months agosrc.conf.5: Regen
Jose Luis Duran [Thu, 27 Jul 2023 15:40:42 +0000 (15:40 +0000)]
src.conf.5: Regen

Regenerate makeman after enabling the building of lib32 on arm64.

Fixes: a1b675731301 ("arm64 lib32: enable building of lib32 on arm64")
Pull Request: https://github.com/freebsd/freebsd-src/pull/804

11 months agotcp: document that conditional fields in tcpcb should be at the end
Michael Tuexen [Thu, 27 Jul 2023 07:02:19 +0000 (09:02 +0200)]
tcp: document that conditional fields in tcpcb should be at the end

Reviewed by:  rscheff, Peter Lei
Sponsored by: Netflix, Inc.

11 months agorelease: Fix make :@ modifier syntax
Jessica Clarke [Thu, 27 Jul 2023 07:36:12 +0000 (08:36 +0100)]
release: Fix make :@ modifier syntax

This spits out errors but seemingly isn't actually fatal, so was missed.

Fixes: 6853d893c7fe ("release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists")

11 months agoetcupdate: Remove redundant semicolons
Jessica Clarke [Thu, 27 Jul 2023 06:55:13 +0000 (07:55 +0100)]
etcupdate: Remove redundant semicolons

Fixes: 03e62670c33c ("etcupdate: Consolidate nobuild cases and make more robust")

11 months agogve: Fix Tx tcpdump panic
Shailend Chand [Thu, 27 Jul 2023 05:22:31 +0000 (22:22 -0700)]
gve: Fix Tx tcpdump panic

Ringing the doorbell before making the BPF call can result in the
mbuf being freed before the BPF call.

Reviewed-by: markj
MFC-after: 3 days
Differential Revision: https://reviews.freebsd.org/D41189

11 months agovm_mmap_object: Update the spelling of true/false
Alan Cox [Wed, 26 Jul 2023 05:58:51 +0000 (00:58 -0500)]
vm_mmap_object: Update the spelling of true/false

Since fitit is already a bool, use true/false instead of TRUE/FALSE.

MFC after: 2 weeks

11 months agoMakefile.inc1: Reinstate kbdcontrol bootstrap for BUILD_WITH_STRICT_TMPPATH
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
Makefile.inc1: Reinstate kbdcontrol bootstrap for BUILD_WITH_STRICT_TMPPATH

During BUILD_WITH_STRICT_TMPPATH builds we need to symlink the host's
kbdcontrol into WORLDTMP/legacy/bin so that it can be used. For
completeness, also check if the host has it, since technically the host
could have been built with WITHOUT_LEGACY_CONSOLE (though given nobody's
screamed since this code was removed that's likely not something that
gets hit in practice), and handle BOOTSTRAP_ALL_TOOLS (especially since
that case will cover cross-building if and when kbdcontrol can be built
on non-FreeBSD).

This allows a BUILD_WITH_STRICT_TMPPATH tinderbox to pass.

This partially reverts commit 33550b47391330362ea58984aa3fd691f6219ee0.

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

11 months agoetcupdate: Use new buildetc and installetc targets when available
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
etcupdate: Use new buildetc and installetc targets when available

These new targets avoid the need to invoke internal build system targets
or set internal variables when building, and also have the added benefit
of working with BUILD_WITH_STRICT_TMPPATH. Old source trees lacking such
targets will not work with BUILD_WITH_STRICT_TMPPATH; they could be made
to work by copying the steps, but it's not worth doing so, as they never
have worked in the past. The primary goal of this is to support changing
the default of BUILD_WITH_STRICT_TMPPATH to enabled.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D41206

11 months agoMakefile.inc1: Add new buildetc and installetc targets
Jessica Clarke [Thu, 27 Jul 2023 04:10:49 +0000 (05:10 +0100)]
Makefile.inc1: Add new buildetc and installetc targets

These implement the steps that etcupdate (and mergemaster) need in order
to build their pristine trees, avoiding the need to use internal targets
and variables. Additionally, buildetc includes the steps needed to build
with BUILD_WITH_STRICT_TMPPATH enabled, since we need some host tools to
be available during the various build and install steps.

Reviewed by: jhb, imp
Differential Revision: https://reviews.freebsd.org/D41205

11 months agoetcupdate: Consolidate nobuild cases and make more robust
Jessica Clarke [Thu, 27 Jul 2023 04:10:48 +0000 (05:10 +0100)]
etcupdate: Consolidate nobuild cases and make more robust

The distrib-dirs and distribution steps are shared between the two, the
only difference is whether MAKEOBJDIRPREFIX is in the environment for
the latter. Having in the environment for the former is currently not
needed but does no harm and will be needed in future, so we can just
export it up-front in the subshell. When we do distrib-dirs relative to
_obj and everything also doesn't matter, so move it next to distribution
where it makes more sense. Finally, to avoid complicated && chains, use
"|| exit 1" everywhere to make the subshell fail, and add an extra one
on to the cd $SRCDIR to handle that failing (otherwise we'd go on and
try to build the current directory after cd prints its error, which is
unhelpful).

These changes will make it easier to bundle these steps up into new
top-level targets to allow the build system to manage the steps rather
than etcupdate, which will also handle BUILD_WITH_STRICT_TMPPATH, which
currently does not work with etcupdate.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D41204

11 months agoMakefile.inc1: Split _cleanworldtmp out from _worldtmp
Jessica Clarke [Thu, 27 Jul 2023 04:10:48 +0000 (05:10 +0100)]
Makefile.inc1: Split _cleanworldtmp out from _worldtmp

This mirrors _cleanobj vs _obj, and will be used by etcupdate to ensure
its build tree has host tools available when BUILD_WITH_STRICT_TMPPATH
is enabled by default (whether in the source tree, like CheriBSD, or in
a system config file).

Note that due to line length the .MAKE .PHONY dependency line is split
into two, one for the filtered WMAKE_TGTS and one for the filtered
.ALLTARGETS.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41190

11 months agotools/build: Create toolchain symlinks for non-absolute compiler/linker
Jessica Clarke [Thu, 27 Jul 2023 04:10:47 +0000 (05:10 +0100)]
tools/build: Create toolchain symlinks for non-absolute compiler/linker

If any of the toolchain variables are not absolute then we need to
create a symlink in WORLDTMP/legacy/bin in order to make them available
during a BUILD_WITH_STRICT_TMPPATH build.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41188

11 months agodepend-cleanup.sh: Generalise lib32 code and avoid duplication
Jessica Clarke [Thu, 27 Jul 2023 04:10:47 +0000 (05:10 +0100)]
depend-cleanup.sh: Generalise lib32 code and avoid duplication

By passing through _ALL_libcompats we can avoid hard-coding the list of
libcompats in depend-cleanup.sh. This cleanup also makes clean_dep
shorter by using a loop instead of handling each case explicitly (at the
expense of slightly tweaked logging).

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41187

11 months agoOptionalObsoleteFiles.inc: Automatically generate libcompat directories
Jessica Clarke [Thu, 27 Jul 2023 04:10:46 +0000 (05:10 +0100)]
OptionalObsoleteFiles.inc: Automatically generate libcompat directories

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41186

11 months agobsd.lib.mk: Automatically generate libcompat TAGS
Jessica Clarke [Thu, 27 Jul 2023 04:10:46 +0000 (05:10 +0100)]
bsd.lib.mk: Automatically generate libcompat TAGS

Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41185

11 months agorelease: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists
Jessica Clarke [Thu, 27 Jul 2023 04:10:45 +0000 (05:10 +0100)]
release: Automatically generate MK_LIB${LIBCOMPAT} and lib${libcompat}-dbg lists

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41184

11 months agolibexec: Automatically generate rtld-elf list and generalise TAGS
Jessica Clarke [Thu, 27 Jul 2023 04:10:45 +0000 (05:10 +0100)]
libexec: Automatically generate rtld-elf list and generalise TAGS

Note that the pattern for matching is made slightly more specific, so as
to permit libcompats where one is a prefix of another (e.g. CheriBSD has
lib64 and lib64c).

Reviewed by: brooks, jhb, emaste, imp, kib
Differential Revision: https://reviews.freebsd.org/D41183

11 months agoetc: Automatically generate BSD.lib${libcompat}.dist lists
Jessica Clarke [Thu, 27 Jul 2023 04:10:44 +0000 (05:10 +0100)]
etc: Automatically generate BSD.lib${libcompat}.dist lists

Note that each libcompat still has its own file that must exist.

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41182

11 months agoObsoleteFiles.inc: Automatically generate OpenSSL 3 obsoleted libcompat dirs
Jessica Clarke [Thu, 27 Jul 2023 04:10:44 +0000 (05:10 +0100)]
ObsoleteFiles.inc: Automatically generate OpenSSL 3 obsoleted libcompat dirs

Older entries in this file are left alone as hard-coding lib32 as
they're not worth the churn; downstreams will have already moved past
them (in particular, CheriBSD, which adds additional libcompats).

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41181

11 months agoMakefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
Makefile.inc1: Automatically generate _LIBCOMPATS and list-old-* libcompats

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41180

11 months agoMakefile: Automatically generate list of libcompat targets
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
Makefile: Automatically generate list of libcompat targets

Reviewed by: brooks, jhb
Differential Revision: https://reviews.freebsd.org/D41179

11 months agobsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables
Jessica Clarke [Thu, 27 Jul 2023 04:10:43 +0000 (05:10 +0100)]
bsd.compat.mk Extract _ALL_LIBCOMPATS and add related variables

Adding these to a new bsd.compat.pre.mk will allow other parts of the
tree to iterate over the set of possible libcompats (upper and/or lower)
rather than having to hard-code the list.

Reviewed by: brooks, jhb, emaste
Differential Revision: https://reviews.freebsd.org/D41178

11 months agoinpcb: do not copy so_options into inp_flags2
Gleb Smirnoff [Thu, 27 Jul 2023 03:35:41 +0000 (20:35 -0700)]
inpcb: do not copy so_options into inp_flags2

Since f71cb9f74808 socket stays connnected with inpcb through latter's
lifetime and there is no reason to complicate things and copy these
flags.

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

11 months agoinpcb: use internal flag to mark pcbs that are inserted into lbgroup
Gleb Smirnoff [Thu, 27 Jul 2023 03:35:30 +0000 (20:35 -0700)]
inpcb: use internal flag to mark pcbs that are inserted into lbgroup

Using INP_REUSEPORT_LB is unsafe, as it is basically a copy of socket's
SO_REUSEPORT_LB flag, which can be cleared by userland after bind().

Reviewed by: markj
Reported by: syzbot+e7d2e451f89fb444319b@syzkaller.appspotmail.com
Differential Revision: https://reviews.freebsd.org/D41197

11 months agofork1(): properly track the state of the pg_killsx lock
Konstantin Belousov [Wed, 26 Jul 2023 23:24:30 +0000 (02:24 +0300)]
fork1(): properly track the state of the pg_killsx lock

Reported by: dchagin
Fixes: 232b922cb363e01ac0dd2a277d93cf74d8485e79
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

11 months agotcp: fix handling of <RST,ACK> segments in SYN-RCVD for RACK and BBR
Michael Tuexen [Wed, 26 Jul 2023 14:22:13 +0000 (16:22 +0200)]
tcp: fix handling of <RST,ACK> segments in SYN-RCVD for RACK and BBR

This deals with TCP endpoints in the SYN-RCVD state coming from the
SYN-SENT state.

Reviewed by: rscheff
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D41203

11 months agotcp: Handle <RST,ACK> in SYN-RCVD
Richard Scheffenegger [Wed, 26 Jul 2023 22:41:25 +0000 (00:41 +0200)]
tcp: Handle <RST,ACK> in SYN-RCVD

Patch base stack to correctly handle the RST bit independently
of other header flags per TCP RFC.

MFC after: 1 week
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D40982

11 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.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
11 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

11 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.

MFC after: 1 week
Reviewed by: sjg, glebius
Differential Revision: https://reviews.freebsd.org/D41160

11 months agokillpg(): close a race with fork(), part 2
Konstantin Belousov [Thu, 20 Jul 2023 21:19:03 +0000 (00:19 +0300)]
killpg(): close a race with fork(), part 2

When we are sending terminating signal to the group, killpg() needs
to guarantee that all group members are to be terminated (it does not
need to ensure that they are terminated on return from killpg()).  The
pg_killsx change eliminates the largest window there, but still, if
a multithreaded process is signalled, the following could happen:
- thread 1 is selected for the signal delivery and gets descheduled
- thread 2 waits for pg_killsx lock, obtains it and forks
- thread 1 continue executing and terminates the process
This scenario allows the child to escape still.

Fix it by single-threading forking parent if a conflict with pg_killsx
is noted.  We try to lock pg_killsx without sleeping, and failure to
acquire it means that a parallel killpg(2) is executed.  Then, stop
other threads for running and in particular, receive signals, to avoid
the situation explained above.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41128

11 months agosigtd(): prefer non-stopped thread as a target for signal queue
Konstantin Belousov [Fri, 21 Jul 2023 09:41:39 +0000 (12:41 +0300)]
sigtd(): prefer non-stopped thread as a target for signal queue

This should improve signal delivery latency and better expose the
process state to the executing threads.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41128

11 months agoRevert "killpg(): close a race with fork(), part 2"
Konstantin Belousov [Thu, 20 Jul 2023 20:59:41 +0000 (23:59 +0300)]
Revert "killpg(): close a race with fork(), part 2"

This reverts commits 81a37995c757b4e3ad8a5c699864197fd1ebdcf5 and
565a343ae3a30bc2973182ff8dfd2fa37d7f615f.

There is still a leakage of the p_killpg_cnt, some but not all sources
of which were identified.

Second, and more important, is that there is a fundamental issue with
blocked signals having KSI_KILLPG flag set.  Queueing of such signal
increments p_killpg_cnt, but it cannot be decremented until the signal
is delivered.  If, for instance, a single-threaded process with blocked
signal receives killpg-kill and executes fork(2), the fork enter check
returns with ERESTART.  And since signal is blocked, the condition
cannot be cleared.

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

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

Reindend and re-fill the statement.

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

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

converting user allocation address into overhead pointer

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

11 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

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

11 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

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

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

The ovu_magic is not neccessary overlaps with low byte of the ov_next,
for the big endian machines.

There is no range checking in the allocator.

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

11 months agobase: Remove support for the VTOC8 partitioning scheme
Marius Strobl [Wed, 26 Jul 2023 11:08:37 +0000 (13:08 +0200)]
base: Remove support for the VTOC8 partitioning scheme

The removal of the sparc64 support in February 2020 obsoleted the
VTOC8 partitioning scheme as no other FreeBSD platform makes use
of it. Moreover, the code is bitrotting as nothing defines e. g.
LOADER_VTOC8_SUPPORT any more and, thus, should go now, too. With
this change, the following commits are reverted as far as VTOC8
is concerned and parts haven't already previously been deleted
along with prior sparc64 removals:
094fcb157d4c98211899cf09d06e2cf19149b7e0
a7d366e9589c95feda6f3bc78c59c6355d51f126
ba8d50d08b9df4e8213f9a6997ff6792ecebcd9b

The alignment example d9711c28efc4ec89ba5ea11f8fd63e9d0a7fc81b
added to the VTOC8 section of gpart.8 is folded into the MBR one.

This should finally conclude the deorbit of sparc64-specific bits.

        We had joy, we had fun
        we ran Unix on a Sun.
        But that source and the song
        of FreeBSD have all gone.

Credits to Michael Bueker for the original "Unix on a Sun" and Rod
McKuen for the "Seasons in the Sun" lyrics.

11 months agoofw(4): Add my copyright and additional history for ofw_reg_to_paddr()
Marius Strobl [Wed, 26 Jul 2023 07:38:53 +0000 (09:38 +0200)]
ofw(4): Add my copyright and additional history for ofw_reg_to_paddr()

The ofw_reg_to_paddr() in this file is the powerpc OF_decode_addr()
formerly added in 812403402e0bc2165c03e37c6f657c7405f95c15. However,
the latter function in turn was based on the sparc64 counterpart I
previously added in 2b2250b149706f492dd615a518aa669e39b78d0a.

11 months agogif(4): Assert that gif_output() isn't called for EtherIP
Marius Strobl [Sun, 23 Jul 2023 16:58:42 +0000 (18:58 +0200)]
gif(4): Assert that gif_output() isn't called for EtherIP

With the current implementation of if_bridge(4), bridge_enqueue()
calls gif_transmit() only. Ensure it stays that way so that the
expectations in both drivers are either met or changed accordingly.

PR: 227450

11 months agogif(4): Revert in{,6}_gif_output() misalignment handling
Marius Strobl [Wed, 19 Jul 2023 17:17:43 +0000 (19:17 +0200)]
gif(4): Revert in{,6}_gif_output() misalignment handling

The code added in c89c8a1029860182eece5d51ec09119b9500e5a1 in order
to compensate possible misalignment caused by prepending the IP4/6
header with an EtherIP one got broken at some point by a rewrite of
gif(4). For better or worse, 8018ac153f7671699ca008f31c0fad9caef2f531
relaxed the alignment of struct ip from 32 bit to 16 bit, though. As
a result, a 16 bit offset of the IPv4 header induced by the addition
of the 16 bit EtherIP one no longer is a problem in the first place.
The alignment of struct ip6_hdr currently is even only 8 bit, making
it even less problematic with regards to possible misalignment.
Thus, remove the code for handling misalignment in in{,6}_gif_output()
altogether again.
While at it, replace the 3 bcopy(9) calls in gif(4) with memcpy(9) as
there's no need to handle overlap here.

11 months agotzsetup: fix "misleading indentation" warning with -DVERBOSE
Yuri Pankov [Wed, 26 Jul 2023 10:33:42 +0000 (12:33 +0200)]
tzsetup: fix "misleading indentation" warning with -DVERBOSE

11 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")

11 months agoarm64 pmap: Eliminate unnecessary TLB invalidations
Alan Cox [Sun, 23 Jul 2023 07:11:43 +0000 (02:11 -0500)]
arm64 pmap: Eliminate unnecessary TLB invalidations

Eliminate unnecessary TLB invalidations by pmap_kenter(),
pmap_qenter(), and pmap_mapbios() when the old page table entries
were invalid.

While I'm here, correct some nearby whitespace issues.

MFC after: 2 weeks

11 months agovm: Fix vm_map_find_min()
Alan Cox [Tue, 25 Jul 2023 07:24:19 +0000 (02:24 -0500)]
vm: Fix vm_map_find_min()

Fix the handling of address hints that are less than min_addr by
vm_map_find_min().

Reported by: dchagin
Reviewed by: kib
Fixes: d8e6f4946cec0 "vm: Fix anonymous memory clustering under ASLR"
Differential Revision: https://reviews.freebsd.org/D41159

11 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.

A new command, quitclean, is added to fsdb(8) to request that the
filesystem not be marked as needing a full fsck(8). This is useful
when creating deliberately bad filesystem images to be used to check
that fsck is properly able to clean them up.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
11 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.

Until this update, the fsdb(8) command always marked a filesystem
as needing a full fsck unless it was run with the -n flag which
allowed no changes to be made.

This change tracks modifications to the filesystem. Two types of
changes are tracked. The first type of changes are those that are
not critical to the integrity of the filesystem such as changes to
owner, group, time stamps, access mode, and generation number. The
second type of changes are those that do affect the integrity of
the filesystem including zeroing inodes, changing block pointers,
directory entries, link counts, file lengths, file types, and file
flags.

When quitting having made no changes or only changes to data that
is not critical to filesystem integrity, the clean state of the
filesystem is left unchanged. But if filesystem critical data are
changed then fsdb will set the unclean flag which will require a
full fsck to be run before the filesystem can be mounted.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
11 months agomac_ipacl: new MAC policy module to limit jail/vnet IP configuration
Shivank Garg [Tue, 25 Jul 2023 20:27:06 +0000 (20:27 +0000)]
mac_ipacl: new MAC policy module to limit jail/vnet IP configuration

The mac_ipacl policy module enables fine-grained control over IP address
configuration within VNET jails from the base system.
It allows the root user to define rules governing IP addresses for
jails and their interfaces using the sysctl interface.

Requested by: multiple
Sponsored by: Google, Inc. (GSoC 2019)
MFC after: 2 months
Reviewed by: bz, dch (both earlier versions)
Differential Revision: https://reviews.freebsd.org/D20967

11 months agoarm64 lib32: enable building of lib32 on arm64
Mike Karels [Tue, 25 Jul 2023 23:59:52 +0000 (18:59 -0500)]
arm64 lib32: enable building of lib32 on arm64

Enable LIB32 option on aarch64, defaulting to YES; it had defaulted
to "broken".  Add required variables for how to compile lib32 on
arm.  Use /usr/include/arm for armv7 (32-bit) headers, analogous to
/usr/include/i386 on amd64.  Omit libomp from lib32; it is not
supported on armv7.

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

11 months agoarm64 lib32: prepare arm64 headers to redirect to arm
Mike Karels [Tue, 25 Jul 2023 23:59:26 +0000 (18:59 -0500)]
arm64 lib32: prepare arm64 headers to redirect to arm

In order to compile lib32 libraries and other 32-bit code on arm64,
<machine/foo.h> needs to be redirected to an arm header rather
than arm64 when building with -m32.  Ifdef the arm64 headers that
are installed in /usr/include/machine and used by user-level software
(including references from /usr/include/*.h) so that if __arm__ is
defined when including the arm64 version, <arm/foo.h> is included
rather than using the rest of the file's contents.  Some arm headers
had no arm64 equivalent; headers were added just to do the redirection.
These files use #error if __arm__ is not defined to guard against
confusion.  Also add an include/arm Makefile, and modify Makefiles
as needed to install everything, including the arm files in
/usr/include/arm.  fenv.h comes from lib/msun/arm/fenv.h.

The new arm64 headers are:
    acle-compat.h
    cpuinfo.h
    sysreg.h

Reviewed by: jrtc27, imp
Differential Revision: https://reviews.freebsd.org/D40944

11 months agoarm64 lib32: change clang to allow -m32 on arm64
Mike Karels [Tue, 25 Jul 2023 23:58:51 +0000 (18:58 -0500)]
arm64 lib32: change clang to allow -m32 on arm64

The FreeBSD driver support for clang tested explicitly for 32-bit
Intel, MIPS, or PowerPC targets where /usr/lib32/libcrt1.o was
present to decide whether -m32 should use /usr/lib32.  At jrtc27's
suggestion, simply test for a 32-bit platform rather than adding
arm to the list.  Upstreamed as
https://github.com/llvm/llvm-project/commit/3450272fc281979388bb845a9fffb59b42cc2e7e
Bump the freebsd version to force a bootstrap build.  This is one
step in adding support for -m32 on arm64.

Reviewed by: jrtc27, brooks, dim
Differential Revision: https://reviews.freebsd.org/D40943

11 months agoMakefile.inc1: add LIBCOMPAT_INCLUDE_DIRS to reduce arch ifdefs
Mike Karels [Tue, 25 Jul 2023 23:58:29 +0000 (18:58 -0500)]
Makefile.inc1: add LIBCOMPAT_INCLUDE_DIRS to reduce arch ifdefs

In preparation for adding support for building lib32 on arm64,
add a list of architecture-specific include directories,
LIBCOMPAT_INCLUDE_DIRS, then replace the architecture-specific
ifdefs throughout the file with simple loops.  Another commit
will add a definition of LIBCOMPAT_INCLUDE_DIRS for aarch64.

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

11 months agotools/build: Tidy up whitespace and comments, and delete duplicate code
Jessica Clarke [Tue, 25 Jul 2023 21:24:02 +0000 (22:24 +0100)]
tools/build: Tidy up whitespace and comments, and delete duplicate code

We already handle the make and bmake links unconditionally above.

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

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation