Commit Graph

148338 Commits

Author SHA1 Message Date
Emmanuel Vadot
393387820b arm64: rockchip: rk_i2c: Probe again at ORDER_LATE
The gic driver is also probed at this pass and depending on the order of
the nodes in the dts rk_i2c can be probed first and will fail, this is the
case for the rk3328 SoC.
The PMIC drivers are also probed at this pass but on the iicbus which is created
in rk_i2c so there is no order conflict here.

Fixes:		ddefad7c4f ("arm64: rockchip: Tweak i2c, pmic and iodomain order")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-08-09 10:50:04 +02:00
Michael Tuexen
85e5480df9 sctp: another cleanup
No functional change intended.

MFC after:	1 week
2023-08-09 04:17:52 +02:00
Doug Moore
15047a6509 rangesets: use PCTRIE_DEFINE
subr_rangeset.c is the only source file that calls functions like
pctrie_insert and pctrie_remove directly; other users of pctries use
the PCTRIE_DEFINE macro to define interfaces to pctrie that let them
ignore issues of offsets within structs and uint64_t return values.

Change subr_rangeset.c to use PCTRIE_DEFINE too. And change pctrie.h
to mark the lookup function as unused, to avoid warnings when
compiling files, like subr_rangeset.c, that don't invoke lookup().

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41391
2023-08-09 02:26:25 -05:00
Konstantin Belousov
28b36ecf99 Revert "exit1(): Revert sparc64 workaround"
This reverts commit 96c76d9306.

There are other relatively common reasons why init might get killed
during reboot, the workaround was really not sparc64-specific.

Discussed with:	marius
Sponsored by:	The FreeBSD Foundation
2023-08-09 09:00:20 +03:00
Konstantin Belousov
0f613ab85e tmpfs: add a knob to enable pgcache read for mount
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41334
2023-08-09 06:54:15 +03:00
Konstantin Belousov
821dec4d56 vnode io: request range-locking when pgcache reads are enabled
PR:	272678
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41334
2023-08-09 06:54:15 +03:00
Konstantin Belousov
651fdc3d19 Revert "vnode read(2)/write(2): acquire rangelock regardless of do_vn_io_fault()"
This reverts commit 5b353925ff.

The reason is the lesser scalability of the vnode' rangelock comparing
with the vnode lock.

Requested by:	mjg
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D41334
2023-08-09 06:54:15 +03:00
Kirk McKusick
6dff61a1d1 Rate limit kernel UFS/FFS cylinder group check-hash error messages.
When a large file is deleted or a large number of files are deleted,
even a single cylinder group with a bad check hash can generate
thousands of check-hash warnings. As with other filesystem messages
such as out-of-space, print a maximum of one check-hash error per
second. Note the limit is per filesystem. If two filesystems have
cylinder group(s) with a bad check hash, each will print a maximum
of one check-hash error message per second.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-08-08 17:11:04 -07:00
Marius Strobl
37c8ee8847 ath(4): Remove MIPS AHB frontend and join PCI one w/ main support again
Following the removal of general MIPS support, there's no longer a need
to have the AHB bus-frontend in place, which according to Linux sources
also isn't used with any non-MIPS SoCs. For simplicity, PCI bus support
is only made conditional on the main one again, i. e. device ath_pci is
removed, and built into the main module, i. e. if_ath_pci.ko obsoleted,
respectively.
Effectively, this reverts the following commits and associated changes:
dba9c85977
e849bb3ecb

Approved by:	adrian
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D41354
2023-08-08 22:30:13 +02:00
Warner Losh
09c20a2932 nvme: Move bools to fill hole
The two bools in nvme_request create a 6 byte hole today. Move them to
after retires to fill the 4 byte hole there and add a spare[2] to make
nvme_request 8 bytes smaller. spare[2] isn't strictly necessary, but
documents how many bytes we have left in that hole, as the number of
booleans will increase shortly.

