Commit Graph

142008 Commits

Author SHA1 Message Date
Bjoern A. Zeeb
b3b836251f LinuxKPI: pci: implement pci_upstream_bridge()
Allow drivers to query the "upstream PCI bridge".
Currently we point back to ourselves on pdev->bus->self rather than
to the parent PCI bridge.
We keep this as status-quo with an extra comment and only on-demand
allocate a pci_dev for the parent bridge if we are asked for in
pci_upstream_bridge().
When releasing the pci_dev we check if pdev->bus->self has changed
and call pci_dev_put() to release the reference count on the parent
bridge as well.

This code moves pci_is_root_bus() higher up in pci.h but no functional
change there.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky, (jhb some earlier)
Thanks to:	wulf for handling drm-kmod
Differential Revision: https://reviews.freebsd.org/D34305
2022-03-21 14:35:23 +00:00
firk
bb53dd56c3 kern_tc.c/cputick2usec() (which is used to calculate cputime from
cpu ticks) has some imprecision and, worse, huge timestep (about
20 minutes on 4GHz CPU) near 53.4 days of elapsed time.

kern_time.c/cputick2timespec() (it is used for clock_gettime() for
querying process or thread consumed cpu time) Uses cputick2usec()
and then needlessly converting usec to nsec, obviously losing
precision even with fixed cputick2usec().

kern_time.c/kern_clock_getres() uses some weird (anyway wrong)
formula for getting cputick resolution.

PR:		262215
Reviewed by:	gnn
Differential Revision:	https://reviews.freebsd.org/D34558
2022-03-21 09:33:46 -04:00
Andrew Turner
cab496e16c Make SHMMAXPGS an unsigned long
This is used to calculate sizes that are then stored in unsigned long
fields. Make this unsigned long so the calculations use this type and
not an int that can lead to an integer overflow with a large PAGE_SIZE.

This allows building this on arm64 with PAGE_SIZE of 16k. Further work
will be needed if a 32-bit architecture tries to use a similar sized
page.

Sponsored by:	The FreeBSD Foundation
2022-03-21 10:27:35 +00:00
Colin Percival
2406867f5b tslog: Add CTLFLAG_SKIP to sysctls
The timestamp logs are quite large (often much larger than all the
other sysctls combined) so it's unlikely anyone will want to have
them displayed by `sysctl -a`.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34616
2022-03-20 11:31:16 -07:00
Ed Maste
e39ec8933b Add deprecation notices to ISA sound cards
ISA sound cards (and ISA itself) are long obsolete.  NYCBUG dmesgd has
no entries for any of these devices after 2005.

Add deprecation notices to device attach routines and man pages for:

snd_ad1816  Analog Devices AD1816 SoundPort
snd_ess     Ensoniq ESS
snd_gusc    Gravis UltraSound
snd_mss     Microsoft Sound System
snd_sbc     Creative Sound Blaster

Reviewed by:	cy, mav
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34604
2022-03-19 14:57:26 -04:00
hlh-restart
1b1bab0078 rtsx: Call rtsx_init() on resume.
MFC after:	3 days
2022-03-19 12:37:24 -04:00
Mateusz Guzik
6ff3e8a316 cache: add a comment about a realpath bug 2022-03-19 15:11:25 +00:00
Mateusz Guzik
eb574ba0b6 vfs: replace VFS_NOTIFY_UPPER_* macros with an enum 2022-03-19 13:15:55 +00:00
Mateusz Guzik
cceb91b025 vfs: add missing flags to db show mount 2022-03-19 12:04:44 +00:00
Mateusz Guzik
93a0ba8f49 vfs: retire the no longer used MNTK_LOOKUP_EXCL_DOTDOT flag
Reviewed by:	markj
Tested by:	pho (previous version)
Differential Revision:	https://reviews.freebsd.org/D34466
2022-03-19 10:47:29 +00:00
Mateusz Guzik
aeabf8d4b9 nullfs: hash insertion without vnode lock upgrade
Use the hash lock to serialize instead.

This enables shared-locked ".." lookups.

Reviewed by:	markj
Tested by:	pho (previous version)
Differential Revision:	https://reviews.freebsd.org/D34466
2022-03-19 10:47:10 +00:00
Mateusz Guzik
1cb0045c97 vfs: add MNTK_UNLOCKED_INSMNTQUE
Can be used when the fs at hand can synchronize insmntque with other
means than the vnode lock.

Reviewed by:	markj
Tested by:	pho (previous version)
Differential Revision:	https://reviews.freebsd.org/D34466
2022-03-19 10:46:40 +00:00
Kyle Evans
2218070b2c psci: finish psci_present implementation
This was already declared in psci.h, but it was never defined/set.  Do
this now, so we can use it to decide if enable-method in /cpus FDT nodes
should be inspected later on.  While we're here, convert it to a
boolean.

Reviewed by:	andrew (slightly earlier version)
Differential Revision:	https://reviews.freebsd.org/D34553
2022-03-18 22:04:32 -05:00
Kyle Evans
1236b04bb7 arm64: gic: disable the ITS if it's enabled prior to configuration
The ITS is defined to be disabled on a warm reset, but we may be coming
in via another kernel/hypervisor type setup where the ITS has been
previously configured then relinquished to the next kernel in the chain.

If it's enabled, the later configuration of GITS_BASER will almost
certainly fail -- clear it to prevent that.

Reviewed by:	andrew
Sponsored by:	Ampere Computing
Submitted by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34546
2022-03-18 22:03:44 -05:00
Ed Maste
92e6b4712b Retire broken snd_ds1 and snd_maestro drivers
In 2012 joel@ reported[1] that these were not functional, and they do
not appear to have been fixed since.

[1] https://lists.freebsd.org/pipermail/freebsd-multimedia/2012-January/012751.html

Reported by:	joel
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2022-03-18 20:33:19 -04:00
Ed Maste
ef5dec7cc7 Remove snd_aureal driver source
This driver was not finished when it was committed in 1999 and was never
connected to the build.

A version of the driver used to be available in ports as
audio/aureal-kmod, but it has been removed.  It did not build on FreeBSD
10.x or later and the binary objects it required were not available
after Google Code disappeared.

PR:		124343
Reported by:	joel
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-03-18 16:27:35 -04:00
Andrew Gallatin
b50abe6bd4 namei: Treat non-tied KLDs as if they had INVARIANTS enabled
When working with a vendor to debug their kernel module,
I found that a non-tied kld which uses NDINIT will panic
due to "namei: bad debugflags " on a kernel compiled with
INVARIANTS because non-tied KLDs do not pick up the
initialization that is done in NDINIT_DBG/NDREINIT_DBG().

Fix this by making this initialization happen for non-KLD_TIED
as well as INVARIANTS

