]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
9 hours agoifconfig: make interface address without mask an error main
Ed Maste [Thu, 13 Jun 2024 17:37:32 +0000 (13:37 -0400)]
ifconfig: make interface address without mask an error

In commit d8237b955528, as part of the deprecation of IPv4 address
classes, Mike Karels introduced a warning in ifconfig for setting an
address without a width or mask.  The commit message says "This will
hopefully be an error in the future."

As the warning has been included in releases from FreeBSD 13.1 on, and
sufficient time has passed, turn this into an error.

Reviewed by: allanjude, olce, grembo, philip, gordon
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45585

12 hours agocxgbe: handle vlan PF restrictions
Kristof Provost [Thu, 30 May 2024 13:59:09 +0000 (15:59 +0200)]
cxgbe: handle vlan PF restrictions

Co-Authored-by: Navdeep Parhar <np@FreeBSD.org>
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D45428

15 hours agorelease: Remove mergemaster mm-mtree.sh script
Ed Maste [Sat, 9 Sep 2023 16:14:58 +0000 (12:14 -0400)]
release: Remove mergemaster mm-mtree.sh script

It is unused after 8ee478dfd46d ("release: stop generating mergemaster
databases").

Sponsored by: The FreeBSD Foundation

16 hours agocxgbev(4): Pay attention to the VLAN configuration for the VF.
Navdeep Parhar [Mon, 17 Jun 2024 17:11:16 +0000 (10:11 -0700)]
cxgbev(4): Pay attention to the VLAN configuration for the VF.

Make sure that the transmit traffic is tagged correctly or else the
firmware will refuse to transmit and will report an ACL violation.

On receive the hardware will make sure that tagged traffic is delivered
to the appropriate VM.  The driver only asserts that the VLAN id that
was extracted from the wire traffic matches the VF's configuration.

All this works when associating a specific VLAN id with a VF.  The
'trunk' setting likely needs more work.

MFC after: 1 week
Sponsored by: Chelsio Communications

16 hours agocxgbev(4): Shared code for the VF driver to query a VF's VLAN config.
Navdeep Parhar [Wed, 12 Jun 2024 22:24:25 +0000 (15:24 -0700)]
cxgbev(4): Shared code for the VF driver to query a VF's VLAN config.

MFC after: 1 week
Sponsored by: Chelsio Communications

17 hours agoRevert "tzsetup: ask local/UTC question only on x86"
Ed Maste [Mon, 17 Jun 2024 17:03:44 +0000 (13:03 -0400)]
Revert "tzsetup: ask local/UTC question only on x86"

I am unsure if AArch64 Windows systems keep UTC or local time in the RTC
by default, so keep tzsetup consistent across architectures for now.

This reverts commit aa6fb1d277be47c51abc309ac9305def0fce7f9d.

Reported by:  Mark Millard

17 hours agodevelopment.7: markup nits, tag spdx
Alexander Ziaee [Sun, 2 Jun 2024 13:47:44 +0000 (09:47 -0400)]
development.7: markup nits, tag spdx

Using quoted literals is a mistake in roff(7).
Please escape with `\&`, the zero-width-space.

Reviewed by: emaste
MFC after: 3 days

25 hours agomlx5: handle vlan PF restrictions
Kristof Provost [Thu, 30 May 2024 13:56:56 +0000 (15:56 +0200)]
mlx5: handle vlan PF restrictions

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D45427

25 hours agoiovctl: allow vlan restrictions to be passed to the driver
Kristof Provost [Wed, 29 May 2024 17:29:35 +0000 (19:29 +0200)]
iovctl: allow vlan restrictions to be passed to the driver

Allow iovctl to create VFs that are restricted to specific VLAN IDs.

Reviewed by: kib, np
MFC after: 2 weeks
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D45402

32 hours agocxgbe(4): New knob to limit driver to the specified types of doorbells.
Navdeep Parhar [Thu, 13 Jun 2024 17:22:03 +0000 (10:22 -0700)]
cxgbe(4): New knob to limit driver to the specified types of doorbells.

hw.cxgbe.doorbells_allowed="0xf"

The adapter's doorbells bitmap is clipped to the value specified in the
tunable, which is meant for debug and workarounds only.  There is no
change in default behavior.

MFC after: 1 week
Sponsored by: Chelsio Communications

32 hours agocxgbe(4): Do not issue an L1CFG command from a VF.
Navdeep Parhar [Thu, 13 Jun 2024 18:05:51 +0000 (11:05 -0700)]
cxgbe(4): Do not issue an L1CFG command from a VF.

It is pointless to attempt an operation that is not permitted.  It spams
the firmware devlog with "insufficient caps" errors that distract from
real errors.

78 2463625358 ERR CORE insufficient caps to process mailbox cmd: pfn 0x0 vfn 0x1; r_caps 0x86 wx_caps 0x82 required r_caps 0x81 w_caps 0x5

MFC after: 1 week
Sponsored by: Chelsio Communications

32 hours agocxgbev(4): Use the correct source pf for T6 in the VF driver.
Navdeep Parhar [Sun, 16 Jun 2024 18:27:15 +0000 (11:27 -0700)]
cxgbev(4): Use the correct source pf for T6 in the VF driver.

MFC after: 1 week
Sponsored by: Chelsio Communications

32 hours agocxgbetool(8): Be flexible about the nexus name.
Navdeep Parhar [Thu, 13 Jun 2024 20:17:55 +0000 (13:17 -0700)]
cxgbetool(8): Be flexible about the nexus name.

Use the name as-is but perform cxgbe specific ioctls on the device to
make sure that it is a Terminator device nexus.  Determine the chip
type, pf/vf, etc. from the device registers rather than the nexus name.

This allows cxgbetool to work with the VF driver.

MFC after: 1 week
Sponsored by: Chelsio Communications

37 hours agogetblk: track "non-sterile" bufobj to avoid bo lock on miss if sterile
Ryan Libby [Sun, 16 Jun 2024 21:09:45 +0000 (14:09 -0700)]
getblk: track "non-sterile" bufobj to avoid bo lock on miss if sterile

This is a scheme to avoid taking the bufobj lock and doing a second
lookup in the case where in getblk we do an unlocked lookup and find no
buf.  Was there really no buf, or were we in the middle of a reassignbuf
race?  By tracking any use of reassignbuf with a flag, we can know if
there can't have been a race because there has been no reassignbuf.
Because this scheme is spoiled on the first use of reassignbuf, it is
mostly only beneficial for cases where a certain vnode is never expected
to use dirty bufs at all.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D45571

37 hours agojedec_dimm: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:34:30 +0000 (15:34 -0400)]
jedec_dimm: Use device_set_descf()

