Commit graph

270775 commits

Author SHA1 Message Date
Alexander Motin
2bd4b5475f hwpmc: Skip GLOBAL_CTRL updates on stop_pmc().
After we wipe PMC configuration, including its local enable bit(s),
we don't really care about its global enable bit.  Global enable bits
now may only be cleared by interrupt handler in case of error (sample
buffer overflow).  Being set is actually a reset default for them.

This saves one WRMSR per process-scope PMC per context switch, that
is clearly visible in profiles.

MFC after:	1 month

(cherry picked from commit 326a8d3e08)
2022-07-04 13:48:10 -04:00
Alexander Motin
c4cafc24df libpmc: Prefer fixed counters in Intel event aliases.
It is recommended by Intel to use fixed counters when possible to
leave programmable ones for different events.

This fixes `pmc stat`, which tries to count 6 events same time, while
many Intel CPUs have only 4 programmable counters.

MFC after:	1 month

(cherry picked from commit e144cd92bb)
2022-07-04 13:48:10 -04:00
Alexander Motin
6b1e6a629d hwpmc: Bump Intel's IA32_PERFEVTSELx width to 64 bits.
Haswell added there bits 32/33 for TSX, and AlderLake added bit 34
for Adaptive PEBS Record.

MFC after:	1 month

(cherry picked from commit 1a4614a51e)
2022-07-04 13:48:10 -04:00
Alexander Motin
fad7a311d9 hwpmc: Make powerpc memory allocation alike to x86.
It should remove some unneeded pointer dereferences.

MFC after:	1 month

(cherry picked from commit 47699fc265)
2022-07-04 13:48:10 -04:00
Alexander Motin
633cab8aa4 hwpmc: Remove always zero pc_resync field.
MFC after:	1 month

(cherry picked from commit 5acb4c862b)
2022-07-04 13:48:09 -04:00
Alexander Motin
0cd1f9831c libpmc: Fix INVERT flag mapping for both Intel and AMD.
Looks like somebody's trivial copy/paste bug.

MFC after:	1 month

(cherry picked from commit 037dd0a967)
2022-07-04 13:48:09 -04:00
Alexander Motin
b8ef2ca9ea hwpmc: Add basic Intel Alderlake CPUs support.
The PMC subsystem is not designed for non-uniform CPU capabilities
(P/E-cores are different), but at least several working architectural
events like cpu_clk_unhalted.thread_p should be better than nothing.

MFC after:	1 month

(cherry picked from commit fe109d3113)
2022-07-04 13:48:09 -04:00
Alexander Motin
e7b63a7c6d hwpmc: Update Intel's programmable counters restrictions.
Primarily remove unneeded restrictions from later CPUs.

MFC after:	1 month

(cherry picked from commit ae57fbc7ec)
2022-07-04 13:48:09 -04:00
Alexander Motin
b120f6d625 libpmc: Disable hardcoding of Intel fixed counters.
Intel json's now have pretty reasonable fixed counters representation
via event=0 and umask.  Hardcoded values create more confusion than fix.

MFC after:	1 month

(cherry picked from commit 73b7b181e6)
2022-07-04 13:48:09 -04:00
Alexander Motin
2154db2220 hwpmc: Correct selection of Intel fixed counters.
Intel json's use event=0 to specify fixed counter number via umask.
Alternatively fixed counters have equivalent programmable event/umask.

MFC after:	1 month

(cherry picked from commit c1e813d123)
2022-07-04 13:48:09 -04:00
Alexander Motin
cc2310bd2a libpmc: jevents: Sync with the latest Linux kernel.
commit f4df0dbbe62ee8e4405a57b27ccd54393971c773
Date:   Wed May 25 22:04:10 2022 +0800

MFC after:	1 month

(cherry picked from commit 62ff619dcc)
2022-07-04 13:48:09 -04:00
Alexander Motin
1b4b65dedf Revert "libpmc: jevents: Partial style(9) pass"
This file is shared with Linux.  Having local style patches does not
help with updating it.

This reverts commit 3ea691c261.