Reviewed by: mjg
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34588
2022-03-18 10:14:14 -04:00
Roger Pau Monné
1ca34862dc x86/tsc: fetch frequency from CPUID when running on Xen
Introduce a helper to fetch the TSC frequency from CPUID when running
under Xen.

Since the TSC can also be initialized early when running as a Xen
guest pull out the call to tsc_init() from the
early_clock_source_init() handlers and place it in clock_init(), as
otherwise all handlers would call tsc_init() anyway.

Reviewed by: markj
Sponsored by: Citrix Systems R&D
Differential revision: https://reviews.freebsd.org/D34581
2022-03-18 10:21:04 +01:00
Ed Maste
06731139ca hda: add patch for Framework laptop headphone jack
For Framework laptops built after Oct 2021 (like mine) that have a Tempo
Semiconductor 92HD95B codec rather than Realtek ALC295 (see
https://frame.work/ca/en/blog/solving-for-silicon-shortages).

As we do for many other laptops, put the headphone jack and speakers in
the same association by default so that the generic sound device
automatically switches between them.  Also specify the jack colour and
location.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34596
2022-03-17 19:22:02 -04:00
Mark Johnston
c0b98fe16f fusefs: Initialize a pad word in the mknod message
Reported by:	Jenkins (KMSAN job)
Reviewed by:	asomers
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34593
2022-03-17 18:30:21 -04:00
Mark Johnston
077564cfdb hdac: Handle interrupts racing with device suspend
- Avoid looping forever if a concurrent reset causes a read of the
  interrupt status register to return all ones.
- Lock the softc before reading the interrupt status, so as to avoid a
  similar infinite loop in hdac_one_intr().

This fixes suspend-to-S3 on some laptops.

PR:		261207
Reviewed by:	mav, imp
Tested by:	uqs
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34117
2022-03-17 15:39:00 -04:00
firk
28d08dc7d0 clock_gettime: Fix CLOCK_THREAD_CPUTIME_ID race
Use a spinlock section instead of a critical section to synchronize with
statclock().  Otherwise the CLOCK_THREAD_CPUTIME_ID clock can appear to
go backwards.

PR:		262273
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D34568
2022-03-17 15:39:00 -04:00
Mark Johnston
fc7e121d88 file: Move FILEDESC_FOREACH macros to kern_descrip.c
They are only used in kern_descrip.c, so make them private.  No
functional change intended.

Discussed with:	mjg
Sponsored by:	The FreeBSD Foundation
2022-03-17 15:39:00 -04:00
Mark Johnston
c702242292 file: Avoid a read-after-free of fd tables in sysctl handlers
Some loops access the fd table of a different process, and drop the
filedesc lock while iterating, so they check the table's refcount.
However, we access the table before the first iteration, in order to get
the number of table entries, and this access can be a use-after-free.

Fix the problem by checking the refcount before we start iterating.

Reported by:	pho
Reviewed by:	mjg
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34575
2022-03-17 15:39:00 -04:00
Alexander Motin
016d18229c ipmi: Make all sysctls also tunables.
MFC after:	1 week
2022-03-17 13:34:15 -04:00
Rick Macklem
f37dc50d9f nfscl: Do not do a Lookup+Open for pNFS mounts
A NFSv4.1/4.2 pNFS mount needs to do a
separate Open+LayoutGet RPC, so do not do
a Lookup+Open RPC for these mounts.

The Lookup+Open RPCs are still disabled,
until further testing is done, so this patch
has no effect at this time.
2022-03-17 07:48:06 -07:00
Hans Petter Selasky
6bce8a35cf usb(4): Check return value from bus_generic_get_device_path().
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-17 15:27:50 +01:00
Hans Petter Selasky
5e203517e0 usb(4): Use the global BUS topology lock where appropriate.
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-17 15:27:45 +01:00
Roger Pau Monné
0518832011 vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized
There's too many broken hardware out there that wrongly has the
ACPI_FADT_NO_VGA bit set. Ignore it unless running as a virtualized
guest, as then the expectation would be that the hypervisor does
provide correct ACPI tables.

Reviewed by: emaste, 0mp, eugen
MFC: 3 days
Sponsored by: Citrix Systems R&D
PR: 230172
Differential revision: https://reviews.freebsd.org/D34392
2022-03-17 14:30:39 +01:00
Roger Pau Monné
396a8479b0 x86/xen: fix CPUID signature
MFC: 3 days
Reviewed by: cem
Sponsored by: Citrix Systems R&D
Differential revision: https://reviews.freebsd.org/D34580
2022-03-17 12:56:36 +01:00
Kristof Provost
0bf7acd6b7 if_epair: build fix
66acf7685b failed to build on riscv (and mips). This is because the
atomic_testandset_int() (and friends) functions do not exist there.
Happily those platforms do have the long variant, so switch to that.

PR:		262571
MFC after:	3 days
2022-03-17 06:43:47 +01:00
Robert Wing
ab2dbd9b87 ffs_mount(): fix snapshotting
Commit 0455cc7104 broke snapshotting for ffs. In that commit,
ffs_mount() was changed so the namei() lookup for a disk device happens
before ffs_snapshot(). This caused the issue where namei() would lookup
the snapshot file and fail because the file doesn't exist. Even if it did
exist, taking a snapshot would still fail since it's not a disk device.

Fix this by taking a snapshot of the filesystem as-is and return without
altering ro/rw or any other attributes that are passed in.

Reported by:    pho
Reviewed by:	mckusick
Fixes: 0455cc7104 ("ffs_mount(): return early if namei() fails to lookup disk device")
Differential Revision:	https://reviews.freebsd.org/D34562
2022-03-16 17:32:37 -08:00
Michael Gmelin
66acf7685b if_epair: fix race condition on multi-core systems
As an unwanted side effect of the performance improvements in
24f0bfbad5, epair interfaces stop forwarding traffic on higher
load levels when running on multi-core systems.

This happens due to a race condition in the logic that decides when to
place work in the task queue(s) responsible for processing the content
of ring buffers.

In order to fix this, a field named state is added to the epair_queue
structure. This field is used by the affected functions to signal each
other that something happened in the underlying ring buffers that might
require work to be scheduled in task queue(s), replacing the existing
logic, which relied on checking if ring buffers are empty or not.

epair_menq() does:
  - set BIT_MBUF_QUEUED
  - queue mbuf
  - if testandset BIT_QUEUE_TASK:
      enqueue task

epair_tx_start_deferred() does:
  - swap ring buffers
  - process mbufs
  - clear BIT_QUEUE_TASK
  - if testandclear BIT_MBUF_QUEUED
      enqueue task

PR:		262571
Reported by:	Johan Hendriks <joh.hendriks@gmail.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34569
2022-03-16 23:08:55 +01:00
Zhenlei Huang
ba46c6c4b7 x86: Correctly report unexpected cache level
Reviewed by:	rpokala, emaste
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34577
2022-03-16 16:30:38 -04:00
Gleb Smirnoff
a693d17b99 pf: fix !INET or !INET6 builds
Fixes:	pfr_match_addr8a42005d1e4
2022-03-16 12:52:07 -07:00
Ed Maste
e997f33700 Add Tempo Semiconductor 92HD95B HDA codec ID
This codec is found in recent versions of the Framework laptop.  Tempo
Semiconductor acquired these products from IDT's Audio Business Unit.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-03-16 12:22:23 -04:00
Hans Petter Selasky
19837718ab xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Submitted by:		John F Carr <jfc@mit.edu>
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-16 16:49:00 +01:00
Hans Petter Selasky
c6cf874c7d LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
MFC after:		1 week
Sponsored by:		NVIDIA Networking
2022-03-16 15:44:07 +01:00
Vincenzo Maffione
3937299165 netmap: Fix TOCTOU vulnerability in nmreq_copyin
The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after:	3 days
2022-03-16 06:58:50 +00:00
Vincenzo Maffione
694ea59c70 netmap: Fix integer overflow in nmreq_copyin
An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085
2022-03-16 06:57:54 +00:00
Eugene Grosbein
adbf7727b3 virtio_random(8): avoid deadlock at shutdown time
FreeBSD 13+ running as virtual guest may load virtio_random(8) driver
by means of devd(8) unless the driver is blacklisted or disabled
via device.hints(5). Currently, the driver may prevent
the system from rebooting or shutting down correctly.

This change deactivates virtio_random at very late stage
during system shutdown sequence to avoid deadlock
that results in kernel hang.

PR:		253175
Tested by:	tom
MFC after:	3 days
2022-03-16 11:41:51 +07:00
Justin Hibbits
d7661890ef gpiopower: Fix failure case for attach
Summary:
We really should be checking the return value of
ofw_gpiobus_parse_gpios_impl, not the value of sc_pins, which isn't
changed on failure.

Reported by:	alfredo@

Reviewers: #powerpc, alfredo

Reviewed By: #powerpc, alfredo

Subscribers: imp, loos

Differential Revision: https://reviews.freebsd.org/D34571
2022-03-15 19:16:17 -05:00
Andrew Turner
813738faba Fix arm64 TLB invalidation with non-4k pages
When using 16k or 64k pages atop will shift the address by more than
the needed amount for a tlbi instruction. Replace this with a new macro
to shift the address by 12 and use PAGE_SIZE in the for loop to let the
code work with any page size.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34516
2022-03-15 17:25:28 +00:00
Andrew Turner
51f5cafcdc Remove a redundant L1_BLOCK == L2_BLOCK check
We have two checks for L1_BLOCK == L2_BLOCK. Remove one.

Sponsored by:	The FreeBSD Foundation
2022-03-15 17:25:28 +00:00
Alfredo Dal'Ava Junior
aa37fbc200 powerpcspe: add virtio in-kernel support
Adding it in order to make easier using powerpcspe images under qemu

Reviewed by:	jhibbits
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D34554
2022-03-15 09:34:22 -03:00
Mateusz Guzik
b3b50e64d7 zfs: add missing replay check to an assert in zfs_xvattr_set 2022-03-15 11:38:58 +00:00
Andrew Turner
f2e36d47e3 Make page size dynamic in libkvm for arm64
To allow for a future 16k or 64k page size we need to tell libkvm which
is being used. Add a flag field in unused space in minidumphdr and use
it to signal between the different options.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34548
2022-03-15 09:52:15 +00:00
Andrew Turner
5e2f304cb4 Fix calculating l0index in _pmap_alloc_l3 on arm64
When moving from the l1 index to l0 index we need to use the l1 shift
value not the l0 shift value. With 4k pages they are identical, however
with 16k pages we only have 2 l0 entries so the shift value is incorrect.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34517
2022-03-15 09:51:41 +00:00
Wei Hu
80c3eb7bc6 Hyper-V: hn: add switch to turn on and off RSC
Currently RSC offloading is enabled by default.
With this new change rsc will be disabled by default.
By using sysctl we can enable and disable it.

Reviewed by:	whu
Signed-off-by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Fixes:		a491581f3f Enable vSwitch RSC support in hn netvsc driver
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D34507
2022-03-15 08:12:22 +00:00
Kristof Provost
8a42005d1e pf: support basic L3 filtering in the Ethernet rules
Allow filtering based on the source or destination IP/IPv6 address in
the Ethernet layer rules.

Reviewed by:	pauamma_gundo.com (man), debdrup (man)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34482
2022-03-14 22:42:37 +01:00
John Baldwin
2814ba8ef1 Move NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.
Reviewed by:	imp, dim, emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34537
2022-03-14 14:05:25 -07:00
Wojciech Macek
25bcd81b8d armv6/legacy: optimize cpu_getcount performance
Use nanotime instread of binuptime.
This change is for old and legacy platforms and does not impact any armv7 and later.
Might be MFCed to 13.0 once armv6 support is finally dropped in 14.0

Sponsored by:		Stormshield
Reviewed by:		mw
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D33719
2022-03-14 07:51:21 +01:00
Rick Macklem
57014f21e7 nfscl: Fix NFSv4.1/4.2 Lookup+Open RPC
Use of the Lookup+Open RPC is currently disabled,
due to a problem detected during testing.  This
patch fixes this problem.  The problem was that
nfscl_postop_attr() does not parse the attributes
if nd_repstat != 0.  It also would parse the
return status for the operation, where the
Lookup+Open code had already parsed it.

The first change in the patch does not make any
semantics change, but makes the code identical
to what is done later in the function, so that
it is apparent that the semantics should be the
same in both places.

Lookup+Open remains disabled while further
testing is being done, so this patch has no
effect at this time.
2022-03-13 13:15:12 -07:00
Mateusz Guzik
0134bbe56f vfs: prefix lookup and relookup with vfs_
Reviewed by:	imp, mckusick
Differential Revision:		https://reviews.freebsd.org/D34530
2022-03-13 14:44:39 +00:00
Mateusz Guzik
02fc4e319c cache: use flexible array member
... instead of 0-sizing the array
2022-03-13 14:43:35 +00:00
Alexander Motin
7f16b501e2 GEOM: Introduce partial confxml API
Traditionally the GEOM's primary channel of information from kernel to
user-space was confxml, fetched by libgeom through kern.geom.confxml
sysctl.  It is convenient and informative, representing full state of
GEOM in a single XML document.  But problems start to arise on systems
with hundreds of disks, where the full confxml size reaches many
megabytes, taking significant time to first write it and then parse.

This patch introduces alternative solution, allowing to fetch much
smaller XML document, subset of the full confxml, limited to 64KB and
representing only one specified geom and optionally its parents.  It
uses existing GEOM control interface, extended with new "getxml" verb.
In case of any error, such as the buffer overflow, it just transparently
falls back to traditional full confxml.  This patch uses the new API in
user-space GEOM tools where it is possible.

Reviewed by:	imp
MFC after:	2 month
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D34529
2022-03-12 11:55:52 -05:00
Ed Maste
cf8880d52b teken: color #3 is yellow not brown - use TC_YELLOW as the name
The console escape code standard (ECMA-48) specifies color #3 (escape
code 33) as yellow.  A brown console color is an artifact of the VGA
palette, which replaces dim (but not bright) yellow with brown.