Note that it is ok to use device_get_desc() as one of the format string
parameters because it is set using device_set_desc() (not
device_set_desc_copy()) and so won't be freed when the description is
updated.

No functional change intended.

MFC after: 1 week

37 hours agopadlock: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:33:59 +0000 (15:33 -0400)]
padlock: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agomana: Use device_set_desc()
Mark Johnston [Wed, 5 Jun 2024 19:30:15 +0000 (15:30 -0400)]
mana: Use device_set_desc()

No functional change intended.

MFC after: 1 week

37 hours agopir: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:29:30 +0000 (15:29 -0400)]
pir: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agooce: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:28:13 +0000 (15:28 -0400)]
oce: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agocfi: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:26:50 +0000 (15:26 -0400)]
cfi: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agosuperio: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:25:58 +0000 (15:25 -0400)]
superio: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agohidbus: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:25:05 +0000 (15:25 -0400)]
hidbus: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agobxe: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:24:16 +0000 (15:24 -0400)]
bxe: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agobge: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:23:26 +0000 (15:23 -0400)]
bge: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agobce: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 19:22:32 +0000 (15:22 -0400)]
bce: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agoliquidio: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:26:22 +0000 (10:26 -0400)]
liquidio: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agomsk: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:20:58 +0000 (10:20 -0400)]
msk: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agompc85xx: Use device_set_desc()
Mark Johnston [Wed, 5 Jun 2024 14:20:12 +0000 (10:20 -0400)]
mpc85xx: Use device_set_desc()

No functional change intended.

MFC after: 1 week

37 hours agowbwd: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:19:51 +0000 (10:19 -0400)]
wbwd: Use device_set_descf()

No functional change intended.

37 hours agoiicbus: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:19:06 +0000 (10:19 -0400)]
iicbus: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agonvmf: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:17:50 +0000 (10:17 -0400)]
nvmf: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agonetmap: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:17:14 +0000 (10:17 -0400)]
netmap: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agoamdsmn: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:16:22 +0000 (10:16 -0400)]
amdsmn: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agoamdsbwd: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:15:36 +0000 (10:15 -0400)]
amdsbwd: Use device_set_descf()

No functional change intended.

MFC after: 1 week

37 hours agocavium/thunder: Use device_set_desc()
Mark Johnston [Wed, 5 Jun 2024 14:14:00 +0000 (10:14 -0400)]
cavium/thunder: Use device_set_desc()

No functional change intended.

MFC after: 1 week

37 hours agoarcmsr: Use device_set_descf()
Mark Johnston [Wed, 5 Jun 2024 14:13:26 +0000 (10:13 -0400)]
arcmsr: Use device_set_descf()

No functional change intended.

MFC after: 1 week

40 hours agowg: Implement if_transmit unconditionally
Mark Johnston [Sun, 16 Jun 2024 17:33:45 +0000 (13:33 -0400)]
wg: Implement if_transmit unconditionally

Commit bf454ca88bdf made wg_transmit() defined only when "device netmap"
is configured, as if_wg's if_transmit implementation should never be
called otherwise, but this breaks a requirement that interfaces
implement both or neither of if_transmit and if_qflush.

Restore the old behaviour of unconditionally defining wg_transmit().  It
contains an assertion that the interface is in netmap mode.

