]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agopci_dw_mv: Don't enable unhandled interrupts.
Michal Meloun [Wed, 27 Jan 2021 11:45:32 +0000 (12:45 +0100)]
pci_dw_mv: Don't enable unhandled interrupts.

Mainly link errors interrupts should only be activated on fully linked port,
otherwise noise on lanes can cause livelock. But we don't have error
counters yet, so leave these interrupts disabled.

(cherry picked from commit ce5a4083de2d79bc44d209c9e355a09ede47346c)

2 years agosimple_mfd: switch to controllable locking for syscon provider.
Michal Meloun [Thu, 4 Mar 2021 14:09:32 +0000 (15:09 +0100)]
simple_mfd: switch to controllable locking for syscon provider.

MFC after 3 weeks

(cherry picked from commit f97f57b51855cecb9b497a90dfed06dac2c21111)

2 years agomvebu_gpio: Fix settings of gpio pin direction.
Michal Meloun [Sun, 7 Mar 2021 08:50:57 +0000 (09:50 +0100)]
mvebu_gpio: Fix settings of gpio pin direction.

Data Output Enable Control register is inverted – 0 means output direction.
Reflect this fact in code.

MFC after: 3 weeks

(cherry picked from commit 01c6d7918985c6e8610d6245af0f745ced86ffd5)

2 years agomvebu_gpio: Multiple fixes.
Michal Meloun [Wed, 3 Mar 2021 17:28:45 +0000 (18:28 +0100)]
mvebu_gpio: Multiple fixes.

- gpio register access primitives
- locking in interrupt path
- cleanup

In cooperation with: mw
Reviewed by: mw (initial version)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D29044
Differential Revision: https://reviews.freebsd.org/D28911

(cherry picked from commit a5dce53b75d8750ba95623ad2dbffac4acfd3545)

2 years agomvebu_gpio: fix interrupt cause register configuration
Marcin Wojtas [Wed, 24 Feb 2021 17:02:40 +0000 (18:02 +0100)]
mvebu_gpio: fix interrupt cause register configuration

According to Armada 8k documentation, the interrupt cause register
(at offset 0x14) is RW0C. Update the configuration in attach and
the mvebu_gpio_isrc_eoi() to follow the description.

Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Marvell
Differential Revision: https://reviews.freebsd.org/D29013

(cherry picked from commit 819760b35f3196227a1d90089fb98ee115e7ed0d)

2 years agotegra/ahci: do not advertise enclosure management facility
Michal Meloun [Fri, 24 Dec 2021 19:25:36 +0000 (20:25 +0100)]
tegra/ahci: do not advertise enclosure management facility

It is not implemented in HW.

MFC after: 1 week

(cherry picked from commit 6e9119768dad5289c188e8a07aada98783b52abf)

2 years agotegra124: Implement new get_gate method for tegra124 clocks.
Michal Meloun [Fri, 24 Dec 2021 19:13:33 +0000 (20:13 +0100)]
tegra124: Implement new get_gate method for tegra124 clocks.

MFC after: 1 week

(cherry picked from commit be01656fa4cd78f191c0ad8a6f4640a0c520d5a9)

2 years agotegra210: Implement new get_gate method for tegra210 clocks.
Michal Meloun [Fri, 24 Dec 2021 17:23:59 +0000 (18:23 +0100)]
tegra210: Implement new get_gate method for tegra210 clocks.

MFC after: 1 week

(cherry picked from commit 7c0ec6638548e78a4fd85a5a2d811bac7c2da98b)

2 years agoextres/clk: Add a method to detect the HW state of the clock gate.
Michal Meloun [Fri, 24 Dec 2021 11:18:49 +0000 (12:18 +0100)]
extres/clk: Add a method to detect the HW state of the clock gate.

- add method to read gate enable/disable staust from HW
- show gate status in sysctl clock dump

MFC after: 1 week

(cherry picked from commit 1a74d77f851212f8cc80e6b15e30c2b252b84d48)

2 years agoextres/clk: Improve sysctl dump of clocks.
Michal Meloun [Fri, 24 Dec 2021 07:38:32 +0000 (08:38 +0100)]
extres/clk: Improve sysctl dump of clocks.

Always recalculate the frequency, the cache is lazily initialized so it is not always up to date.
While I'm in mark sysctl as MPSAFE.

Discussed with: manu, adrian
MFC after: 1 week

(cherry picked from commit 72a2f3b5e28ada60de01f08b28888f70eec0baed)

2 years agoarm: Fix handling of undefined instruction aborts in THUMB2 mode.
Michal Meloun [Sun, 17 Oct 2021 17:36:33 +0000 (19:36 +0200)]
arm: Fix handling of undefined instruction aborts in THUMB2 mode.

Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass
these to the appropriate handler. Note that it is not necessary to filter
all undefined instruction variant or register combinations, this is a job
for given handler.

Reported by: Robert Clausecker <fuz@fuz.su>
PR: 259187
MFC after: 2 weks

(cherry picked from commit a670e1c13a522df4fb8c63bb023b88b1d65de797)

2 years agodwmmc: Calculate the maximum transaction length correctly.
Michal Meloun [Thu, 7 Oct 2021 18:42:56 +0000 (20:42 +0200)]
dwmmc: Calculate the maximum transaction length correctly.

We should reserve two descriptors (not MMC_SECTORS) for potentially
unaligned (so bounced) buffer fragments, one for the starting fragment
and one for the ending fragment.

Submitted by: kjopek@gmail.com
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30387

(cherry picked from commit dfb7360222856e7e4f5e0e5564281a25af63319c)