Reviewed by:	adrian, imp
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34531
2022-03-12 09:17:29 -05:00
Mateusz Guzik
66b177e1b4 vfs: reduce spurious zeroing in VOP_STAT
clang fails to take advantage of the fact that majority of the struct
gets written to in the routine and decides to bzero the entire thing.

Explicitly zero padding and spare fields, relying on KMSAN to catch
problems should anything pop up later which also needs explicit
zeroing.

fstat on tmpfs (ops/s):
before: 8216636
after:  8508033
2022-03-12 12:05:37 +00:00
Mateusz Guzik
381dd12cea vfs: stop evaluating the argument multpile times in stat macros 2022-03-12 11:47:07 +00:00
John Baldwin
6bb7ba4aa1 arm64 hwpmc: Support restricting counters to user or kernel mode.
Support the "usr" and "os" qualifiers on arm64 events to restrict
event counting to either usermode or the kernel, respectively.  If
neither qualifier is given, events are counted in both.

Reviewed by:	emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34527
2022-03-11 11:29:45 -08:00
John Baldwin
456d57a66d aarch64: Add constants for fields in the PMEVTYPERn_EL0 event registers.
Reviewed by:	andrew
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34526
2022-03-11 11:29:45 -08:00
Andrew Turner
7e35f7834c Revert "Add the PMCR_EL0.N arm64 register field"
This reverts commit b6fd96ed0b.
2022-03-11 17:52:08 +00:00
Hans Petter Selasky
a23e475c48 lindebugfs: Make single_release() NULL safe.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-11 17:41:33 +01:00
Hans Petter Selasky
68ec2949ad lindebugfs: The Linux file operations use negative return values in the kernel.
Fix sign.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-11 17:41:33 +01:00
Hans Petter Selasky
88a29d89eb lindebugfs: Zero the linux_file structure before use.
This avoids clients using garbage values on the stack and makes
debugging easier.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-11 17:41:33 +01:00
Andrew Turner
4dc815608e Add more arm64 register op* and CR* values
These will be used by bhyve/arm64.

