Commit Graph

148338 Commits

Author SHA1 Message Date
John Baldwin
c70e615051 udf: Reject read requests with an invalid length
- If the size is negative or if rounding it up to a multiple of
  the block size overflows, fail the read request with ERANGE.

- While here, add a sanity check that the ICB length for the root
  directory is at least as long as a minimum-sized file entry.

PR:		257768
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	1 week
Sponsored by:	FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41220
2023-08-04 16:40:19 -07:00
Konstantin Belousov
9e6941a2c7 udf: reject invalid block sizes from lvd
PR:	272893
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-05 01:49:36 +03:00
Michael Tuexen
efb04fb404 sctp: improve consistency of acc and ccc handling in snd buffer
Don't clear the counters for the socket snd buffer when
shutdown(..., SHUT_WR) or shutdown(..., SHUT_RDWR) is called.
This was causing the system to panic() when SCTP pf tests were
running.

Reported by:	dchagin, kp
MFC after:	1 week
2023-08-04 08:32:25 +02:00
Doug Moore
ccdb28275d vm_phys_enq_range: no alignment assert for npages==0
Do not assume that when vm_phys_enq_range is passed npages==0 that the
vm_page argument is valid in any way, much less that it has a
page-aligned address. Just don't look at it. Assert nothing about it.

Reported by:	karels
Differential Revision:	https://reviews.freebsd.org/D41317
2023-08-04 13:41:59 -05:00
Andrew Turner
a0e20c0ded Limit the number of CPUs in the gicv1/2 driver
The GICv2 can only send IPIs to 8 CPUs. Because of this it should only
be in machines with no more than 8 cores.

Create a new macro to hold this limit to reduce the size of the softc.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41322
2023-08-04 18:47:47 +01:00
Mark Johnston
78cc000cba amd64: Increase sanitizers' static shadow memory reservation
Because KASAN shadows the kernel image itself (KMSAN currently does
not), a shadow mapping of the boot stack must be created very early
during boot.  pmap_san_enter() reserves a fixed number of pages for the
purpose of creating and mapping this shadow region.

After commit 789df254cc ("amd64: Use a larger boot stack"), it could
happen that this reservation is insufficient; this happens when
bootstack crosses a PAGE_SHIFT + KASAN_SHADOW_SCALE_SHIFT boundary.
Update the calculation to take into account the new size of the boot
stack.

Fixes:		789df254cc ("amd64: Use a larger boot stack")
Sponsored by:	The FreeBSD Foundation
2023-08-04 12:38:24 -04:00
Stéphane Rochoy
8e4aa6317e nctgpio: Enable all the 9 groups for NCT6116D and remove FIXMEs
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/810
2023-08-04 11:27:54 -04:00
Stéphane Rochoy
301e69218c ncthwm: Use sysctl_handle_16 to match CTLTYPE_U16
Pull Request:	https://github.com/freebsd/freebsd-src/pull/810
2023-08-04 11:23:42 -04:00
Kristof Provost
76afcbb524 pf: handle multiple IPv6 fragment headers
With 'scrub fragment reassemble' if a packet contains multiple IPv6
fragment headers we would reassemble the packet and immediately
continue processing it.

That is, we'd remove the first fragment header and expect the next
header to be a final header (i.e. TCP, UDP, ICMPv6, ...). However, if
it's another fragment header we'd not treat the packet correctly.
That is, we'd fail to recognise the payload and treat it as if it were
an IPv6 fragment rather than as its actual payload.

Fix this by restarting the normalisation on the reassembled packet.
If there are multiple fragment headers drop the packet.

Reported by:	Enrico Bassetti bassetti@di.uniroma1.it (NetSecurityLab @ Sapienza University of Rome)
MFC after:	instant
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-08-04 15:23:49 +02:00
Dmitry Chagin
bbe017e041 linux(4): Add a dedicated ioprio system calls
On Linux these system calls have an effect only when used in conjuction
with an I/O scheduler that supports I/O priorities. If no I/O scheduler
has been set for a thread, then by defaut the I/O priority will follow
the CPU nice value. Due to FreeBSD lack of I/O scheduler facilities, the
default Linux behavior is implemented.

Ubuntu 23.04 debootstrap requires Linux ionice which depends on these
syscalls.

Differential Revision:	https://reviews.freebsd.org/D41153
MFC after:		1 month
2023-08-04 16:03:57 +03:00
Dmitry Chagin
b5c0b9555d linux(4): Regen for ioprio syscalls
MFC after:		1 month
2023-08-04 16:03:57 +03:00
Dmitry Chagin
1c83154e49 linux(4): Modify ioprio syscalls to match Linux
MFC after:		1 month
2023-08-04 16:03:55 +03:00
Gordon Bergling
f0ab805200 arm64-iommu: Fix a typo in a kernel message
- s/endianess/endianness/

MFC after:	5 days
2023-08-04 13:52:36 +02:00
Andrew Turner
a2afd7b818 Remove MAXCPUS from the gicv3 driver
We create a static array of pointers to per-CPU data. Because the cpuid
space on arm64 is not sparse there is no need to add an extra level of
indirection. Move to use mallocarray to allocate the redistributors as
a single array.

Sponsored by:	Arm Ltd
2023-08-04 10:50:09 +01:00
Andrew Turner
4350a03fef arm64: Make dpcpu static
We don't use this directly outside this file so it can be static.

Sponsored by:	Arm Ltd
2023-08-04 10:50:09 +01:00
Kevin Bowling
f1b5488f7b e1000: Enable TSO for lem(4) and em(4)
Most em(4) devices now enjoy TSO and TSO6, matching NetBSD and Linux
defaults.

A prior commit automasks TSO on 10/100 Ethernet due to errata and other
bugs for IPv6 were fixed recently allowing this.

Mike Karels identified a performance anomaly on Intel 82574L devices.
These are multiqueue enabled on FreeBSD since the conversion to
iflib.  I am investigating whether this can be fixed, in the mean time
MSI-X with checksum offloads remain default.

i219 SPT devices have an errata that downclocks the DMA engine, which
results in TSO not being able to acheive line rate.  Therefore, it is
disabled on:
* Intel(R) I219-LM and I219-V SPT
* Intel(R) I219-LM and I219-V SPT-H (2)
* Intel(R) I219-LM and I219-V LBG (3)
* Intel(R) I219-LM and I219-V SPT (4)
* Intel(R) I219-LM and I219-V SPT (5)

Many lem(4) devices enjoy TSO, exceptions being 82542, 82543, 82547.
TSO6 may be possible for some chipsets but I am still working through
my testing matrix and that is hidden behind hw.em.unsupported_tso.

If you encounter issues, you may disable TSO with for example:
ifconfig em0 -tso -tso6.
I ask to be informed of any deviations from normal operation requiring
this.

