Commit Graph

4752 Commits

Author SHA1 Message Date
Bjoern A. Zeeb
75388b9ca5 LinuxKPI: add (skeleton) functions to make drivers compile
Add more functions to netdevice.h (netif_napi_add_tx() being the only
one implemented) and add platform_device.h and netlink.h in order to
make driver code compile.
The skeleton functions are used only in very limited scope and not at
all in our usage so far but add (invasive) #ifdef if removed.
Add pr_debug() calls to each of them in order to log a TODO (if DEBUG
compiled in) and someone should hit them in the future.

MFC after:	3 days
Commented on by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37599
2023-01-13 00:38:11 +00:00
Bjoern A. Zeeb
f82cf28b31 LinuxKPI: add kstrtou32_from_user() and mac_pton()
While here:
- fix an argument of kstrtouint_from_user() to correct signedness.
- make kstrtou32() call kstrtouint() to avoid duplication (keep inline
  function)

Add kstrtou32_from_user() based on other examples in the file
making it a copy of the now fixed kstrtouint_from_user().

Also add a rudimentarily hacked up version of mac_pton() which is
leanient accepting non-well-formed input but so far only with ':'
separators.  It does not seem to obviously belong to any networking
header file so add it here.

Both new functions are needed for debugfs support for iwlwifi hence
coming together in one commit.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Commented on by:	emaste
Differential Revision: https://reviews.freebsd.org/D37088
2023-01-13 00:34:32 +00:00
Bjoern A. Zeeb
51e94a4658 LinuxKPI: fix possible NULL dereference in linuxkpi_page_frag_alloc()
Fix a possible NULL pointer deref in case alloc_pages() fails.
This is theoretical so far as up to now no code in the tree uses
linuxkpi_page_frag_alloc().

Reported by:	Coverity via emaste
Coverity ID:	1502345
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC-with:	55038a6306
2023-01-11 23:40:05 +00:00
Val Packett
0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Jean-Sébastien Pédron
17f2b12a38
linuxkpi: Define lockdep_assert_none_held_once()
This is defined as a no-op even when INVARIANTS is defined. I admit I
don't know how to implement that in FreeBSD and didn't search
thoroughly.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37911
2023-01-02 22:07:31 +01:00
Jean-Sébastien Pédron
8dfb5571c4
linuxkpi: Include errno.h from acpi/video.h
This defines `ENODEV` used in this header. This fixes a build failure in
the DRM drivers.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37909
2023-01-02 22:05:27 +01:00
Bjoern A. Zeeb
4052b0e4b2 LinuxKPI: pm.h add pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS
Extend pm.h by pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS().
For the moment this duplicates some parts (as can be seen in the earlier
review I tried to simplify bits but given our implementation this
was easier in the end).

While here and cleanup the SIMPLE_DEV_PM_OPS() bits (white-space only).

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D37527
2022-12-31 02:51:09 +00:00
Bjoern A. Zeeb
55038a6306 LinuxKPI: add simplified vesion of page_frag_cache
For the moment and the currently only consumer (mt76) add a simplified
version of the page_frag_cache.  We will only accept fragement sizes up
to 1 PAGE_SIZE (KASSERT) and we will always return a full page.
Should we add more consumers or small (or large) objects would become a
problem we can always add a more elaborate version.

Discussed with:	markj
Reviewed by:	markj (,hselasky commented as well)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37595
2022-12-31 02:45:44 +00:00
Bjoern A. Zeeb
4b0af11437 LinuxKPI: 802.11: move ieee80211_{unregister,restart}_hw out of header
Migrate the two functions from the header into the implementation file
in order to have access to more facilities and not to run into possible
allocation/locking/... problems in the future.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:24:23 +00:00
Bjoern A. Zeeb
c990500bf1 LinuxKPI; 802.11: update mac80211.h structures and fields
Cleanup some fields and structures and add new ones.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:15:28 +00:00
Bjoern A. Zeeb
3391199496 LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()
Implement ieee80211_get_hdrlen_from_skb() doing basic sanity checks
on lengths (minimal length or skb data length vs. header length).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:02:01 +00:00
Bjoern A. Zeeb
13d87d92e4 LinuxKPI: 802.11: implement cfg80211_get_ies_channel_number()
Using the previous changes implement cfg80211_get_ies_channel_number()
either based on DSPARMS (or for the future HTINFO).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:59:20 +00:00
Bjoern A. Zeeb
5db817d864 LinuxKPI: 802.11: implement some *eleme/ie* lookup functions
Implement cfg80211_find_elem(), ieee80211_bss_get_elem(),
ieee80211_bss_get_ie(), and cfg80211_find_vendor_ie() with the last
one having a short cut always also checking oui_type in the pattern.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:33:28 +00:00
Bjoern A. Zeeb
5edde07c2a LinuxKPI: 802.11: implement cfg80211_{get,put}_bss
Implement cfg80211_{get,put}_bss currently doing malloc/free bits,
so hopefully the drivers get the calls right.

cfg80211_get_bss() sets up a lookup structure which may also take a
result (first hit wins) and calls ieee80211_scan_iterate() comparing
the various values in the iterator funcion.  Some of the checks are
partially pointless (as it seems the drivers are not interested in
these parts [ANY] but we keep them for documentation purposes should
futher values arise in the future).

We currently only iterate over the first VAP which will do for now.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:18:16 +00:00
Bjoern A. Zeeb
b6b352e4c7 LinuxKPI: 802.11: set sta supported legacy rates
When initializing the sta set the per-band supported legacy rates
as some drivers take the information from there.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 00:33:34 +00:00
Vladimir Kondratyev
68f08e26e2 LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
calls and addition of missing critical section.
While here strip one inline wrap layer to reduce code size.

Fixes startup lockup of i915kms after update to drm-kmod v5.12

Reviewed by:	hselasky, bz
MFC after:	1week
Differential Revision:	https://reviews.freebsd.org/D37699
2022-12-24 12:01:20 +03:00
Konstantin Belousov
140ceb5d95 ptrace(2): add PT_SC_REMOTE remote syscall request
Reviewed by:	markj
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Konstantin Belousov
f081a291a1 compat32: move struct ptrace_sc_ret32 definition from .c to .h
Reviewed by:	markj
Sponsoreed by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Emmanuel Vadot
ccd8c4488a linuxkpi: seq_read: Fix off by one error
strscpy needs the buffer length not the string length (so including
the '\0').

Reviewed by:	bz
Fixes:	f697b9432d ("linuxkpi: drm-kmod debugfs support")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37771
2022-12-21 21:11:31 +01:00
Mateusz Guzik
e6bc24b038 kref: switch internal type to atomic_t and bring back const to kref_read
This unbreak drm-kmod build.

the const is part of Linux API

Unfortunately drm-kmod uses hand-rolled refcount* calls on a kref
object. For now go the easy route of keeping it operational by casting
stuff internally.

The general goal here is to make FreeBSD refcount API use an opaque
type, hence the ongoing removal of hand-rolled accesses.

Reported by:	emaste
2022-12-13 20:46:58 +00:00
Mateusz Guzik
67e628b7a6 kref: replace hand-rolled atomic ops with refcount API
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37608
2022-12-13 09:24:57 +00:00
Emmanuel Vadot
72621b543e linuxkpi: Fix style for dma_map_sgtable
Reported by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-12-06 16:52:16 +01:00
Austin Shafer
4085bde9fa linuxkpi: Fix return value of dma_map_sgtable
dma_map_sgtable internally uses the dma_map_sg_attrs helper. The problem is
that dma_map_sg_attrs returns the number of entries mapped, whereas
dma_map_sgtable returns nonzero on failure. This leads to dma_map_sgtable
returning non-zero-but-positive values which tricks other areas of the stack
into thinking nents is a valid pointer.

This checks if nents is valid and returns zero if so, updating the nents field
in sgt. This fixes PRIME render offload with nvidia-drm.

Fixes:	9202c95f47 ("linuxkpi: Add dma_{un,}map_sgtable")
2022-12-06 16:25:53 +01:00
Jean-Sébastien Pédron
e101c1c2c9 linuxkpi: Introduce module_param() of type bint
In Linux, this limits the accepted value to -1, 0 and 1.
In FreeBSD, this remains a signed integer with no specific constraints.

This change is a requirement to update our DRM drivers to Linux 5.12.

