Commit graph

149901 commits

Author SHA1 Message Date
Jessica Clarke c55272fdf8 riscv: Create a newbus device for the SBI driver
This approach is based on the Arm PSCI driver, though that makes more
extensive use of its softc than we do here. This will be used to extract
the SBI IPI code as a real PIC.

Reviewed by:	mhorne, imp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D35900
2024-01-24 23:49:54 +00:00
Jessica Clarke 103d39efe0 intrng: Allow alternative IPI PICs to be registered and used
On RISC-V, the root PIC (whether the PLIC or, as will be the case in
future, the local interrupt controller) cannot send IPIs, relying on
another means to trigger the necessary software interrupts (firmware
calls), but there are upcoming standard devices that will be able to
inject them, so we can't just put the firmware calls in the root PIC
driver.

Thus, split out a new intr_ipi_dev from intr_irq_root_dev to use for
sending IPIs. New devices can be registered with a given priority up
until the first IPI is set up, when the best device seen so far gets
frozen as the IPI device to use.

Reviewed by:	mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D35899
2024-01-24 23:49:54 +00:00
Jessica Clarke fae8755f16 intrng: Extract arm/arm64 IPI->PIC glue code
The arm and arm64 implementations of dispatching IPIs via PIC_IPI_SEND
are almost identical, and entirely MI with the lone exception of a
single store barrier on arm64 (that is likely either redundant or needed
on arm too). Thus, de-duplicate this code by moving it to INTRNG as a
generic IPI glue framework. The ipi_* functions remain declared in MD
smp.h headers and implemented in MD code, but are trivial wrappers
around intr_ipi_send that could be made MI, at least for INTRNG ports,
at a later date.

Note that, whilst both arm and arm64 had an ii_send member in intr_ipi
to abstract over how to send interrupts,, they were always ultimately
using PIC_IPI_SEND, and so this complexity has been removed. A follow-up
commit will re-introduce the same flexibility by instead allowing a
device other than the root PIC to be registered as the IPI sender.

As part of this, strengthen a MAXCPU assertion that was missed in commit
2f0b059eea ("intrng: switch from MAXCPU to mp_ncpus") (which itself is
mis-titled).

Reviewed by:	mmel, mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D35898
2024-01-24 23:49:53 +00:00
Jessica Clarke e06afdb285 intrng: Remove irq_root_ipicount and corresponding intr_pic_claim_root arg
The static irq_root_ipicount variable is only ever written to (with the
value passed to irq_root_ipicount), never read. Moreover, the bcm2836
driver, as used by the Raspberry Pi 2B and 3A/B (but not 4, which uses a
GIC-400, though does have the legacy interrupt controller present too)
passes 0 as ipicount, despite implementing IPIs. It's thus inaccurate
and serves no purpose, so should be removed.

Reviewed by:	mmel, imp, mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D35897
2024-01-24 23:49:53 +00:00
Kyle Evans 5738d741fb kern: tty: fix recanonicalization
`ti->ti_begin` is actually the offset within the first block that is
unread, so we must use that for our lower bound.

Moving to the previous block has to be done at the end of the loop in
order to correctly handle the case of ti_begin == TTYINQ_DATASIZE.  At
that point, lastblock is still the last one with data written and the
next write into the queue would advance lastblock.  If we move to the
previous block at the beginning, then we're essentially off by one block
for the entire scan and run the risk of running off the end of the block
queue.

The ti_begin == 0 case is still handled correctly, as we skip the loop
entirely and the linestart gets recorded as the first byte available for
writing.  The bit after the loop about moving to the next block is also
still correct, even with both previous fixes in mind: we skipped moving
to the previous block if we hit ti_begin, and `off + 1` would in-fact be
a member of the next block from where we're reading if it falls on a
block boundary.