Sponsored by:	Innovate UK
2022-03-11 11:21:09 +00:00
Andrew Turner
b6fd96ed0b Add the PMCR_EL0.N arm64 register field
Sponsored by:	Innovate UK
2022-03-11 11:21:09 +00:00
Andrew Turner
a1b4e4fa9a Correct the location of the arm64 PMCR register
This was one of the last registers to not be in alphabetical order in
armreg.h. Fix this to make it easier to find.

Sponsored by:	Innovate UK
2022-03-11 11:21:09 +00:00
Andrew Turner
2abeef7300 Sort the M* and P* arm64 registers
Sponsored by:	Innovate UK
2022-03-11 11:21:09 +00:00
Martin Matuska
f03aca96b8 zfs: update zfs_config.h and zfs_gitrev.h
Update zfs_config.h and zfs_gitrev.h as missed in c03c5b1c8
2022-03-11 07:45:48 +01:00
John Baldwin
832acea92f icl_soft: Use PHYS_TO_DMAP instead of pmap_map_io_transient.
The latter API is not actually MI but is only supported on amd64,
arm64, and RISC-V.

Sponsored by:	Chelsio Communications
2022-03-10 18:20:28 -08:00
John Baldwin
2beaefe884 cxgbei: Support unmapped I/O requests.
- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- Add new page pod routines for allocating and writing page pods for
  unmapped bio requests.  Use these new routines for setting up DDP
  for iSCSI tasks with a SCSI I/O CCB which uses CAM_DATA_BIO.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.  This also requires changes in the t4_push_pdus path
  to support unmapped mbufs.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34383
2022-03-10 15:50:52 -08:00
John Baldwin
530e725d8e iscsi: Support unmapped I/O requests in the default initiator.
- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.

- Use m_apply with a helper to compute crc32 digests on mbuf chains
  to handle unmapped mbufs.  Since m_apply requires PMAP_HAS_DMAP
  for unmapped mbufs, only support unmapped requests when PMAP_HAS_DMAP
  is true.

Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D34406
2022-03-10 15:50:26 -08:00
John Baldwin
7aab9c14a4 iscsi: Handle unmapped I/O requests.
Don't assume that csio->data_ptr is pointer to a data buffer that can
be passed to icl_get_pdu_data and icl_append_data.  For unmapped I/O
requests, csio->data_ptr is instead a pointer to a struct bio as
indicated by CAM_DATA_BIO.  To support these requests, add
icl_pdu_append_bio and icl_pdu_get_bio methods which pass a pointer to
the bio and an offset and length relative to the bio's buffer.

Note that only backends supporting unmapped requests need to implement
these hooks.

Implement simple no-op hooks for the iser backend.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34382
2022-03-10 15:49:53 -08:00
John Baldwin
c6a43f7f10 iser: Fix check for opcodes in iser_conn_pdu_append_data.
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34487
2022-03-10 15:49:37 -08:00
John Baldwin
9c7a4875bc iscsi: Use ICL_NOCOPY for SCSI command immediate data and R2T.
The associated csio ccb will not be completed via xpt_done() until
after the associated PDUs are transmitted to the other side and either
the original PDU is acked with a SCSI response, or a response is
received for a subsequent abort CCB (which means the earlier PDU has
also been sent since it would have been sent before the abort PDU).

This does assume that once an I/O request has been aborted, no further
PDUs with data payload are queued for that I/O request.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34405
2022-03-10 15:48:20 -08:00
John Baldwin
6b71405bfe Store core dump notes for all valid register sets for FreeBSD processes.
In particular, use a generic wrapper around struct regset rather than
requiring per-regset helpers.  This helper replaces the MI
__elfN(note_prstatus) and __elfN(note_fpregset) helpers.  It also
removes the need to explicitly dump NT_ARM_ADDR_MASK in the arm64
__elfN(dump_thread).