Differential Revision:	https://reviews.freebsd.org/D37364
2022-12-01 15:03:00 +01:00
Jean-Sébastien Pédron
0adc02a979 linuxkpi: Add PCIE_SPEED_{32,64}_0GT PCI-E bus speed constants
This change is a requirement to update our DRM drivers to Linux 5.12.

Differential Revision:	https://reviews.freebsd.org/D37363
2022-12-01 15:02:27 +01:00
Jean-Sébastien Pédron
e79a57d4ec linuxkpi: Add cmpxchg64() in <asm/atomic.h>
Differential Revision:	https://reviews.freebsd.org/D36966
2022-12-01 14:59:16 +01:00
Jean-Sébastien Pédron
18e4112337 linuxkpi: Add seqcount_mutex_t support in <linux/seqlock.h>
To achieve that, the header uses the C11 type generic selection keyboard
_Generic() because the macros are supposed to work with seqcount_t
and seqcount_mutex_t.

Differential Revision:	https://reviews.freebsd.org/D36965
2022-12-01 14:58:27 +01:00
Bjoern A. Zeeb
69cc163001 LinuxKPI: 802.11: minor header updates
- add comments for enum values constantly looked up, and another one to
  a net80211 equivalent (should possibly re-define those in the future?)
- add another nl80211_sta_info flag
- add enum environment_cap used in cfg80211.h in the future.

MFC after:	3 days
2022-11-28 21:21:06 +00:00
Bjoern A. Zeeb
5504bd59a3 LinuxKPI: SKB update
- skb_reset_tail_pointer(): we do not do offsets so do a plain reset
- skb_add_rx_frag(): adjust data_len to keep track of the frag
- based on that implement skb_is_nonlinear() and skb_linearize()
- implement build_skb() and adjust linuxkpi_kfree_skb() and ddb macro.

Sponsored by:	The FreeBSD Foundation (partially)
MFC after:	3 days
2022-11-28 20:54:57 +00:00
Bjoern A. Zeeb
ce9f36610e LinuxKPI: SKB: implement skb_peek()
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-28 18:47:08 +00:00
Bjoern A. Zeeb
23c73dbae7 LinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()
In preparation for future updates remove the budget argument from the
netif_napi_add() in drivers and update LinuxKPI to reflect that it is
gone and only set it internally.  This required changes to the currently
committed wireless drivers based on LinuxKPI (iwlwifi, rtw88, rtw89).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-28 17:30:40 +00:00
Bjoern A. Zeeb
1b91eba37b LinuxKPI: ethtool.h add more definitions
While we do not currently use ethtool, add the definitions to avoid
other longer-term maintenance problems with drivers.

Also migrate ETH_GSTRING_LEN into here from if_ether.h as it seems this
is where it belongs.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37214
2022-11-28 17:25:58 +00:00
Bjoern A. Zeeb
0fce2dc157 LinuxKPI,lindebugfs: add u8 base type and blob support
Add debugfs_create_u8() based on other already present implementations.
Add a read-only implementation for debugfs_create_blob().

Both are needed for iwlwifi debugfs support.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
OKed by:	jfree (earlier version)
Differential Revision: https://reviews.freebsd.org/D37090
2022-11-28 17:21:50 +00:00
Bjoern A. Zeeb
af393426b3 LinuxKPI: add a no-op generic_file_llseek()
This is needed for debugfs implementations in drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
OKed by:	jfree
Differential Revision: https://reviews.freebsd.org/D37092
2022-11-28 17:14:10 +00:00
Bjoern A. Zeeb
5f2f582ccc LinuxKPI: pci.h add more MSI related constanst and pci_is_enabled()
Add more MSI related constansts defined to our native defines and
pci_is_enabled().  All are needed for another wireless driver.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37225
2022-11-28 17:11:47 +00:00
Ed Maste
eafafebe47 compat32: retire now-unused MIPS support
This reverts commit a6d20bbaa2.
2022-11-23 09:33:43 -05:00
Bjoern A. Zeeb
325ba12055 LinuxKPI: in efi.h include queue.h
sys/linker.h needs sys/queue.h;  this gets another wireless driver
closer to compiling on main.

MFC after:	3 days
2022-11-15 23:08:05 +00:00
Bjoern A. Zeeb
5d310ea8c5 LinuxKPI: add memset_startat macro
Add a memset_startat() macro which sets a pattern from a struct member
to the end of the struct.   Needed by a wireless driver.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37389
2022-11-15 12:52:10 +00:00
Jean-Sébastien Pédron
208d02fd5d
linuxkpi: Define ZERO_OR_NULL_PTR() in <linux/slab.h>
On Linux, the `kmalloc()` family of functions returns a special value if
the size of the allocation is zero. This macro verifies if the pointer
is NULL (the allocation failed) or the size is 0 (the allocation was not
performed AFAIU). This special value can be passed to `kfree()`.

On FreeBSD, our `malloc(9)` functions don't return a special value for
0-size allocations. Therefore we can simply compare the result against
NULL.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37367
2022-11-11 21:03:25 +01:00
Jean-Sébastien Pédron
86a1c5d129
linuxkpi: Define pci_reset_function() in <linux/pci.h>
Currently, it always returns an error on FreeBSD.

Reviewed by:	bz manu
Approved by:	bz manu
Differential Revision:	https://reviews.freebsd.org/D37366
2022-11-11 21:00:36 +01:00
Jean-Sébastien Pédron
42bb586116
linuxkpi: Include <linux/list.h> and <linux/kernel.h> from <linux/mutex.h>
They are not really used in this header. However they are included in
Linux and at least the DRM drivers unfortunately rely on this namespace
pollution.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37365
2022-11-11 20:59:40 +01:00
Jean-Sébastien Pédron
24c7853f39
linuxkpi: Add <linux/mman.h> which includes <linux/smp.h>
This is used by `i915_gem.c` in the i915 DRM driver to get access to
`wbinvd_on_all_cpus()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36970
2022-11-11 20:57:46 +01:00
Jean-Sébastien Pédron
708a570255
linuxkpi: Add <linux/page-flags.h>
It just provides a `PageHighMem()` macro stub.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36961
2022-11-11 20:56:42 +01:00
Jean-Sébastien Pédron
58cf3a69a5
linuxkpi: Define boot_cpu_data.x86_max_cores
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36971
2022-11-11 18:43:07 +01:00
Jean-Sébastien Pédron
c4163160e4
linuxkpi: Add dev_warn_once() in <linux/device.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36968
2022-11-11 18:42:31 +01:00
Jean-Sébastien Pédron
23ebeac87f
linuxkpi: Add list_for_each_entry_from_rcu() in <linux/rculist.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36967
2022-11-11 18:42:10 +01:00
Jean-Sébastien Pédron
d3584f9283
linuxkpi: Define typeof_member() in <linux/kernel.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36964
2022-11-11 18:41:36 +01:00
Jean-Sébastien Pédron
0e5569a08c
linuxkpi: Add <linux/dma-buf-map.h>
I took the implementation from OpenBSD, commit
d55ef580b1748517027c3eabdb715316ca5b1442.

The only difference is the addition of `dma_buf_map_is_equal()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36963
2022-11-11 18:40:57 +01:00
Jean-Sébastien Pédron
c9c1255012
linuxkpi: Add <linux/mmzone.h>
It provides the `MAX_ORDER` constant.

Reviewed by:	emaste manu
Approved by:	emaste manu
Differential Revision:	https://reviews.freebsd.org/D36962
2022-11-11 18:39:48 +01:00
Jean-Sébastien Pédron
1676c97d5d
linuxkpi: Add <acpi/actbl.h>
It simply includes the same header in FreeBSD (which is located
elsewhere).

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36960
2022-11-11 18:38:06 +01:00
Jean-Sébastien Pédron
1ad6b2b1da
linuxkpi: Add krealloc_array()
In FreeBSD, this is a wrapper on top of `realloc()`.

V2: Check if `n * size` would overflow and return `NULL` if that's the
    case. Suggested by hselasky@ and emaste@.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36959
2022-11-11 18:37:34 +01:00
Jean-Sébastien Pédron
0b8a423d07
linuxkpi: Introduce module_param() of type hexint
In Linux, this affects how the value is formatted. In FreeBSD, this
remains an unsigned integer.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36958
2022-11-11 18:36:46 +01:00
Jean-Sébastien Pédron
c72dd0aabe
linuxkpi: Introduce vma_set_file()
This code was moved from the i915 driver in Linux 5.11.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36957
2022-11-11 18:36:00 +01:00
Jean-Sébastien Pédron
415ca4d27d
linuxkpi: Include <linux/shinker.h> in <linux/mm.h>
This is done like this in Linux.