Suggested by:		chuck
Sponsored by:		Netflix
2023-08-08 11:44:51 -06:00
Warner Losh
3e1f69523b modules: Use MACHINE_CPUARCH more
Replace two cases of MACHINE_ARCH with MACHINE_CPUARCH and also use
`aarch64` instead of the improper `arm64` for that test.

Noticed by:		Mark Millard
Sponsored by:		Netflix
2023-08-08 11:44:51 -06:00
Mike Karels
58a46cfd75 md driver compat32: fix structure padding for arm, powerpc
Because the 32-bit md_ioctl structure contains 64-bit members, arm
and powerpc add padding to a multiple of 8.  i386 doesn't do this.
The md_ioctl32 definition was correct for amd64/i386 without padding,
but wrong for arm64 and powerpc64.  Make __packed__ conditional on
__amd64__, and test for the expected size on non-amd64.  Note that
mdconfig is used in the ATF test suite.  Note, I verified the
structure size for powerpc, but was unable to test.

MFC after:	1 week
Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D41339
Discussed with:	jhibbits
2023-08-08 09:09:03 -05:00
Emmanuel Vadot
ddefad7c4f arm64: rockchip: Tweak i2c, pmic and iodomain order
We need i2c first to set it to MIDDLE, then we need one of the pmics
so set them to LATE, only then we can attach iodomain which needs some
regulators exposed by the pmic so set it to LAST.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-08-08 15:58:26 +02:00
Emmanuel Vadot
4b5f5fe78f arm64: intel: Remove firmware driver
This is now covered by ofw_firmware.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37613
2023-08-08 15:13:33 +02:00
Emmanuel Vadot
fdfd3a90b6 ofw: Add a ofw_firmware driver
Some SoCs have an external firmware doing power management, clock
and other stuffs. (Xilinx, ARM Juno etc ...)
The way it is represent in the DTB is usually having a 'firmware' node
under the root node and have some nodes under it with the correct
compatible strings.
The firmware node itself doesn't have any compatible strings.
This driver is simple subclassed from simplebus and attaches at
BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE so early drivers (like clock drivers)
can still have a change to attach early.

Reviewed by:	andrew
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37612
2023-08-08 15:13:31 +02:00
Michael Tuexen
9ade2745db sctp: remove duplicate code
No functional change intended.

MFC after:	1 week
2023-08-08 13:05:39 +02:00
Michael Tuexen
c7587f7a3f sctp: cleanup
No functional change intended.

MFC after:	1 week
2023-08-08 12:40:51 +02:00
Andrey V. Elsukov
600bf006d3 carp: delete interface routes on link loss.
Obtained from:	Yandex LLC
MFC after:	10 days
Sponsored by:	Yandex LLC
Differential Revision: https://reviews.freebsd.org/D41290
2023-08-08 13:22:10 +03:00
Michael Zhilin
e0bc8f8da2 etherswitch/arswitch: correct version detection
During porting of etherswitch to NetBSD mistypo was discovered in
Atheros switch version detection.

Reported by:    Hiroki Mori yamori813@yahoo.co.jp
MFC after:	1 week
2023-08-08 11:02:09 +03:00
Kirk McKusick
d4a8f5bf13 Handle UFS/FFS file deletion from cylinder groups with check-hash failure.
When a file is deleted, its blocks need to be put back in the free
block list and its inode needs to be put back in the inode free list.
These lists reside in cylinder-group maps. If either some of its blocks
or its inode reside in a cylinder-group map with a bad check hash
it is not possible to free the associated resource. Since the cylinder
group cannot be repaired until the filesystem is unmounted these
resources cannot be freed. They simply accumulate in memory. And
any attempt to unmount the filesystem loops forever trying to flush them.

With this change, the resource update claims to succeed so that the
file deletion can successfully complete. The filesystem is marked as
requiring an fsck so that before the next time that the filesystem is
mounted, the offending cylinder groups are reconstructed causing the
lost resources to be reclaimed.

A better solution would be to downgrade the filesystem to read-only,
but that capability is not currently implemented.