Reviewed by:	markj, emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34446
2022-03-10 15:40:19 -08:00
John Baldwin
904a13759c ddb: Add 'show gic <name>' and 'show all gics' commands.
To handle the different register layouts for different versions, add a
GIC_DB_SHOW() method.  Currently this hook is only implemented for
versions 1 and 2.

Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34415
2022-03-10 15:39:37 -08:00
Eugene Grosbein
f5a2e7b0e8 linuxkpi: fix module build outside of kernel build environment
MFC after:	3 days
2022-03-11 04:31:23 +07:00
Ed Maste
a2774a9264 vt: clarify comments on kbd add/release
PR:		247498
2022-03-10 16:04:57 -05:00
Andrew Turner
5055ffaeba Remove an unneeded memset from the arm64 pmap
There is no need to zero pagetable_dmap as we already did it when
creating the page tables in locore.S

Sponsored by:	The FreeBSD Foundation
2022-03-10 19:13:49 +00:00
Andrew Turner
ba3b602001 Split out creating the arm64 L2 dmap entries
When creating the DMAP region we may need to create level 2 page table
entries at the start and end of a block of memory. The code to do this
was almost identical so we can merge into a single function.

Sponsored by:	The FreeBSD Foundation
2022-03-10 18:17:06 +00:00
Andrew Turner
854d5a4f72 Remove l1ptfrom pmap_early_vtophys on arm64
The first argument was unused as we use an address translation
instruction to get the physical address.

Sponsored by:	The FreeBSD Foundation
2022-03-10 18:17:06 +00:00
Mateusz Guzik
b163dcab27 pf: hoist the unlinked rules lock out of the mass rule removal loop
Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-10 17:20:41 +00:00
Mateusz Guzik
f11b6505f1 pf: add PF_UNLNKDRULES_ASSERT
Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-10 17:20:41 +00:00
Mateusz Guzik
15ada75149 pf: remove spurious zeroing from pf_ioctl_addrule
Newly allocated counters are guaranteed to be 0.

This removes 5 IPIs for each loaded rule.

Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-10 17:20:41 +00:00
Corvin Köhne
e47fe3183e bhyve: add ROM emulation
Some PCI devices especially GPUs require a ROM to work properly.
The ROM is executed by boot firmware to initialize the device.
To add a ROM to a device use the new ROM option for passthru device
(e.g. -s passthru,0/2/0,rom=<path>/<to>/<rom>).

It's necessary that the ROM is executed by the boot firmware.
It won't be executed by any OS.
Additionally, the boot firmware should be configured to execute the
ROM file.
For that reason, it's only possible to use a ROM when using
OVMF with enabled bus enumeration.

Differential Revision:	https://reviews.freebsd.org/D33129
Sponsored by:   Beckhoff Automation GmbH & Co. KG
MFC after:      1 month
2022-03-10 12:30:37 +01:00
Kornel Duleba
b344de4d0d Extend device_get_property API
In order to support various types of data stored in device
tree properties or ACPI _DSD packages, create a new enum so
the caller can specify the expected type of a property they
want to read, according to the binding. The bus logic will use
that information to process the underlying data.

For example in DT all integer properties are stored in BE format.
In order to get constant results across different platforms we
need to convert its endianness to match the host.

Another example are ACPI_TYPE_INTEGER properties stored
as uint64_t. Before this patch the ACPI logic would refuse
to read them if the provided buffer was smaller than 8 bytes.
Now this can be handled by using DEVICE_PROP_UINT32 type.

Modify the existing consumers of this API to reflect the changes
and update the man pages accordingly.

Reviewed by: mw
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33457
2022-03-10 12:11:32 +01:00
Kornel Duleba
206dc82bc3 bus_if: Add a default implementation of get_property
There are multiple buses that pretend to be ofw compatible,
e.g ofw_pci, mii_fdt. We now need to provide an implementation
of BUS_GET_PROPERTY for every one of them. Instead of modifying
them one by one it's better to just provide a default
implementation that simply traverses up the device tree.
Remove the now unneeded BUS_GET_PROPERTY implementation in mii_fdt.

Reviewed by: andrew, bz
Obtained from: Semihalf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34031
2022-03-10 12:11:32 +01:00
Andrew Turner
a19acfd56c Fix the arm64 DMAP start address in a comment
Sponsored by:	The FreeBSD Foundation
2022-03-10 11:00:44 +00:00
Andrew Turner
f62e099ed5 Fix the TCR_TG0 values
They are in a different order to the TCR_TG1 values but appear to have
been copied incorrectly.

While here use TCR_TG0_4K in locore.S to make it explicit the userspace
page size is 4K.

Sponsored by:	The FreeBSD Foundation
2022-03-10 10:54:39 +00:00
Andrew Turner
9cf15aefb9 Fix the spelling of EFI_PAGE_SIZE
We assume EFI_PAGE_SIZE is the same as PAGE_SIZE, however this may not
be the case. Use the former when working with a list of pages from the
UEFI firmware so the correct size is used.

This will be needed on arm64 where PAGE_SIZE could be 16k or 64k in the
future. The other architectures have been updated to be consistent.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34510
2022-03-10 10:43:54 +00:00
Andrew Turner
e3f7087489 Add more arm64 PAC identification fields
Sponsored by:	The FreeBSD Foundation
2022-03-10 10:43:48 +00:00
Mateusz Guzik
3a4c5dab92 vfs: [2/2] fix stalls in vnode reclaim by only counting attempts
... and ignoring if they succeded, which matches historical behavior.

Reported by:	pho
2022-03-10 09:41:50 +00:00
Mateusz Guzik
c35ec1efdc vfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru
Reported by:	pho
2022-03-10 09:41:50 +00:00
Rick Macklem
3fc3fe9091 nfsd: Do not exempt NFSv3 Fsinfo from the TLS check
The Fsinfo RPC is exempt from the check for
Kerberized NFS being required, as recommended
by RFC2623.  However, there is no reason to
exempt Fsinfo from the requirement to use TLS.

This patch fixes the code so that the exemption
only applies to Kerberized NFS and not
NFS-over-TLS.

This only affects NFS-over-TLS for an NFSv3
mount when it is required, but the client does
not do so.

MFC after:	1 month
2022-03-09 16:52:42 -08:00
John Baldwin
f1d450ddee bhyve: Remove VM_MAXCPU from the userspace API/ABI.
Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D34494
2022-03-09 15:39:28 -08:00
Ryan Moeller
2ea6414ed8 zfs: Fix typo in module Makefile
Fixes:	c03c5b1c80
Sponsored by:	iXsystems, Inc.
2022-03-09 18:19:42 +00:00
Warner Losh
4f77349d57 Update smartqpi driver to vendor's latest submission
Newly added features & bug fixes

o Fixed an issue smartpqi debug log messages are flooding kernel logs.
o Fixed an issue where devices are shown as RAID 0 in display info.
o Feature: Changed 32 bit dma address to 64 bit address
o Added new controlller ids.