Reviewed by:	emaste manu
Approved by:	emaste manu
Differential Revision:	https://reviews.freebsd.org/D36956
2022-11-11 18:34:19 +01:00
Jean-Sébastien Pédron
f021c5c4a1
linuxkpi: Update struct irq_work
The previous `llnode` field is moved inside another field `node`.

This `node` field is a `struct __call_single_node` in Linux. Here, we
simply add an anonymous struct with the `llnode` field inside. That
field's new name is `llist` now.

V2: Use an anonymous union to keep the structure backward compatible
    with drivers using the previous `llnode` field. This was suggested
    by wufl@ and hselasky@. Thank you!

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36955
2022-11-11 18:32:58 +01:00
Jean-Sébastien Pédron
bfe6bfd79e
linuxkpi: Add __GFP_NOMEMALLOC kmalloc flag
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36954
2022-11-11 18:30:31 +01:00
Emmanuel Vadot
ee247fc1e9 linuxkpi: Move cpu_relax out of ifdef for x86
It's needed by drm-kmod and this allow building on arm64 and powerpc.

Reported by:	jhibbits
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-11-10 12:50:51 +01:00
Alex S
9f7bf94ee2 linux(4): Fix get_robust_list() syscall return value.
The system call returns the head of the robust futex list. The list head is stored
in the location pointed to by the head argument. When copying data between address
spaces use proper head storage size as it depends on an emulated ABI.

PR:		267616
MFC after:	3 days
2022-11-09 00:17:17 +03:00
Bjoern A. Zeeb
b5c3819c7b LinuxKPI: add virt_to_phys()
Add virt_to_phys() as a define to vtophys().
This is used by a wireless driver for dma related work; sigh.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37301
2022-11-08 18:18:01 +00:00
Bjoern A. Zeeb
f2978460c7 LinuxKPI: tasklet add (*callback) support
In addition to (*func) tasklet also seems to have a (*callback) with
a different argument.  Add support for this and add tasklet_setup()
as well for support in more drivers.

The from_tasklet() definition is duplicated in the tree; hide it there
under #ifndef to avoid a re-definition.  People should generally add
LinuxKPI bits to linuxkpi rather than private files if they also rely
on other LinuxKPI bits.

X-MFC:		DO NOT MFC, space allocated by drivers not us.
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37216
2022-11-08 18:14:17 +00:00
Bjoern A. Zeeb
e2361e04b0 LinuxKPI: implement cpumask_of()
Add a static set of cpumasks for all (possible) cpus with only the one
indexed cpu enabled in each set.
This is needed for cpumask_of(_cpuid) which returns a cpumask (cpuset)
with only cpu _cpuid enabled and is used by one wireless driver at least.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37223
2022-11-08 18:11:55 +00:00
Bjoern A. Zeeb
a62d5ff5b0 LinuxKPI: add linux/leds.h
This is just a dummy enum and struct in order to make drivers compile
more happily as some parts are simply not hidden behind #ifdefs and
this avoids a longer-term maintenance problem.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37215
2022-11-07 12:52:41 +00:00
Bjoern A. Zeeb
6e8d676131 LinuxKPI: add devm_request_irq()
Add devm_request_irq() needed by a driver.  Turns out all we need
is a wrapper with the right arguments to lkpi_request_irq().

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37217
2022-11-07 12:51:01 +00:00
Bjoern A. Zeeb
6a647ae514 LinuxKPI: string.h implement memcpy_and_pad()
Add a memcpy variant which takes length of source and destination
buffers and a padding character in case there is free space in the
destination.  This is used by a wireless driver.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37226
2022-11-07 12:49:01 +00:00
Bjoern A. Zeeb
4a67f1df8b LinuxKPI: 802.11: enable WME support
Most of the WME code has been there disabled for months.  One of the
reasons was that it lead to crashes early on.  It is now understood
that the crashes are independent event and we can enable WME.
Update the code and deal with the calls from net80211 and adjust the
updates to when mac80211 drivers expect them, coherently put it under
LKPI_80211_WME and enable the define locally.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-07 12:39:46 +00:00
Elliott Mitchell
21cc0918c7 sys: Nuke double-semicolons
A distinct number of double-semicolons have ended up in FreeBSD.  Take a
pass at getting rid of many of these harmless typos.

Reviewed by: emaste, rrs
Pull Request: https://github.com/freebsd/freebsd-src/pull/609
Differential Revision: https://reviews.freebsd.org/D31716
2022-11-02 09:34:20 -06:00
Bjoern A. Zeeb
e7fe037310 LinuxKPI: 802.11: pass internal variable to lkpi_80211_mo_sta_state()
With mac80211 operations (MO) tracing on we have seen some ill-ordered
executions of MO functions.  In order to limit visibility of the mac80211
sta, pass the internal version into lkpi_80211_mo_sta_state() and only
there convert to the argument needed.  This mostly eases tracing and
debugging.

Sposnored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-01 00:00:18 +00:00
Bjoern A. Zeeb
05e640dc9e LinuxKPI: 802.11: update struct member types
Update struct member types for ongoing work towards HT support.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-10-31 22:24:08 +00:00
Bjoern A. Zeeb
1d70218e9e LinuxKPI: 802.11 update header files
Adjust struct members, add more (for HE dummy) defines, add more
(wrapper) functions in order to acoomodate another driver.

MFC after:	3 days
2022-10-31 22:09:25 +00:00
Bjoern A. Zeeb
cca40d7cc7 LinuxKPI: add timekeeping.h, another dummy (empty) header file
The file is included by a driver but it seems we don't need to implement
anything here.

MFC after:	3 days
2022-10-30 17:35:24 +00:00
Ed Maste
43d0c2ddd2 netlink: use (void) for function definitions with no arguments
For some of these Clang produced a warning that "a function declaration
without a prototype is deprecated in all versions of C".  In other cases
the function defintion used () which did not match the header
declaration, which used (void).

Sponsored by:	The FreeBSD Foundation
2022-10-27 11:14:00 -04:00
Bjoern A. Zeeb
b5a8107590 LinuxKPI: seq_file add "private" versions.
Add __seq_open_private() and seq_release_private() needed by iwlwifi
debugfs support.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37089
2022-10-24 21:39:48 +00:00
Bjoern A. Zeeb
d3975204e4 LinuxKPI: add MSEC_PER_SEC
Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37087
2022-10-23 21:54:36 +00:00
Bjoern A. Zeeb
64d3da0063 LinuxKPI: 802.11: add MO tracing
Add a macro to each implemented mac80211 operation.  This currently
turns into a printf if LINUXKPI_80211_DEBUG is defined but in the
future could become a different probe as well.
This is helpful for quick analysis and boot-time problem debugging
when DTrace and other frameworks may be harder to use.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-10-23 21:48:22 +00:00
Bjoern A. Zeeb
0080f30ff1 LinuxKPI: 802.11: add changes to support debugfs in iwlwifi
Add new fields (also have to move a struct up, no changes there)
in order to make iwlwifi debugfs support compile.

Sposnored by:	The FreeBSD Foundation
MFC after:	3 days
2022-10-22 20:42:35 +00:00
John Grafton
4c9db9566e linprocfs: Add net/route.
PR:			266482
Reviewed by:		melifaro, me
Differential revision:	https://reviews.freebsd.org/D36949
MFC after:		1 week
2022-10-22 13:52:58 +03:00
Ed Maste
9f6097d6a6 linuxkpi: retire now-unused MIPS support
Reviewed by:	bz, manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37023
2022-10-17 16:31:20 -04:00
Jake Freeland
4cb3cb2de2 LinuxKPI: Add pci_power querying for drm-kmod
Adds a few struct members and a function to get i915_runtime_pm_status()
to compile in drm-kmod.

Differential Revision:	https://reviews.freebsd.org/D36749
Sponsored by:   Google, Inc. (GSoC 2022)
2022-10-06 10:15:41 +02:00
Alexander V. Chernikov
7c40e2d5f6 linuxolator: add netlink support
Add the glue code to support netlink in Linuxolator.
linux_common(4) now depends on netlink(4).

