Commit graph

4237 commits

Author SHA1 Message Date
Dmitry Chagin
34b00959fb linprocfs: Decode SGX CPU feature in cpuinfo
MFC after:		2 weeks

(cherry picked from commit c8e7070ce3)
2022-07-13 14:48:38 +03:00
Dmitry Chagin
9736c19884 linprocfs: Decode more CPU flags in cpuinfo
Differential revision:	https://reviews.freebsd.org/D35556
MFC after:		2 weeks

(cherry picked from commit 7ab03740ae)
2022-07-13 14:48:27 +03:00
Dmitry Chagin
f56ea6b7d0 linprocfs: Decode constant_tsc CPU feature
Differential revision:	https://reviews.freebsd.org/D35554
MFC after:		2 weeks

(cherry picked from commit 8da00a514e)
2022-07-13 14:48:14 +03:00
Dmitry Chagin
f8da863470 linux(4): Implement __vdso_time
PR:		240769
MFC after:	3 days

(cherry picked from commit 42317e6426)
2022-07-12 00:28:28 +03:00
Dmitry Chagin
b1d0fe755b 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

(cherry picked from commit ef1976ccf5)
2022-07-06 14:02:15 +03:00
Dmitry Chagin
8287577434 linux(4): Trace Linux l_sigset_t.
MFC after:		2 weeks

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

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

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

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

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

Found debugging:	rtw89

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

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

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

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

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

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

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

(cherry picked from commit d0d2911035)
(cherry picked from commit fb6eaf74e9)
2022-07-01 13:45:09 +00:00
Mateusz Guzik
b2ae573abd linux: plug a set-but-not-used var
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 93494e425b)
2022-06-22 13:07:07 +03:00
Emmanuel Vadot
ae3ffc0060 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

(cherry picked from commit d87fad3633)
2022-06-21 17:13:57 +02:00
Emmanuel Vadot
d0d0d14abc 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

(cherry picked from commit 25d21a8452)
2022-06-21 17:13:57 +02:00
Vladimir Kondratyev
a646c45756 LinuxKPI: Allow lkpi_iic driver to be a child of drm device.
i915kms exposes "AUX #/port #" I2C adapters as drm children

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D35046

(cherry picked from commit f49cddbda6)
2022-06-21 17:13:57 +02:00
Warner Losh
7eaee6ba9f linuxkpi: Remove write only variable from lkpi_iicbb_reset
Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34770

(cherry picked from commit 58e6719ca0)
2022-06-21 17:13:57 +02:00
Emmanuel Vadot
e813d16c01 linuxkpi: i2c: Add MODULE_DEPEND for iicbus
MFC after:	1 month
MFC with:	1961a14a47
Fixes:	1961a14a47 ("linuxkpi: Add i2c support")
Reported by:	GregV
Sponsored by:	Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 81de556105)
2022-06-21 17:13:57 +02:00
Emmanuel Vadot
7f14bc4402 linuxkpi: Add i2c support
Add i2c support to linuxkpi. This is needed by drm-kmod.
For every i2c_adapter added by i2c_add_adapter we add a child to the
device named "lkpi_iic". This child handle the conversion between
Linux i2c_msgs to FreeBSD iic_msgs.
For every i2c_adapter added by i2c_bit_add_bus we add a child to the
device named "lkpi_iicbb". This child handle the conversion between
Linux i2c_msgs to FreeBSD iic_msgs.
With the help of iic(4), this expose the i2c controller to userspace
allowing a user to query DDC information from a monitor.
e.g.: i2c -f /dev/iic0 -a 0x28 -c 128 -d r
will query the standard EDID from the monitor if plugged.

The bitbang part (lkpi_iicbb) isn't tested at all for now as I don't have
compatible hardware (all my hardware have native i2c controller).

Tested on:	Intel (SandyBridge, Skylake, ApolloLake)
Tested on:	AMD (Picasso, Polaris (amd64 and arm64))

MFC after:	1 month
Reviewed by:	hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33053

(cherry picked from commit 1961a14a47)
2022-06-21 17:13:57 +02:00
Warner Losh
db761c6a64 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831

(cherry picked from commit c6df6f5322)
2022-06-21 17:13:20 +02:00
Edward Tomasz Napierala
e226a45a66 linux(4): bump osrelease to 4.4.0.
This is required for the current Arch Linux binaries to work.

PR:		254112
Reviewed By:	emaste
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D29218

(cherry picked from commit 156da725d3)
2022-06-17 22:35:42 +03:00
Dmitry Chagin
8cbf694e68 linux(4): Return EINVAL when the clockid has invalid bits are set
Linux forbids PERTHREAD bit set for CLOCKFD clock.

MFC after:		2 weeks

(cherry picked from commit 539fadb493)
2022-06-17 22:35:41 +03:00
Dmitry Chagin
ee3efd6341 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

(cherry picked from commit 452f4636c3)
2022-06-17 22:35:41 +03:00
Dmitry Chagin
b3c809b96f 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