Submitted by:		Microsemi
Reviewed by:		Scott Benesh (Microsemi), imp
Differential Revision:	https://reviews.freebsd.org/D34469
MFC After:		3 days

Sponsored by:		Netflix
2022-03-08 17:05:36 -07:00
John Baldwin
bca6e339ac cxgbe tom: Compile fix for disabled KTR trace.
Sponsored by:	Chelsio Communications
2022-03-08 14:30:51 -08:00
John Baldwin
87b0e7711f cxgbe tom: Use VM_PAGE_TO_PHYS().
Sponsored by:	Chelsio Communications
2022-03-08 14:30:26 -08:00
John Baldwin
44e7472d0e cxgbe tom: Use be64toh instead of htobe64 to convert to host order.
This is a no-op but more accurately conveys intent.

Sponsored by:	Chelsio Communications
2022-03-08 14:30:05 -08:00
John Baldwin
de414339c9 cxgbe tom: Use vm_paddr_t for physical addresses in page pod routines.
Sponsored by:	Chelsio Communications
2022-03-08 14:28:06 -08:00
Hans Petter Selasky
c7cd6f809d usb(4): Don't skip calling uhub_explore_sub() even on HUB port errors.
This should fix an issue where the "udev->re_enumerate_wait" field never gets
processed and reset. In this case usbconfig will wait forever and never return.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-08 19:59:23 +01:00
Martin Matuska
c03c5b1c80 zfs: merge openzfs/zfs@a86e08941 (master) into main
Notable upstream pull request merges:
  #9078:  log xattr=sa create/remove/update to ZIL
  #11919: Cross-platform xattr user namespace compatibility
  #13014: Report dnodes with faulty bonuslen
  #13016: FreeBSD: Fix zvol_cdev_open locking
  #13019: spl: Don't check FreeBSD rwlocks for double initialization
  #13027: Fix clearing set-uid and set-gid bits on a file when
          replying a write
  #13031: Add enumerated vdev names to 'zpool iostat -v' and
          'zpool list -v'
  #13074: Enable encrypted raw sending to pools with greater ashift
  #13076: Receive checks should allow unencrypted child datasets
  #13098: Avoid dirtying the final TXGs when exporting a pool
  #13172: Fix ENOSPC when unlinking multiple files from full pool

Obtained from:	OpenZFS
OpenZFS commit:	a86e089415
2022-03-08 18:53:02 +01:00
Greg V
45b6c31a38 bcm5974(4): set mode again on resume
This is necessary to not break SPI devices on suspend-resume.

Reviewed by:    wulf
MFC with:       5aa839c9e2
Differential revision:  https://reviews.freebsd.org/D34434
2022-03-08 15:51:07 +03:00
Greg V
fda9ac06aa bcm5974(4): fix endian conversion signedness bug
This fixes wrong coordinates resulting in weird behavior.

Reviewed by:	wulf
MFC with:	5aa839c9e2
Differential revision:	https://reviews.freebsd.org/D34433
2022-03-08 15:51:06 +03:00
Hans Petter Selasky
b18c510844 mlx5/mlx4: Bump driver version to 3.7.1
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-08 13:12:03 +01:00
Andrew Turner
ed30663426 Make the arm64 get_pcpu a function again
We assume the pointer returned from get_pcpu will be consistent even
if the thread is moved to a new CPU. Fix this by partially reverting
63c858a04d to make get_pcpu a function again.

Sponsored by:	The FreeBSD Foundation
2022-03-08 11:54:58 +00:00
Andrew Turner
e793a55a74 Print the instruction for the unknown exception
The arm64 unknown exception will be raised when we execute an
instruction that id invalid or disabled. To help debug these print
the instruction that failed.

Sponsored by:	The FreeBSD Foundation
2022-03-08 11:54:58 +00:00
Hans Petter Selasky
a75444c143 u3g(4): Add new USB IDs.
Submitted by:	Matthew Luckie <mjl@luckie.org.nz>
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-03-08 11:03:33 +01:00
Navdeep Parhar
9282f04ff0 cxgbe(4): dump_devlog should never fail silently.
Do the same thing as dump_cimla and log a warning on failure.

MFC after:	3 days
Sponsored by:	Chelsio Communications
2022-03-07 12:05:48 -08:00
Robert Wing
0455cc7104 ffs_mount(): return early if namei() fails to lookup disk device
With soft updates enabled, an INVARIANTS panic is hit in ffs_unmount().

The problem occurs in ffs_mount() when upgrading a mount from ro->rw.
During a mount update, the soft update code gets set up but doesn't get
cleaned up if namei() fails when looking up the disk device.

Avoid this scenario by looking up the disk device first and bail early
if the namei() lookup fails.

PR:             256511
MFC After:      2 weeks
Reviewed by:	mckusick, kib
Differential Revision:	https://reviews.freebsd.org/D30870
2022-03-07 10:48:44 -09:00
Alexander Motin
dd7a5bc1e6 GEOM: Make G_F_CTLDUMP also dump result.
MFC after:	1 month
2022-03-07 14:41:47 -05:00
Marcin Wojtas
016f965722 Revert "sdhci: extend bus_dma_tag boundary to 64-bit space"
This reverts commit 7d8700bc29.

Reason for revert: the patch is incomplete. 64-bit operation
is supported fully in SDHCI v4.0, v3.0 does it only for ADMA mode.
This differentiation is missing and should be taken into consideration
in case the reverted code is re-introduced.

Reported by: mmel
2022-03-07 17:45:59 +01:00
Alexander Motin
01b9c48b5d GEOM: Skip copyin() for GCTL_PARAM_WR parameters.
Kernel does not read those parameters, so copyin is pointless.

While there, replace some KASSERT()s with CTASSERT()s.

MFC after:	1 month
2022-03-07 11:12:25 -05:00
Ed Maste
080b4e8a0c kcov: use __func__ in KASSERT instead of old function name
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-03-07 10:47:27 -05:00
Mark Johnston
afb44cb010 rmlock: Temporarily revert commit c84bb8cd77
It appears to have introduced a regression on arm64, possibly due to the
fact that the pcpu pointer is reloaded outside of the critical section
in _rm_rlock().  Until this is resolved one way or another, let's
revert.