Thanks to cc@ for access to emulab.net.

On a sample I219 system it saves about 16% CPU on IPv4 and 19% on IPv6.

iperf3 -Vc reported numbers:
total%	user%	system%

IPv4 TSO
21.3	7	14.4
21.4	6	15.4
21.5	6	15.5

IPv4 no TSO
36.8	5.4	31.4
38.5	5.1	33.5
38.2	5.7	32.6

IPv4 no TSO no TXCSUM
45.1	5.8	39.3
46	6.3	39.7
46.2	5.9	40.4

IPv6 TSO6
21.7	5.4	16.3
21.6	5.1	16.5
21.9	5.6	16.3

IPv6 no TSO6
41.2	5.2	36
41	5.1	36
40.8	5.2	35.7

IPv6 no TSO6 no TXCSUM6
49	5.9	43.1
48.8	4.9	43.9
49	5.6	43.4

Tested by:	cc (lem(4)), karels (82574L)
MFC after:	3 months
Relnotes:	yes
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D41170
2023-08-03 15:35:28 -07:00
Ed Maste
9051987e40 amd64: Bump MAXCPU to 1024 (from 256)
Hardware with more than 256 CPU cores is currently available and will
become increasingly common over FreeBSD 14's lifetime.  Increase MAXCPU
in the amd64 GENERIC kernel configuration to 1024.

Earlier commits increased some related limits.  These prerequisite
commits include at least:

- d7ed40243769 Increase MAX_APIC_ID safeguard to 0x800
- d1639e43c5 cpuset: increase userland maximum size to 1024

Global and allocated arrays sized by MAXCPU result in excessive bloat
on systems with lower core counts.  In addition, some code used u_char
(8 bits) to hold a CPU index, which is not valid if MAXCPU is greater
than 256.

A number of recent commits addressed these sorts of issues, including
at least:

- 133935d26f pf: atomically increment state ids
- 74ac712f72 vmm: Dynamically allocate a couple of per-CPU state save areas
- 78cfa762eb callout: Move per-CPU callout state into the dpcpu region
- 42f722e721 amd64: store pcids pmap data in pcpu zone
- 9801e7c275 smp_topo: dynamically allocate group array
- 9fb6718d1b smp: Dynamically allocate the stoppcbs array
- 2bb16c6352 x86: retire use of intr_bind

There are some additional allocations still to be converted and
more scalability work is required to make effective use of very high
core count systems, but this change allows us to boot on these systems
and provides a Kernel Binary Interface (KBI) for the FreeBSD 14 release
that supports these configurations.

Special thanks to AMD for providing hardware to test these changes.

PR:		269572
Reviewed by:	des
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36838
2023-08-03 17:41:26 -04:00
Marius Strobl
7ff9ae90f0 iflib(9): Remove support for cloning pseudo interfaces
This code was used by the first incarnation of wg(4) and is dead ever
since f187d6dfbf has removed the latter
again. Moreover, this code matched iflib(4) like a square peg fits in
a round hole, was incomplete and despite some hacks still tailored to
VPC and wg(4) but not generic. In effect, this reverts the following:
09f6ff4f1a (w/ its "ancillary changes")
9aeca21324
1f93e931d9
0f9544d03e
0dd691b412

Reviewed by:		erj, kbowling
Differential Revision:	<https://reviews.freebsd.org/D41196>
2023-08-03 23:10:18 +02:00
Elliott Mitchell
eee6537665 x86: remove intr_bind
`intr_bind(u_int vector, u_char cpu);` looked suspicious since
everywhere else "cpu" is a u_int and >256 processors isn't unreasonable
now.  `intr_bind()` is not used anywhere in FreeBSD (now, after commit
bf42f3738087).  Time to remove.

Relnotes:	Yes
Reviewed by:	mjg
Differential Revision: https://reviews.freebsd.org/D36901
2023-08-03 17:01:56 -04:00
Elliott Mitchell
2bb16c6352 x86: retire use of intr_bind
`intr_bind(u_int vector, u_char cpu);` looked suspicious since
everywhere else "cpu" is a u_int and >256 processors isn't unreasonable
now.

Reviewed by:	mjg
Differential Revision: https://reviews.freebsd.org/D36901
2023-08-03 17:01:18 -04:00
Yuichiro Naito
61a8231d15 ixv: Separate VFTA table for each interface
The vlan setting is independent for each interface. Use VFTA table in
'struct ixgbe_softc' that is already defined.

This pull request fixes following bug scenario.

    create ixv0.10
    create ixv1.10
    destroy ixv1.10
    create ixv0.11
    ixv0.10 no longer receives vlan 10 packets.

In this case, destroying ixv1.10 affects to ixv0.

MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/774
2023-08-03 13:36:21 -07:00
Andrew Turner
f12952eaee arm64: Comment out some ID registers
Older toolchains don't support reading these registers. Until a fix is
added comment them out.

Reported by:	jhb
Sponsored by:	Arm Ltd
2023-08-03 19:13:17 +01:00
Vladimir Kondratyev
ed77b89670 Bump __FreeBSD_version to 1400094 for HID KPI changes 2023-08-03 19:10:51 +03:00
Vladimir Kondratyev
7d380b986a spibus(4): Add support for ACPI-based children enumeration
When spibus is attached as child of Intel SPI controller it scans all
ACPI nodes for "SPI Serial Bus Connection Resource Descriptor" described
in section 19.6.126 of ACPI specs.
If such a descriptor is found, SPI child is added to spibus, it's SPI
chip select, mode, clock, IRQ resource and ACPI handle are added to ivars.
Existing ACPI bus-hosted child is deleted afterwards.
Apple ACPI SPI extensions are supported.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41248
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
5adcec04b5 intelspi: Add support for ddb/kdb -compatible polled mode
Required for Apple and Microsoft -compatible HID-over-SPI drivers.

Most logic was already implemented in commit 3c08673438
"spibus: extend API: add cs_delay ivar, KEEP_CS and NO_SLEEP flags".
It dissallowed driver sleeps in the interrupt context. This commit
extends this feature to handle ddb/kdb context with following:
- Skip driver locking if SPI functions were called from kdb/ddb.
- Reinitialize controller if kdb/ddb initiated SPI transfer has
  interrupted another already running one. Does not work very
  reliable yet.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41247
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
4151ac9f12 hidbus(4): Use generic hid methods to start and stop interrupts 2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
4b1712817e hid: Add child device parameter to HID methods
Some devices like Apple HID-over-SPI may contain more than one report
descriptors necessitating creation of multiple hidbus children.
Add indentificator of child devices to distinct them.
No functional changes intended.