Reported by: peterj
MFC after: 2 weeks
Fixes: bf454ca88bdf ("wg: Add netmap support")

40 hours agokasan: Increase the size of the bootstrap PTP reservation
Mark Johnston [Sun, 16 Jun 2024 17:33:13 +0000 (13:33 -0400)]
kasan: Increase the size of the bootstrap PTP reservation

We were undercounting in the case where the boot stack crosses a 2MB
boundary, resulting in a panic during locore execution.

MFC after: 1 week
Fixes: 756bc3adc578 ("kasan: Create a shadow for the bootstack prior to hammer_time()")

40 hours agovm_phys: Fix a typo
Mark Johnston [Sat, 15 Jun 2024 14:54:23 +0000 (10:54 -0400)]
vm_phys: Fix a typo

Fixes: b16b4c22d2d1 ("vm_page: Implement lazy page initialization")
Reported by: Steffen Nurpmeso <steffen@sdaoden.eu>

41 hours agoriscv pmap: Release PTP reference on leaf ptpage allocation failure
Bojan Novković [Thu, 13 Jun 2024 16:14:21 +0000 (18:14 +0200)]
riscv pmap: Release PTP reference on leaf ptpage allocation failure

d0941ed fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.

Reported by: alc
Approved by: markj (mentor)
Fixes: d0941ed
Differential Revision: https://reviews.freebsd.org/D45580

41 hours agoriscv pmap: Introduce 'pmap_abort_ptp'
Bojan Novković [Thu, 13 Jun 2024 16:13:53 +0000 (18:13 +0200)]
riscv pmap: Introduce 'pmap_abort_ptp'

This commit moves code for releasing pagetable page references
into a separate function. No functional change intended.

Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D45579

41 hours agopowerpc_mmu_radix: Release PTP reference on leaf ptpage allocation failure
Bojan Novković [Thu, 13 Jun 2024 16:11:12 +0000 (18:11 +0200)]
powerpc_mmu_radix: Release PTP reference on leaf ptpage allocation failure

0013741 fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.

Reported by: alc
Approved by: markj (mentor)
Fixes: 0013741
Differential Revision: https://reviews.freebsd.org/D45582

41 hours agopowerpc_mmu_radix: Introduce 'pmap_abort_ptp'
Bojan Novković [Thu, 13 Jun 2024 16:03:31 +0000 (18:03 +0200)]
powerpc_mmu_radix: Introduce 'pmap_abort_ptp'

This commit moves code for releasing pagetable page references
into a separate function. No functional change intended.

Approved by: markj (mentor)
Differential Revision:  https://reviews.freebsd.org/D45581

41 hours agoarm64 pmap: Release PTP reference on leaf ptpage allocation failure
Bojan Novković [Thu, 13 Jun 2024 15:59:29 +0000 (17:59 +0200)]
arm64 pmap: Release PTP reference on leaf ptpage allocation failure

808f5ac fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.

Reported by: alc
Approved by: markj (mentor)
Fixes: 808f5ac
Differential Revision: https://reviews.freebsd.org/D45578

41 hours agoamd64 pmap: Release PTP reference on leaf ptpage allocation failure
Bojan Novković [Thu, 13 Jun 2024 15:58:49 +0000 (17:58 +0200)]
amd64 pmap: Release PTP reference on leaf ptpage allocation failure

aa3bcaa fixed an edge case invloving mlock() and superpage creation
by creating and inserting a leaf pagetable page for mlock'd superpages.
However, the code does not properly release the reference to the
pagetable page in the error handling path.
This commit fixes the issue by adding calls to 'pmap_abort_ptp'
in the error handling path.

Reported by: alc
Approved by: markj (mentor)
Fixes: aa3bcaa
Differential Revision: https://reviews.freebsd.org/D45577

42 hours agovirtio(4): Fix two typos in KASSERT messages
Gordon Bergling [Sun, 16 Jun 2024 16:02:46 +0000 (18:02 +0200)]
virtio(4): Fix two typos in KASSERT messages

- s/emtpy/empty/

MFC after: 5 days

42 hours agocamcontrol.8: Fix a typo in the manual page
Gordon Bergling [Sun, 16 Jun 2024 16:01:12 +0000 (18:01 +0200)]
camcontrol.8: Fix a typo in the manual page

- s/emtpy/empty/

MFC after: 3 days

42 hours agoRevert "swap_pager: small improvement to find_least"
Doug Moore [Sun, 16 Jun 2024 15:37:16 +0000 (10:37 -0500)]
Revert "swap_pager: small improvement to find_least"

This reverts commit dd0e5c02ab13b9eb240d42a71a8f41a8b036bd33.

2 days agofparseln: Update license
Pedro F. Giffuni [Sat, 15 Jun 2024 23:30:27 +0000 (18:30 -0500)]
fparseln: Update license

Remove 3rd and 4th clauses in christos' license. OK christos.

Obtained from: NetBSD

2 days agoRevert "fparseln: Update NetBSD version strings"
Pedro F. Giffuni [Sat, 15 Jun 2024 22:46:56 +0000 (17:46 -0500)]
Revert "fparseln: Update NetBSD version strings"