Reported by:	Ronald Klop <ronald-lists@klop.ws>
Sponsored by:	The FreeBSD Foundation
2022-03-07 10:43:19 -05:00
Mark Johnston
bdf290cd3e ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}
ctfdump handles v2 and v3.  ctfconvert now emits only CTFv3, whereas
ctfmerge can merge v2 and v3 containers into v3 containers.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34364
2022-03-07 10:43:19 -05:00
Mark Johnston
8dbae4ce32 linker: Permit CTFv3 containers
Reviewed by:	Domagoj Stolfa
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34362
2022-03-07 10:43:19 -05:00
Mark Johnston
d9175438c0 fbt: Add support for CTFv3 containers
The general aim in this and subsequent patches is to minimize the
amount of code that directly references CTF types such as ctf_type_t,
ctf_array_t, etc.  To that end, introduce some routines similar to the
existing fbt_get_ctt_size() (which exists to deal with differences
between v1 and v2) and change ctf_lookup_by_id() to return a void
pointer.

Support for v2 containers is preserved.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34361
2022-03-07 10:43:18 -05:00
Mark Johnston
994297b01b ctf: Add definitions for CTFv3
These are based on definitions added to binutils' libctf.  Specifically:
- Type IDs are now encoded in 32 bits rather than 16, changing the
  layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t.
- Type info is encoded in 32 bits rather than 16.  The type "kind" is
  extended from 5 bits to 6, and the type "vlen" is extended from 10
  bits to 25.

The main upside is that we remove the current limit, imposed by CTFv2,
of 2^{15} distinct types in the main kernel executable.  Other limits,
such as that on the number of elements in an enum, imposed by the vlen
limit, are also raised.

This change adds v2 and v3 flavours of macros and type definitions which
differ between the two versions.  Compatibility is preserved for now by
having generic names refer to the v2 definitions, so, e.g., ctf_type_t
is still a v2 type.

No functional change intended.

Reviewed by:	Domagoj Stolfa
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34360
2022-03-07 10:43:18 -05:00
Mark Johnston
cab9382a2c linker: Simplify CTF container handling
Use sys/ctf.h to provide various definitions required to parse the CTF
header.  No functional change intended.

Reviewed by:	Domagoj Stolfa, emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34359
2022-03-07 10:43:18 -05:00
Mark Johnston
2d5d2a986c ctf: Import ctf.h from OpenBSD
Use it instead of the existing ctf.h from OpenSolaris.  This makes it
easier to use CTF in the core kernel, and to extend the CTF format to
support wider type IDs.

The imported ctf.h is modified to depend only on _types.h, and also to
provide macros which use the "parent" bit of a type ID to refer to types
in a parent CTF container.

No functional change intended.

Reviewed by:	Domagoj Stolfa, emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34358
2022-03-07 10:43:18 -05:00
Alfredo Dal'Ava Junior
c3b6408ee8 powerpc: FreeBSD kernel compatibility cleanup
Adjust FreeBSD kernel backward compatibility list

Reviewed by:	jhibbits, pkubaj
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D33421
2022-03-07 14:30:26 -03:00
Andrew Turner
db3a1eec37 Rework the arm64 sigtramp code to be a trampoline
To help with switching to a vdso sigtramp switch to passing through the
sigcode function when entering a signal. This ensures the return address
is within the function.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33690
2022-03-07 10:03:07 +00:00
Vincenzo Maffione
dd6ab49a9a netmap: add a tunable for the maximum number of VALE switches
The new dev.netmap.max_bridges sysctl tunable can be set in
loader.conf(5) to change the default maximum number of VALE
switches that can be created. Current defaults is 8.

MFC after:	2 weeks
2022-03-06 17:29:44 +00:00
Vincenzo Maffione
09a1893398 netmap: fix refcount bug in netmap allocator
Symptom: when a single extmem memory region is provided to netmap
multiple times, for multiple interfaces, the memory region is
never released by netmap once all the existing file descriptors
are closed.

Fix the relevant condition in netmap_mem_drop(): release the memory
when the last user of netmap_adapter is gone, rather then when
the last user of netmap_mem_d is gone.

MFC after:	2 weeks
2022-03-06 16:39:16 +00:00
Konstantin Belousov
1fb00c8f10 buf_alloc(): Stop using LK_NOWAIT, use LK_NOWITNESS
Despite the buffer taken from cache or free list, it still can be
locked, due to 'lockless lookup' in getblkx() potentially operating on
the freed buffers.  The lock is transient, but prevents the use of
LK_NOWAIT there for the goal of neutralizing WITNESS.

Just use LK_NOWITNESS.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-03-06 10:29:31 -05:00
Alexander Motin
25375b1415 ahci/siis/mvs: Fix panics after 3394d4239b.
Full CCB header overwrites made frees go into wrong zones, causing
kernel panics.  Instead of copying full header use xpt_setup_ccb(),
since the only field I see used from all the header is target_id.

PR:	262263
2022-03-04 20:55:23 -05:00
Mark Johnston
075e2779ac x86: Defer early TSC timecounter calibration to SI_SUB_CPU
If we can't determine the TSC frequency using CPU registers, we need to
give a chance for Hyper-V drivers to register a timecounter (during
SI_SUB_HYPERVISOR) since an emulated 8254 might not be available.
Thus, split probe_tsc_freq() into early and late stages, and wait until
the latter to attempt calibration using a reference clock.

Fixes:		84369dd523 ("x86: Probe the TSC frequency earlier")
Reported and tested by:	khng, Shawn Webb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34444
2022-03-04 19:34:43 -05:00
Mark Johnston
f7a6dccf42 amd64: Call clock_init() after finishidentcpu()
As in commit c3d830cf7c, we should finalize CPU identification before
probing the TSC frequency.

Fixes:		84369dd523 ("x86: Probe the TSC frequency earlier")
Reported by:	khng
2022-03-04 19:32:39 -05:00
Eric Joyner
61d83041ab
ice(4): Fix build error when ALTQ is enabled
The previous commit (56429daea2) that updated the driver included a
bug where a variable was undefined when ALTQ was enabled; this fixes
that issue to declare the missing variable. This wasn't caught before
because we don't use ALTQ, and so it fell on the Jenkins CI's LINT
builds to catch it.

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

Reported by:	Jenkins CI
MFC after:	3 days
MFC with:	56429daea2
Sponsored by:	Intel Corporation
2022-03-04 14:11:14 -08:00
Piotr Pietruszewski
d381c80751
ix(4): Add control of 2.5/5G autonegotiation speeds
This change enables the user to control 2.5G and 5G autonegotiation
speeds via advertise_speed sysctl for X550T devices. Due to reported
interoperability issues with switches, 2.5G and 5G speeds will not be
advertised by default.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Co-authored-by: Krzysztof Galazka <krzysztof.galazka@intel.com>

Tested by:	gowtham.kumar.ks@intel.com
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision: https://reviews.freebsd.org/D26245
2022-03-04 10:53:07 -08:00
Piotr Pietruszewski
a3e719bbc2
ixv(4): Allow PF to control the VF link state
This patch adds checks of a VF link state provided by PF via mailbox
API. Such change enables the PF to disable a VF administratively.