2 years agobooti: Enable loading the kernel image to any address aligned to 2 MB
Michal Meloun [Fri, 9 Jul 2021 17:33:36 +0000 (19:33 +0200)]
booti: Enable loading the kernel image to any address aligned to 2 MB

We've supported this for a long time, plus most u-boot setups quietly expect

MFC after: 2 weeks

(cherry picked from commit b07a6bd15a58aa6e23761c51eba78d449cd2cbf3)

2 years agointrng: remove now redundant shadow variable.
Michal Meloun [Fri, 2 Jul 2021 18:28:25 +0000 (20:28 +0200)]
intrng: remove now redundant shadow variable.

Should not be a functional change.

Submitted by:  ehem_freebsd@m5p.com
Discussed in: https://reviews.freebsd.org/D29310
MFC after: 4 weeks

(cherry picked from commit e88c3b1b02a663f18f51167f54a50e7b4f0eca02)

2 years agointrng: Releasing interrupt source should clear interrupt table full state.
Michal Meloun [Fri, 2 Jul 2021 18:17:36 +0000 (20:17 +0200)]
intrng: Releasing interrupt source should clear interrupt table full state.

The first release of an interrupt in a situation where the interrupt table
is full should schedule a full table check the next time an interrupt is
allocated. A full check is necessary to ensure maximum separation between
the order of allocation and the order of release.

Submitted by: ehem_freebsd@m5p.com (initial version)
Discussed in: https://reviews.freebsd.org/D29310
MFC after: 4 weeks

(cherry picked from commit a49f208d94b873b2187adbfe1d785b3bc8bdc598)

2 years agoFix error value returned by ofw_bus_gen_get_node().
Michal Meloun [Thu, 24 Jun 2021 09:56:20 +0000 (11:56 +0200)]
Fix error value returned by ofw_bus_gen_get_node().

By definition ofw_bus_get_node() should  consistently return -1 when there
is no associated OF node.

MFC after: 4 weeks
Discussed with: nwhitehorn
Analyzed in:  https://reviews.freebsd.org/D30761

(cherry picked from commit 3eae4e106ac7222364fc9dc8c3d35d4ad8c5293a)

2 years agoriscv: gdb(4) support
Mitchell Horne [Fri, 11 Sep 2020 17:02:17 +0000 (14:02 -0300)]
riscv: gdb(4) support

Add the MD portion required for the gdb stub.

Reviewed by: jhb (earlier version)
Discussed with: jrtc27
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33734

(cherry picked from commit d72e944812f8774ab0b78fdff9b0204386dd6151)

2 years agoipfilter: Fixup comment
Cy Schubert [Wed, 12 Jan 2022 21:03:46 +0000 (13:03 -0800)]
ipfilter: Fixup comment

Fix comment documenting checksum block in ip_nat.c. Fastforward doesn't
perform checksum.

(cherry picked from commit 896a0153190937e071a31c682c6cf55e4c599886)

2 years agoipfilter: Fix whitespace errors
Cy Schubert [Tue, 11 Jan 2022 23:10:43 +0000 (15:10 -0800)]
ipfilter: Fix whitespace errors

(cherry picked from commit 6af38b34e4b9863171e0240df1d1d432606c21a1)

2 years agoipfilter: Fix IP header checksums post ftp proxy
Cy Schubert [Wed, 12 Jan 2022 20:55:11 +0000 (12:55 -0800)]
ipfilter: Fix IP header checksums post ftp proxy

Don't assume checksums will be calculated later in fastforward.

(cherry picked from commit 2a6465245fa3f5323c2036049a730e2f2b95d270)

2 years agoipfilter: Correct function description
Cy Schubert [Tue, 11 Jan 2022 23:02:09 +0000 (15:02 -0800)]
ipfilter: Correct function description

Correct the parameters descriptions for ipf_fix_outcksum and
ipf_fix_incksum.

(cherry picked from commit 4b5c0c9b813160842b942a4e978d482e8a7d3f7e)

2 years agommc_da: remove write-only local variables
Andriy Gapon [Wed, 12 Jan 2022 07:17:35 +0000 (09:17 +0200)]
mmc_da: remove write-only local variables

(cherry picked from commit dfb1c97ab973d6c248b4886d7cc28be72c7b33f2)

2 years agotruss(1): detach more carefully
Konstantin Belousov [Wed, 12 Jan 2022 08:21:19 +0000 (10:21 +0200)]
truss(1): detach more carefully

(cherry picked from commit 12f747e6ff675edfc1f2f95f7fc435dc01e0c29c)

2 years agotruss: remove write-only variable
Konstantin Belousov [Wed, 12 Jan 2022 08:20:51 +0000 (10:20 +0200)]
truss: remove write-only variable

(cherry picked from commit ba33c288488d4543d1a140cd5c44b8b3c4c29915)

2 years agolibc: correct SPDX tag on strstr.c
Ed Maste [Sun, 16 Jan 2022 16:56:28 +0000 (11:56 -0500)]
libc: correct SPDX tag on strstr.c

It was obtained from musl, and is MIT licensed.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2e9bc9d14440aa17e6945a9b6613ebb1711fe960)

2 years agolibc: fix misleading comment in strstr
Ed Maste [Sun, 16 Jan 2022 16:50:10 +0000 (11:50 -0500)]
libc: fix misleading comment in strstr

Obtained from: musl c53e9b239418

(cherry picked from commit c6750f07b43d18d39729570533f4ecb56da286bf)

2 years agoWhen doing a read-only mount of a UFS filesystem using gjournal(8),
Kirk McKusick [Sun, 2 Jan 2022 22:04:06 +0000 (14:04 -0800)]
When doing a read-only mount of a UFS filesystem using gjournal(8),
suppress error message about a missing gjournal provider.