Reported by:	dim
Fixes:	522083ffbd ("kern: tty: recanonicalize the buffer on [...]")
2024-01-24 13:48:31 -06:00
Kristof Provost f1c0030bb0 pf: only check MTU for IPv6 packets when forwarding
When the packets are generated locally (i.e. PFIL_FWD is not set) we
might generate overly large packets and rely on the NIC to fragment it
for us. In that case we'd reject a valid packet.

Reported by:	Herbert J. Skuhra <herbert@gojira.at>
Tested by:	Herbert J. Skuhra <herbert@gojira.at>
Fixes:		54c62e3e5d
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-24 19:08:29 +01:00
Gleb Smirnoff 5fc3104ae7 callout: retire callout_async_drain()
This function was used only in TCP before 446ccdd08e.  It was born in
pain in 2016 to plug different complex panics in TCP timers.  It wasn't
warmly accepted in phabricator by all of the reviewers and my recollection
of overall agreement was that "if you need this KPI, then you'd better fix
your code to not need it".  However, the function served its duty well all
the way to FreeBSD 14.  But now that TCP doesn't need it anymore, let's
retire it to reduce complexity of callout code and also to avoid its
further use.

Reviewed by:		jhb, markj, kib, rrs
Differential Revision:	https://reviews.freebsd.org/D43546
2024-01-24 09:33:27 -08:00
Richard Scheffenegger c7c325d01d tcp: pass maxseg around instead of calculating locally
Improve slowpath processing (reordering, retransmissions)
slightly by calculating maxseg only once. This typically
saves one of two calls to tcp_maxseg().

Reviewed By:           glebius, tuexen, cc, #transport
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43536
2024-01-24 16:43:29 +01:00
Martin Matuska fedf5b965f zfs: merge openzfs/zfs@a4bf6baae
Notable upstream pull request merges:
 #15630 a4bf6baae FreeBSD: Fix file descriptor leak on pool import
 #15780 d9cb42da9 FreeBSD: Fix bootstrapping tools under Linux/musl

Obtained from:	OpenZFS
OpenZFS commit:	a4bf6baaeb
2024-01-24 12:41:51 +01:00
Konstantin Belousov 120ceebab5 Bump __FreeBSD_version for kern_openatfp(9) and kcmp(2) 2024-01-24 07:13:26 +02:00
Konstantin Belousov c662306e19 Add kern_openatfp(9)
Reviewed by:	markj, pjd
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43529
2024-01-24 07:13:26 +02:00
Konstantin Belousov 3d59b93b20 kern_openat(): minor style fixes
Reviewed by:	markj, pjd
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43529
2024-01-24 07:13:25 +02:00
Konstantin Belousov 2a284076ec kern_openat(): rename fd argument to dirfd
Reviewed by:	markj, pjd
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43529
2024-01-24 07:13:25 +02:00
Konstantin Belousov 38bfddf597 regen 2024-01-24 07:11:27 +02:00
Konstantin Belousov f006524d6d kcmp(2): implement for procdesc
Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
2024-01-24 07:11:27 +02:00
Konstantin Belousov 41fb6dc3d4 kcmp(2): implement for linuxkpi cdevs
Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
2024-01-24 07:11:27 +02:00
Konstantin Belousov 5c41d888de kcmp(2): implement for devfs files
Compare not vnodes, which are different between mount points, but
actual cdev referenced by the devfs node.

Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov f04220c1b0 kcmp(2): implement for vnode files
Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov f28526e946 kcmp(2): implement for generic file types
Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov d8decc9ae3 Add kcmp(2) kernel bits
This is based purely on reading the Linux kcmp(2) man page.
In addition to the Linux set of comparators, I also added KCMP_FILEOBJ to
compare underlying file' objects.