(cherry picked from commit 51f329660f)
2022-07-04 13:48:09 -04:00
Alexander Motin
a7588be68c hwpmc: Use hardware PMCs freezing on PMI on Intel v2+.
Since version 2 Intel CPUs can freeze PMCs when intering PMI to reduce
PMI effects on collected statistics.  Since version 4 hardware supports
"streamlined" mechanism, not requiring IA_GLOBAL_CTRL MSR access.

MFC after:	1 month

(cherry picked from commit 81ffb45f02)
2022-07-04 13:48:09 -04:00
Alexander Motin
698c67184a hwpmc: Add Intel Core register defines up to version 5.
MFC after:	1 month

(cherry picked from commit 245b056556)
2022-07-04 13:48:08 -04:00
Alexander Motin
e58ca5c09b libpmc: Another update of x86 event definitions.
MFC after:	1 month

(cherry picked from commit 18054d0220)
2022-07-04 13:48:08 -04:00
Mitchell Horne
78f8ebe0c3 hwpmc_intel: assert for correct nclasses value
This variable is set based on the exact CPU model detected. If this
value is set too small, it could lead to a NULL-dereference from an
improperly initialized pmc_rowindex_to_classdep array.

Though it has been fixed, this was previously the case for Broadwell.
Add two asserts to catch this in DEBUG kernels, as it represents a
configuration error that may be hard to uncover otherwise.

PR:		253687
Reported by:	Zhenlei Huang <zlei.huang@gmail.com>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8399d923a5)
2022-07-04 13:48:08 -04:00
Mitchell Horne
f0577f42b2 riscv timer: remove intermediate helper
get_counts() doesn't do anything at the moment but return the result of
get_cycles(), so remove it.

For clarity, rename get_cycles() to get_timecount(); RISC-V defines
separate time and cyclecount CSRs, so let's avoid confusing the two.
They may be backed by the same underlying clock, but this is an
implementation detail.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35461

(cherry picked from commit b82f4170fc)
2022-07-04 13:37:05 -03:00
Mitchell Horne
11895d2176 set_cputicker: use a bool
The third argument to this function indicates whether the supplied
ticker is fixed or variable, i.e. requiring calibration. Give this
argument a type and name that better conveys this purpose.

Reviewed by:	kib, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35459

(cherry picked from commit 8701571df9)
2022-07-04 13:37:05 -03:00
Mitchell Horne
b6e6c534a8 riscv timer: cleanup
- Prune unused definitions and includes
- Slight renaming of callback functions to indicate their usage
- Place vdso_fill_timehands callback logically in the file
- Small style nits

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35460

(cherry picked from commit 715276a08b)
2022-07-04 13:37:05 -03:00
Mitchell Horne
25ece2331f riscv timer: implement riscv_timer_et_stop()
Simply by masking timer interrupts.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35463

(cherry picked from commit 3a4256dd86)
2022-07-04 13:37:05 -03:00
Mitchell Horne
f64845598e riscv timer: provide a function for cpu_ticks
This is cheaper than the default of tc_cpu_ticks().

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35462

(cherry picked from commit 33734a1f76)
2022-07-04 13:37:05 -03:00
Mitchell Horne
bdedfb3a00 if_ffec: free the dmamem allocation in detach
Calling bus_dmamap_destroy() for a mapping which was allocated with
bus_dmamem_alloc() will result in a panic. This change is not run-time
tested, but I identified the issue while implementing the analogous
method in if_dwc(4), using this implementation as the template.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8757d0fca9)
2022-07-04 13:34:57 -03:00
Mitchell Horne
eea2563d7f if_ffec: fix some misleading indentation
(cherry picked from commit b93985c11a)
2022-07-04 13:34:57 -03:00
Mitchell Horne
3a72965a25 if_dwc: avoid duplicate packet counts
We already increment the unicast IPACKETS and OPACKETS counters in the
rx/tx paths, respectively. Multicast packets are counted in the generic
ethernet code. Therefore, we shouldn't increment these counters in
dwc_harvest_stats().

Drop the early return from dwc_rxfinish_one() so that we still count
received packets with e.g. a checksum error.