Submitted by: Andreas Longwitz
Sponsored by: Netflix

(cherry picked from commit 1fbcaa13b033230c52487a270803bd0f7723e107)

2 years agosystat -vm: Humanize output for ease of reading.
Kirk McKusick [Sun, 2 Jan 2022 03:47:27 +0000 (19:47 -0800)]
systat -vm: Humanize output for ease of reading.

Using 8 width is too wide for large numbers like 1379991K;
1330M is easier to read.

Submitted by: ota_j.email.ne.jp
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33495

(cherry picked from commit a115a4aa51ae891330c9c4404dd4df13b601556f)

2 years agousbconfig: actually set the exit code in usage()
Joerg Wunsch [Mon, 20 Dec 2021 21:25:19 +0000 (22:25 +0100)]
usbconfig: actually set the exit code in usage()

Oversight in previous commit: usage() had been turned to accept
an "exitcode" parameter, but it hasn't been used.

MFC after: 2 weeks

(cherry picked from commit 1654b51455cd1c890b08685551abafec88111606)

2 years agousbconfig: implement a -v option
Joerg Wunsch [Mon, 20 Dec 2021 19:33:05 +0000 (20:33 +0100)]
usbconfig: implement a -v option

Implement a -v option to usbconfig(8), as a shortcut for the most
frequently needed commands dump_device_desc, dump_curr_config_desc,
and show_ifdrv.

While here, implement a real -h option that has been promised by the
man page.

Use <sysexits.h> to declare the utility return codes.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D33586
MFC after: 2 weeks

(cherry picked from commit d69b9cc26d1c24a4cbc37478a571b1f531aa7bcc)

2 years agousbconfig: documentation fixes, mainly for -i option
Joerg Wunsch [Mon, 20 Dec 2021 09:17:57 +0000 (10:17 +0100)]
usbconfig: documentation fixes, mainly for -i option

* in usage(), clearly mark -i interface as optional
* both, -u busnum and -a devaddr are optional as well
* various minor man page fixes
* clearly mark those two commands that actually use -i ifaceidx
* remove unused bitfield tag got_iface
* fix indentation level according to review comment

Differential Revision: https://reviews.freebsd.org/D33579/
Reviewed by: hselasky
MFC after: 2 weeks

(cherry picked from commit cae1884d4791726f5acf5d64bba9a3583b63e38b)

2 years agousbconfig: use getopt(3) for option handling
Joerg Wunsch [Sun, 19 Dec 2021 22:49:23 +0000 (23:49 +0100)]
usbconfig: use getopt(3) for option handling

This makes option handling consistent with other utilities as well as
Posix rules. By that, it's no longer important whether option name and
its argument are separated by a space or not, so -d5.3 works the same
as -d 5.3.

Also, recognize either /dev/ugen or ugen as prefix to the -d argument.

Note that this removes the undocumented feature that allowed to
specify multiple -d n.m options interleaved with commands referring to
that particular device in a single run.

(cherry picked from commit ae450e6de96b5ec65f425a52b08dc859576ab8d0)

2 years agoswap_pager: uma_zcreate() doesn't fail
Mark Johnston [Tue, 11 Jan 2022 14:22:32 +0000 (09:22 -0500)]
swap_pager: uma_zcreate() doesn't fail

Remove always-false checks for UMA zone creation failure.  No functional
change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 43b3b8e52d642e94876728202d9b9863315c8525)

2 years agovm_pageout: Group sysctl variables together with sysctl definitions
Mark Johnston [Tue, 11 Jan 2022 14:22:44 +0000 (09:22 -0500)]
vm_pageout: Group sysctl variables together with sysctl definitions

Fix some style bugs while here.  No functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4a25e0713263200d41673fe1740e3e0362ccd95)

2 years agofusefs: implement VOP_ALLOCATE
Alan Somers [Sat, 1 Jan 2022 04:04:12 +0000 (21:04 -0700)]
fusefs: implement VOP_ALLOCATE

Now posix_fallocate will be correctly forwarded to fuse file system
servers, for those that support it.

Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33389

(cherry picked from commit 398c88c7582a195cbfeb689ceff1400cc717673f)

2 years agofusefs: in the tests, always assume debug.try_reclaim_vnode is available
Alan Somers [Thu, 2 Dec 2021 02:38:04 +0000 (19:38 -0700)]
fusefs: in the tests, always assume debug.try_reclaim_vnode is available

In an earlier version of the revision that created that sysctl (D20519)
the sysctl was gated by INVARIANTS, so the test had to check for it.
But in the committed version it is always available.

(cherry picked from commit 19ab361045343bb777176bb08468f7706d7649c4)

fusefs: move common code from forget.cc to utils.cc

(cherry picked from commit 8d99a6b91b788b7ddf88f975f288f7c6479f4be3)

fusefs: fix .. lookups when the parent has been reclaimed.

By default, FUSE file systems are assumed not to support lookups for "."
and "..".  They must opt-in to that.  To cope with this limitation, the
fusefs kernel module caches every fuse vnode's parent's inode number,
and uses that during VOP_LOOKUP for "..".  But if the parent's vnode has
been reclaimed that won't be possible.  Previously we paniced in this
situation.  Now, we'll return ESTALE instead.  Or, if the file system
has opted into ".." lookups, we'll just do that instead.

This commit also fixes VOP_LOOKUP to respect the cache timeout for ".."
lookups, if the FUSE file system specified a finite timeout.

PR: 259974
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33239

(cherry picked from commit 1613087a8127122b03a3730046d051adf4edd14f)

2 years agofusefs: copy_file_range must update file timestamps
Alan Somers [Mon, 29 Nov 2021 02:50:56 +0000 (19:50 -0700)]
fusefs: copy_file_range must update file timestamps