Since command needed by the PF to control the VF is introduced in
mailbox api version 1.2, this patch also bumps supported mailbox api
version to 1.2.

Co-authored-by: Krzysztof Galazka <krzysztof.galazka@intel.com>

Reviewed By:	kbowling@
Tested by:	lukasz.szczepaniak@intel.com
MFC after:	3 days
Sponsored by:	Intel Corporation
Differential Revision: https://reviews.freebsd.org/D32004
2022-03-04 10:53:07 -08:00
Eric Joyner
56429daea2
ice(4): Update to 1.34.2-k
- Adds FW logging support
  - Once enabled, this lets the firmware print event and error messages
    to the log, increasing the visibility into what the hardware is
    doing; this is useful for debugging
- General bug fixes
- Adds inital DCB support to the driver
  - Notably, this adds support for DCBX to the driver; now with the
    fw_lldp sysctl set to 1, the driver and adapter will adopt a DCBX
    configuration sent from a link partner
  - Adds statistcs sysctls for priority flow control frames
  - Adds new configuration sysctls for DCB-related features: (VLAN) user
    priority to TC mapping; ETS bandwidth allocation; priority flow
    control
- Remove unused SR-IOV files (until support gets added)

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

Tested by:	jeffrey.e.pieper@intel.com
MFC after:	3 days
MFC with:	213e91399b, e438f0a975
Relnotes:	yes
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D34024
2022-03-04 10:51:41 -08:00
Ram Kishore Vegesna
625a8bfb04 ocs_fc: Ignore flogi failure when the remote node is pt2pt winner
Updated commit 79c56c9af5, do not proceed with discovery
if flogi fails in pt2pt winner case.

MFC after: 3 days
2022-03-04 20:23:38 +05:30
Ram Kishore Vegesna
965e2154e7 ocs_fc: Support persistent topology feature
Summary: Enable persistent topology across power cycles/firmware resets.

Reviewed by: mav

MFC after: 3 days

Differential Revision: https://reviews.freebsd.org/D34425
2022-03-04 10:19:03 +05:30
Ram Kishore Vegesna
57e4b67755 ocs_fc: Do not respond to unsolicited NOP BLS command.
Summary: Drop unsolicited BLS commands other than ABTS.

Reviewed by: mav

MFC after: 3 days

Differential Revision: https://reviews.freebsd.org/D34423
2022-03-04 10:19:03 +05:30
Ram Kishore Vegesna
79c56c9af5 ocs_fc: Ignore flogi failure when the discovery is already done.
Summary:
Some targets are not responding to the FLOGI in point-to-point topology,
If the pt2pt discovery is done, Ignore the FLOGI failure.

MFC after: 3 days

Differential Revision: https://reviews.freebsd.org/D34422
2022-03-04 10:19:03 +05:30
Alexander Motin
56070dd2e4 Improve timeout precision of pthread_cond_timedwait().
This code was not touched when all other user-space sleep functions were
switched to sbintime_t and decoupled from hardclock.  When it is possible,
convert supplied times into sbinuptime to supply directly to msleep_sbt()
with C_ABSOLUTE.  This provides the timeout resolution of few microseconds
instead of 2 milliseconds, plus avoids few clock reads and conversions.

Reviewed by:	vangyzen
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D34163
2022-03-03 22:03:09 -05:00
John Baldwin
0b25cbc79d Fix the size returned for NT_FPREGSET.
Sponsored by:	University of Cambridge, Google, Inc.
2022-03-03 17:53:06 -08:00
John Baldwin
9af41803cb Use vnsz2log directly in assertion on its relation to sizeof(struct vnode).
This reduces the size of diffs required to support different values of
vnsz2log.  In CheriBSD, kernels for CHERI architectures have vnodes
larger than 512 bytes and require a value of 9.

Reviewed by:	mjg
Obtained from:	CheriBSD
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34418
2022-03-03 17:52:07 -08:00
Bjoern A. Zeeb
5493c6277a LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux
MODULE_DEVICE_TABLE.

This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do
not currently as they attach to vgapci0 which in turn grabs the PCI
to my understanding) and make any loading from loader or kld_list in
rc.conf unnecessary; see devmatch(8) for more information.

We need to ensure there is a DRIVER_MODULE() (or probably just
a DECLARE_MODULE but that makes not much difference) before the
MODULE_PNP_INFO (which we otherwise would not need).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D26651
2022-03-04 00:12:45 +00:00
Bjoern A. Zeeb
fbedd9d708 LinuxKPI: remove duplicate include
Remove a duplicate bus.h include from pci.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-03-04 00:04:19 +00:00
Bjoern A. Zeeb
3d248a914d iwlwifi: adjust the LinuxKPI pci return for now
Rather than having LinuxKPI return BUS_PROBE_DEFAULT, return
"one less" so that on conflict of IDs others would be preferred.

This means that iwm(4) will attach instead of iwlwifi(4) for the
chipsets iwm(4) supports and iwlwifi(4) only for the other--in iwm(4)
unsupported--chipsets.  This is done so that we can enable auto-loading
of drivers but for the upcoming 13.1-Release people with working iwm(4)
will not yet be affected by iwlwifi(4).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-03-03 23:16:40 +00:00
Bjoern A. Zeeb
b91dd79ba3 LinuxKPI: allow a driver to override the default pci probe result
Add bsd_probe_return which a driver can set in their 'struct pci_driver'
definition to set a driver-sepcific LinuxKPI pci return value.
This is helpful in case of multiple drivers with overlapping IDs,
such as iwlwifi(4) and iwm(4).

Contrary to an earlier version we now assume 0 is not BUS_PROBE_SPECIFIC
(which no driver should really return these days) but the bss initialized
value (bsd_probe_return unset) and we will return BUS_PROBE_DEFAULT.

Suggested by:	jhb
Reviewed by:	jhb
Reviewed by:	hselasky, imp (earlier versions)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC:		new struct members need to go to the end for stable/13
Differential Revision:	https://reviews.freebsd.org/D33915
2022-03-03 23:16:39 +00:00
Mateusz Guzik
d283601b80 Revert "Expand __diagused to include the KTR kernel diagnostic option."
This reverts commit 55339af296.

Induces warnings for kernels built with KTR but without debug.

Discussed with:	scottl
2022-03-03 20:26:59 +00:00
Santiago Martinez
52bcdc5b80 if_epair: fix build with RSS and INET or INET6 disabled
Reviewed by:	kp
MFC after:	1 week
2022-03-03 18:31:26 +01:00
Mateusz Guzik
afb08a6d07 cache: hide hash stats behind DEBUG_CACHE
They take a long time to dump and hinder sysctl -a when used with
DIAGNOSTIC.
2022-03-03 17:21:58 +00:00