Tested by:	manu
Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov 168c7580c6 file: add fo_cmp method
The method should return 0 if the file' underlying objects are same.  In
other words, if 0 is returned, io from either of file causes
modifications of the same object.

Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov 58d3171698 Add fget_remote()
The function holds and returns struct file for a file descriptor index
in the given process.

Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Konstantin Belousov 24fee9771e sys/file.h: style
Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
2024-01-24 07:11:25 +02:00
Gleb Smirnoff 90ad2dc287 tcp: remove 20+ year old disabled code from d912c694ee 2024-01-23 13:16:34 -08:00
Gleb Smirnoff c809435b18 tcp: clear outdated comment mentioning T/TCP 2024-01-23 12:59:21 -08:00
Gleb Smirnoff e21c668719 tcp: pass positive errno to tcp_drop()
Fixes:	446ccdd08e
2024-01-23 12:59:21 -08:00
Mike Karels 2e68c5a44c tmpfs: increase vfs.tmpfs.memory_percent to 100 as workaround
The changes to avoid letting tmpfs use all of memory + swap do not
work well with ZFS ARC.  The ARC can grow quite large, and will shrink
when there is memory pressure, but tmpfs does not allow for that.
Pending investigation of the right way to handle this, change the
default value of the vfs.tmpfs.memory_percent sysctl to 100 as a
workaround.  The sysctl can be set to 95 to get back to the previous
default.
2024-01-23 12:46:31 -06:00
John Baldwin a82470212b powerpc: Add RF_LITTLEENDIAN resource flag
If this powerpc-specific flag is set on a resource, then the
little-endian bus tag is always used when mapping that resource.

Make use of this flag in the mpc85xx/fsl_sata driver to avoid setting
the SATA BAR's bus tag after bus_alloc_resource.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D43553
2024-01-23 09:38:36 -08:00
John Baldwin 3cf553288b simplebus: Consistently map SYS_RES_IOPORT to SYS_RES_MEMORY
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43442
2024-01-23 09:38:25 -08:00
John Baldwin 0b60d7a600 ofw_pcib: Use bus_generic_rman_*
- Implement bus_map/unmap_resource pulling bits from the previous
  ofw_pcib_activate/deactivate_resource.  One difference here is that
  the bus_unmap_resource implementation uses bus_space_unmap instead
  of pmap_unmapdev as a complement to the existing use of bus_space_map.

- Use bus_generic_rman_* in various routines for memory and I/O port
  resources.

- Use pci_domain_* for PCI_RES_BUS in
  ofw_pcib_activate/deactivate_resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43441
2024-01-23 09:38:09 -08:00
John Baldwin a3d6e0de1c powerpc: Fix bus_space_unmap
Previously it failed to compile since the macro passed too many
arguments to the function.  Fix by adding the bus handle to the
function and adding an implementation that calls pmap_unmapdev.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D43440
2024-01-23 09:37:53 -08:00
John Baldwin e5c6dbd576 arm64 thunder: Use bus_generic_rman_* in the pcie_pem driver
- Implement bus_map/unmap_resource pulling bits from the previous
  thunder_pem_activate/deactivate_resource.

- Use bus_generic_rman_* in various routines for memory and I/O port
  resources.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43439
2024-01-23 09:37:41 -08:00
John Baldwin 4e1d94d997 arm mv_pcib: Use bus_generic_rman_*
- Implement bus_get_rman pulling bits from mv_pcib_alloc_resource.

- Implement bus_map/unmap_resource pulling bits from
  mv_pcib_activate/deactivate_resource.

- Use bus_generic_rman_* to handle memory and I/O resources for
  mv_pcib_alloc/activate/adjust/deactivate/release_resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43438
2024-01-23 09:37:30 -08:00
John Baldwin faeb273e7a arm nexus: Use bus_generic_rman_*
- Implement bus_get_rman pulling bits from nexus_alloc_resource.

- Implement bus_map/unmap_resource pulling bits from
  nexus_activate/deactivate_resource.

- Use bus_generic_rman_* for
  bus_alloc/adjust/activate/deactivate/release_resource except for
  custom interrupt activate/deactivate logic still in
  nexus_activate/deactivate_resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43437