If FUSE_COPY_FILE_RANGE returns successfully, update the atime of the
source and the mtime and ctime of the destination.

Reviewers: pfg
Differential Revision: https://reviews.freebsd.org/D33159

(cherry picked from commit 5169832c96451e0c939338d8ef34cd0875a24b83)

2 years agoFix a race in fusefs that can corrupt a file's size.
Alan Somers [Mon, 29 Nov 2021 02:17:34 +0000 (19:17 -0700)]
Fix a race in fusefs that can corrupt a file's size.

VOPs like VOP_SETATTR can change a file's size, with the vnode
exclusively locked.  But VOPs like VOP_LOOKUP look up the file size from
the server without the vnode locked.  So a race is possible.  For
example:

1) One thread calls VOP_SETATTR to truncate a file.  It locks the vnode
   and sends FUSE_SETATTR to the server.
2) A second thread calls VOP_LOOKUP and fetches the file's attributes from
   the server.  Then it blocks trying to acquire the vnode lock.
3) FUSE_SETATTR returns and the first thread releases the vnode lock.
4) The second thread acquires the vnode lock and caches the file's
   attributes, which are now out-of-date.

Fix this race by recording a timestamp in the vnode of the last time
that its filesize was modified.  Check that timestamp during VOP_LOOKUP
and VFS_VGET.  If it's newer than the time at which FUSE_LOOKUP was
issued to the server, ignore the attributes returned by FUSE_LOOKUP.

PR: 259071
Reported by: Agata <chogata@moosefs.pro>
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D33158

(cherry picked from commit 13d593a5b060cf7be40acfa2ca9dc9e0e2339a31)

2 years agofile: upgrade to 5.41.
Xin LI [Tue, 4 Jan 2022 06:02:42 +0000 (22:02 -0800)]
file: upgrade to 5.41.

(cherry picked from commit 43a5ec4eb41567cc92586503212743d89686d78f)

2 years agobhyve: dynamically register FwCtl ports
Corvin Köhne [Mon, 3 Jan 2022 13:20:38 +0000 (14:20 +0100)]
bhyve: dynamically register FwCtl ports

Qemu's FwCfg uses the same ports as Bhyve's FwCtl. Static allocated
ports wouldn't allow to switch between Qemu's FwCfg and Bhyve's
FwCtl.

Reviewed by:    markj
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:  https://reviews.freebsd.org/D33496

(cherry picked from commit 9fe79f2f2b22ea068e5acb2af23d130a13d2ab06)

2 years agobhyve: add more slop to 64 bit BARs
Corvin Köhne [Mon, 3 Jan 2022 13:19:39 +0000 (14:19 +0100)]
bhyve: add more slop to 64 bit BARs

Bhyve allocates small 64 bit BARs below 4 GB and generates ACPI tables
based on this allocation. If the guest decides to relocate those BARs
above 4 GB, it could lead to mismatching ACPI tables. Especially
when using OVMF with enabled bus enumeration it could cause
issues. OVMF relocates all 64 bit BARs above 4 GB. The guest OS
may be unable to recover from this situation and disables some PCI
devices because their BARs are located outside of the MMIO space
reported by ACPI. Avoid this situation by giving the guest more
space for relocating BARs.

Let's be paranoid. The available space for BARs below 4 GB is 512 MB
large. Use a slop of 512 MB. It'll allow the guest to relocate all
BARs below 4 GB to an address above 4 GB. We could run into issues
when we exceeding the memlimit above 4 GB. However, this space has
a size of 32 GB. Even when using many PCI device with large BARs
like framebuffer or when using multiple PCI busses, it's very
unlikely that we run out of space due to the large slop.
Additionally, this situation will occur on startup and not at runtime
which is much better.

Reviewed by:    markj
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:  https://reviews.freebsd.org/D33118

(cherry picked from commit 7d55d295086e0f568b42c89604fad3e47633b2ed)

2 years agobhyve: allow reading of fwctl signature multiple times
Corvin Köhne [Mon, 3 Jan 2022 13:18:31 +0000 (14:18 +0100)]
bhyve: allow reading of fwctl signature multiple times

At the moment, you only have one single chance to read the fwctl
signature. At boot bhyve is in the state IDENT_WAIT. It's then
possible to switch to IDENT_SEND. After bhyve sends the signature,
it switches to REQ. From now on it's impossible to switch back to
IDENT_SEND to read the signature. For that reason, only a single
driver can read the signature. A guest can't use two drivers to
identify that fwctl is present. It gets even worse when using
OVMF. OVMF uses a library to access fwctl. Therefore, every single
OVMF driver would try to read the signature. Currently, only a
single OVMF driver accesses the fwctl. So, there's no issue with
it yet. However, no OS driver would have a chance to detect fwctl when
using OVMF because it's signature was already consumed by OVMF.

Reviewed by:    markj
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:  https://reviews.freebsd.org/D31981

(cherry picked from commit 8ec366ec6c943550a011effe50bc73e3875f8ead)

2 years agobhyve: enumerate BARs by size
Corvin Köhne [Mon, 3 Jan 2022 13:16:59 +0000 (14:16 +0100)]
bhyve: enumerate BARs by size

E.g. Framebuffers can require large space and BARs need to be aligned
by their size. If BARs aren't allocated by size, it'll cause much
fragmentation of the MMIO space. Reduce fragmentation by ordering
the BAR allocation on their size to reduce the risk of
OUT_OF_MMIO_SPACE issues.

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D28278

(cherry picked from commit 01f9362ef4eb14b041ccdf935fccf0f794074258)