Differential Revision:	https://reviews.freebsd.org/D41246
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
b109946d75 intelspi: Release LPSS reset on Sunrise Point controllers.
MacBookPro 14.1 SPI controller requires that to start functioning.

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41245
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
f56dbe7ad9 intelspi: Move ACPI/PCI ids table out of header file.
There is no reason to store it multiple times.

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41244
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
c6889cbf66 spibus(4): Allow IRQ resource to be released
IRQ Resource is allocated on spibus(4). We must release it here too
rather than propagate request down the tree.

Fixes:	4dd8db62e9 ("Add IRQ resource to SPIBUS")

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41243
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
2a04c3a47b intelspi: Add generic resource methods to bus interface
That allows intelspi grandchildren to allocate IRQs

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41242
2023-08-03 19:10:50 +03:00
Vladimir Kondratyev
16ab2c318d intelspi: don't leak spibus on detach.
MFC after:      1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41241
2023-08-03 19:10:49 +03:00
Vladimir Kondratyev
1e55a13062 spibus(4): Skip bus_generic_detach() on device detach
device_delete_children() detaches all children too.

MFC after:	1 month
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D41240
2023-08-03 19:10:49 +03:00
Doug Moore
c9b06fa527 vm_phys_enqueue_contig: handle npages==0
By letting vm_phys_enqueue_contig handle the case when npages == 0,
the callers can stop checking it, and the compiler can stop
zero-checking with every call to ffs(). Letting vm_phys_enqueue_contig
call vm_phys_enqueue_contig for part of its work also saves a few
bytes.

The amd64 object code shrinks by 128 bytes.

Reviewed by:	kib (previous version)
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D41154
2023-08-03 09:19:48 -05:00
Mitchell Horne
9c0a2d522f hwpmc_armv7: plug memory leak
Free allocated per-CPU structures in the pcpu_fini and finalize methods.

While here, add debug trace entries to these methods.

Reviewed by:	jkoshy, andrew
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41269
2023-08-03 11:13:10 -03:00
Mitchell Horne
8bdceaecab hwpmc_arm64: plug memory leak
Free allocated per-CPU structures in the pcpu_fini and finalize methods.

While here, add debug trace entries to these methods.

Reviewed by:	jkoshy, andrew
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41268
2023-08-03 11:13:03 -03:00
Mitchell Horne
32e47f6272 sys/README.md: Add a section for documentation
Add web links to intro(9) and the Architecture Handbook.

Reviewed by:	lwhsu, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41253
2023-08-03 11:07:41 -03:00
Kevin Bowling
a93409fc3c ixgbe: Warn once for unsupported SFPs
The driver belabors the point about unsupported SFPs, printing multiple
times on link up. Limit it to once.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39785
2023-08-02 23:00:58 -07:00
Kevin Bowling
2ddf24f8f5 e1000: Automask TSO on lem(4)/em(4) 10/100 Ethernet
This feature masks TSO capability when a link comes up at 10 or 100mbit
due to errata on the chips.  This behavior matches previous versions of
FreeBSD as well as NetBSD and Linux.

A tunable, hw.em.unsupported_tso may be set if the admin desires to
disabling automasking and configure TSO settings manually.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41170
2023-08-02 22:52:55 -07:00
Justin Hibbits
0c783a37d5 mii: Add the Broadcom BCM54616S ID to the list
Obtained from:	Juniper Networks, Inc.
Sponsored by:	Juniper Networks, Inc.
2023-08-02 10:47:40 -04:00
Mark Johnston
bd16c274c3 kdb: Permit a NULL thread credential in kdb_backend_permitted()
Early during boot, thread0 runs with td->td_ucred == NULL.  This is
fixed up in proc0_init() at SI_SUB_INTRINSIC.  If a panic occurs before
then, rather than dereference a NULL pointer, simply allow the thread to
enter KDB.

Reported by:	stevek
Reviewed by:	mhorne, stevek
MFC after:	1 week
Fixes:		cab1056105 ("kdb: Modify securelevel policy")
Differential Revision:	https://reviews.freebsd.org/D41280
2023-08-02 09:15:08 -04:00
Gordon Bergling
29eab3e4e0 linux(4): Fix two typos in source code comments
- s/decriptors/descriptors/

MFC after:	3 days
2023-08-02 11:55:30 +02:00
Gordon Bergling
2f0e0bd506 elf(3): Fix a typo in a source code comment
- s/speciaal/special/

MFC after:	3 days
2023-08-02 11:51:56 +02:00
Gordon Bergling
d3367c35cb isp(4): Fix a typo in a source code comment
- s/Constatns/Constants/

Obtained from:	NetBSD
MFC after:	3 days
2023-08-02 11:48:46 +02:00
Doug Moore
b7370efade Revert "vm_phys_enqueue_contig: handle npages==0"
This reverts commit 1a7fcf6d51.

Peter Holm reported a problem, so I'm reverting now and looking for
the problem later.
2023-08-02 04:33:40 -05:00
Gordon Bergling
11892bc710 nfsserver: Fix a typo in a source code comment
- s/restared/restarted/

MFC after:	3 days
2023-08-02 11:27:30 +02:00
Gordon Bergling
586eda6b24 cam(4): Fix a typo in a source code comment
- s/uppper/upper/

MFC after:	3 days
2023-08-02 11:14:53 +02:00
Gordon Bergling
a924b48579 usb(4): Fix a typo in a source code comment
- s/determin/determine/

MFC after:	3 days
2023-08-02 11:04:24 +02:00
Kristof Provost
6736511623 arm64: enable kern.conftxt
Match other platforms, include the kernel config in the build.

Reviewed by:	emaste
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41284
2023-08-02 10:51:44 +02:00
Gordon Bergling
cfd05de194 netpfil: Fix a typo in a source code comment
- s/interprted/interpreted/

MFC after:	3 days
2023-08-02 09:41:29 +02:00
Gordon Bergling
b73763fc10 vnic: Fix a typo in a source code comment
- s/Enabele/Enable/

MFC after:	3 days
2023-08-02 09:33:35 +02:00
Gordon Bergling
3514686b34 aic7xxx: Fix two typos in source code comments
- s/reslection/reselection/

MFC after:	3 days
2023-08-02 09:20:17 +02:00
Gordon Bergling
7eb8fbfb04 psm(4): Fix a typo in a source code comment
- s/diable/disable/

MFC after:	3 days
2023-08-02 09:14:04 +02:00
Gordon Bergling
734c9698d9 et(4): Fix a typo in a source code comment
- s/diabled/disabled/

MFC after:	3 days
2023-08-02 09:09:56 +02:00
Doug Moore
1a7fcf6d51 vm_phys_enqueue_contig: handle npages==0
By letting vm_phys_enqueue_contig handle the case when npages == 0,
the callers can stop checking it, and the compiler can stop
zero-checking with every call to ffs(). Letting vm_phys_enqueue_contig
call vm_phys_enqueue_contig for part of its work also saves a few
bytes.