Reported-by:  Peter Holm
Tested-by:    Peter Holm
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-08-07 16:28:11 -07:00
Eric Joyner
d2dd3d5a98
iflib: Remove redundant variable
In iflib_init_locked(), sctx and scctx both point to the same value,
which is the ifc_softc_ctx field in the iflib softc. Remove the
declaration and assignment to sctx since scctx can be used instead, and
the name of scctx follows the naming convention used for local variables
that point to ifc_softc_ctx.

In theory there should be no functional impact with this change.

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

Reviewed by:	kbowling@
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D41325
2023-08-07 15:46:48 -07:00
Eric Joyner
7f527d4812
iflib: Fix white space and reduce some line lengths
This helps align some of the code with the rest of the style used in
iflib, but as marius@ points out, this is not style(9).

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

Reviewed by:	kbowling@
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D41324
2023-08-07 15:46:48 -07:00
Warner Losh
2ad9a815fd nvme: Directly lookup op code
Rather than have a table to walk through, use a sparse array.

Suggested by:		jhb
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D41353
2023-08-07 16:44:32 -06:00
Warner Losh
63b0c00eb0 nvme: Update comment
Fix comment to note we should grab additional data from the error log
page, but don't currently (it's inclear if we should do that here
and other places in nvd that want it, or if we should let nvd / the
nda periph make the request).

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41315
2023-08-07 16:44:31 -06:00
Warner Losh
95cd10f139 nvme: Add comments about other fields in status
When manually completing an I/O, we do so because we have no status back
from the card. Note M, CRD and P are all 0 because this is an artificial
event (and phase isn't checked when it's completed this way). There's no
MORE information in the error log page and there's no delayed retry
(CRD=0) and we don't currently request CRD to be set to anything other
than 0 and thus don't implement delayed retry.

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41314
2023-08-07 16:44:31 -06:00
Warner Losh
a510dbc848 nvme: Be less verbose when cancelling I/O or admin commands
When we're resetting, and there's outstanding I/O that we're cancelling,
only report we're cancelling the I/O once rather than once per
I/O. Likewise when we reschedule the I/O. We don't need to say for each
one that we're cancelling/rescheduling something, and then report the
I/O that we're doing. Likewise with cancelling admin commands (we never
retry them here, so a similar change isn't needed).

Sponsored by:		Netflix
Reviewed by:		chuck, mav
Differential Revision:	https://reviews.freebsd.org/D41313
2023-08-07 16:44:31 -06:00
Warner Losh
ac8c866fda nvme: Add more NVME Base Spec 2.0 and NVME Command Set Spec 1.0a
Add admin commands capacity management, lockdown and fabrics commands.
Add I/O copy command.

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41311
2023-08-07 16:44:31 -06:00
Warner Losh
edd23e4dc0 nvme: Eliminate redundant code
get_admin_opcode_string and get_io_opcode_string are identical, but
start with different tables. Use a helper routine that takes an argument
to implement these instead. A future commit will refine this further.

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41310
2023-08-07 16:44:31 -06:00
Warner Losh
7be0b06885 nvme: Remove duplicate command printing routine
Both nvme_dump_command and nvme_qpair_print_command print nvme
commands. The former latter better. Recode the one call to
nvme_dump_command to use nvme_qpair_print_command and delete the
former. No sense having two nearly identical routines. A future commit
will convert to sbuf.

Sponsored by:		Netflix
Reviewed by:		chuck, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D41309
2023-08-07 16:44:30 -06:00
Warner Losh
6f76d49386 nvme: Remove duplicate completion printing routine
Both nvme_dump_completion and nvme_qpair_print_completion print
completions. The latter is better. Recode the two instances of
nvme_dump_completion to use nvme_qpair_print_completion and delete the
former. No sense having two nearly identical routines. A future commit
will convert this to sbuf.

Sponsored by:		Netflix
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D41308
2023-08-07 16:44:30 -06:00
Mark Johnston
454c425dbe ossl: Add missing labels to bsaes-armv7.S
There is a bug in the OpenSSL script which generates this file; the bug
is in the process of being fixed upstream.