2024-01-23 09:37:13 -08:00
John Baldwin 7b5a5e4eef powerpc nexus: Use bus_generic_rman_*
Reviewed by:	imp, jhibbits
Differential Revision:	https://reviews.freebsd.org/D43436
2024-01-23 09:37:02 -08:00
John Baldwin af081ec6f7 powerpc powermac: Use bus_generic_rman_*
Implement bus_map/unmap_resource and add bus_get_rman for use by
bus_generic_rman_*.

Reviewed by:	imp, jhibbits
Differential Revision:	https://reviews.freebsd.org/D43435
2024-01-23 09:36:49 -08:00
John Baldwin 5a7e717fb7 powerpc mpc85xx: Use bus_generic_rman_*
- Consistently map SYS_RES_IOPORT to SYS_RES_MEMORY for
  bus_activate/deactivate/adjust/release_resource.

- Implement bus_map/unmap_resource.

- Add an implementation of bus_adjust_resource.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D43434
2024-01-23 09:36:37 -08:00
John Baldwin d7c16b3334 powerpc psim: Use bus_generic_rman_*
- Split out bits of iobus_activate/deactive_resource to implement
  iobus_map/unmap_resource.

- Use bus_generic_rman_* methods in several bus methods to handle
  memory and I/O port resources.

- Add an implementation of bus_adjust_resource.

Reviewed by:	imp, jhibbits
Differential Revision:	https://reviews.freebsd.org/D43433
2024-01-23 09:36:26 -08:00
John Baldwin 3dd55df982 powerpc ps3bus: Use bus_generic_rman_*
- Split out part of ps3bus_activate_resource into a
  ps3bus_map_resource method.

- Implement ps3bus_unmap_resource via pmap_unmapdev.

- Use bus_generic_rman_* to add bus_adjust_resource,
  bus_deactivate_resource, and bus_release_resource methods.

Reviewed by:	imp, jhibbits
Differential Revision:	https://reviews.freebsd.org/D43432
2024-01-23 09:36:12 -08:00
John Baldwin 9c4effb106 hyperv vmbus_pcib: Use pci_domain_*_bus for PCI_RES_BUS resources
Specifically for bus_activate/adjust/deactivate_bus methods.

Differential Revision:	https://reviews.freebsd.org/D43431
2024-01-23 09:35:58 -08:00
John Baldwin 31e15e531c x86: Use pci_domain_[de]activate_bus for PCI_RES_BUS resources
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43430
2024-01-23 09:35:47 -08:00
John Baldwin e9eb353b32 pci_host_generic: Use pci_domain_[de]activate_bus for PCI_RES_BUS resources
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43429
2024-01-23 09:35:36 -08:00
John Baldwin c2d4fef658 acpi_pcib: Use pci_domain_[de]activate_bus for PCI_RES_BUS resources
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43428
2024-01-23 09:35:22 -08:00
John Baldwin 23e3b83ab6 pcib: Add helper routines for [de]activating PCI_RES_BUS resources
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43427
2024-01-23 09:35:08 -08:00
Elliott Mitchell a8b2189c90 arm/mpic: remove empty pic_init_secondary() hook
The default hook does nothing, so having an empty handler is pointless.
Simple cleanup.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D40475
2024-01-23 02:52:37 +00:00
Gordon Bergling e125371fb6 dwc: Fix two typos in a source code comment
- s/recevied/received/
- s/descriptr/descriptor/

MFC after:	3 days
2024-01-22 22:03:29 +01:00
Gordon Bergling 97a4045aaf virtio(4): Fix a typo in a source code comment
- s/recevied/received/

MFC after:	3 days
2024-01-22 21:59:06 +01:00
Gordon Bergling d743711016 usb: Fix a typo in a source code comment
- s/recevied/received/

MFC after:	3 days
2024-01-22 21:57:06 +01:00
Gordon Bergling b2c48aa4d1 vmd(4): Fix typos in source code comments
- s/harwdare/hardware/

MFC after:	3 days
2024-01-22 21:55:33 +01:00
Gordon Bergling c1ada39783 net80211: Fix a typo in a source code comment
- s/recevied/received/

MFC after:	3 days
2024-01-22 21:54:36 +01:00