Commit Graph

4394 Commits

Author SHA1 Message Date
Emmanuel Vadot
37cda2837c linuxkpi: Add compat_ptr and ptr_to_compat
Needed by drm-kmod.

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36016
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
39da3678b1 linuxkpi: Add try_cmpxchg and atomic_try_cmpxchg
Needed by drm-kmod

Obtain from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36015
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
fa1f02baaf linuxkpi: Add some memset functions
Needed by drm-kmod

Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35943
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
96b917bfcf linuxkpi: Add io.h
out* arguments are different on Linux and the i915 driver uses them.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35942
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
a0c171328f linuxkpi: Add pagevec implementation
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35941
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
aec6a64c68 linuxkpi: Add linux/nospec.h
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35940
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
4aa82e4358 linuxkpi: Add mapping_clear_unevictable stub
Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35939
2022-08-08 15:22:34 +02:00
Emmanuel Vadot
6890e327a8 linuxkpi: pci: Add more functions needed by drm
Mostly stubs to satisfy building

Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35938
2022-08-08 15:22:34 +02:00
Emmanuel Vadot
885ab0dba2 linuxkpi: math.h: Add mul_u64_u32_div and mul_u64_u32_shr
Needed by drm-kmod.

Reviewed by:	hselasky
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35937
2022-08-08 15:22:34 +02:00
Emmanuel Vadot
6be89cc88d linuxkpi: atomic: Add atomic_fetch_inc
Reviewed by:	hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35936
2022-08-08 15:22:34 +02:00
Konstantin Belousov
f04f3afbf5 linuxkpi: more precise need_resched() definition
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D35888
2022-08-02 21:11:10 +03:00
Konstantin Belousov
c6d31b8306 AST: rework
Make most AST handlers dynamically registered.  This allows to have
subsystem-specific handler source located in the subsystem files,
instead of making subr_trap.c aware of it.  For instance, signal
delivery code on return to userspace is now moved to kern_sig.c.

Also, it allows to have some handlers designated as the cleanup (kclear)
type, which are called both at AST and on thread/process exit.  For
instance, ast(), exit1(), and NFS server no longer need to be aware
about UFS softdep processing.

The dynamic registration also allows third-party modules to register AST
handlers if needed.  There is one caveat with loadable modules: the
code does not make any effort to ensure that the module is not unloaded
before all threads processed through AST handler in it.  In fact, this
is already present behavior for hwpmc.ko and ufs.ko.  I do not think it
is worth the efforts and the runtime overhead to try to fix it.

Reviewed by:	markj
Tested by:	emaste (arm64), pho
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D35888
2022-08-02 21:11:09 +03:00
Bjoern A. Zeeb
d8dd6b329e LinuxKPI: 802.11: add missing linuxkpi_cfg80211_bss_flush()
Add the missing implementation of linuxkpi_cfg80211_bss_flush().
without this we get unresolved symbols and drivers won't load.

Reported by:	eduardo, Berislav Purgar (bpurgar gmail.com)
MFC after:	3 days
X-MFC-Squash:	b0f7376822
2022-07-30 14:23:14 +00:00
Bjoern A. Zeeb
b0f7376822 LinuxKPI: 802.11 header updates
While working on new and updates to drivers more structs, fields,
functions, .. were found, had to be shuffled around, ..
Some of these are (so far still dummy) functions or not properly
typed fields.  The IEEE80211_HE_ constants are all still dummy.
This was msotly as a start to make new (out-of-tree) things compile.

Sponsored by:	The FreeBSD Foundation (minor VHT/chan width bits)
MFC after:	1 week
2022-07-29 15:23:49 +00:00
Bjoern A. Zeeb
89c32dafa5 LinuxKPI: skbuff: sort list header and add new (dummy) functions
While working on new and updates to drivers more skbuff changes
came up.  Sort out the list/prev/next header problem and add more
(so far dummy) functions needed.

MFC after:	1 week
2022-07-29 15:21:48 +00:00
Bjoern A. Zeeb
467d3e2e8a LinuxKPI 802.11/iwlwifi/rtw88: update KPI
Upgrade the argument of (*bss_info_changed) mac80211 ops function call
from 32 to 64 bit.
Add an extra argument to ieee80211_beacon_get_template().

Both changes are needed in order to keep other out-of-tree drivers in
synch and to move forward.

The driver changes were extracted from Linux wireless-testing
7b7090b4c6a906cc7c3e2a460335f705b93f4506 and
6e8912a503759bb8f1f01c5b761d0d45815fa6de.