All netlink protocol constants are consistent with the Linux version.
However, certain OS-specific constants such as AF_INET6, interface
flags or default routing table id, are different between FreeBSD and
Linux. Thus, it may be needed to rewrite some message parts or even
rewrite the whole message, adding or removing some TLVs. The core
netlink implementation code provides efficient rewriting callbacks
 which Linuxolator now uses.

Reviewed by:	dchagin
Differential Revision: https://reviews.freebsd.org/D36361
MFC after:	2 months
2022-10-01 14:16:45 +00:00
Ed Schouten
af3c78886f Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface.

Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.

With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.

C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.

Symbol versioning is used to keep old binaries working.

MFC:			never
Relnotes:		yes
Reviewed by:		cem, imp, hps, pauamma
Differential revision:	https://reviews.freebsd.org/D17083
2022-09-30 15:26:30 -07:00
Hans Petter Selasky
dd6bb9abf0 LinuxKPI: Use SYSCTL_FOREACH()
Differential Revision:  https://reviews.freebsd.org/D36748
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-09-28 13:59:55 +02:00
Alan Somers
d3f96f6610 Fix O(n^2) behavior in sysctl
Sysctl OIDs were internally stored in linked lists, triggering O(n^2)
behavior when userland iterates over many of them.  The slowdown is
noticeable for MIBs that have > 100 children (for example, vm.uma).  But
it's unignorable for kstat.zfs when a pool has > 1000 datasets.

Convert the linked lists into RB trees.  This produces a ~25x speedup
for listing kstat.zfs with 4100 datasets, and no measurable penalty for
small dataset counts.

Bump __FreeBSD_version for the KPI change.

Sponsored by:	Axcient
Reviewed by:	mjg
Differential Revision: https://reviews.freebsd.org/D36500
2022-09-26 18:03:34 -06:00
Bjoern A. Zeeb
0b9bc97342 LinuxKPI: add DMA_MAPPING_ERROR
While we deal with 0 returned, some drivers directly use and check for
DMA_MAPPING_ERROR.  Add the case and check for both in dma_mapping_error().

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36686
2022-09-26 19:42:02 +00:00
Bjoern A. Zeeb
f486b35247 LinuxKPI: add struct dmi_header and unsupported dmi_walk()
Add a structure definition as well as a dummy dmi_walk for now
which returns an error as not supported.  Our current dmi implementation
is special but does not give access to all details but rather only
information from kenv which does not suffice all use cases.

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36687
2022-09-26 19:40:49 +00:00
John Baldwin
f49fd63a6a kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.
Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36549
2022-09-22 15:09:19 -07:00
John Baldwin
7ae99f80b6 pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.
This matches the return type of pmap_mapdev/bios.

Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36548
2022-09-22 15:08:52 -07:00
Bjoern A. Zeeb
f7c0c1590e LinuxKPI: cache.h add L1_CACHE_ALIGN()
Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36655
2022-09-22 15:10:04 +00:00
Bjoern A. Zeeb
30048f6142 LinuxKPI: pci.h split up pcim_iomap_regions_request_all()
Factor out parts of pcim_iomap_regions_request_all() into
pcim_iomap_regions() now needed for a driver.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36654
2022-09-22 15:10:04 +00:00
Bjoern A. Zeeb
8e30f49256 LinuxKPI: if_ether.h add more constants
In addition to the ones added last year add more found in modern
drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36656
2022-09-22 15:10:04 +00:00
Bjoern A. Zeeb
046b82842c LinuxKPI: io.h constify arguments and add more functions
Constify "*from" arguments and add __ioread32_copy() and
__ioread64_copy() based on the already existing implementations.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36657
2022-09-22 15:10:04 +00:00
Bjoern A. Zeeb
7105f0d967 LinuxKPI: dma-mapping: add dmam_alloc_coherent()
Add the devres version dmam_alloc_coherent() of dma_alloc_coherent()
along with the ancillary free function.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36661
2022-09-22 15:10:03 +00:00
Bjoern A. Zeeb
f9f4988dc4 LinuxKPI: tracepoint.h add more defines
Add some more defines used in drivers to make it easier to compile.

MFC after:	7 days
Reviewed by:	hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36660
2022-09-22 15:10:03 +00:00
Bjoern A. Zeeb
fdc7ef3c98 LinuxKPI: pci_ids.h Add more Vendor IDs.
Add PCI vendor IDs found in ath and mt76 drivers.  This should make it
easier for me and others not having to re-define them locally.

MFC after:	7 days
Reviewed by:	hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36659
2022-09-22 15:10:03 +00:00
Bjoern A. Zeeb
b27c3aa800 LinuxKPI: lockdep.h add lockdep_{,un}register_key()
Add NOPs for lockdep_{,un}register_key().

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36658
2022-09-22 15:10:03 +00:00
Bjoern A. Zeeb
c41d83548b LinuxKPI: pci.h add more defines and functions
Add #defines for PCI_DEVICE_ID and repoint the PCI_VENDOR_ID one.
Add dev_is_pci().
Add pcie_capability_clear_word() according to similar implementations.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
Reviewed by:	hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36653
2022-09-22 15:10:03 +00:00
Bjoern A. Zeeb
e999fbf077 LinuxKPI: device.h add devm_kmemdup()
Add devm_kmemdup() as needed by a networking driver.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
eviewed by: 	hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36652
2022-09-22 15:09:26 +00:00
Bjoern A. Zeeb
8ea48fc59e LinuxKPI: device.h remove duplicate #include
linux/types.h is included twice; reduce to the first.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-09-21 17:25:34 +00:00
Bjoern A. Zeeb
f02e21159b LinuxKPI: 802.11: add more header compat bits
First part adding more bits in order to synch up drivers to the same
level and enable a new ones.

MFC after:	3 days
2022-09-21 17:12:48 +00:00
Hans Petter Selasky
cbda8bed15 linuxkpi: Resolve duplicate global symbol name to fix LINT kernel build.
seq_printf() is defined in both spl_procfs_list.c and linux_seq_file.c .
Fix this by renaming the LinuxKPI ones and use macros to invoke the
correct function.

Reported by:	jfree@
Differential Revision:  https://reviews.freebsd.org/D35883
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-09-20 22:37:15 +02:00
Jake Freeland
f697b9432d linuxkpi: drm-kmod debugfs support
This diff extends LinuxKPI to support simple attribute files in debugfs.
These simple attributes are an essential component for compiling drm-kmod
with CONFIG_DEBUG_FS enabled.
This will allow for easier graphics driver debugging using
Intel's igt-gpu-tools.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D35883
Sponsored by:	Google, Inc. (GSoC 2022)
2022-09-20 19:41:10 +02:00
Jake Freeland
a11195df34 linuxkpi: Add strndup_user
Reviewed by:	hselasky, markj
Differential Revision:	https://reviews.freebsd.org/D36350
Sponsored by:	Google, Inc. (GSoC 2022)
2022-09-20 19:40:05 +02:00
Jake Freeland
a06eeeaa1d linuxkpi: Add EPOLL aliases
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D36527
Sponsored by:	Google, Inc. (GSoC 2022)
2022-09-20 19:39:52 +02:00
Jake Freeland
f0b0f28f35 linuxkpi: Add down_read_killable()
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D36528
Sponsored by:	Google, Inc. (GSoC 2022)
2022-09-20 19:39:32 +02:00
Mateusz Guzik
c3707bd3d6 linuxkpi: use SI_SUB_EVENTHANDLER + 1, like other consumers
Otherwise it may try to initialize before eventhandler subsystem.
2022-09-17 23:52:23 +00:00
Jessica Clarke
7b673a2c73 freebsd32: Make sendmsg match native ABI for unpadded final control message
The API says that CMSG_SPACE should be used for msg_controllen, but in
practice the native ABI allows you to only use CMSG_LEN for the final
(typically only) control message, and real-world software does this,
including Wayland. For freebsd32, this is in practice mostly harmless,
since control messages are generally used to carry file descriptors,
which are already 4 bytes in size and thus no padding is needed, but
they can carry other quantities that may not result in an aligned
length. This was discovered after CheriBSD's freebsd64 equivalent was
updated to match the freebsd32 implementation, as that uses 8 byte
alignment which does break the file descriptor use case, and thus
Wayland.

This used to be addressed by aligning buflen before the first iteration,
but that allowed unwanted invalid inputs and was lost in 1b1428dcc8,
with no safer equivalent put in its place.