This reverts commit 1a968da448b0795184884ffe428fb24d7e695628.

I was mistakenly looking at the version strings in the CVS attic
but the function was moved to libc/stdio where it matches the
current string.

2 days agofparseln: Update NetBSD version strings
Pedro F. Giffuni [Sat, 15 Jun 2024 20:32:06 +0000 (15:32 -0500)]
fparseln: Update NetBSD version strings

The correponding changes (mostly ANSIfication) were done long ago locally.
No functional change.

Obtained from: NetBSD (libutil CVS Attic)

2 days agoHyper-V: move memory alloc call for tlb hypercall out of smp_rendezvous
Wei Hu [Sat, 15 Jun 2024 14:07:58 +0000 (14:07 +0000)]
Hyper-V: move memory alloc call for tlb hypercall out of smp_rendezvous

The allocation call could result in sleep lock violation if it is in
smp_rendezvous. Move it out. Also move the pcpu memory pointer to
vmbus_pcpu_data since it is only used on Hyper-V.

PR: 279738
Reported by: gbe
Fixes: 2b887687edc25bb4553f0d8a1183f454a85d413d
MFC after: 2 weeks
Sponsored by: Microsoft

3 days agostress2: Revert change accidentally added in ff4a72c159e0
Peter Holm [Sat, 15 Jun 2024 06:33:14 +0000 (08:33 +0200)]
stress2: Revert change accidentally added in ff4a72c159e0

3 days agolinux: Translate Linux NVME ioctls to the lower layers.
Chuck Tuffli [Fri, 14 Jun 2024 22:40:20 +0000 (16:40 -0600)]
linux: Translate Linux NVME ioctls to the lower layers.

The lower layers implement a ABI compatible Linux ioctl for a few of the
Linux IOCTLs. Translate them and pass them down. Since they are ABI
compatible, just use the nvme ioctl name.

Co-Authored-by: Warner Losh <imp@bsdimp.com>
Reviewed by: chuck
Differential Revision: https://reviews.freebsd.org/D45416

3 days agonvme: Add Linux copatible ioctls
Warner Losh [Fri, 14 Jun 2024 22:40:08 +0000 (16:40 -0600)]
nvme: Add Linux copatible ioctls

Add the NVME_IOCTL_ID, NVME_IOCTL_ADMIN_CMD, and NVME_IOCTL_IO_CMD Linux
compatible ioctls. These may be run on either an I/O (ns) dev or a nvme
(admin) dev. Linux allows both on either device, and programs use this
and aren't careful about having the right device open. Emulate this
feature, and implement these ioctls. The data is passed in into the
kernel in host byte order (not converted to le). Results are returned in
host order.

The timeout field is ignore, and the metadata and metadata_len fields
must be zero.