2 years agogpart(8): MFC: add minimal reference to glabel(8) to manual page
Eugene Grosbein [Mon, 10 Jan 2022 15:00:30 +0000 (22:00 +0700)]
gpart(8): MFC: add minimal reference to glabel(8) to manual page

(cherry picked from commit ba94a95402f335c8e7aa8e28ebdad43361c65909)

2 years agoLinuxKPI: 802.11 correctly spell queues
Ruslan Makhmatkhanov [Mon, 10 Jan 2022 18:08:17 +0000 (18:08 +0000)]
LinuxKPI: 802.11 correctly spell queues

PR: 261078
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 312ba38a9bee9510fb7836997b1360d95b9305d8)

2 years agoLinuxKPI: 802.11 fix locking in lkpi_stop_hw_scan()
Bjoern A. Zeeb [Mon, 10 Jan 2022 22:12:53 +0000 (22:12 +0000)]
LinuxKPI: 802.11 fix locking in lkpi_stop_hw_scan()

In lkpi_stop_hw_scan() we have to unlock around cancelling the
hardware scan and an msleep to wait for the confirmation that the
scan ended.  Otherwise we are sleeping with the non-sleepable
net80211 com lock held.  At the same time we need to hold the lhw
lock for the msleep().
This lock change got lost in the refactoring of lkpi_iv_newstate().

Reported by: ambrisko, delphij
PR: 261075
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bec766282f242aab3a4bfba402ea74cb0ccf96fb)

2 years agoLinuxKPI: 802.11 update compat code for driver updates
Bjoern A. Zeeb [Sun, 9 Jan 2022 18:08:47 +0000 (18:08 +0000)]
LinuxKPI: 802.11 update compat code for driver updates

Add more (dummy in case of HE) defines, structs, functions and another
mac80211 function pointer needed to update and support recent drivers.

(cherry picked from commit 51b461b3db33b7cd7cbc62c9206568321f7298ad)

2 years agoLinuxKPI / iwlwifi: fix spelling of constants
Bjoern A. Zeeb [Sun, 9 Jan 2022 02:21:05 +0000 (02:21 +0000)]
LinuxKPI / iwlwifi: fix spelling of constants

Fix the spelling of IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_*
(was "NOMIMAL").  The original version came from iwlwifi
in iwlwifi-next.  Other drivers (from wireless-testing) already
use the correct spelling and need this change in LinuxKPI.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e200809190fd8472fe525b2527ff1122b37999ac)

2 years agoLinuxKPI: 802.11 handle IEEE80211_CONF_IDLE better
Bjoern A. Zeeb [Sun, 9 Jan 2022 00:59:50 +0000 (00:59 +0000)]
LinuxKPI: 802.11 handle IEEE80211_CONF_IDLE better

We never initialized hw->conf.flags for IEEE80211_CONF_IDLE but
on set_channel we would clear it and announce a change.
This lead to a problem that drivers may do some work every time
which was not needed and may lead to unexpected behaviour (for no
better driver code).

Properly initialize conf.flags with IEEE80211_CONF_IDLE.
Factor out the toggling into a function and clear IDLE while
sw scanning and when associated and set again when scan ends
or we are bouncing out of assoc.

(cherry picked from commit 086be6a80979f76124972273d62106583e35c83c)

2 years agoLinuxKPI: ip.h add #include
Bjoern A. Zeeb [Sun, 9 Jan 2022 00:57:13 +0000 (00:57 +0000)]
LinuxKPI: ip.h add #include

Also include netinet/in.h so that in_addr in known for ip.h.
Found by compiling a new piece of code which complained.

(cherry picked from commit 4ddc0079eab3633aa8370eeec9e37b3796cc88bd)

2 years agoLinuxKPI: bitfields add more *replace_bits()
Bjoern A. Zeeb [Sun, 9 Jan 2022 01:12:05 +0000 (01:12 +0000)]
LinuxKPI: bitfields add more *replace_bits()

Add or extend the already existing *_replace_bits() implementations
using macros as we do for the other parts in the file for
le<n>p_replace_bits(), u<n>p_replace_bits(), and _u<n>_replace_bits().

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D33799

(cherry picked from commit 2fb0569f1ff58209420ed9c5500476ad7d93e702)

2 years agoLinuxKPI: add hex2bin()
Bjoern A. Zeeb [Sun, 9 Jan 2022 01:09:17 +0000 (01:09 +0000)]
LinuxKPI: add hex2bin()

Add a hex2bin() implementation needed by a driver's debugfs code.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D33798

(cherry picked from commit deb9bfbd5bcea70c79f70c7091c35d399b40fb0a)

2 years agotests: Add some regression tests for a couple of KERN_PROC_* sysctls
Mark Johnston [Thu, 16 Dec 2021 21:06:55 +0000 (16:06 -0500)]
tests: Add some regression tests for a couple of KERN_PROC_* sysctls

Sponsored by: The FreeBSD Foundation

(cherry picked from commit fff0ae77b9960bb26034297fcb885d26432354bf)

2 years agofd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}
Mark Johnston [Thu, 16 Dec 2021 21:07:04 +0000 (16:07 -0500)]
fd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}

These sysctls failed to return an error if the caller had provided too
short an output buffer.  Change them to return ENOMEM instead, to ensure
that callers can detect truncation in the face of a concurrently
changing fd table.

PR: 228432
Discussed with: cem, jhb

(cherry picked from commit 36bd49ac4db8c62a3b354094646cbd8547ad2c51)

2 years agoFix variable name: freq_khz -> freq
Colin Percival [Thu, 30 Dec 2021 19:47:50 +0000 (11:47 -0800)]
Fix variable name: freq_khz -> freq