PR:		263817
Reported by:	Jiahao LI <jiahali@blackberry.com>
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35499

(cherry picked from commit 9718759043)
2022-07-04 13:34:57 -03:00
Mitchell Horne
5dec16de37 if_dwc: add detach method
It can be useful for testing.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35496

(cherry picked from commit 27b39e58b3)
2022-07-04 13:34:57 -03:00
Jiahao Li
164bdd8f9a if_dwc: enable RX checksum offload feature
We claim support in ifcaps, but don't actually enable it.

PR:		263886
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35498

(cherry picked from commit 35c9edab41)
2022-07-04 13:34:56 -03:00
Mitchell Horne
1da82ebe49 if_dwc: recognize additional rgmii phy-modes
Per the reports, some Allwinner device trees now list the desired
phy-mode as "rgmii-id". The manual string comparison fails to detect
this, and we end up falling back to MII mode. Instead, select the clock
name using the sc->phy_mode variable, which is set in the main attach
function.

The logic to actually handle rgmii-id mode delays will be added to the
relevant PHY driver.

PR:		261355, 264673
Reported by:	Maren <marentoy@protonmail.com>
Reported by:	Arie Bikker <src-2016@bikker.homeunix.net>
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35500

(cherry picked from commit 3428997cb3)
2022-07-04 13:34:56 -03:00
Mitchell Horne
68d02feaef if_dwc: consistently use if.c helper methods
And if_t rather than struct ifnet *. No functional change intended.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35497

(cherry picked from commit ca01879004)
2022-07-04 13:34:56 -03:00
Mark Johnston
de0b1239df vm: Fix racy checks for swap objects
Commit 4b8365d752 introduced the ability to dynamically register
VM object types, for use by tmpfs, which creates swap-backed objects.
As a part of this, checks for such objects changed from

  object->type == OBJT_DEFAULT || object->type == OBJT_SWAP

to

  object->type == OBJT_DEFAULT || (object->flags & OBJ_SWAP) != 0

In particular, objects of type OBJT_DEFAULT do not have OBJ_SWAP set;
the swap pager sets this flag when converting from OBJT_DEFAULT to
OBJT_SWAP.

A few of these checks are done without the object lock held.  It turns
out that this can result in false negatives since the swap pager
converts objects like so:

  object->type = OBJT_SWAP;
  object->flags |= OBJ_SWAP;

Fix the problem by adding explicit tests for OBJT_SWAP objects in
unlocked checks.

PR:		258932
Fixes:		4b8365d752 ("Add OBJT_SWAP_TMPFS pager")
Reported by:	bdrewery
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e123264e4d)
2022-07-04 09:06:55 -04:00
Andriy Gapon
3c04909b9c aw_mmc: add crash dumping support in MMCCAM mode
(cherry picked from commit af8b51b0ba)
2022-07-04 13:19:51 +03:00
Andriy Gapon
153664d5ad liberate wdog_kern_pat call from SW_WATCHDOG in arm minimdump code
Obviosuly, there are hardware watchdogs on arm.

(cherry picked from commit 1a93b2288c)
2022-07-04 13:17:24 +03:00
Alfredo Dal'Ava Junior
e879436ce4 loader: fix powerpc* ofw loader
With the introduction of llvm14, the powerpc* loader used on ofw/pseries
for 32 and 64 bit architectures puts the .data.rel.ro section after
.data section. This caused a crash kernel didn't boot. Bisect pointed to
change https://reviews.llvm.org/D111717 but problem could be fixed by
adding a section description to make it appear in the expected order.

This patch is based on discussion at:
        https://github.com/llvm/llvm-project/issues/56306

MFC after:	1 day
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)

(cherry picked from commit 5d48fb3b16)
2022-07-04 09:36:04 -03:00
Toomas Soome
67f8b6d985 loader: GELI encrypted disk should still use device name disk
geli_probe_and_attach() does pick geli_devsw structure for
encrypted disks, the implementation depends on device
name "disk" when device type is DEVT_DISK, but geli_devsw is
setting name field "gelidisk".