Specifically, when generating the output, bsaes-armv7.pl strips some
labels that are used when the output asm is compiled with __KERNEL__
defined, resulting in a build error.  As a step towards adding armv7
support to ossl(4), manually patch the generated asm.  The upstream fix
will be imported later.

Reviewed by:	andrew, jhb, emaste
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D41303
2023-08-07 10:17:16 -04:00
Bjoern A. Zeeb
d73de45743 net80211: Radiotap: add two more EHT defines
An updated iwlwifi needs further radiotap updates for EHT.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-08-07 01:22:53 +00:00
Bjoern A. Zeeb
dcb0c54968 LinuxKPI: replace vtophys+PHYS_TO_VM_PAGE with virt_to_page
Rather than using the FreeBSD internal calls vtophys() and
PHYS_TO_VM_PAGE() use the already existing LinuxKPI abstraction for
this called virt_to_page().  This reduces the amount of compat code
to maintain and will allow further work on struct [vm_]page.

This should be a NOP.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D41257
2023-08-07 00:58:21 +00:00
Bjoern A. Zeeb
d1ea07642c LinuxKPI: cleanup internal calls to VM_PAGE_TO_PHYS
Replace FreeBSD native VM_PAGE_TO_PHYS() calls with page_to_phys()
allowing us to work on a struct page in the future using the one
single public Linux KPI interface to map to a native FreeBSD vm_page.

This should be a NOP.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D41256
2023-08-07 00:57:42 +00:00
Bjoern A. Zeeb
9e9c682ff3 LinuxKPI: reduce usage of struct vm_page and vm_page_t
We currently define (Linux) page to (FreeBSD) vm_page.
Cleanup some of the direct struct vm_page and vm_page_t declarations
and usages in the Linux KPI and make them 'struct page' or
'struct page *' to prepare for more upcoming work.

This should be a NOP.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D41255
2023-08-07 00:55:30 +00:00
Bjoern A. Zeeb
f74c09f3ec LinuxKPI: pci.h add more constants
Add two more PCI_EXP_LNKSTA_CLS constants to the compat defines
needed by wireless drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
Reviewed by:	manu, emaste
Differential Revision: https://reviews.freebsd.org/D41258
2023-08-07 00:54:03 +00:00
Bjoern A. Zeeb
1dcd1a5392 LinuxKPI: implement get_random_u32_inclusive()
Implementation of get_random_u32_inclusive().
This is needed by an update for wireless drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
Differential Revision: https://reviews.freebsd.org/D40121
2023-08-07 00:52:41 +00:00
Konstantin Belousov
676f02a482 acpi_spibus.c: fix i386 build
intmax_t requires %j format specifier, %z is for size_t.

Fixes:	7d380b986a
Sponsored by:	The FreeBSD Foundation
2023-08-07 00:09:52 +03:00
Sebastian Huber
15876d9fd8 sys/cdefs.h: fix for use __restrict in C++
Newlib shares large parts of <sys/cdefs.h> with FreeBSD and received
this bug report:

https://sourceware.org/pipermail/newlib/2023/020400.html

As an extension, GCC and clang offer C99-style restricted pointers in
C++ mode:
https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html

We notice that this extension is broken when including newlib headers:
restricted pointers are treated as ordinary pointers.

We traced this to the following section of
newlib/libc/include/sys/cdefs.h:

  /*
   * GCC 2.95 provides `__restrict' as an extension to C90 to support the
   * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
   * a way to define the `restrict' type qualifier without disturbing older
   * software that is unaware of C99 keywords.
   */
  #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
  #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
  #define	__restrict
  #else
  #define	__restrict	restrict
  #endif
  #endif

While the GCC __restrict extension was indeed introduced in GCC 2.95, it
is not limited to this version; the extension is also not limited to
C90:
https://gcc.gnu.org/gcc-2.95/c++features.html

Rewrite the logic in the header so that __restrict is kept alone when
available.

PR:	272723
MFC after:	1 week
2023-08-07 00:09:52 +03:00
Marius Strobl
96c76d9306 exit1(): Revert sparc64 workaround
If this still is a problem on other architectures, it should be fixed
properly.