Sponsored by:	The FreBSD Foundation
MFC after:	1 week
2022-07-28 23:39:03 +00:00
Dimitry Andric
e90d1b5748 Adjust linux_get_char_devices() definition to avoid clang 15 warning
With clang 15, the following -Werror warning is produced:

    sys/compat/linux/linux_util.c:243:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    linux_get_char_devices()
                          ^
                           void

This is because linux_get_char_devices() is declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after:	3 days
2022-07-25 00:40:13 +02:00
Kornel Dulęba
939f0b6323 Implement shared page address randomization
It used to be mapped at the top of the UVA.
If the randomization is enabled any address above .data section will be
randomly chosen and a guard page will be inserted in the shared page
default location.
The shared page is now mapped in exec_map_stack, instead of
exec_new_vmspace. The latter function is called before image activator
has a chance to parse ASLR related flags.
The KERN_PROC_VM_LAYOUT sysctl was extended to provide shared page
address.
The feature is enabled by default for 64 bit applications on all
architectures.
It can be toggled kern.elf64.aslr.shared_page sysctl.

Approved by:	mw(mentor)
Sponsored by:	Stormshield
Obtained from:	Semihalf
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D35349
2022-07-18 16:27:37 +02:00
Kornel Dulęba
361971fbca Rework how shared page related data is stored
Store the shared page address in struct vmspace.
Also instead of storing absolute addresses of various shared page
segments save their offsets with respect to the shared page address.
This will be more useful when the shared page address is randomized.

Approved by:	mw(mentor)
Sponsored by:	Stormshield
Obtained from:	Semihalf
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D35393
2022-07-18 16:27:32 +02:00
Gordon Bergling
d3d3b76c1b linux(4): Fix a typo in a source code comment
- s/alredy/already/

MFC after:	3 days
2022-07-16 13:39:17 +02:00
Mark Johnston
6b38974085 vm_object: Modify various drivers to allocate OBJT_SWAP objects
This is in preparation for removal of OBJT_DEFAULT.  In particular, it
is now cheap to check whether an OBJT_SWAP object has any swap blocks
allocated, so the benefit of having a separate OBJT_DEFAULT type is
quite marginal, and the OBJT_DEFAULT->SWAP transition is a source of
bugs.

Reviewed by:	alc, hselasky, kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35779
2022-07-12 09:10:15 -04:00
Dmitry Chagin
42317e6426 linux(4): Implement __vdso_time
PR:		240769
MFC after:	3 days
2022-07-04 23:41:32 +03:00
Emmanuel Vadot
2b743f65f1 linuxkpi: Add pwm.h
Provide dummy functions needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35572
2022-06-29 09:55:26 +02:00
Emmanuel Vadot
0e45856f9a linuxkpi: Add asm/set_memory.h
Provide functions needed for drm-kmod.

MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35571
2022-06-29 09:55:23 +02:00
Emmanuel Vadot
137e91dbf6 linuxkpi: Add asm/iosfmbi.h
Provide dummy functions needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35570
2022-06-29 09:55:19 +02:00
Emmanuel Vadot
631bf94fe9 linuxkpi: Add typecheck.h
typecheck macro check if the type of a variable matches a type.

MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35569
2022-06-29 09:55:15 +02:00
Emmanuel Vadot
456a92d5d3 linuxkpi: Add pm_runtime.h
Provide dummy functions needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35568
2022-06-29 09:55:12 +02:00
Emmanuel Vadot
cfe72b9f09 linuxkpi: Add mmu_notifier.h
Provide dummy structure needed for drm-kmod.

MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35567
2022-06-29 09:55:08 +02:00
Emmanuel Vadot
a95f28800a linuxkpi: Add mmu_context.h
Provide dummy functions needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35566
2022-06-29 09:55:04 +02:00
Emmanuel Vadot
7e4f9ebeaa linuxkpi: Add media-bus-format.h
Provide macros needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35565
2022-06-29 09:55:00 +02:00
Emmanuel Vadot
8730ba418e linuxkpi: Add kmemleak.h
Provide macros needed for drm-kmod.

Obtain from:	OpenBSD (via drm-kmod)
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35564
2022-06-29 09:54:57 +02:00
Emmanuel Vadot
088b746cbd linuxkpi: Add kfifo.h
Provide macros needed for drm-kmod.

Reviewed by:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35563
2022-06-29 09:54:53 +02:00
Emmanuel Vadot
57c9ec539c linuxkpi: Add console.h
Provide dummy functions needed for drm-kmod.

Reviewed By:	bz
MFC after:      1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35562
2022-06-29 09:54:49 +02:00
Emmanuel Vadot
7674baeb37 linuxkpi: Add circ_buf.h
Provide macros needed for drm-kmod.