An earlier version of this code computed the TSC frequency in kHz.
When the code was changed to compute the frequency more accurately,
the variable name was not updated.

Reviewed by: markj
Fixes: 22875f88799e x86: Implement deferred TSC calibration
Differential Revision: https://reviews.freebsd.org/D33696

(cherry picked from commit 698727d637341f2306138ca0ea181444de3df479)

2 years agoSkip TSC calibration if exact value known
Colin Percival [Thu, 30 Dec 2021 19:43:15 +0000 (11:43 -0800)]
Skip TSC calibration if exact value known

It's possible that the "early" TSC calibration gave us a value which
is known to be exact; in that case, skip the later re-calibration.

Differential Revision: https://reviews.freebsd.org/D33695

(cherry picked from commit 9cb3288287ba1b3c1d0ec891c552fc4b9472027e)

2 years agoIgnore debugger-injected signals left after detaching
Konstantin Belousov [Sat, 8 Jan 2022 09:46:45 +0000 (11:46 +0200)]
Ignore debugger-injected signals left after detaching

PR: 261010

(cherry picked from commit a24afbb4e633f6725dfe3de099b8e2a4f6b1b631)

2 years agoscript(1): work around slow reading child
Konstantin Belousov [Sat, 8 Jan 2022 13:19:14 +0000 (15:19 +0200)]
script(1): work around slow reading child

PR: 260938

(cherry picked from commit c0ba4c2ee2c48ec9892d10c0aca797f3685c53ee)

2 years agofsck(8): Fix typo
Li-Wen Hsu [Wed, 12 Jan 2022 05:52:23 +0000 (13:52 +0800)]
fsck(8): Fix typo

PR: 260949
Reported by: Graham Perrin <grahamperrin@gmail.com>
MFC after: 3 days

(cherry picked from commit 6853ef66f16ae8cb3e1d622c613b88948d15efed)

2 years agoldconfig: remove two symbols
Konstantin Belousov [Sat, 8 Jan 2022 10:42:36 +0000 (12:42 +0200)]
ldconfig: remove two symbols

(cherry picked from commit fcbb1441d07db81899d7a7063405544e6f31e2af)

2 years agolibc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
Konstantin Belousov [Sun, 9 Jan 2022 05:09:22 +0000 (07:09 +0200)]
libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper

PR: 261051

(cherry picked from commit 6d06bc688eb5a9f9e389b69c388d591a40edc422)

2 years agoamd64 pmap: preset A and M bits for pmap_qenter() and pmap_kenter() mappings
Konstantin Belousov [Wed, 5 Jan 2022 01:25:41 +0000 (03:25 +0200)]
amd64 pmap: preset A and M bits for pmap_qenter() and pmap_kenter() mappings

(cherry picked from commit 15964f1cb3935b612c833b863219fef0a3932edf)

2 years agoamd64 pmap: simplify vtopte() and vtopde()
Konstantin Belousov [Wed, 5 Jan 2022 00:26:12 +0000 (02:26 +0200)]
amd64 pmap: simplify vtopte() and vtopde()

(cherry picked from commit 720a892ac60fc1fa7c784edc40f188c93ac7e0b7)

2 years agomsdosfs: use mntfs vnode for pm_devvp
Konstantin Belousov [Thu, 6 Jan 2022 01:47:31 +0000 (03:47 +0200)]
msdosfs: use mntfs vnode for pm_devvp

(cherry picked from commit aaaa4fb54e5c427b7a8d305c3562fe5dde4ec8ec)

2 years agomsdosfs: on integrity error, fire a task to remount filesystem to ro
Konstantin Belousov [Sat, 25 Dec 2021 19:45:47 +0000 (21:45 +0200)]
msdosfs: on integrity error, fire a task to remount filesystem to ro

(cherry picked from commit 41e85eeab90dec540c7aa3973ba601bae1f16c10)

2 years agomsdosfs: add msdosfs_integrity_error()
Konstantin Belousov [Sat, 25 Dec 2021 21:20:56 +0000 (23:20 +0200)]
msdosfs: add msdosfs_integrity_error()

(cherry picked from commit b2e4b635844091de0601f5b7157d87115386b2a9)

2 years agoAdd vfs_remount_ro()
Konstantin Belousov [Sat, 25 Dec 2021 19:44:59 +0000 (21:44 +0200)]
Add vfs_remount_ro()

(cherry picked from commit 4a4b059a97950740f04b091d7050460a984e7555)

2 years agomsdosfs: sanity check sector count from BPB
Konstantin Belousov [Thu, 30 Dec 2021 19:45:40 +0000 (21:45 +0200)]
msdosfs: sanity check sector count from BPB

(cherry picked from commit ba2c98389b78b548aedac0be53121df909c3fe2f)

2 years agomsdosfs: clusterfree() is used only in error handling cases
Konstantin Belousov [Tue, 4 Jan 2022 14:43:02 +0000 (16:43 +0200)]
msdosfs: clusterfree() is used only in error handling cases

(cherry picked from commit 65990b68a2cd89a08f0350e187df1968b16f4255)

2 years agomsdosfs: do no allow lookup to return vdp except for dot lookups
Konstantin Belousov [Sun, 26 Dec 2021 21:51:48 +0000 (23:51 +0200)]
msdosfs: do no allow lookup to return vdp except for dot lookups

(cherry picked from commit aec97963cd03f10e04083537ed449a84a5e42f87)

2 years agomsdosfs: handle a case when non-dot lookup returned dvp
Konstantin Belousov [Tue, 28 Dec 2021 13:41:30 +0000 (15:41 +0200)]
msdosfs: handle a case when non-dot lookup returned dvp