PR:		264282
Submitted by:	yamagi@yamagi.org
Reported by:	yamagi@yamagi.org

(cherry picked from commit e417249016)
2022-07-04 09:14:43 +03:00
Mateusz Piotrowski
2353343b32 Link pwd.db.5 and spwd.db.5 to passwd.5
Let's make it easier to find documentation for those databases.

MFC after:	3 days

(cherry picked from commit 87f49967d3)
2022-07-03 22:16:11 +02:00
Mateusz Piotrowski
dc90922b80 devfs.5: Replace Nm with Xr devfs 8 where appropriate
MFC after:	3 days

(cherry picked from commit 523477f8c5)
2022-07-03 22:15:32 +02:00
Jamie Gritton
cf18a61708 MFC jail: Remove a prison's shared memory when it dies
Add shm_remove_prison(), that removes all POSIX shared memory segments
belonging to a prison.  Call it from prison_cleanup() so a prison
won't be stuck in a dying state due to the resources still held.

PR:		257555
Reported by:	grembo

(cherry picked from commit 7060da62ff)
2022-07-03 12:25:43 -07:00
Jamie Gritton
06dcf1499b MFC jail: add prison_cleanup() to release resources held by a dying jail
Currently, when a jail starts dying, either by losing its last user
reference or by being explicitly killed,
osd_jail_call(...PR_METHOD_REMOVE...) is called.  Encapsulate this
into a function prison_cleanup() that can then do other cleanup.

(cherry picked from commit a9f7455c38)
2022-07-03 12:24:49 -07:00
Juraj Lutter
7c500f98b8 kldload: Bring functionality in line with manual page
Honor -q parameter and do not display any warning messages when -q is
specified.

Approved by:		dfr
MFC after:		2 weeks
Sponsored by:		Resulta, s.r.o.
Differential Revision:	https://reviews.freebsd.org/D35511

(cherry picked from commit ad0a7ea650)
2022-07-01 17:16:22 +02:00
Bjoern A. Zeeb
66754c01ff XHCI: clear warm and port reset
It seems we do not clear UPS_C_BH_PORT_RESET and UPS_C_PORT_RESET
conditions after warm or port reset.  Add that code.

Obtained from:	an old patch mainly debugging other problems
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D35483

(cherry picked from commit 8f892e9bee)
2022-07-01 13:50:19 +00:00
Bjoern A. Zeeb
39cd7aa134 USB: add quirks to XHCI
While XHCI is very generic some revisions of chipsets have problems.
On dwc3 <= 3.00a Port Disable does not seem to work so we need to not
enable it.
For that introduce quirks to xhci so that controllers can steer
certain features.  I would hope that this is and remains the only one.

Obtained from:	an old patch mainly debugging other problems
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D35482

(cherry picked from commit 447c418da0)
2022-07-01 13:50:10 +00:00
Bjoern A. Zeeb
2217448bcc LinuxKPI: 802.11: cleanup lsta better
This changes cleans up lsta from the VIF station list as well as
deals with freeing the lsta itself so it is not leaked.

lkpi_iv_update_bss() makes this more complicated than it should be
as we ties more sta state (incl. drv/fw) to the node that net80211
does not know about.  There is more work to be done detangling this
now that is better understood.

(cherry picked from commit e24e8103e0)
2022-07-01 13:50:03 +00:00
Bjoern A. Zeeb
05b1792754 LinuxKPI: 802.11: remove an early bandaid to make sure queues are allocated
iwlwifi allocates queues on first wakeup.  This takes a lot longer on
FreeBSD's work implementation that it seems to on Linux based on some
discussion.  That meant that we couldn't get non-data frames out quickly
enough initially and failed to associate.
d0d2911035 should have solved most of this
for us with iwlwifi.  None of the other drivers ported to LinuxKPI/802.11
up to today will call a dequeue so we get notified when the queus are
allocated or even need to do so.
Remove the bandaid initilly put in for iwlwifi now and speed up the
overall process of getting us associated.