The amd64 object code shrinks by 80 bytes.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41154
2023-08-01 22:12:00 -05:00
John Baldwin
83453b46e8 mmc_xpt: Update function name in debug trace
Reported by:	mav
Fixes:		7eb538974c cam mmc_xpt/nvme_xpt: Add _sbuf variants of {an,de}nounce xport and proto ops
2023-08-01 16:14:58 -07:00
John Baldwin
b2c44f1fc1 cam: Remove non-sbuf announce/denounce proto and xport ops
Reviewed by:	mav, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41264
2023-08-01 15:25:38 -07:00
John Baldwin
0a57cdd971 cam_xpt: Reimplement xpt_*nounce_periph in terms of the _sbuf versions
Use an sbuf that drains to printf to avoid duplicating code in the two
versions of each function.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41263
2023-08-01 15:24:36 -07:00
John Baldwin
b82711764c cam_xpt: Remove fallbacks for non-sbuf protocol methods
This includes removing the kern.cam.announce_nosbuf sysctl.

Reviewed by:	mav, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41262
2023-08-01 15:24:10 -07:00
John Baldwin
7eb538974c cam mmc_xpt/nvme_xpt: Add _sbuf variants of {an,de}nounce xport and proto ops
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41261
2023-08-01 15:23:25 -07:00
John Baldwin
32734eb14c mmc_xpt: Remove dubious end of mmc_print_ident
The end of this function finishes the passed in sbuf, calls printf
manually on the contents, and then clears it.  The caller then tries
to print the resulting sbuf.  This works currently but will not work
for future callers that pass in an external sbuf to be appended to.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41260
2023-08-01 15:20:53 -07:00
John Baldwin
76b2e3907c cam xpt_*nounce_periph*: Various fixes for periphs without a protocol
If the periph doesn't have a valid protocol, these routines emit
fallback messages.  However, the fallback messages duplicated the
periph name and unit number, and in the case of *denounce* included a
spurious newline.

Reviewed by:	mav, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41177
2023-08-01 15:20:25 -07:00
John Baldwin
0be27bde5f cam/nvme: Remove spurious newline during periph detach announcement
Other protocol denounce routines use a "short" variant of announce
that does not include a trailing newline.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41176
2023-08-01 15:19:50 -07:00
Akio Morita
323a94afb6 amdsmn(4), amdtemp(4): add support for Zen 4
Zen 4 support, tested on Ryzen 9 7900

Reviewed by:	imp (previous version), mhorne
Approved by:	mhorne
Obtained from:	http://jyurai.ddo.jp/~amorita/diary/?date=20221102#p01
Differential Revision:	https://reviews.freebsd.org/D41049
2023-08-01 23:21:17 +02:00
Warner Losh
cf0a543f1f cam: Log more error codes
Log CAM_DEV_NOT_THERE status CCBs because they get dropped if a drive
disappears and these requests timeout or are cancelled. It's useful to
know the outstanding commands for failure analysis. Log
CAM_NVME_STATUS_ERROR status CCBs to bring in NVMe errors (this will be
more important in future commits that expand the information logged).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D41168
2023-08-01 14:51:54 -06:00
Jonathan T. Looney
ff3d1a3f9d frag6: Avoid a possible integer overflow in fragment handling
Reviewed by:	kp, markj, bz
Approved by:	so
Security:	FreeBSD-SA-23:06.ipv6
Security:	CVE-2023-3107
2023-08-01 15:45:41 -04:00
Mark Johnston
d0e4e53ebd vm_map: Add a macro to fetch a map entry's split boundary index
The resulting code is a bit more concise.  No functional change
intended.

Reviewed by:	alc, dougm, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41249
2023-08-01 10:10:02 -04:00
Gordon Bergling
135c2b7156 sk(4): Fix a typo in a source code comment
- s/nomral/normal/

MFC after:	3 days
2023-08-01 07:50:45 +02:00
Doug Moore
c2cbd7ffa7 isa_common: find next bit faster
Since ffs is no longer implemented with a linear search, find_next_bit
can work in constant time, with masking.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D41251
2023-07-31 21:02:56 -05:00
Konstantin Belousov
fa3cf6cdc6 cd9660: do not leak buffers in cd9660_rrip_loop()
Reported by:	 Robert Morris <rtm@lcs.mit.edu>
PR:	272856
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-01 01:55:13 +03:00
John Baldwin
f561c2ec08 memdesc: Add routines for copying data to/from memory descriptors
These are modeled on the API used for m_copydata/m_copyback and the
crypto buffer APIs.  One day it might be nice to reduce the
proliferation of these by adding cursors and using memdesc directly
for crypto request buffers.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40615
2023-07-31 13:24:44 -07:00
John Baldwin
56e9a0136f gsb_crc32: Fix a warning when compiled in userland.
crc32_tab[] is only exposed as a global in <sys/gsb_crc32.h> for the
kernel, not for userland.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40614
2023-07-31 13:24:18 -07:00
Kevin Bowling
e1353dcb63 e1000: Fix lem(4)/em(4) TSO6
* Fix TSO6 by specializing IP checksum insertion and following Intel SDM
  values for IPv6.
* Remove unnecessary 82544 IP-bit handling
* Remove TSO6 from lem(4) capabilitities