(cherry picked from commit 1319c433f4e5d67f8ea6fd2369c604069f733c94)

2 years agomsdosfs: take inusemap inconsistency as an error, not invariants violation
Konstantin Belousov [Sat, 25 Dec 2021 18:39:15 +0000 (20:39 +0200)]
msdosfs: take inusemap inconsistency as an error, not invariants violation

(cherry picked from commit 2c9a1c22c323b069d1f4883170349545c94b7b8d)

2 years agomsdosfs: handle inconsistently hashed denodes
Konstantin Belousov [Thu, 23 Dec 2021 23:21:53 +0000 (01:21 +0200)]
msdosfs: handle inconsistently hashed denodes

(cherry picked from commit 595ed4d76713c1e9cab7d8a160ed59f8f4e5ecb4)

2 years agogeom label msdosfs: sanity check BPB before using it for io request
Konstantin Belousov [Thu, 30 Dec 2021 13:17:59 +0000 (15:17 +0200)]
geom label msdosfs: sanity check BPB before using it for io request

(cherry picked from commit 9f4073d44628bc70dbe67df5163266cbfbe37167)

2 years agosched_get/setaffinity(): try to be more compatible with Linux
Konstantin Belousov [Sun, 2 Jan 2022 22:11:49 +0000 (00:11 +0200)]
sched_get/setaffinity(): try to be more compatible with Linux

(cherry picked from commit d9cacbf4b010d96dbfe96a09259972a95c675f26)

2 years agosys/kern/sched_4bsd.c: fix typo introduced in previous commit
Stefan Eßer [Sat, 1 Jan 2022 14:33:38 +0000 (15:33 +0100)]
sys/kern/sched_4bsd.c: fix typo introduced in previous commit

(cherry picked from commit ec3af9d0ca6b48d2595bb713a638a9b0ce77b9f7)

2 years agoRestore variable aliasing in the context of cpu set operations
Stefan Eßer [Sat, 1 Jan 2022 10:41:54 +0000 (11:41 +0100)]
Restore variable aliasing in the context of cpu set operations

(cherry picked from commit a19bd8e30eba1673782376a93e9787ed9b490e4e)

2 years agosys/cpuset.h: fix macro definition
Stefan Eßer [Fri, 31 Dec 2021 13:09:44 +0000 (14:09 +0100)]
sys/cpuset.h: fix macro definition

(cherry picked from commit 5650d340ad66a47fb8ea182c7057a2d07806ca7e)

2 years agosys/cpuset.h: add 3 more macros provided by GLIBC
Stefan Eßer [Fri, 31 Dec 2021 10:08:34 +0000 (11:08 +0100)]
sys/cpuset.h: add 3 more macros provided by GLIBC

(cherry picked from commit cb65d4432aed11a0cd77d2bd235d6f760ae91c38)

2 years agosys/sys/cpuset.h: Fix typo in source file
Stefan Eßer [Thu, 30 Dec 2021 12:14:43 +0000 (13:14 +0100)]
sys/sys/cpuset.h: Fix typo in source file

(cherry picked from commit b78860f96c82b0c65fe8737a346d8afe74d54ada)

2 years agoMake CPU_SET macros compliant with other implementations
Stefan Eßer [Thu, 30 Dec 2021 11:20:32 +0000 (12:20 +0100)]
Make CPU_SET macros compliant with other implementations

(cherry picked from commit e2650af157bc7489deaf2c9054995f0f88a6e5da)

2 years agosys/_bitset.h: Fix fall-out from commit 5e04571cf3c
Stefan Eßer [Wed, 8 Dec 2021 07:47:42 +0000 (08:47 +0100)]
sys/_bitset.h: Fix fall-out from commit 5e04571cf3c

(cherry picked from commit 49c2c62889b06d781c5e1f96bce0e26fd21ceb04)

2 years agosys/_bitset.h: Fix fall-out from commit 5e04571cf3c
Stefan Eßer [Tue, 7 Dec 2021 19:29:26 +0000 (20:29 +0100)]
sys/_bitset.h: Fix fall-out from commit 5e04571cf3c

(cherry picked from commit 22c4ab6cb015dc99eb82504e5fd957662cded3c3)

2 years agosys/bitset.h: reduce visibility of BIT_* macros
Stefan Eßer [Sun, 5 Dec 2021 21:27:33 +0000 (22:27 +0100)]
sys/bitset.h: reduce visibility of BIT_* macros

(cherry picked from commit 5e04571cf3cf4024be926976a6abf19626df30be)

2 years agoRegen
Konstantin Belousov [Wed, 10 Nov 2021 19:44:25 +0000 (21:44 +0200)]
Regen

2 years agosched.h: Use pid_t type for pid argument
David CARLIER [Fri, 17 Dec 2021 06:22:21 +0000 (08:22 +0200)]
sched.h: Use pid_t type for pid argument

(cherry picked from commit 65dd321054cbbbcca192375b08843e860fc3b3c5)

2 years agosched_get/setaffinity(3): pid 0 should designate current process
Math Ieu [Fri, 17 Dec 2021 05:31:09 +0000 (07:31 +0200)]
sched_get/setaffinity(3): pid 0 should designate current process

PR: 260487

(cherry picked from commit caacda7a3e898a8b142d27732a9f13a525b08ea7)

2 years agosched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T
Konstantin Belousov [Thu, 11 Nov 2021 08:01:54 +0000 (10:01 +0200)]
sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T

(cherry picked from commit 90fa9705d5cd29cf11c5dc7319299788dec2546a)

2 years agosched.h: add CPU_EQUAL() for better compatibility with Linux
Konstantin Belousov [Sat, 30 Oct 2021 07:36:24 +0000 (10:36 +0300)]
sched.h: add CPU_EQUAL() for better compatibility with Linux