Reviewed by:	brooks, kib, markj
Obtained from:	CheriBSD
Fixes:		1b1428dcc8 ("Fix a TOCTOU vulnerability in freebsd32_copyin_control().")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36554
2022-09-15 17:16:22 +01:00
Doug Moore
4893472c9a rb_tree: pass parent to RB_INSERT_COLOR
Change RB_COLOR_INSERT to take a parent parameter, to avoid looking up
a value already available. Make adjustments to a linux rbtree header,
which invokes it.

Reviewed by:	alc, hselasky
Differential Revision:	https://reviews.freebsd.org/D36114
2022-09-13 01:11:47 -05:00
Mateusz Guzik
3212ad15ab Add getsock
All but one consumers of getsock_cap only pass 4 arguments.
Take advantage of it.
2022-09-10 19:47:47 +00:00
Bjoern A. Zeeb
800aa9cd3d LinuxKPI: 80211 (+net80211): update and cleanup headers
Fix types for various struct fields (initially added as int).

Move structs and inline functions logically together, e.g., for wowlan.
Add more skeleton functions and #defines needed for iwlwifi d3.c
in the future.

Add struct ieee80211_vht_cap (without "_ie") to net80211 and remove
duplicate definitions in LinuxKPI headers now using net80211 structs.
For now leave ieee80211_ie_vhtcap in net80211.  I am not sure yet if we
actually need it as such.  That'll be cleaned up with more VHT updates
in net80211 in the future.

No functional changes in currently compiled code intended.

Try to implement ieee80211_action_contains_tpc() as I ran into it with
an older iwlwifi chipset.  This depends on c994352a88.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2022-09-09 18:40:23 +00:00
Bjoern A. Zeeb
d6d687daaa LinuxKPI: 80211: add ieee80211_stop_tx_ba_session()
rtw89 needs ieee80211_stop_tx_ba_session().
Add the skeleton function for now so we can implement BA functions all
together.

MFC after:	3 days
2022-09-09 16:30:00 +00:00
Felix Palmen
600f161295 linuxkpi: Add non-atomic readq()/writeq()
The non-atomic versions are required by drm-510-kmod to build on 32-bit
architectures.

Approved by:		hselasky, manu, tcberner (mentor)
Differential Revision:	https://reviews.freebsd.org/D36507
2022-09-09 16:59:41 +02:00
Doug Moore
d0354fa7b6 rb_tree: reduce duplication in balancing code
Change RB_INSERT_COLOR and RB_REMOVE_COLOR so that the blocks of code
that are identical except for left and right being exchanged are made
only one block with a variable to indicate left- or right-handedness.

Rename RB macros so that those not intended for external use begin
with an underscore.

Add comments to the balancing code so that another might understand it.

Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36393
2022-09-07 23:46:19 -05:00
Bjoern A. Zeeb
549198b1ab LinuxKPI, dev: 80211 update mac80211 KPI
Update the mac80211 ops KPI for (*conf_tx), (*assign_vif_chanctx),
(*unassign_vif_chanctx), (*start_ap), and (*stop_ap), as well as
ieee80211_beacon_get_tim() and ieee80211_beacon_get_template().

Update in-tree drivers iwlwifi and rtw88 accordingly based on upstream
changes (as well as out-of-tree ones).  This was triggered by trying to
synchronize more drivers to a common state.

MFC after:	1 week
2022-09-07 23:38:54 +00:00
Bjoern A. Zeeb
ac07a3b8b6 LinuxKPI: netdev: expose napi state
There are drivers directly accessing napi->state testing for bits
(NAPI_STATE_SCHED encountered so far).  Rename the internal _flags
struct field to state and expose our internal state flag bits along
with the one official aliased.

As I left in a comment, I wished Linux would hide these accesses
behind inline functions or by other means and not public expose
the implementation details.

MFC after:	1 week
2022-09-07 23:35:41 +00:00
Bjoern A. Zeeb
fb3c549738 LinuxKPI: firmware: add request_partial_firmware_into_buf()
A (so far out-of-tree) driver update needs
request_partial_firmware_into_buf().  Given we load the full .ko file
using firmware(9) just do that and copy the requeste data into the
buffer (rather than poissibly only reading portions of the firmware
file).

MFC after:	1 week
2022-09-07 23:33:45 +00:00
Bjoern A. Zeeb
e3a0b1202b LinuxKPI: 80211 / iwlwifi: improve queue management
For one initialise vif->hw_queues later set in lkpi_80211_txq_tx_one()
for drivers using them.  This may still need slightly more cleanup once
we get QUEUE_CONTROL-supporting drivers into the tree.

For the other rework and improve how we deal with tid/ac/txq in
lkpi_80211_txq_tx_one() and cleanup old comments and unused code.
This seems to reduce (remove) "Invalid TXQ id" reports from iwlwifi.
(The assumption is that the frame(s) triggering this WARN_ONCE or the
added FreeBSD specific logging were sent with lkpi_80211_mo_tx()).

Adjust the one logging from e674ddec0b
to IWL_DEBUG_TX so that now this is fixed it is also not always logged
anymore but leave it in case we need to further debug queues in the
future.

Tested by:	pstef, Kevin Oberman (rkoberman gmail.com)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-09-05 21:03:03 +00:00
Bjoern A. Zeeb
ec190d9150 LinuxKPI: 80211: improve linuxkpi_ieee80211_get_tid()
Continue what was started in 26a3694833
in iwlwifi and extend out internal implementation of
linuxkpi_ieee80211_get_tid() by an argument as to whether "no-QoS"
answers are acceptable.  For the LinuxKPI ieee80211_get_tid() set
this to false as the Linux derived drivers seem to do extra checks
for the QoS-Data frame before acquiring the tid.
Add KASSERTs to enforce the extra argument.
This allows us to use the net80211 variant in LinuxKPI for other
means explicitly documenting that we do accept a IEEE80211_NONQOS_TID.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-09-05 20:57:17 +00:00
Bjoern A. Zeeb
a486fbbd78 LinuxKPI: 80211: scanning code updates
For consistency rename LKPI_SCAN_RUNNING adding a LHW_ prefix.
Add a local flag LKPI_LHW_SCAN_HW mirroring the net80211
IEEE80211_FEXT_SCAN_OFFLOAD flag.
Slightly simplify the code.
Overload (*ic_scan_curchan) and (*ic_scan_mindwell) so that we can
call the net80211 implementation in case of software scan but skip it
in case of full-offload scans.
Also add a bandaid to our (*ic_set_channel) implementation to not siwtch
channels if we have an active hw_scan running.

Obtained from:	bz/wireless-dev
Sponsored by:	The FreeBSD Foundation (partially)
MFC after:	4 days
2022-09-03 23:40:51 +00:00
Bjoern A. Zeeb
527687a9e3 LinuxKPI: 80211: implement (*get_antenna) and set ic_[rt]xstream
Implement the mac80211 (*get_antenna) call and after checking any
antenna information present query the current configuration on startup
(both informations should be identical at this point in theory).
Both the wiphy variables and function call report a bitmask not a count.
Count the bits for net80211 for as long as we get away with just a
number in ic_[rt]xstream.

Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
2022-09-03 23:11:05 +00:00
Bjoern A. Zeeb
b35f6cd066 LinuxKPI: 80211: make HW_CRYPTO compileable again
Rename TRY_HW_CRYPTO to LKPI_80211_HW_CRYPTO for consitency and make
it compileable again in case someone wants to sit down and make it
work.  It's probably not too much to do.  Otherwise I might eventually
get around to it.

Obtained from:	bz/wireless-dev
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
2022-09-03 22:51:16 +00:00
Bjoern A. Zeeb
c9b7e9df18 net80211 / drivers: rename to IEEE80211_FC0_SUBTYPE_QOS_DATA
Going through the Frame (Sub)types the "QOS Data" being called "QOS"
scheme leads to a naming conflict for QOS_CFPOLL and QOS_CFACKPOLL
(if added).   Rename QOS* to QOS_DATA* to avoid the conflict and
to also better match the standards name.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	5 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36409
2022-09-03 21:04:13 +00:00
Tijl Coosemans
fdc1894795 linuxkpi: on i386 only use first_msi_irq if apic is in kernel config 2022-09-01 14:08:15 +02:00
Bjoern A. Zeeb
caaa79c3f8 LinuxKPI 802.11: change type of bssid in struct ieee80211_bss_conf
Enabling other driver code found that the bssid in
struct ieee80211_bss_conf is not an array but expected to be
a const pointer (const, != NULL checks).
Adjust accordingly in the header and in the LinuxKPI compat code.
There initialization now needs to be a static array always present
as we need a value before we will have a BSS (node in scan_to_auth)
as the mac80211 driver (*handlers) are expecting the pointer to be
not NULL (copying without checks).
This is a pre-req to enable d3 (CONFIG_PM[_SLEEP]) in the future.