This reverts commit 5486ffc898.
2023-08-06 22:26:01 +02:00
Vladimir Kondratyev
f1d955be2a hidraw(4): Implement HIDRAW_GET_DEVICEINFO ioctl
In commit c77bfaa750 uhid(4) gained support for ioctl from
USB_GET_DEVICEINFO. This is used in libraries like libfido2 to
retrieve information about a device.

This commit adds binary compatible version to hidraw(4).

PR:		264843
MFC after:	1 month
Requested by:	grembo
2023-08-06 14:51:08 +03:00
Ed Maste
1a6238d1ea sigexit: add a break in default case
Suggested by:	markj
Fixes:		6edbe5616c ("Provide some more information for...")
Sponsored by:	The FreeBSD Foundation
2023-08-05 19:21:11 -04:00
Ed Maste
6edbe5616c Provide some more information for userland core dumps
Previously the log message indicated only "(core dumped)" if a core was
successfully created, or nothing if it was not. This provides
insufficient information to faciliate debugging. Dtrace is no help as
coredump() is static and we cannot find the return value via fbt.
Expand the log message to include error return value information.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39942
2023-08-05 19:18:35 -04:00
Michael Tuexen
10b2b30670 sctp: improve consistency
MFC after:	1 week
2023-08-05 11:29:23 +02:00
Michael Tuexen
e3771cc034 sctp: remove redundant check
This is already checked by the caller.

MFC after:	1 week
2023-08-05 11:26:45 +02:00
Doug Moore
e77f4e7f59 vm_phys: tune vm_phys_enqueue_contig loop
Rewrite the final loop in vm_phys_enqueue_contig as a new function,
vm_phys_enq_beg, to reduce amd64 code size.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41289
2023-08-04 21:09:39 -05:00
Igor Ostapenko
452661c967 exit1(): fix a comment typo
Signed-off-by: Igor Ostapenko <pm@igoro.pro>
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/809
2023-08-04 20:42:07 -04:00
John Baldwin
aca3d65fed netsmb: Add bounds checking to smb_t2_placedata
Verify that the requested region of the mbuf chain is not beyond the
end of the chain before trimming it from the end.  If it is out of
bounds, fail with an error (EPROTO).

While here, properly handle the case that the amount of data at the
end of the chain might span more than one mbuf by using m_adj to drop
the extra bytes rather than assuming m_len of the last mbuf can be
adjusted directly.

PR:		258504
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Co-authored-by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41229
2023-08-04 16:42:41 -07:00
John Baldwin
4af849d71f cd9660: Reject volumes with small logical block sizes
ISO9660 permits specifying a logical block size that is any power of 2
greater than or equal to 512.  The geom disk layer requires requests
to be aligned on sector boundaries of the provider.  With a volume
that uses a logical block size smaller than the underlying disk sector
size (e.g. a logical block size of 512 or 1024 on a CD which uses 2048
byte sectors), the current cd9660 vfs can issue requests for partial
sectors, or on non-sector boundaries.

Fixing this properly would require wrapping all of the calls to
bread*/bwrite* in cd9660 vfs to roundup requests to be on sector
boundaries which can include both the length, but also the starting
sector number (and thus requiring use of an offset relative to b_data
in the resulting buf).

These images do not seem to be common however given that no one has
fixed this in cd9660's vfs in the past few decades, so just reject
them during mount with an error.  If such images are found to be used
in the wild in practice, then the larger fix can be applied.

PR:		258063
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41228
2023-08-04 16:41:50 -07:00
John Baldwin
4c89c0127d g_raid concat: Fail requests to read beyond the end of the volume
Previously a debug kernel would trigger an assertion failure if an I/O
request attempted to read off the end of a concat volume, but a
non-debug kernel would use an invalid sub-disk to try to complete the
request eventually resulting in some sort of fault in the kernel.

Instead, turn the assertions into explicit checks that fail requests
beyond the end of the volume with EIO.  For requests which run over
the end of the volume, return a short request.

PR:		257838
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41222
2023-08-04 16:41:05 -07:00
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