(cherry picked from commit 43e6f07b06e05cd36c22b204be5be94c2807aec8)

2 years agox86: provide userspace implementation of sched_getcpu() where possible
Konstantin Belousov [Sun, 31 Oct 2021 01:39:31 +0000 (03:39 +0200)]
x86: provide userspace implementation of sched_getcpu() where possible

(cherry picked from commit f239545591a821386f9bdb84c02044884ad415b5)

2 years agoAdd sched_getcpu()
Konstantin Belousov [Fri, 22 Oct 2021 15:35:53 +0000 (18:35 +0300)]
Add sched_getcpu()

(cherry picked from commit 77b2c2f81451db8119e4ea6398fe76813db790de)

2 years agoAdd sched_get/setaffinity(3)
Konstantin Belousov [Fri, 22 Oct 2021 15:21:33 +0000 (18:21 +0300)]
Add sched_get/setaffinity(3)

(cherry picked from commit 43736b71dd051212d5c55be9fa21c45993017fbb)

2 years agoAdd real sched.h
Konstantin Belousov [Fri, 22 Oct 2021 15:17:21 +0000 (18:17 +0300)]
Add real sched.h

(cherry picked from commit 160b4b922b6021848b6b48afc894d16b879b7af2)

2 years agoefifb,vbefb: implement vd_fini
Greg V [Tue, 30 Mar 2021 15:46:17 +0000 (17:46 +0200)]
efifb,vbefb: implement vd_fini

This removes the pmap entry when switching away to e.g. drm fb.

Differential Revision: https://reviews.freebsd.org/D29020
MFC After: 1 month

(cherry picked from commit 8ebda6e44bb6ac9113e2a7fe65889811d894dd63)

2 years agobhyve: emulate reads of MSI-X capabilities for passthru devices
Corvin Köhne [Mon, 22 Nov 2021 15:27:33 +0000 (16:27 +0100)]
bhyve: emulate reads of MSI-X capabilities for passthru devices

Reads of the MSI-X capabilites aren't emulated by passthru devices
yet. The guest will read the host MSI-X capabilites which could
cause issues.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D32686
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit fe66bcf9ff8623bf69a183c9eb8c5ce72cce7db6)

2 years agobhyve: keep physical and virtual COMMAND reg in sync
Corvin Köhne [Mon, 22 Nov 2021 15:26:03 +0000 (16:26 +0100)]
bhyve: keep physical and virtual COMMAND reg in sync

On startup all virtual BARs are registered.
Additionally, the encoding bit in the virtual cmd register is set.
After that, the passthru emulation overwrites the virtual cmd register with
the physical one.
This could lead to a mismatch between registered BARs and the encoding
bits in the cmd register.
Instead of writing the physical to the virtual cmd register,
write the virtual to the physical cmd register to solve this issue.

Reviewed by:   markj
Differential Revision: https://reviews.freebsd.org/D32687
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 2eb2079554f4d54c4283410b4ee1aca549b29616)

2 years agobhyve: use a fixed 32 bit BAR base address
Corvin Köhne [Mon, 22 Nov 2021 15:24:47 +0000 (16:24 +0100)]
bhyve: use a fixed 32 bit BAR base address

OVMF always uses 0xC0000000 as base address for 32 bit PCI MMIO space.
For that reason, we should use that address too.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31051
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 5cf21e48ccf114928da9c6564c7e5dec7d6119c5)

bhyve: Fix compile

We need err.h

Fixes: 5cf21e48ccf11 ("bhyve: use a fixed 32 bit BAR base address")
Sponsored by: Bechoff Automation GmbH & Co. KG

(cherry picked from commit fc7207c87795da4533dc7f97287638f6da85b3b0)

2 years agobhyve: move 64 bit BAR location to match OVMF assumptions
Corvin Köhne [Mon, 22 Nov 2021 15:22:48 +0000 (16:22 +0100)]
bhyve: move 64 bit BAR location to match OVMF assumptions

OVMF will fail, if large 64 bit BARs are used. GCD-Map doesn't cover
64 bit addresses of BARs.
OVMF assumes that 64 bit addresses of BARS are located on next 32 GB
boundary behind Top of High RAM.

This patch moves 64 bit BARs on next 32 GB boundary behind Top of High
RAM to match OVMF assumptions.

Differential Revision: https://reviews.freebsd.org/D27970
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 4a4053e1b053e840cf167a629f8d2b8ae76e6da7)

2 years agobhyve: do not explicitly map fbuf framebuffer
Corvin Köhne [Thu, 18 Nov 2021 15:26:34 +0000 (16:26 +0100)]
bhyve: do not explicitly map fbuf framebuffer

Allocating a BAR will call baraddr which maps the framebuffer. No need
to allocate it explicitly on init.

Reviewed by:     grehan
Sponsored by:    Beckhoff Autmation GmbH & Co. KG
Differential Revision:    https://reviews.freebsd.org/D32596

(cherry picked from commit 5085153ae4d55692415716e0ed03204bdf96d34a)

2 years agobhyve: use physical lobits for BARs of passthru devices
Corvin Köhne [Thu, 18 Nov 2021 15:25:09 +0000 (16:25 +0100)]
bhyve: use physical lobits for BARs of passthru devices

Tell the guest whether a BAR uses prefetched memory or not for
passthru devices by using the same lobits as the physical device.

Reviewed by:  grehan
Sponsored by:  Beckhoff Autmation GmbH & Co. KG
Differential Revision:   https://reviews.freebsd.org/D32685

(cherry picked from commit e87a6f3ef284593c01e0fd3f8b5bfc1f645e5b18)