Tested by:	Tomoaki AOKI (junchoon dec.sakura.ne.jp)
Tested by:	Berislav Purgar (bpurgar gmail.com)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-08-27 14:54:02 +00:00
Brooks Davis
c46697b9cb freebsd32_sendmsg: fix control message ABI
When a freebsd32 caller uses all or most allowed space for control
messages (MCLBYTES == 2K) then the message may no longer fit when
the messages are padded for 64-bit alignment.  Historically we've just
shrugged and said there is no ABI guarantee.  We ran into this on
CheriBSD where a capsicumized 64-bit nm would fail when called with more
than 64 files.

Fix this by not gratutiously capping size of mbuf data we'll allocate
to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger).
Instead of hard-coding a length check, let m_get2 do it and check for a
NULL return.

Reviewed by:	markj, jhb, emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36322
2022-08-24 18:34:39 +01:00
Emmanuel Vadot
6364180582 linuxkpi: unbreak linux_i2cbb
This is a joint work with manu.

- fixed conditions in do_i2c_transfer and i2c_transfer as linux_i2cbb
  does not set adapter->algo->master_xfer but does set
  adapter->algo_data;
- fixed parent bus specification for linux_i2cbb driver module;
- actually implemented iicbb_transfer method;
- added iicbb_pre_xfer and iicbb_post_xfer methods;
- removed unnecessary and harmful delays (and other extra logic) from
  iicbb methods as iicbb driver already has them;
- added setting of iicbb speed based on algo_data->udelay, so that iicbb
  uses correct delays;