(cherry picked from commit 841719c08f)
2022-07-01 13:49:55 +00:00
Bjoern A. Zeeb
d4d3ba68b7 LinuxKPI: 802.11: sync sta->addr in lkpi_iv_update_bss()
In lkpi_iv_update_bss() introduced in d9f59799fc we swap lsta and
along with that sta and drv state if ni gets reused and swapped under
us by net80211.  What we did not do was to sync sta->addr which later
(usually in lkpi_sta_assoc_to_run) during a bss_info update cause
problems in drivers (or firmware) as the BSSID and the station address
were not aligned.

If this proves to hold up to fix iwlwifi issues seem on firmware
for older chipsets, multi-assoc runs, and rtw89 (which this fixes)
we should add asserts that lkpi_iv_update_bss() can only happen in
pre-auth stages and/or make sure we factor out synching more state
fields.

Found debugging:	rtw89

(cherry picked from commit ed3ef56b29)
2022-07-01 13:49:42 +00:00
Bjoern A. Zeeb
07bec0d40e net80211 / LinuxKPI: 802.11: add Control Trigger Subframe information
Add definitions related to 802.11ax Control Trigger frame format
needed for rtw89.

(cherry picked from commit 4c3684ef5c)
2022-07-01 13:49:19 +00:00
Bjoern A. Zeeb
f5d0b181f4 LinuxKPI: 802.11: ieee80211_start_tx_ba_session()
For as long as we do not implement the compat code for tx aggregation
return -EINVAL in ieee80211_start_tx_ba_session() as both rtw88 and
rtw89 check for this value and only then disable further attempts.

(cherry picked from commit 799051e2ca)
2022-07-01 13:49:11 +00:00
Bjoern A. Zeeb
54f9ddf4ae rtw88: update Realtek's rtw88 driver
Update rtw88 based on wireless-testing at
4e051428044d5c47cd2c81c3b154788efe07ee11 (tag: wt-2022-06-10).

This is in preparation to apply USB changes to work on these and
LinuxKPI for them over the next weeks, as well to debug a
reported issue, and possibly extract and upstream some local fixes.

(cherry picked from commit 9c951734c2)
2022-07-01 13:49:02 +00:00
Bjoern A. Zeeb
a478f4afd8 LinuxKPI: move pm_message_t from kernel.h to pm.h
Move pm_message_t from kernel.h to pm.h and remove a private define
in usb.h as well as adjust the implementation in linux_usb.c.
This cleans up what I believe to be a historic shortcut and is
needed for future wireless driver updates.

Leave a note in UPDATING that drm-kmod users need to update to the
latest version before re-compiling a new kernel to avoid errors
(see PR).

Sponsored by:	The FreeBSD Foundation
PR:		264449 (drm-kmod port update, thanks wulf)
Obtained from:	bz_git_iwlwifi (Dec 2020) (partly)
Reviewed by:	hselasky, imp
Differential Revision: https://reviews.freebsd.org/D35276

(cherry picked from commit 0e981d79b1)
2022-07-01 13:48:24 +00:00
Bjoern A. Zeeb
74cedb5e90 LinuxKPI: 802.11: rework handling of the special IEEE80211_NUM_TIDS queue
Rework the way we are dealing with the last queue.  If the driver
opts in to STA_MMPDU_TXQ then preferably send all non-data frames
via the last (IEEE80211_NUM_TIDS) queue which otherwise is not used
in station mode.
If we do not have that queue we do individual tx() calls for non-data
frames now.
Everything else goes via the selected queue if possible for as long as
we have a ni (sta) and otherwise resorts to direct tx.

Tested on:	Intel AX200 and AX210
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d0d2911035)
(cherry picked from commit fb6eaf74e9)
2022-07-01 13:45:09 +00:00
Mateusz Piotrowski
b8aa1e16ab hier.7: Refer to build(7) for details about /usr/obj
MFC after:	3 days

(cherry picked from commit ecd3759719)
2022-07-01 10:46:17 +02:00
Mark Johnston
70fd40edb8 debugnet: Fix an error handling bug in the DDB command tokenizer
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c262d5e877)
2022-06-30 10:12:15 -04:00