Reviewed by:	erj (earlier version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41170
2023-07-31 08:19:14 -07:00
Vladimir Kondratyev
fc14525044 nvme(4): detect S3X NVMe controller in 2016-2017 MacBooks
Adds support for detection of the S3X NVMe controller found in the
13" MacBook Pro 2017 without Touch Bar (MacBook14,1)
It is known to be used in following MacBooks:
- Retina MacBook 2016 (MacBook9,1)
- 13" MacBook Pro 2016 without Touch Bar (MacBook13,1)
- 13" MacBook Pro 2016 with Touch Bar (MacBook13,2)
2023-07-31 17:33:14 +03:00
Vladimir Kondratyev
d101156ec6 intelspi(4): Add missing driver mutex unlock in NO_SLEEP mode
Fixes: 1f40866feb ("intelspi: add PCI attachment (Lynx/Wildcat/Sunrise Point)")

MFC after:	1 week
2023-07-31 17:30:24 +03:00
Doug Moore
ac0572e660 radix_tree: compute slot from keybarr
The computation of keybarr(), the function that determines when a
search has failed at a non-leaf node, can be done in a way that
computes the 'slot' value when keybarr() fails, which is exactly when
slot() would next be invoked. Computing things this way saves space in
search loops.

This reduces the amd64 coding of the search loop in vm_radix_lookup
from 40 bytes to 28 bytes.

Reviewed by:	alc
Tested by:	pho (as part of a larger change)
Differential Revision:	https://reviews.freebsd.org/D41235
2023-07-30 15:12:06 -05:00
Mark Johnston
5ad29bc8d4 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
2023-07-30 11:12:35 -04:00
Doug Moore
38f5cb1bfb 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
2023-07-30 01:20:07 -05:00
Dmitry Chagin
dbac8474fe vfs: Deleting a doubled inclusion of sys/capsicum.h
Reviewed by:
Differential Revision:	https://reviews.freebsd.org/D41223
MFC after:		1 week
2023-07-29 11:21:58 +03:00
Dmitry Chagin
67116c6905 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
2023-07-29 11:21:35 +03:00
Kevin Bowling
38588749af 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
2023-07-28 18:17:35 -07:00
Michael Tuexen
c620788150 sctp: keep sb_acc and sb_ccc in sync
PR:		260116
MFC after:	1 week
2023-07-28 15:16:23 +02:00
Michael Tuexen
b279e84a47 sctp: improve consistency
This is simplifying a patch to address PR 260116.

PR:		260116
MFC after:	1 week
2023-07-28 14:36:11 +02:00
Alan Cox
3d7c37425e 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.
2023-07-28 15:13:13 -05:00
Warner Losh
e474a8e243 cam: Log errors from passthru commands
Since a30ecd42b8 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
2023-07-28 12:11:21 -06:00
Doug Moore
2d2bcba7ba 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
2023-07-28 11:39:52 -05:00
Mark Johnston
dd24d475d5 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
2023-07-28 09:34:38 -04:00
Andrew Turner
53e1af5a10 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
2023-07-28 12:53:02 +01:00
Andrew Turner
8c111e5b37 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
2023-07-28 12:53:02 +01:00
Andrew Turner
0766dde9b5 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
2023-07-28 12:53:02 +01:00
Andrew Turner
22235b631b 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
2023-07-28 12:53:02 +01:00
Andrew Turner
c65679143f arm64: Decode the ID_AA64MMFR3_EL1 register
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40893
2023-07-28 12:53:02 +01:00
Andrew Turner
2134cfe793 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
2023-07-28 12:53:02 +01:00
Andrew Turner
284f91de8b arm64: Update the ID_AA64MMFR1_EL1 fields
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40891
2023-07-28 12:53:01 +01:00
Andrew Turner
b21402d058 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
2023-07-28 12:53:01 +01:00
Andrew Turner
de01309926 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
2023-07-28 12:53:01 +01:00
Andrew Turner
4182f58172 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
2023-07-28 12:53:01 +01:00
Andrew Turner
6fd44e5f53 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
2023-07-28 12:53:01 +01:00
Kristof Provost
680ad06f90 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
2023-07-28 11:32:39 +02:00
Dmitry Chagin
4281dab8bc 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
2023-07-28 11:56:59 +03:00
Dmitry Chagin
5440e7017a 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
2023-07-28 11:55:31 +03:00
Warner Losh
7872131605 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
2023-07-27 22:28:01 -06:00
Jessica Clarke
8a6ab0f71f 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 ec41a96daa ("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:	ec41a96daa ("sys: Switch the kernel's C standard from C99 to GNU99.")
2023-07-28 05:08:43 +01:00
Kevin Bowling
cbcab907f8 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.
2023-07-27 15:58:05 -07:00
Przemyslaw Lewandowski
04d4e34538
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
2023-07-27 15:47:12 -07:00
Kirk McKusick
831b1ff791 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
2023-07-27 15:27:36 -07:00
Mark Johnston
1083a8cd85 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
2023-07-27 16:02:03 -04:00
Mark Johnston
ca6cd604c8 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
2023-07-27 16:02:03 -04:00
Mark Johnston
640e5cb304 kmsan: Add a comment explaining why KMSAN doesn't shadow above KERNBASE
Sponsored by:	The FreeBSD Foundation
2023-07-27 16:01:58 -04:00
Mark Johnston
96c2538121 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
2023-07-27 15:44:52 -04:00
Mark Johnston
1be56e0bb1 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
2023-07-27 15:44:00 -04:00
Michael Tuexen
cf32543fa4 tcp: document that conditional fields in tcpcb should be at the end
Reviewed by: 	rscheff, Peter Lei
Sponsored by:	Netflix, Inc.
2023-07-27 09:02:19 +02:00
Shailend Chand
74861578d9 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
2023-07-26 22:36:42 -07:00
Alan Cox
5ec2d94ade 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
2023-07-27 00:25:53 -05:00
Gleb Smirnoff
e3ba0d6add inpcb: do not copy so_options into inp_flags2
Since f71cb9f748 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
2023-07-26 20:35:42 -07:00
Gleb Smirnoff
a43e7a96b6 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
2023-07-26 20:35:30 -07:00
Konstantin Belousov
474708c334 fork1(): properly track the state of the pg_killsx lock
Reported by:	dchagin
Fixes:	232b922cb3
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-07-27 02:33:58 +03:00
Michael Tuexen
ab65c64bc4 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
2023-07-26 16:22:13 +02:00
Richard Scheffenegger
b352ef58c2 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
2023-07-27 00:42:26 +02:00
Kirk McKusick
6f0ca273a3 Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-26 14:50:02 -07:00
Konstantin Belousov
232b922cb3 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
2023-07-26 18:13:02 +03:00
Konstantin Belousov
dfe172484d 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
2023-07-26 18:12:55 +03:00
Konstantin Belousov
aaa924138a Revert "killpg(): close a race with fork(), part 2"
This reverts commits 81a37995c7 and
565a343ae3.

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
2023-07-26 18:12:55 +03:00
Marius Strobl
4ef1c6f75d 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:
094fcb157d
a7d366e958
ba8d50d08b

The alignment example d9711c28ef
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.
2023-07-26 13:16:12 +02:00
Marius Strobl
29fe5efc8a 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 812403402e. However,
the latter function in turn was based on the sparc64 counterpart I
previously added in 2b2250b149.
2023-07-26 13:14:22 +02:00
Marius Strobl
8a03087223 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
2023-07-26 13:14:22 +02:00
Marius Strobl
e82d7b2952 gif(4): Revert in{,6}_gif_output() misalignment handling
The code added in c89c8a1029 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, 8018ac153f
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.
2023-07-26 13:14:22 +02:00
Alan Cox
a98a0090b2 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
2023-07-26 00:37:13 -05:00
Alan Cox
50d663b14b 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:	d8e6f4946c "vm: Fix anonymous memory clustering under ASLR"
Differential Revision:	https://reviews.freebsd.org/D41159
2023-07-26 00:24:50 -05:00
Shivank Garg
215bab7924 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
2023-07-26 00:07:57 +00:00
Mike Karels
d5d97bed4a 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
2023-07-25 18:59:26 -05:00
Kirk McKusick
4a3444428d Comment cleanup.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-25 14:07:31 -07:00
Brooks Davis
437e1e37df kern_sig.c: include sys/jail.h per style(9)
Fixes:		e722820434
Sponsored by:	DARPA
2023-07-25 18:13:17 +01:00
Warner Losh
73551d4f60 cam/mmc: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:57 -06:00
Warner Losh
7f85b11c57 cam/nvme: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:56 -06:00
Warner Losh
a74530d9e2 cam/ctl: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:56 -06:00
Warner Losh
7c5d20a6c2 cam/scsi: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:56 -06:00
Warner Losh
9db2db6bf6 cam/ata: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:56 -06:00
Warner Losh
7af2f2c801 cam: 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.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:56 -06:00
Mark Johnston
789df254cc amd64: Use a larger boot stack
With sanitizers enabled, it becomes possible to overflow the stack when
only a single page is used.  Follow arm64's example and use the default
kernel stack size instead.  This is a bit wasteful, but without a guard
page, overflow merely corrupts adjacent .bss entries and is thus
difficult to debug.

Note, with a GENERIC kernel we already consume over half of the
available boot stack space, see the review for an example.

Reviewed by:	kib
Reported by:	Jenkins
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41166
2023-07-24 18:49:36 -04:00
Konstantin Belousov
5b353925ff vnode read(2)/write(2): acquire rangelock regardless of do_vn_io_fault()
To ensure atomicity of reads against parallel writes and truncates,
vnode lock was not enough at least since introduction of vn_io_fault().
That code only take rangelock when it was possible that vn_read() and
vn_write() could drop the vnode lock.

At least since the introduction of VOP_READ_PGCACHE() which generally
does not lock the vnode at all, rangelocks become required even
for filesystems that do not need vn_io_fault() workaround.  For
instance, tmpfs.

PR:	272678
Analyzed and reviewed by:	Andrew Gierth  <andrew@tao11.riddles.org.uk>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41158
2023-07-25 01:02:59 +03:00
Mykola Hohsadze
4a07c77863 arm64/disassem.c: add extended register instruction definitions
Add disassembly support for the following extended register
instructions: add, adds, sub, subs, cmp, cmn.

Reviewed by:	mhorne
MFC after:	1 week
Pull Request:	https://reviews.freebsd.org/D40967
2023-07-24 17:51:11 -03:00
Mykola Hohsadze
e57b86266b arm64/disassem.c: remove redundant OP_RN_SP for TYPE_02
Removed redundant OP_RN_SP for TYPE_02, since these addressing modes
always use the SP register, never XZR.

Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D40588
2023-07-24 17:51:08 -03:00
John Baldwin
92103adbeb nvme: Use a memdesc for the request buffer instead of a bespoke union.
This avoids encoding CAM-specific knowledge in nvme_qpair.c.

Reviewed by:	chuck, imp, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41119
2023-07-24 10:32:58 -07:00
Marius Strobl
0b416346e1 bus_dma: Trim CAM includes from subr_bus_dma.c
These are no longer needed after commit c5312bd79e.  This did
require adding an include of <sys/limits.h> instead for SIZE_T_MAX
which previously was dragged in via header pollution.
2023-07-24 10:26:06 -07:00
Andrew Turner
7a16546025 arm: Only include sysreg.h when needed in asm.h
We only need sysreg.h for armv6 barriers

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41141
2023-07-24 17:58:16 +01:00
Andrew Turner
29629d9e76 arm: Rename pte-v6.h to pte.h
There is no need for this to be versioned after the removal of armv4/v5

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41139
2023-07-24 17:58:15 +01:00
Andrew Turner
1e7dfc94cc arm: Move contents of pmap-v6.h into pmap.h
Previously we had an armv4/v5 and armv6/v7 copy of the pmap header. As
we have removed armv4/v5 support we can now merge the armv6/v7 code
into pmap.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41138
2023-07-24 17:58:15 +01:00
Andrew Turner
67d39872e2 arm: Move contents of cpu-v6.h into cpu.h
Previously we had an armv4/v5 and armv6/v7 copy of the cpu.h header. As
we have removed armv4/v5 support we can now merge the armv6/v7 code
into cpu.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41137
2023-07-24 17:58:14 +01:00
Andrew Turner
835927fd8e arm: Remove swi.h
It has been unneeded since moving to the Arm EABI

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41136
2023-07-24 17:58:14 +01:00
Andrew Turner
04b1532935 arm: Move contents of atomic-v6.h into atomic.h
Previously we had an armv4/v5 and armv6/v7 implementation of the atomic
operations. As we have removed armv4/v5 support we can now merge the
armv6/v7 code into atomic.h

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41135
2023-07-24 17:58:13 +01:00
Andrew Turner
554cdf8f57 arm: Explain why _atomic_subword.h is needed
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41134
2023-07-24 17:58:13 +01:00
Andrew Turner
e0e5127ff4 Remove left over includes from armv4/v5
These includes were added for armv4 and armv5 support. Remove them as
this has been removed from the tree.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41133
2023-07-24 17:58:13 +01:00
Kristof Provost
9c9a76dc68 mld: always commit state changes on leaving
Resolve a race condition where we'd lose the Solicited-node multicast
group subscription if we assigned the same IPv6 address twice.

PR:		233683
Reviewed by:	ae
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D41124
2023-07-24 16:47:34 +02:00
Mitchell Horne
a4e4ea738b sys_getrandom: fix a function reference in a comment
MFC after:	3 days
Sponsored by:	FreeBSD Foundation
2023-07-24 10:50:04 -03:00
Mitchell Horne
09e5d91069 puc: fix man page reference
The reference to puc(9) is wrong; the page does not exist, and drivers
belong to section 4. Change the reference to puc(4), which does exist.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2023-07-24 09:54:42 -03:00
Dimitry Andric
80e4ac2964 Work around VNET and DPCPU related panics on aarch64
lld >= 14 and recent GNU ld can relax adrp+add and adrp+ldr
instructions, which breaks VNET and DPCPU when used in modules.

Until VNET and DPCPU can be fixed to deal with these relaxed
instructions, disable linker relaxation for now.

PR:		264094
Reviewed by:	markj
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D41156
2023-07-24 00:35:04 +02:00
Michael Tuexen
058d1722b0 sctp: include sctp_module.c in kernel builds
Allow kldload to detect that SCTP has been build into the kernel.

MFC after:	3 days
2023-07-23 14:34:10 +02:00
Mateusz Guzik
176d83eafc vfs: fix up NDFREE_PNBUF usage in vfs_mountroot_shuffle
Noted by:	karels
2023-07-23 13:44:15 +00:00
Mateusz Guzik
4d9b2ed34b ufs: stop using LK_SLEEPFAIL in ffs_sync
It provides nothing as either locking succeeds or fails with ENOENT as
is.
2023-07-23 13:44:15 +00:00
Michael Tuexen
52640d6174 sctp: update zero checksum support
Implement support for the error detection method identifier.
MFC after:	2 weeks
2023-07-23 06:41:32 +02:00
Marius Strobl
83e67a9d14 xhci(4): Describe AMD 400 Series USB 3.1 controllers
While at it, correct the string for 300 series ones, these also are
already xHCI 3.1.

Fixes:	d171d2f2 Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system
2023-07-23 09:21:46 +02:00
Alan Cox
7b1e606c72 arm64 pmap: Retire PMAP_INLINE
Neither of the remaining callers to pmap_kremove() warrant inlining.
Those calls rarely occur.  In other words, we were optimizing for the
uncommon case.

MFC after:	1 week
2023-07-23 00:34:17 -05:00
Alan Cox
0aebcfc9f4 arm64 pmap: Eliminate some duplication of code
pmap_unmapbios() can simply call pmap_kremove_device() rather than
duplicating its code.

While I'm here, add a comment to pmap_kremove_device() explaining its
proper use, and fix a whitespace issue.

MFC after:	1 week
2023-07-23 00:34:17 -05:00
Kevin Bowling
92fd2f39e5 e1000: add missing parens in csum setup
Reported by:	rscheff
Fixes:	4f9a44a215 e1000: Fix/enable IPv6 transmit checksum offload
MFC after:	2 weeks
2023-07-22 17:05:55 -07:00
Kevin Bowling
4f9a44a215 e1000: Fix/enable IPv6 transmit checksum offload
Fixes and enables txcsum6 offload for lem(4) and em(4).

MFC after:	2 weeks
2023-07-22 15:58:34 -07:00
Kevin Bowling
918c25677d e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes
* em(4) obey administrative ifcaps for using hwcsum offload
* em(4) obey administrative ifcaps for hw vlan receive tagging
* em(4) add additional TSO6 ifcap, but disabled by default as is TSO4
* lem(4) obey administrative ifcaps for using hwcsum offload
* lem(4) add support for hw vlan receive tagging
* lem(4) Add ifcaps for TSO offload experimentation, but disabled by
  default due to errata and possibly missing txrx code.
* lem(4) disable HWCSUM ifcaps by default on 82547 due to errata around
  full duplex links.  It may still be administratively enabled.

Reviewed by:	markj (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D30072
2023-07-22 12:13:43 -07:00
Dmitry Chagin
22dca7acf7 linux(4): Implement xattr syscalls
Reviewed by:
Differential revision:	https://reviews.freebsd.org/D35544
MFC after:		1 month
2023-07-22 14:03:33 +03:00
Dmitry Chagin
6453d4240f vfs: Export exattr methods to reuse by Linuxulator
Reviewed by:
Differential revision:	https://reviews.freebsd.org/D35543
MFC after:		1 month
2023-07-22 14:03:33 +03:00
Dmitry Chagin
d9c2dc6bf1 linux(4): Regen for xattr syscalls
MFC after:		1 month
2023-07-22 14:03:32 +03:00
Dmitry Chagin
41f2c69ee3 linux(4): Modify xattr syscalls to match Linux
MFC after:		1 month
2023-07-22 14:03:31 +03:00
Alan Cox
29edff0dea arm64/riscv pmap: Initialize the pmap's pm_pvchunk field
I believe that there are two reasons that the missing TAILQ
initialization operations haven't caused a problem.  First, the TAILQ
head's first field is being initialized to zeroes elsewhere.  Second,
the first access to the TAILQ head's last field is by
TAILQ_INSERT_HEAD(), which assigns to the last field without reading
it when the first field is NULL.

Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41118
2023-07-21 23:58:18 -05:00
Kevin Bowling
5d3c982549 Revert "e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes"
Seems to cause a panic when booting under VitrualBox.

Reported by:	yasu

This reverts commit 95f7b36e8f.
2023-07-21 21:42:23 -07:00
Konstantin Belousov
bc310a95c5 ip output: ensure that mbufs are mapped if ipsec is enabled
Ipsec needs access to packet headers to determine if a policy is
applicable. It seems that typically IP headers are mapped, but the code
is arguably needs to check this before blindly accessing them. Then,
operations like m_unshare() and m_makespace() are not yet ready for
unmapped mbufs.

Ensure that the packet is mapped before calling into IPSEC_OUTPUT().

PR:	272616
Reviewed by:	jhb, markj
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41112
2023-07-21 21:51:13 +03:00
Warner Losh
ff4633d9f8 cam_periph: Comment about why we need to reset cbfcnp
Just spent a few minutes puzzling out why we do this. Add a comment to
remind my future self (and other intersted folk) why we do the reset
here when we'd set it a few lines above.

Sponsored by:		Netflix
2023-07-21 10:11:37 -06:00
Warner Losh
b4993704d6 cam_periph: Fix a comment
Add a couple of words so that this sentence makes sense.

Sponsored by:		Netflix
2023-07-21 10:07:13 -06:00
Kristof Provost
6053adafaa pf: add SCTP NAT support
Support NAT-ing SCTP connections.

This is mostly similar to UDP and TCP, but we refuse to change ports for
SCTP, to avoid interfering with multihomed connections.

As a result we also never copy the SCTP header back or recalculate
checksums as we'd do for TCP or UDP (because we don't modify the header
for SCTP).

We do use the existing pf_change_ap() function to modify the packet,
because we may still need to update the IPv4 header checksum.

Reviewed by:	tuexen
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40866
2023-07-21 12:32:19 +02:00
Kristof Provost
d1bc1e9e1a pf: support 'return' for SCTP
Send an SCTP Abort message if we're refusing a connection, just like we
send a RST for TCP.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40864
2023-07-21 12:32:18 +02:00
Kristof Provost
010ee43f56 pf: initial SCTP support
Basic state tracking for SCTP. This means we scan through the packet to
identify the different chunks (so we can identify state changes).

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40862
2023-07-21 12:32:18 +02:00
Kristof Provost
61e22e9b29 pf: use sctp_calculate_cksum()
This function is always available, even if the SCTP or SCTP_SUPPORT options
are not set.
That lets us remove an ifdef, and also means we improve pf's SCTP handling
when the options are not set.

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40911
2023-07-21 12:32:17 +02:00
Elliott Mitchell
20fc5bf7df xen: move vcpu_info to common, leave hook for setup
vcpu_info is crucial for the Xen event channel core.  Since both the
data and setup steps are identical between architectures, move them to
the common file.  Since there is no cross-architecture method to call
a function on every processor during bring-up, simply leave the setup
function.

The number of vcpu_info structures available on the shared information
page varies by architecture.  Instead of hard-coding the count use
nitems().  Add a warning message for this being used.

Switch to XEN_VCPUID() and use Xen's typedefs.

panic() on failure since >32 processors is no longer unusual.

royger: Specify 64-byte alignment for vcpu_info to try to defend
against vcpu_info crossing a page boundary.  Add detection for this
limit.

Reviewed by: royger
2023-07-21 10:59:12 +02:00
Warner Losh
774ab87cf2 cam: Add CAM_NVME_STATUS_ERROR error code
Add CAM_NVME_STATUS_ERROR error code. Flag all NVME commands that
completed with an error status as CAM_NVME_STATUS_ERROR (a new value)
instaead of CAM_REQ_CMP_ERR. This indicates to the upper layers of CAM
that the 'cpl' field for nvmeio CCBs is valid and can be examined for
error recovery, if desired.

No functional change. nda will still see these as errors, call
ndaerror() to get the error recovery action, etc. cam_periph_error will
select the same case as before (even w/o the change, though the change
makes it explicit).

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41085
2023-07-20 22:32:31 -06:00
Warner Losh
0732617ec1 cam/nda: Remove impossible CAM codes
The NVME SIM does not generate these status values, so remove them.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D41084
2023-07-20 22:32:31 -06:00
Warner Losh
33734ddf2b cam: Be explict about CAM_SMP_STATUS_ERROR
This is normally caught by default:, but no harm in making it explicit
that we'll retry valid periphs.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D41083
2023-07-20 22:32:31 -06:00
Warner Losh
367699ca7a cam/scsi: Better action for ASC/ASCQ 0x18/0x08
0x18/0x8 is another code to indicate that the data was recovered
successfully, so complete the command w/o an error rather than retry the
operation.

Sponsored by:		Netflix
Reviewed by:		mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41082
2023-07-20 22:32:30 -06:00
Warner Losh
38e831a895 cam: Add comment about recovery ccbs
SS_START and higher actions (currently only SS_TUR) allocate a recovery
CCB to send a command to the periph. Add a quick comment about that here.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D41081
2023-07-20 22:32:30 -06:00
Kevin Bowling
95f7b36e8f e1000: lem(4)/em(4) ifcaps, TSO and hwcsum fixes
* em(4) obey administrative ifcaps for using hwcsum offload
* em(4) obey administrative ifcaps for hw vlan receive tagging
* em(4) add additional TSO6 ifcap, but disabled by default as is TSO4
* lem(4) obey administrative ifcaps for using hwcsum offload
* lem(4) add support for hw vlan receive tagging
* lem(4) Add ifcaps for TSO offload experimentation, but disabled by
  default due to errata and possibly missing txrx code.
* lem(4) disable HWCSUM ifcaps by default on 82547 due to errata around
  full duplex links.  It may still be administratively enabled.

Reviewed by:	markj (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D30072
2023-07-20 20:44:04 -07:00
Kevin Bowling
201c4b7c29 e1000: Some fixes for em(4) TSO setup
Always set TXD_CMD_IP for 82544
Otherwise set TXD_CMD_IP for IPv4, not IPv6

Reviewed by:	markj (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D30072
2023-07-20 18:52:53 -07:00
Warner Losh
59dc489a7e mpr: Fix minor 'typos' comment
moving -> removing (we're removing the device)
CAM_REQ_CMO_ERROR -> CAM_REQ_ERR (the former isn't a thing)

Sponsored by:		Netflix
2023-07-20 17:18:28 -06:00
Krzysztof Galazka
ba2f531f81
ixl(4): Add link state polling
In some cases driver may ask FW about link state before FW finishes
configuration of a (Q)SFP+ transceiver. If first attempt of using Get Link
Status AQC after loading driver or handling a reset fails, then re-try
periodically for 5 seconds.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Tested by:	jeffrey.e.pieper@intel.com
Approved by:	erj@
MFC after:	2 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D40899
2023-07-20 15:33:52 -07:00
Konstantin Belousov
db6c7c7f8d vmspace_fork(): do not override offset for the guard entries
The offset field contains protection for the stack guards.

Reported by:	cy
Fixes:	21e45c30c3
MFC after:	1 week
2023-07-20 22:04:03 +03:00
Konstantin Belousov
21e45c30c3 mmap(MAP_STACK): on stack grow, use original protection
If mprotect(2) changed protection in the bottom of the currently grown
stack region, currently the changed protection would be used for the
stack grow on next fault.  This is arguably unexpected.

Store the original protection for the entry at mmap(2) time in the
offset member of the gap vm_map_entry, and use it for protection of the
grown stack region.

PR:	272585
Reported by:	John F. Carr <jfc@mit.edu>
Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41089
2023-07-20 17:11:42 +03:00
Eric Joyner
a52f23f4c4
iflib: Unlock ctx lock around call to ether_ifattach()
Panic occurs during loading driver using kldload. It exists since netlink is
enabled.  There is problem with double locking ctx. This fix allows to call
ether_ifattach() without locked ctx.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

PR:		271768
Reviewed by:	erj@, jhb@
MFC after:	1 day
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D40557
2023-07-19 15:51:26 -07:00
Dmitry Chagin
c84617e87a i386: Switch to PIC kernel modules
It seems since the last llvm project update, the lld linker has started
creating a PLT dependent kernel module object files.

Reviewed by:		kib, jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D41088
2023-07-19 21:21:04 +03:00
Navdeep Parhar
c721694a1c ktls_alloc_rcv_tag: Fix capability checks for RXTLS4/6.
IFCAP2_* has the bit position and not the shifted value.

Reviewed by:	kib@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D41100
2023-07-19 11:12:14 -07:00
Marius Strobl
13d1f5cb62 enic(4): Remove unused dupe prototype 2023-07-19 18:58:51 +02:00
Christos Margiolis
02402ec888 kinst.h: make pointer to probe in kinst_cpu_state const
Fixes: 5b701ed19c ("kinst: start moving towards per-probe
trampolines")

Sponsored by: The FreeBSD Foundation
2023-07-19 19:57:44 +03:00
Christos Margiolis
e967a9a5d5 Revert "dtrace: cache current probe in kdtrace_thread_t"
This reverts commit 22508c8b6c.

The t_kinst_curprobe field is no longer needed by kinst.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41031
2023-07-19 17:58:49 +03:00
Christos Margiolis
07864a8a24 kinst: port to arm64
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40337
2023-07-19 17:58:18 +03:00
Christos Margiolis
2517b2085b kinst: use per-probe trampolines in riscv
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40963
2023-07-19 17:57:59 +03:00