(cherry picked from commit 7e2a451119)
2022-06-17 22:35:41 +03:00
Dmitry Chagin
7c61d8e494 linux(4): Prefer sizeof(object) vs sizeof(type)
MFC after:		2 weeks

(cherry picked from commit 2722e515ac)
2022-06-17 22:35:40 +03:00
Dmitry Chagin
81d68fff1a linux(4): Error is not a bool, use proper comparison
MFC afer:		2 weeks

(cherry picked from commit 5573143777)
2022-06-17 22:35:40 +03:00
Dmitry Chagin
50fe2c32d5 linux(4): Use the copyin_sigset() in the remaining places
MFC after:		2 weeks

(cherry picked from commit 5e872c279a)
2022-06-17 22:35:39 +03:00
Dmitry Chagin
4312a49826 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

(cherry picked from commit 7a7cee5585)
2022-06-17 22:35:39 +03:00
Dmitry Chagin
553fb2c654 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

(cherry picked from commit 669516a1a1)
2022-06-17 22:35:39 +03:00
Dmitry Chagin
601c19df36 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

(cherry picked from commit 2ca34847e7)
2022-06-17 22:35:37 +03:00
Dmitry Chagin
82062a0443 linux(4): Handle multiple mbufs in a control message chain in recvmsg
PR:		230274
MFC after:	2 weeks

(cherry picked from commit 3735f9cff1)
2022-06-17 22:35:37 +03:00
Dmitry Chagin
a66a545578 linux(4): Ratelimit message about unupported cmsg
MFC after:		2 weeks

(cherry picked from commit 31d7f3e9ce)
2022-06-17 22:35:36 +03:00
Dmitry Chagin
d05e863ca2 linux(4): Handle IP_ORIGDSTADDR socket option for IPPROTO_IP protocol level
MFC after:		2 weeks

(cherry picked from commit f8a6615064)
2022-06-17 22:35:36 +03:00
Dmitry Chagin
b13a727fce linux(4): Add LINUX_RATELIMIT_MSG_OPT2 for future use
MFC after:		2 weeks

(cherry picked from commit 4f02a4f48c)
2022-06-17 22:35:36 +03:00
Dmitry Chagin
44c89ec74d 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

(cherry picked from commit 53494b918d)
2022-06-17 22:35:35 +03:00
Dmitry Chagin
fc9014c195 linux(4): Refactor linux_common_recvmsg()
To improve readability lower nesting level, better naming for variables.
No functional changes.

MFC after:		2 weeks

(cherry picked from commit 0eda2ceab7)
2022-06-17 22:35:35 +03:00
Dmitry Chagin
01a6eb8a64 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

(cherry picked from commit 71bc8bcf66)
2022-06-17 22:35:35 +03:00
Dmitry Chagin
6bee81f9c6 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

(cherry picked from commit 0e26e54bdf)
2022-06-17 22:35:34 +03:00
Dmitry Chagin
4c5b420b65 linux(4): For future use replace malloc type for l_sockaddr by M_LINUX
MFC after:		2 weeks

(cherry picked from commit 6335583990)
2022-06-17 22:35:34 +03:00
Dmitry Chagin
ac37e0edf9 linux(4): Improve recvmsg() readability
To improve recvmsg() readability SCM_ handlers moved to a separate
functions.

MFC after:		2 weeks

(cherry picked from commit b408788d6b)
2022-06-17 22:35:34 +03:00
Dmitry Chagin
24f2f93f5e linux(4): For future use move SCM definitions below socket options
MFC after:		2 weeks

(cherry picked from commit f409a7c538)
2022-06-17 22:35:33 +03:00
Dmitry Chagin
e23fea0a08 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

(cherry picked from commit db48fa8319)
2022-06-17 22:35:33 +03:00
Dmitry Chagin
dfbeda6cf4 linux(4): Fix SO_LINGER l_onoff value
On Linux l_onoff should be 1 when linger is used.

MFC after:		2 weeks

(cherry picked from commit e8d9d8082b)
2022-06-17 22:35:32 +03:00
Dmitry Chagin
d573cf010e 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

(cherry picked from commit e92b9a9eaa)
2022-06-17 22:35:32 +03:00
Dmitry Chagin
ccdf2cd423 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

(cherry picked from commit 3a99aac66f)
2022-06-17 22:35:32 +03:00
Dmitry Chagin
089a76e915 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

(cherry picked from commit d46174cd88)
2022-06-17 22:35:31 +03:00
Dmitry Chagin
7aeec4eea8 sysent: Get rid of bogus sys/sysent.h include.
Where appropriate hide sysent.h under proper condition.

MFC after:	2 weeks

(cherry picked from commit 31d1b816fe)
2022-06-17 22:35:31 +03:00
Dmitry Chagin
d63a4afcdf linux(4): Fix unlinkat() after a125ed50
MFC after:		2 weeks

(cherry picked from commit 1bb3faed29)
2022-06-17 22:35:30 +03:00
Dmitry Chagin
959d0bdc24 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

(cherry picked from commit 26700ac0c4)
2022-06-17 22:35:30 +03:00