Reviewed by:	bz
MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35561
2022-06-29 09:54:45 +02:00
Dmitry Chagin
c8e7070ce3 linprocfs: Decode SGX CPU feature in cpuinfo
MFC after:		2 weeks
2022-06-29 10:37:52 +03:00
Dmitry Chagin
7ab03740ae linprocfs: Decode more CPU flags in cpuinfo
Differential revision:	https://reviews.freebsd.org/D35556
MFC after:		2 weeks
2022-06-29 10:37:30 +03:00
Dmitry Chagin
8da00a514e linprocfs: Decode constant_tsc CPU feature
Differential revision:	https://reviews.freebsd.org/D35554
MFC after:		2 weeks
2022-06-29 10:34:04 +03:00
Bjoern A. Zeeb
841719c08f 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.

MFC after:	3 days
2022-06-26 19:17:04 +00:00
Bjoern A. Zeeb
e24e8103e0 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.

MFC after:	3 days
2022-06-26 19:13:00 +00:00
Bjoern A. Zeeb
ed3ef56b29 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
MFC after:		3 days
2022-06-26 19:04:16 +00:00
Bjoern A. Zeeb
9597f7cb99 Revert "LinuxKPI: 802.11: fix iwlwifi fw assert with older chipsets"
This reverts commit 013e516dc9.
2022-06-26 18:50:36 +00:00
Dmitry Chagin
ef1976ccf5 linprocfs: Skip printing of the guard page in the /proc/self/maps
To calculate the base (lowest addressable) address of the stack of the
initial thread glibc parses /proc/self/maps.
In fact, the base address is calculated as 'to' value of stack entry of the
/proc/self/maps - stack size limit (if the stack grows down).
The base address should fit in between preceding entry and stack entry of
the /proc/self/maps.
In FreeBSD, since 19bd0d9 (Implement address space guards), we actually
have two mappings for the stack region. The first one is the no-access
mapping for the region the stack can grow into (guard page), and the
second - initial stack region with size sgrowsiz.
The first mapping confuses Glibc, in the end which is improperly
calculate stack size and the base address.

PR:			253337
Reviewed by:		kib
Differential revision:	https://reviews.freebsd.org/D35537
MFC after:		2 week
2022-06-22 14:49:40 +03:00
Dmitry Chagin
9310737333 linux(4): Trace Linux l_sigset_t.
MFC after:		2 weeks
2022-06-22 14:09:54 +03:00
Greg V
8870cb573f LinuxKPI: add asm/neon.h
This is equivalent to asm/fpu/api.h, but is included by drm on aarch64.

Reviewed by:	bz, imp, hselasky
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35512
2022-06-21 19:10:43 +02:00
Bjoern A. Zeeb
4c3684ef5c net80211 / LinuxKPI: 802.11: add Control Trigger Subframe information
Add definitions related to 802.11ax Control Trigger frame format
needed for rtw89.

MFC after:	3 days
2022-06-17 22:55:13 +00:00
Bjoern A. Zeeb
799051e2ca 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.

MFC after:	3 days
2022-06-15 21:05:33 +00:00
Emmanuel Vadot
d87fad3633 linuxkpi: Acquire giant when adding/removing i2c adapters
We need Giant as we run in a taskqueue_thread via linux_work.
This fix detaching amdgpu and i915kms.

Reviewed by:	bz, hselasky, imp
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D35478
2022-06-15 13:37:43 +02:00
Bjoern A. Zeeb
fb6eaf74e9 LinuxKPI: 802.11: fix compiling with DEBUG
Fix a build with DEBUG after d0d2911035
which lost the __func__, __LINE__ argument in an updated tracing line.

Reported by:	Tomoaki AOKI (junchoon dec.sakura.ne.jp)
MFC after:	2 days
X-MFC with:	d0d2911035
2022-06-11 16:38:00 +00:00
Bjoern A. Zeeb
013e516dc9 LinuxKPI: 802.11: fix iwlwifi fw assert with older chipsets
A problem which showed up on 13.1 between BETA3 and RC1 was that on older
chipsets the fw would crash.  While some 0x18 ADD_STA problems were seen
before, d9f59799fc was the actual trigger for this problem
(in 0x28 MAC_CONTEXT command) in a squashed merge to the releng branch.
Strangely there were no changes to assoc_to_run in that revision so other
circumstances may be the actual cause but swapping the bss_info update and
the sta_state in that function seem to make my 8265 happy while AX200 and
AX210 stay good.

Thanks to everyone who helped debug this.

Sponsored by:	The FreeBSD Foundation (partially)
MFC after:	3 days
2022-06-11 12:49:40 +00:00
Bjoern A. Zeeb
d0d2911035 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
MFC after:	3 days
2022-06-10 14:18:57 +00:00