The addr field can be null, even when the data_len is non zero (FreeBSD's
ioctl interface prohibits this, Linux's just ignores the inconsistency).

Only the cdw10 is returned from the command: the status is not returned
in 'result' field. XXX need to verify that this is what Linux does on an
error signaled from the drive.

No external include file is yet available for this: most programs that
call this interface either use a linux-specific path <linux/nvme.h> or
have their own private copy of the data. It's unclear the best thing to
do.

Also, create a /dev/nvmeXnY as an alias for /dev/nvmeXnsY.

These changes allow a native build of nvme-cli to work for everything
that doesn't depend on sysfs entries in /sys, calls that use metadata,
send / receive drive data and sed functionality not in our nvme driver.

Sponsored by: Netflix
Co-Authored-by: Chuck Tuffli <chuck@freebsd.org>
Reviewed by: chuck
Differential Revision: https://reviews.freebsd.org/D45415

3 days agocdefs.h: Add POSIX.1-2024 values
Warner Losh [Fri, 14 Jun 2024 21:06:53 +0000 (15:06 -0600)]
cdefs.h: Add POSIX.1-2024 values

Sponsored by: Netflix

3 days agovm_phys: Make sure that vm_phys_enq_chunk() stays in bounds
Mark Johnston [Fri, 14 Jun 2024 14:45:02 +0000 (10:45 -0400)]
vm_phys: Make sure that vm_phys_enq_chunk() stays in bounds

vm_phys_enq_chunk() inserts a run of pages into the buddy queues.  When
lazy initialization is enabled, only the first page of each run is
initialized; vm_phys_enq_chunk() thus initializes the page following the
just-inserted run.

This fails to account for the possibility that the page following the
run doesn't belong to the segment.  Handle that in vm_phys_enq_chunk().

Reported by: KASAN
Reported by: syzbot+1097ef4cee8dfb240e31@syzkaller.appspotmail.com
Fixes: b16b4c22d2d1 ("vm_page: Implement lazy page initialization")

3 days agonvme: Fix panic on detach after ce75bfcac9cfe
Alexander Motin [Fri, 14 Jun 2024 19:32:10 +0000 (15:32 -0400)]
nvme: Fix panic on detach after ce75bfcac9cfe

MFC after: 2 weeks

3 days agorc.subr: add some sanity checks for service jails
Alexander Leidinger [Fri, 14 Jun 2024 18:10:07 +0000 (20:10 +0200)]
rc.subr: add some sanity checks for service jails

Add some sanity checks when service jails are used in jails:
 - children.max > 0
 - children.max - children.cur > 0

The nesting is too deep at those places to have a sane formatting, so no
line wrapping at the usual column.
If someone has a better idea how to format this: feel free to go ahead.

3 days agorc.subr: add new sysv option for service jails
Alexander Leidinger [Fri, 14 Jun 2024 18:05:52 +0000 (20:05 +0200)]
rc.subr: add new sysv option for service jails

Clarify that the "sysvipc" svcj option inherits from the host / parent.
Add "sysvipcnew" which creates a new SysV namespace for the service
jail.
Sanity check that only one of them is used.

3 days agoctld: plug memory leaks
Alan Somers [Wed, 12 Jun 2024 21:34:05 +0000 (15:34 -0600)]
ctld: plug memory leaks

MFC after: 2 weeks
Reviewed by: mav
Sponsored by: Axcient
Reported by: valgrind
Pull Request: https://github.com/freebsd/freebsd-src/pull/1288

3 days agoriscv: improve commentary around initial stvec
Mitchell Horne [Mon, 3 Jun 2024 17:24:12 +0000 (14:24 -0300)]
riscv: improve commentary around initial stvec

Make it explicit why we must set the trap vector before enabling virtual
memory.

Reviewed by: br, jhb, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45474

3 days agoriscv: Don't handle missing kernel L3 pages
Mitchell Horne [Fri, 24 Nov 2023 17:21:51 +0000 (13:21 -0400)]
riscv: Don't handle missing kernel L3 pages

This code path should never be hit, if it does it means we did not
bootstrap correctly. Turn it into a panic like we do on amd64 and arm64.

Reviewed by: markj, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45326

3 days agoriscv: adjust physmem reservation
Mitchell Horne [Fri, 14 Jun 2024 17:57:28 +0000 (14:57 -0300)]
riscv: adjust physmem reservation

Make sure we do this BEFORE pmap_bootstrap().

Reviewed by: markj, jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45325

3 days agoboot/efi: Fix warning for non-standard formats when debugging
John F. Carr [Fri, 14 Jun 2024 17:06:03 +0000 (11:06 -0600)]
boot/efi: Fix warning for non-standard formats when debugging

Add -Wno-format for zfs_module and regroup. This fixes warnings when
EFI_DEBUG is defined.

PR: 279071
Reviewed-by: imp
3 days agork_pinctrl: fix error check
John F. Carr [Fri, 14 Jun 2024 16:37:06 +0000 (13:37 -0300)]
rk_pinctrl: fix error check

The parse_bias method returns a signed int, with a value of -1 when
the device tree reports nothing of the bias configuration. Convert the
local 'bias' from unsigned to signed to properly check this condition.

PR: 229721
Reviewed by: mhorne
MFC after: 3 days

3 days agohda: add support for Tiger Lake-H
Adam Retter [Fri, 14 Jun 2024 15:57:15 +0000 (11:57 -0400)]
hda: add support for Tiger Lake-H

PR: 272682
Reported by: Miguel Salcedo
Reviewed by: emaste

3 days agotzsetup: ask local/UTC question only on x86
Ed Maste [Wed, 12 Jun 2024 23:48:24 +0000 (19:48 -0400)]
tzsetup: ask local/UTC question only on x86

Storing local time in the RTC is a legacy of 1990s PCs; it's not
relevant on other platforms of interest to FreeBSD.

While here switch to C99 bool.

Sponsored by: The FreeBSD Foundation
Reviewed by: allanjude (earlier), imp (earlier)
Differential Revision: https://reviews.freebsd.org/D45575

3 days agoboot1.chrp: Include memset
Warner Losh [Fri, 14 Jun 2024 14:30:30 +0000 (08:30 -0600)]
boot1.chrp: Include memset

Normally, memset isn't used. However for OPT_INIT_ALL=zero it is. Always
include it since we're not space constrained and latter-day loaders won't
include a copy if it's not actually used.

Reviewed by: emaste
Sponsored by: Netflix

3 days agolibkern.h: Make more self-sufficient
Warner Losh [Fri, 14 Jun 2024 14:29:08 +0000 (08:29 -0600)]
libkern.h: Make more self-sufficient

libkern.h uses KASSERT, which fails when building in the boot
loader. This is hacked around in a number of other places, but it's
easier to just include sys/kassert.h here. Those other hacks still work,
but are no longer really needed and can be torn down over time.

Reviewed by: emaste
Sponsored by: Netflix

3 days agoudp_var: correct intoudpcb macro unintended identifier dependency
Reid Linnemann [Tue, 7 May 2024 22:46:35 +0000 (16:46 -0600)]
udp_var: correct intoudpcb macro unintended identifier dependency

Change 483fe9651 embedded struct inpcb into struct udpcb and updated the
intoudpcb macro to use __containerof to locate it. This change accidentally
introduced a dependency on the identifier inp being defined in the block the
macro is expanded in. This should have been the macro argument ip. This change
makes this simple correction.

No functional change intended.

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

3 days agotzsetup: add detail for -s option
Ed Maste [Thu, 13 Jun 2024 15:23:26 +0000 (11:23 -0400)]
tzsetup: add detail for -s option

Skipping the UTC question via -s will not create or delete
/etc/wall_cmos_clock.

Reported by: Tomoaki AOKI
Reviewed by: imp, allanjude, jrm
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45576

4 days agopctrie: avoid typecast
Doug Moore [Fri, 14 Jun 2024 07:19:03 +0000 (02:19 -0500)]
pctrie: avoid typecast

Have PCTRIE_RECLAIM_CALLBACK typecast one function pointer type to
another, to relieve the writer of the call back function from having
to cast its first argument from void* to member type.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D45586

4 days agovm_phys: Fix vm_phys_find_range() after commit 69cbb18746b6
Mark Johnston [Fri, 14 Jun 2024 04:09:45 +0000 (00:09 -0400)]
vm_phys: Fix vm_phys_find_range() after commit 69cbb18746b6

vm_phys_seg_paddr_to_vm_page() expects a PA that's in bounds, but
vm_phys_find_range() purposefully returns a pointer to the end of the
last page in a segment.

Fixes: 69cbb18746b6 ("vm_phys: Add a vm_phys_seg_paddr_to_vm_page() helper")

4 days agoamd64/vmm: Make vmm.h more self-contained
Mark Johnston [Fri, 14 Jun 2024 00:17:07 +0000 (20:17 -0400)]
amd64/vmm: Make vmm.h more self-contained

CTASSERT is defined in kassert.h, so include that here.  No functional
change intended.

MFC after: 1 week

4 days agoarm64/vmm: Avoid unnecessary indirection in vmmops_modinit()
Mark Johnston [Fri, 14 Jun 2024 00:16:57 +0000 (20:16 -0400)]
arm64/vmm: Avoid unnecessary indirection in vmmops_modinit()

Most of vmm.h is machine-independent.  Simplify merging amd64 and arm64
vmm code by removing this machine-dependent routine from arm64's vmm.h.
No functional change intended.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D45557

4 days agoarm64/vmm: Implement vm_disable_vcpu_creation()
Mark Johnston [Fri, 14 Jun 2024 00:16:28 +0000 (20:16 -0400)]
arm64/vmm: Implement vm_disable_vcpu_creation()

No functional change intended.

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D45556

4 days agovm_page: Implement lazy page initialization
Mark Johnston [Fri, 14 Jun 2024 00:11:47 +0000 (20:11 -0400)]
vm_page: Implement lazy page initialization

FreeBSD's boot times have decreased to the point where vm_page array
initialization represents a significant fraction of the total boot time.
For example, when booting FreeBSD in Firecracker (a VMM designed to
support lightweight VMs) with 128MB and 1GB of RAM, vm_page
initialization consumes 9% (3ms) and 37% (21.5ms) of the kernel boot
time, respectively.  This is generally relevant in cloud environments,
where one wants to be able to spin up VMs as quickly as possible.

This patch implements lazy initialization of (most) page structures,
following a suggestion from cperciva@.  The idea is to introduce a new
free pool, VM_FREEPOOL_LAZYINIT, into which all vm_page structures are
initially placed.  For this to work, we need only initialize the first
free page of each chunk placed into the buddy allocator.  Then, early
page allocations draw from the lazy init pool and initialize vm_page
chunks (up to 16MB, 4096 pages) on demand.  Once APs are started, an
idle-priority thread drains the lazy init pool in the background to
avoid introducing extra latency in the allocator.  With this scheme,
almost all of the initialization work is moved out of the critical path.

A couple of vm_phys operations require the pool to be drained before
they can run: vm_phys_find_range() and vm_phys_unfree_page().  However,
these are rare operations.  I believe that
vm_phys_find_freelist_contig() does not require any special treatment,
as it only ever accesses the first page in a power-of-2-sized free page
chunk, which is always initialized.

For now the new pool is only used on amd64 and arm64, since that's where
I can easily test and those platforms would get the most benefit.

Reviewed by: alc, kib
Differential Revision: https://reviews.freebsd.org/D40403

4 days agovm_phys: Add a vm_phys_seg_paddr_to_vm_page() helper
Mark Johnston [Fri, 14 Jun 2024 00:11:36 +0000 (20:11 -0400)]
vm_phys: Add a vm_phys_seg_paddr_to_vm_page() helper

No functional change intended.

Suggested by: alc
Reviewed by: dougm, alc, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43636

4 days agovm_phys: Factor out some calls to vm_freelist_add()
Mark Johnston [Fri, 14 Jun 2024 00:11:15 +0000 (20:11 -0400)]
vm_phys: Factor out some calls to vm_freelist_add()

A subsequent patch will make this factoring more worthwhile.

No functional change intended.

Reviewed by: dougm, alc, kib, emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40400

4 days agovm_page: Let vm_page_init_page() take a pool parameter
Mark Johnston [Fri, 14 Jun 2024 00:11:03 +0000 (20:11 -0400)]
vm_page: Let vm_page_init_page() take a pool parameter

This is useful for a subsequent patch which implements lazy
initialization of vm_page structures using a dedicate vm_phys free page
pool.

No functional change intended.

Reviewed by: alc, kib, emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40399

4 days agobnxt: Use a simpler test for 32-bit platforms
Mark Johnston [Fri, 14 Jun 2024 00:02:32 +0000 (20:02 -0400)]
bnxt: Use a simpler test for 32-bit platforms

Suggested by: jrtc27
Fixes: c867ba72889d ("bnxt: Do not compile on 32-bit platforms")

4 days agouniq tests: Make uniq_test:stdout more reliable
Mark Johnston [Fri, 14 Jun 2024 00:00:47 +0000 (20:00 -0400)]
uniq tests: Make uniq_test:stdout more reliable

When running regression tests in paralle, this one occasionally fails
because uniq exits with status 0.  I believe this is because the test is
a bit racy: it assumes that true(1) will exit before uniq writes to
standard out.

Just sleep for a bit to give the other end of the pipe to exit.

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

4 days agosubr_pctrie: add a word to a comment
Doug Moore [Thu, 13 Jun 2024 20:28:15 +0000 (15:28 -0500)]
subr_pctrie: add a word to a comment

No functional changes.
Reported by: alc

4 days agovm: Reduce address space fragmentation
Alan Cox [Sun, 9 Jun 2024 16:58:27 +0000 (11:58 -0500)]
vm: Reduce address space fragmentation

jemalloc performs two types of virtual memory allocations: (1) large
chunks of virtual memory, where the chunk size is a multiple of a
superpage and explicitly aligned, and (2) small allocations, mostly
128KB, where no alignment is requested.  Typically, it starts with a
small allocation, and over time it makes both types of allocation.

With anon_loc being updated on every allocation, we wind up with a
repeating pattern of a small allocation, a large gap, and a large,
aligned allocation.  (As an aside, we wind up allocating a reservation
for these small allocations, but it will never fill because the next
large, aligned allocation updates anon_loc, leaving a gap that will
never be filled with other small allocations.)

With this change, anon_loc isn't updated on every allocation.  So, the
small allocations will be clustered together, the large allocations will
be clustered together, and there will be fewer gaps between the
anonymous memory allocations.  In addition, I see a small reduction in
reservations allocated (e.g., 1.6% during buildworld), fewer partially
populated reservations, and a small increase in 64KB page promotions on
arm64.

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

4 days agosubr_rangeset: use pctrie_reclaim_cb in remove_all
Doug Moore [Thu, 13 Jun 2024 18:49:43 +0000 (13:49 -0500)]
subr_rangeset: use pctrie_reclaim_cb in remove_all

Replace the lookup-remove loop in rangeet_remove_all with a call
to SWAP_PCTRIE_RECLAIM_CALLBACK, to eliminate repeated trie searches.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D45584

4 days agoswap_pager: pctrie_reclaim_cb in meta_free_all
Doug Moore [Thu, 13 Jun 2024 18:47:54 +0000 (13:47 -0500)]
swap_pager: pctrie_reclaim_cb in meta_free_all

Replace the lookup-remove loop in swp_pager_meta_free_all with a call
to SWAP_PCTRIE_RECLAIM_CALLBACK, to eliminate repeated trie searches.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D45583

4 days agosubr_pctrie: add leaf callbacks to pctrie_reclaim
Doug Moore [Thu, 13 Jun 2024 16:44:38 +0000 (11:44 -0500)]
subr_pctrie: add leaf callbacks to pctrie_reclaim

PCTRIE_RECLAIM frees all the interior nodes in a pctrie, but is little
used because most trie-destroyers want to free leaves of the tree
too. Add PCTRIE_RECLAIM_CALLBACK, with two extra arguments, a callback
function and an auxiliary argument, that is invoked on every non-NULL
leaf in the tree as the tree is destroyed.

Reviewed by: rlibby, kib (previous version)
Differential Revision: https://reviews.freebsd.org/D45565

5 days agotzsetup: Correct UTC description
Ed Maste [Thu, 13 Jun 2024 00:08:04 +0000 (20:08 -0400)]
tzsetup: Correct UTC description

UTC is Coordinated Universal Time, not Greenwich Mean Time.

Reviewed by: imp, allanjude
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45573

5 days agonfscl: Add support for read delegations and atomic upgrade
Rick Macklem [Wed, 12 Jun 2024 23:41:12 +0000 (16:41 -0700)]
nfscl: Add support for read delegations and atomic upgrade

For NFSv4.1/4.2, an atomic upgrade of a delegation from a
read delegation to a write delegation is allowed and can
result in significantly improved performance.
This patch adds this upgrade to the NFSv4.1/4.2 client and
enables use of read delegations.

For a test case of building a FreeBSD kernel (sources and
output objects) over a NFSv4.2 mount, these changes reduced
the elapsed time by 30% and included a reduction of 80% for
RPC counts when delegations were enabled.  As such, with this
patch there are at least certain cases where enabling
delegations seems to be worth the increased complexity they
bring.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after: 1 month

5 days agonfscl: Add a check for VREG for delegations
Rick Macklem [Wed, 12 Jun 2024 23:17:23 +0000 (16:17 -0700)]
nfscl: Add a check for VREG for delegations

Since delegations are only issued for regular files, check
v_type to see if the query is for a regular file.  This is
a simple optimization for the non-VREG case.
While here, fix a couple of global variable declarations.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after: 1 month

5 days agonfscl: Add support for the NFSv4.1/4.2 WANT_xxx flags
Rick Macklem [Wed, 12 Jun 2024 23:11:10 +0000 (16:11 -0700)]
nfscl: Add support for the NFSv4.1/4.2 WANT_xxx flags

NFSv4.1/4.2 defined new OPEN_WANT_xxx flags that a client
can use to hint to the server that delegations are or are
not wanted.  This patch adds use of those delegations to
the client.

This patch should only affect the NFSv4.1/4.2 behaviour
when delegations are enabled, which is not the default.

MFC after: 1 month

5 days agopf: make TCP sequence number tracking less strict by one octet for FIN packets
Kristof Provost [Wed, 12 Jun 2024 18:05:22 +0000 (20:05 +0200)]
pf: make TCP sequence number tracking less strict by one octet for FIN packets

The data of a TCP packet must fit into the announced window, but this is not
required for the sequence number of the FIN.  A packet with the FIN bit set and
containing data that fits exactly into the announced window was blocked. Our
stack generates such packets when the receive buffer size is set to 1024. Now
pf uses only the data lenght for window comparison.
OK henning@

Obtained From: OpenBSD
Sponsored by: Rubicon Communications, LLC ("Netgate")

5 days agopf: correctly reset max_win if the SYN-ACK lacks a wscale option.
Kristof Provost [Wed, 12 Jun 2024 18:01:58 +0000 (20:01 +0200)]
pf: correctly reset max_win if the SYN-ACK lacks a wscale option.

pf was setting max_win to 0 and discarded retransmitted SYN-ACK segments without
wscale if the original SYN contained a wscale option. with gerhard@, ok
henning@

Obtained From: OpenBSD
Sponsored by: Rubicon Communications, LLC ("Netgate")

5 days agoifconfig: Fix default netmask calculation
Michael Gmelin [Wed, 12 Jun 2024 16:11:52 +0000 (18:11 +0200)]
ifconfig: Fix default netmask calculation

Reported by: phk
Reviewed by: emaste, kp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D45570

5 days agoarm64: Create a version of vfp_save_state for cpu_switch
Andrew Turner [Wed, 12 Jun 2024 13:09:14 +0000 (14:09 +0100)]
arm64: Create a version of vfp_save_state for cpu_switch

This will be used when we add SVE support to reduce the registers
needed to be saved on context switch.

Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D43305

5 days agoarm64: Clear td_frame when returning to userspace
Andrew Turner [Wed, 12 Jun 2024 13:08:13 +0000 (14:08 +0100)]
arm64: Clear td_frame when returning to userspace

When returning from an exception to userspace clear the saved td_frame.
On the next exception this should point to the frame, however this is
not guaranteed.

To ensure the trap frame pointer is either valid or NULL clear it
before returning to userspace in the EL0 synchronous exception handler.

Reviewed by: kib, markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D44807

5 days agoibcore: Mark write-only variables
Andrew Turner [Wed, 12 Jun 2024 13:04:45 +0000 (14:04 +0100)]
ibcore: Mark write-only variables

Some LinuxKPI lock macros pass need a flags field passed in. This is
written to but never read from so gcc complains.

Fix this by marking the flags variables as unused to quieten the
compiler.

Reviewed by: brooks (earlier version), kib
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D45303

5 days agocdefs: Add __writeonly to mark write only vars
Andrew Turner [Wed, 12 Jun 2024 13:04:13 +0000 (14:04 +0100)]
cdefs: Add __writeonly to mark write only vars

When a variable in write only and can't be removed, e.g. for API
reasons, it is useful to document this fact similar to __diagused
and __witness_used.

Add __writeonly to tell the compiler and anyone looking at the code
that this variable is expected to only be written to, and to not
raise and error.

Reviewed by: imp, kib
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D45561

5 days agoriscv: include ahci device to GENERIC.
Ruslan Bukin [Wed, 12 Jun 2024 12:36:05 +0000 (13:36 +0100)]
riscv: include ahci device to GENERIC.

This is needed for bhyve guest VM.

Reviewed by: mhorne
Sponsored by: UKRI
Differential Revision: https://reviews.freebsd.org/D45497