PR:		265920
Fixes:		1961a14a47 linuxkpi: Add i2c support
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG (manu's work)
2022-08-24 16:23:37 +03:00
Doug Moore
02d0c43c9e rb_tree: speed-up double rotation
RB_ROTATE_LEFT (and it symmetric twin) modify the rb-tree, adjusting
pointers so that what started as a proper tree ends up a proper
tree. When two consecutive rotations move the same node up the tree,
some of the pointers changed in the first rotation are immediately
changed again in the second - namely, the pointer from the rising node
to its new parent, and the pointer from that parent back to the rising
node. This change removes from RB_ROTATE macros the responsibility for
managing those two pointers, and leaves it to the code that calls for
rotations to fix up those pointers afterward. That drops a comparison
and a pair of assignments from every INSERT_COLOR or REMOVE_COLOR call
that ends in a double rotation.

A side-effect of this change is that the SWAP_CHILD macro must take as
a parameter a pointer to the node that is changing children, where it
is now computed from the old child. Since this macro is called in a
couple of places besides the RB_ROTATE macros, those calls are also
affected.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36266
2022-08-19 18:11:29 -05:00
Emmanuel Vadot
319a4bddb0 linuxkpi: i2c: Fix 7bit/8bit addressing
Linux is using 7 bit addressing while FreeBSD uses 8 bit addresses
internally, but i2c(8) uses 7 bit address.
This confused me when originally doing the code and I thought that
0x50 was the 8bit EDID address while it's the 7bit address and since
I did all my testing using this I didn't noticed the problem.

Reported by:	avg
PR:		265920 (somewhat)
2022-08-19 14:39:16 +02:00
Bjoern A. Zeeb
8d37116489 net80211: LinuxKPI 802.11: harmonize IEEE80211_VHT_MCS_*
Rather than defining the same values in two places and having to do
conflict resulution on the name in LKPI, change the defines to an
enum in net80211.  In addition to de-duplication this also gives us
value checks in certain cases.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36250
2022-08-18 20:34:30 +00:00
Bjoern A. Zeeb
4a7e8c7bd4 LinuxKPI: extend kfifo to be usable
Implement some basic kfifo pieces as needed by drivers.

MFC after:	2 weeks
Reviewed by:	wulf, hselasky
Differential Revision: https://reviews.freebsd.org/D35829
2022-08-18 20:26:20 +00:00
Emmanuel Vadot
7bf65b00c6 linuxkpi: Add I2C_NAME_SIZE and I2C_MODULE_PREFIX defines
Both are needed by drm-kmod

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	//reviews.freebsd.org/D36212
2022-08-18 09:47:19 +02:00
Emmanuel Vadot
4b4ab8c310 linuxkpi: Add linux/vgaarb.h
Needed by drm-kmod.

Reviewed by:	bz
Obtained from:	Linux
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36104
2022-08-18 09:47:15 +02:00
Emmanuel Vadot
73e342328b linuxkpi: Add video/mipi_display.h
Needed by drm-kmod.

Reviewed by:	bz
Obtained from:	OpenBSD
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36103
2022-08-18 09:47:12 +02:00
Emmanuel Vadot
afe53d7f7a linuxkpi: acpi/video.h: Add stubs acpi_video_{register,unregister}
Needed by i915.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36102
2022-08-18 09:47:07 +02:00
Emmanuel Vadot
76d93395c5 linuxkpi: Add __copy_to_user_inatomic and __copy_from_user_inatomic
Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36113
2022-08-18 09:47:04 +02:00
Emmanuel Vadot
bf27839aa9 linuxkpi: Add add_taint stub
Needed by drm-kmod.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36112
2022-08-18 09:47:00 +02:00
Emmanuel Vadot
4b2cb13e91 linuxkpi: Add few more include in linux/kernel.h
Those are needed and also included in linux (via polution).

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36111
2022-08-18 09:46:57 +02:00
Emmanuel Vadot
d4eeb02986 linuxkpi: Add a bunch of dummy include
All those are needed for drm-kmod.
Add them to base in another directory that will be append in the CFLAGS.

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36110
2022-08-18 09:46:54 +02:00
Emmanuel Vadot
6d3d565316 linuxkpi: swap.h: Fix include
Add needed includes so we can use it.

Reviewed by:	bz
Fixes:	c3f4f28c63 ("linuxkpi: Add some basic swap functions")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36109
2022-08-18 09:46:50 +02:00
Emmanuel Vadot
35b7625ed0 linuxkpi: Add stub kmem_cache_shrink
Needed by drm-kmod.

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36108
2022-08-18 09:46:47 +02:00
Emmanuel Vadot
b2c860060c linuxkpi: Add asm/processor.h
Also fill the boot_cpu_data struct as drm needs it.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36107
2022-08-18 09:46:43 +02:00
Emmanuel Vadot
9202c95f47 linuxkpi: Add dma_{un,}map_sgtable
Variant of dma_{un,}map_sg_attrs for struct sg_table.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36106
2022-08-18 09:46:40 +02:00
Emmanuel Vadot
b1c82bd402 linuxkpi: Add linux/stackdepot.h
With a typedef needed by drm-kmod.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36105
2022-08-18 09:46:36 +02:00
Emmanuel Vadot
fd62b3fa1e linuxkpi: pgtable: Add more defines
Needed by drm-kmod

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36101
2022-08-18 09:46:33 +02:00
Emmanuel Vadot
8828ebd6fc linuxkpi: Add sched/mm.h
With stubs needed by drm-kmod.

Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36100
2022-08-18 09:46:29 +02:00
Emmanuel Vadot
1a6874e3a4 linuxkpi: Add refcount_dec_and_test
In Linux this takes a refcount_t argument but in linuxkpi struct kref
uses an atomic_t for the refcount and code in drm directly uses this
function with a kref so use an atomic_t here.

Reviewed by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36099
2022-08-18 09:46:25 +02:00
Emmanuel Vadot
4370e9f1cf linuxkpi: Add for_each_sgtable_{sg,page}
Needed by drm-kmod.

Reviewed by:	bz
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36098
2022-08-18 09:46:22 +02:00
Gleb Smirnoff
e7d02be19d protosw: refactor protosw and domain static declaration and load
o Assert that every protosw has pr_attach.  Now this structure is
  only for socket protocols declarations and nothing else.
o Merge struct pr_usrreqs into struct protosw.  This was suggested
  in 1996 by wollman@ (see 7b187005d1), and later reiterated
  in 2006 by rwatson@ (see 6fbb9cf860).
o Make struct domain hold a variable sized array of protosw pointers.
  For most protocols these pointers are initialized statically.
  Those domains that may have loadable protocols have spacers. IPv4
  and IPv6 have 8 spacers each (andre@ dff3237ee5).
o For inetsw and inet6sw leave a comment noting that many protosw
  entries very likely are dead code.
o Refactor pf_proto_[un]register() into protosw_[un]register().
o Isolate pr_*_notsupp() methods into uipc_domain.c

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D36232
2022-08-17 11:50:32 -07:00
Konstantin Belousov
00d17cf342 elf_note_prpsinfo: handle more failures from proc_getargv()
Resulting sbuf_len() from proc_getargv() might return 0 if user mangled
ps_strings enough. Also, sbuf_len() API contract is to return -1 if the
buffer overflowed. The later should not occur because get_ps_strings()
checks for catenated length, but check for this subtle detail explicitly
as well to be more resilent.

The end result is that p_comm is used in this situations.

Approved by:	so
Security:	FreeBSD-SA-22:09.elf
Reported by:	Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by:	delphij, markj
admbugs:	988
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35391
2022-08-09 15:44:45 -04:00
Emmanuel Vadot
521abc32e2 linuxkpi: io.h: Only exclude armv6 and armv7 for asm/set_memory.h
Other arches like powerpc* needs it.

Fixes:  d387a1b4b1 ("linuxkpi: io.h: Do not include asm/set_memory.h for armv6 and armv7")
Fixes:  789dbdbb48 ("linuxkpi: Add arch_io_{reserve,free}_memtype_wc")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-08-08 20:22:44 +02:00
Emmanuel Vadot
d387a1b4b1 linuxkpi: io.h: Do not include asm/set_memory.h for armv6 and armv7
They do not have the same pmap api and this cannot work for those arch.

Fixes:	789dbdbb48 ("linuxkpi: Add arch_io_{reserve,free}_memtype_wc")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-08-08 18:55:58 +02:00
Konstantin Belousov
1b0a4974c5 thread_create(): call cpu_copy_thread() after td_pflags is zeroed
By calling the function too early we might still have the td_pflags
value cached from the previous struct thread use. cpu_copy_thread()
depends on correct value for TDP_KTHREAD at least on x86.

Reported, bisected, and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36069
2022-08-08 19:44:17 +03:00
Emmanuel Vadot
2ff0f05149 linuxkpi: pm: Add more defines and includes
Needed by drm-kmod.

Reviewed By:	emaste, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36024
2022-08-08 15:22:36 +02:00
Emmanuel Vadot
b829f450a7 linuxkpi: Include highmem.h in pagemap.h
Linux does the same.

Reviewed by:	bz, emaste, hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36023
2022-08-08 15:22:36 +02:00
Emmanuel Vadot
789dbdbb48 linuxkpi: Add arch_io_{reserve,free}_memtype_wc
Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36022
2022-08-08 15:22:36 +02:00
Emmanuel Vadot
a7727e1a6d linuxkpi: Add dev_info_once
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36021
2022-08-08 15:22:36 +02:00
Emmanuel Vadot
eca2f0f380 linuxkpi: Add smp_mb__before/after_atomic
Reviewed by:	hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36020
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
d1c3cfd79d linuxkpi: Add trylock_page and unlock_page
Simple wrapper around vm_page_trylock and vm_page_unlock.

Reviewed by:	hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36019
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
7d2702a198 linuxkpi: Add more notifier defines
Needded by drm-kmod.

Reviewed by:	bz, emaste, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36018
2022-08-08 15:22:35 +02:00
Emmanuel Vadot
2d4b17685f linuxkpi: errno: Add EHWPOISON
Needed by drm-kmod.

Reviewed by:	bz, hselasky
Obtained from:	drm-kmod
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D36017
2022-08-08 15:22:35 +02:00
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
Bjoern A. Zeeb
0e981d79b1 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
MFC after:	3 days
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
2022-06-10 14:05:12 +00:00
Hans Petter Selasky
85d7875d42 LinuxKPI: Fix dmi_matches() function
Make sure to check for NULL pointers and also check all search criterias,
not only the first one!

Bump the FreeBSD version.

Reviewed by:	manu@
Differential Revision:	https://reviews.freebsd.org/D35403
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-06-06 10:31:34 +02:00
Bjoern A. Zeeb
71df58aefc LinuxKPI: 802.11: plug a ni leak in lkpi_sta_assoc_to_run()
In lkpi_sta_assoc_to_run() we are going through some code segments
twice (auth->assoc, assoc->authorized).  The 2nd time we shall not
re-gain a reference on the net80211 node as otherwise it'll leak.
Likewise we do not have to re-set lsta and sta.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-06-05 21:12:55 +00:00
Bjoern A. Zeeb
dbc06dd98a LinuxKPI: 802.11 plug mbuf leak in error cases
Manually free the mbuf in certain error cases from net80211 to not
leak it.
Note that the differences between ieee80211_input_mimo() and
ieee80211_input_mimo_all(), the former not consuming the mbuf while
the later does, is confusing.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-06-05 18:10:24 +00:00
Gordon Bergling
8cf0d09462 linux(4): Fix a typo in a source code comment
- s/accross/across/

MFC after:	3 days
2022-06-04 11:27:19 +02:00
Corvin Köhne
99902b1c52 linuxkpi/dmi: don't match exactly on DMI_MATCH
Linux has two defines to check dmi data. DMI_MATCH checks if the dmi
string includes substr. DMI_EXACT_MATCH checks if the dmi string exactly
matches substr. Compat layer should have the same behaviour.

The new definition of dmi_strmatch shouldn't break any driver. A driver
would break if it uses the highest bit of the slot field. Nevertheless,
linux uses the same definition and FreeBSD uses dmi_field values as slot
which are lower than 128.

Sponsored by:		Beckhoff Automation GmbH & Co. KG
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D35395
2022-06-03 16:20:45 +02:00
Dmitry Chagin
539fadb493 linux(4): Return EINVAL when the clockid has invalid bits are set
Linux forbids PERTHREAD bit set for CLOCKFD clock.

MFC after:		2 weeks
2022-05-31 11:46:15 +03:00
Dmitry Chagin
452f4636c3 linux(4): Return ENOTSUP for unsupported clockid
It's much better from the user perspective to get a sane error code.

MFC after:		2 weeks
2022-05-31 11:43:00 +03:00
Dmitry Chagin
7e2a451119 linprocfs: Add /proc/vm/max_map_count
On Linux this limits the number of maps per mm struct.
We don't limit mappings, return a suitable large value.

Reviewed by:		emaste
Differential revision:	https://reviews.freebsd.org/D35351
MFC after:		2 weeks
2022-05-31 11:42:06 +03:00
Dmitry Chagin
2722e515ac linux(4): Prefer sizeof(object) vs sizeof(type)
MFC after:		2 weeks
2022-05-30 20:03:14 +03:00
Dmitry Chagin
5573143777 linux(4): Error is not a bool, use proper comparison
MFC afer:		2 weeks
2022-05-30 20:00:30 +03:00
Dmitry Chagin
5e872c279a linux(4): Use the copyin_sigset() in the remaining places
MFC after:		2 weeks
2022-05-30 19:59:45 +03:00
Dmitry Chagin
7a7cee5585 linux(4): Refactor SIGPWR mapping
Map Linux RT signals to the native RT signals starting from SIGRTMIN,
and Linux SIGPWR signal map to after the last RT signal.

MFC after:		2 weeks
2022-05-30 19:55:49 +03:00
Dmitry Chagin
669516a1a1 linux(4): Fix the type of a constant in the signal mask macro
Since l_sigset_t is 64-bit unsigned on all Linuxulators, fix the type
of a constant in the signal mask manipulation macro.
The suffix L indicates type long which is 32-bit on i386, therefore,
bitwise operations between a 32-bit constant and 64-bit signal mask
lead to the wrong result.

Pointy hat to:		dchagin
MFC after:		2 weeks
2022-05-30 19:53:52 +03:00
Dmitry Chagin
2ca34847e7 linux(4): Reduce duplication between MD parts of the Linuxulator
Move sigprocmask actions defines under compat/linux,
they are identical across all Linux architectures.

MFC after:		2 weeks
2022-05-30 19:47:26 +03:00
Dmitry Chagin
3735f9cff1 linux(4): Handle multiple mbufs in a control message chain in recvmsg
PR:		230274
MFC after:	2 weeks
2022-05-28 23:48:45 +03:00
Dmitry Chagin
31d7f3e9ce linux(4): Ratelimit message about unupported cmsg
MFC after:		2 weeks
2022-05-28 23:48:16 +03:00
Dmitry Chagin
f8a6615064 linux(4): Handle IP_ORIGDSTADDR socket option for IPPROTO_IP protocol level
MFC after:		2 weeks
2022-05-28 23:47:40 +03:00
Dmitry Chagin
4f02a4f48c linux(4): Add LINUX_RATELIMIT_MSG_OPT2 for future use
MFC after:		2 weeks
2022-05-28 23:47:23 +03:00
Dmitry Chagin
53494b918d linux(4): Overwrite SO_TIMESTAMP counterpart
A socket cannot mix SO_TIMESTAMP and SO_TIMESTAMPNS: the two modes
are mutually exclusive.

MFC after:		2 weeks
2022-05-28 23:46:38 +03:00
Dmitry Chagin
0eda2ceab7 linux(4): Refactor linux_common_recvmsg()
To improve readability lower nesting level, better naming for variables.
No functional changes.

MFC after:		2 weeks
2022-05-28 23:46:22 +03:00
Dmitry Chagin
71bc8bcf66 linux(4): Handle SO_TIMESTAMPNS socket option
The SO_TIMESTAMPNS enables or disables the receiving of the SCM_TIMESTAMPNS
control message. The cmsg_data field is a struct timespec.
To distinguish between SO_TIMESTAMP and SO_TIMESTAMPNS in the recvmsg()
map the last one to the SO_BINTIME and convert bintime to the timespec.
In the rest, implementation is identical to the SO_TIMESTAMP.

MFC after:		2 weeks
2022-05-28 23:46:05 +03:00
Dmitry Chagin
0e26e54bdf linux(4): Handle 64-bit SO_TIMESTAMP for 32-bit binaries
To solve y2k38 problem in the recvmsg syscall the new SO_TIMESTAMP
constant were added on v5.1 Linux kernel. So, old 32-bit binaries
that knows only 32-bit time_t uses the old value of the constant,
and binaries that knows 64-bit time_t uses the new constant.

To determine what size of time_t type is expected by the user-space,
store requested value (SO_TIMESTAMP) in the process emuldata structure.

MFC after:		2 weeks
2022-05-28 23:45:39 +03:00
Dmitry Chagin
6335583990 linux(4): For future use replace malloc type for l_sockaddr by M_LINUX
MFC after:		2 weeks
2022-05-28 23:44:48 +03:00
Dmitry Chagin
b408788d6b linux(4): Improve recvmsg() readability
To improve recvmsg() readability SCM_ handlers moved to a separate
functions.

MFC after:		2 weeks
2022-05-28 23:44:02 +03:00
Dmitry Chagin
f409a7c538 linux(4): For future use move SCM definitions below socket options
MFC after:		2 weeks
2022-05-28 23:42:23 +03:00
Dmitry Chagin
db48fa8319 linux(4): Avoid EISCONN if addr is specified for sendto()
If the socket is in a connected state, the target address should be
ignored.

MFC after:		2 weeks
2022-05-28 23:42:09 +03:00
Dmitry Chagin
e8d9d8082b linux(4): Fix SO_LINGER l_onoff value
On Linux l_onoff should be 1 when linger is used.

MFC after:		2 weeks
2022-05-28 23:31:06 +03:00
Dmitry Chagin
e92b9a9eaa linux(4): Add a helper to copyout getsockopt value
For getsockopt(), optlen is a value-result argument, which is modified
on return to indicate the actual size of the value returned.
For some cases this was missed, fixed.

MFC after:		2 weeks
2022-05-28 23:30:22 +03:00
Dmitry Chagin
3a99aac66f linux(4): Check the socket before any others sanity checks
Strictly speaking, this check is performed by the kern_recvit(), but in
the Linux emulation layer before calling the kernel we do other sanity
checks and conversions from Linux types to the native types. This changes
an order of the error returning that is critical for some buggy Linux
applications.

For recvmmsg() syscall this fixes a panic in case when the user-supplied
vlen value is 0, then error is not initialized and garbage passed to the
bsd_to_linux_errno().

MFC after:		2 weeks
2022-05-28 23:29:12 +03:00
Dmitry Chagin
d46174cd88 Finish cpuset_getaffinity() after f35093f8
Split cpuset_getaffinity() into a two counterparts, where the
user_cpuset_getaffinity() is intended to operate on the cpuset_t from
user va, while kern_cpuset_getaffinity() expects the cpuset from kernel
va.
Accordingly, the code that clears the high bits is moved to the
user_cpuset_getaffinity(). Linux sched_getaffinity() syscall returns
the size of set copied to the user-space and then glibc wrapper clears
the high bits.

MFC after:		2 weeks
2022-05-28 20:53:08 +03:00
Dmitry Chagin
31d1b816fe sysent: Get rid of bogus sys/sysent.h include.
Where appropriate hide sysent.h under proper condition.

MFC after:	2 weeks
2022-05-28 20:52:17 +03:00
Emmanuel Vadot
25d21a8452 linuxkpi: Rework detach function
We need to detach the matching i2c adapter so look for the right one.
While here add some locks to protect multiple add/del at the same time.

Fixes:	1961a14a47 ("linuxkpi: Add i2c support")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-05-25 09:57:10 +02:00
Dmitry Chagin
1bb3faed29 linux(4): Fix unlinkat() after a125ed50
MFC after:		2 weeks
2022-05-23 13:19:34 +03:00
Dmitry Chagin
26700ac0c4 linux(4): Deduplicate execve
As linux_execve is common across archs, except amd64 32-bit Linuxulator,
move it under compat/linux.

Noted by:		andrew@
MFC after:		2 weeks
2022-05-23 13:18:41 +03:00
Dmitry Chagin
e0aef0d62d linux(4): Fix unlink() after a125ed50
MFC after:		2 weeks
2022-05-23 13:18:07 +03:00
Bjoern A. Zeeb
6cf748ad94 LinuxKPI 802.11 / iwlwifi / rtw88 : re-factor ieee802211_sta for MLO
Working on an update for rtw88 baed on wireless-testing I ran into
a build issue with struct ieee802211_sta.  Some fields were factored
out into their own struct apparently preparing for MLO (Multi Link
Operation).

In order to be able to update one driver we have to adjust both
rtw88 and iwlwifi (and the ones still out-of-tree) now.

This is mostly a sed-replace job and no functional changes are
intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-05-20 18:45:18 +00:00
Mark Johnston
4a3e51335e cpuset: Fix the KASAN and KMSAN builds
Rename the "copyin" and "copyout" fields of struct cpuset_copy_cb to
something less generic, since sanitizers define interceptors for
copyin() and copyout() using #define.

Reported by:	syzbot+2db5d644097fc698fb6f@syzkaller.appspotmail.com
Fixes:	47a57144af ("cpuset: Byte swap cpuset for compat32 on big endian architectures")
Sponsored by:	The FreeBSD Foundation
2022-05-20 10:34:25 -04:00
Dmitry Chagin
eca368ecb6 Retire sv_transtrap
Call translate_traps directly from sendsig().

MFC after:		2 weeks
2022-05-20 14:54:03 +03:00
Bjoern A. Zeeb
d296b65d89 LinuxKPI: 802.11 updates
Add more values to the ieee80211_min_mpdu_start_spacing enum with
two missing given we do not know how they are called.  Also update
the reference while here.

Add struct ieee80211_hdr_3addr and correct the comment on the
ieee80211_hdr to match the one in net80211 to avoid future confusion.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-05-20 01:11:22 +00:00
Bjoern A. Zeeb
85eb99f9a4 LinuxKPI: implement pcie_capability_set_word()
Implement pcie_capability_set_word() using the already available
read/write functions.
Also define the completion timeout disable value to our PCI one.
Both needed by a driver update.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	manu, hselasky
Differential Revision: https://reviews.freebsd.org/D35250
2022-05-20 01:09:08 +00:00
Dmitry Chagin
b04f5d18b5 linux(4): To improve readability use FUTEX_UNOWNED instead of 0
MFC after:		2 weeks
2022-05-19 21:42:38 +03:00