Commit Graph

3957 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
06d5ef0aad linux: Drop some unnecessary includes
Drop some unnecessary includes from Linuxulator ptrace
and coredump code.  No functional changes.

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32925
2021-11-13 03:26:32 +00:00
Konstantin Belousov
439c3d9563 Regen 2021-11-10 21:18:54 +02:00
Konstantin Belousov
77b2c2f814 Add sched_getcpu()
for compatibility with Linux.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32901
2021-11-10 21:18:54 +02:00
Edward Tomasz Napierala
0bf8d5d5f4 linux: Replace ifdefs in ptrace with per-architecture callbacks
It's a cleanup; no (intended) functional changes.

Sponsored By:	EPSRC
Reviewed By:	kib
Differential Revision:	https://reviews.freebsd.org/D32888
2021-11-09 11:59:17 +00:00
Edward Tomasz Napierala
a90ff3c4bc linux: Add ptrace(2) support on arm64
This moves linux_ptrace.c from sys/amd64/linux/ to sys/compat/linux/,
making it possible to use it on architectures other than amd64.
It also enables Linux ptrace(2) on arm64.

Relnotes:	yes
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32868
2021-11-07 08:39:24 +00:00
Edward Tomasz Napierala
91be6286e2 linprocfs: Fix formatting of Uid and Gid lines
The separator here should be tabs, not spaces.  This fixes a warning
from chromium-browser on Bionic:

[1022/162248.137612:ERROR:process_info_linux.cc(107)] format error: unrecognized Uid format

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32612
2021-11-03 08:40:55 +00:00
Hans Petter Selasky
2390a1441e LinuxKPI: Add sysctl(8) knob to control verbosity of WARN_ON's.
The purpose of this change is to reduce the amount of dmesg(8) noise when
VT switching after a panic.

Submitted by:	Greg V <greg@unrelenting.technology>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30174
Sponsored by:	NVIDIA Networking
2021-11-02 16:53:34 +01:00
Edward Tomasz Napierala
c8c93b1516 linux: Also translate the signal if the code is CLD_KILLED
This fixes ./waitid.gen.test from the strace(1) test suite.

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32617
2021-10-29 15:28:00 +01:00
Edward Tomasz Napierala
6547153e46 linux: Fix ptrace panic with ERESTART
Translate ERESTART into Linux "internal" errno ERESTARTSYS.
This fixes the erestartsys.gen.test from strace(1).

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32623
2021-10-29 14:55:59 +01:00
Bjoern A. Zeeb
c5eec7b57c LinuxKPI: module.h add MODULE_SUPPORTED_DEVICE()
Add a dummy MODULE_SUPPORTED_DEVICE define as we do for other
MODULE_* macros.  This is needed by a wireless driver.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D32641
2021-10-25 20:26:01 +00:00
Bjoern A. Zeeb
548ada00e5 LinuxKPI: add bcd.h
Add bcd2bin() as linuxkpi_bcd2bin().  Libkern does provide a bcd2bin()
which cannot be used leaving us with a conflict (see comment in file).
Fortunately this is only seen in one driver so far and it seems easier
to drop this in and change a single line in the driver than to add this
inline in the driver.

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32647
2021-10-25 20:20:53 +00:00
Bjoern A. Zeeb
cf89934842 LinuxKPI: pci.h / linux_pci.c rename pci_driver field
Rename the struct pci_driver {} field got the list_head from links
to node as a driver is actually initialsing this to {} which seems
questionable but it will at least make us match the Linux structure
field name.

MFC after:	3 days
Reviewed by:	manu, hselasky
Differential Revision: https://reviews.freebsd.org/D32645
2021-10-25 20:19:24 +00:00
Bjoern A. Zeeb
ed5600f532 LinuxKPI: pci.h make pci_dev argument const for pci_{read,write}_config*()
Make the struct pci_dev argument to the pci_{read,write}_config*()
functions "const" to match the Linux definition as some drivers
try to pass in a const argument which we currently fail to honor.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32644
2021-10-25 20:17:56 +00:00
Bjoern A. Zeeb
490f9d8f0e LinuxKPI: add netdev_features.h
Add netdev_features.h as a spearate file from the future netdevice.h
implementation to avoid include problems with a future skbuff.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32643
2021-10-25 20:16:23 +00:00
Bjoern A. Zeeb
41dee251ee LinuxKPI: add simple_open() to fs.h
Add a dummy simple_open() to fs.h as we have for other
(unsupported) functions.
This is needed by a wireless driver.

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32642
2021-10-25 20:14:42 +00:00
Bjoern A. Zeeb
a5e2a27dca LinuxKPI: add strreplace() to string.h
Add strreplace() needed by a driver.
MFC after:	3 days

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32597
2021-10-25 16:12:10 +00:00
Bjoern A. Zeeb
b382b78503 LinuxKPI: add kstrtou8() and kstrtou8_from_user() to kernel.h
Analogous to the other sized version of kstrto[u]<type>() and
kstrtobool_from_user() add the "u8" versions needed by a driver.

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32598
2021-10-25 16:10:48 +00:00
Edward Tomasz Napierala
2c7f798282 linux: Fix ENOTSOCK handling in sendfile(2)
The Linux way for sendfile(2) to tell the application
to fallback to another way of copying data is by EINVAL,
not ENOTSOCK.  This fixes package installation scripts
for Mono packages from Focal.

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32604
2021-10-23 09:15:58 +01:00
Mark Johnston
84c3922243 Convert consumers to vm_page_alloc_noobj_contig()
Remove now-unneeded page zeroing.  No functional change intended.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32006
2021-10-19 21:22:56 -04:00
Mark Johnston
a4667e09e6 Convert vm_page_alloc() callers to use vm_page_alloc_noobj().
Remove page zeroing code from consumers and stop specifying
VM_ALLOC_NOOBJ.  In a few places, also convert an allocation loop to
simply use VM_ALLOC_WAITOK.

Similarly, convert vm_page_alloc_domain() callers.

Note that callers are now responsible for assigning the pindex.

Reviewed by:	alc, hselasky, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31986
2021-10-19 21:22:56 -04:00
Jessica Clarke
82098c8bb5 LinuxKPI: Support lazy BAR allocation
Linux KPIs like pci_resource_start/len assume that BARs have been
allocated, but FreeBSD lazily allocates BARs if it cannot allocate the
firmware-allocated BARs. Thus using the Linux KPIs must force allocation
of the BARs rather than returning 0 for the start and length, which can
crash drm-kmod drivers that assume the BARs are valid. This is needed
for the AMDGPU driver to be able to attach on SiFive's HiFive Unmatched.

Reviewed by:	hselasky, jhb, mav
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32447
2021-10-17 15:32:35 +01:00
Jessica Clarke
60d962e041 LinuxKPI: Implement _ioremap_attr for riscv
Now that riscv implements pmap_mapdev_attr we can enable the non-stub
implementation for riscv, which is needed for drm-kmod to not fail at
run time for drivers that need to map I/O regions.

Reviewed by:	hselasky, bz
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32446
2021-10-17 15:32:20 +01:00
Edward Tomasz Napierala
99f563ed76 linux: recognize TCP_INFO and ratelimit the warning
This ratelimits the "unsupported getsockopt level 6 optname 11"
warnings that happen all the time when watching Netflix.

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32454
2021-10-17 13:19:10 +01:00
Edward Tomasz Napierala
7e7859e7c2 linux: Partially implement TCSBRK
This fixes tcflush(3), unbreaking cheribuild.py under arm64 Focal.

Reviewed By:	imp
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32291
2021-10-17 11:19:56 +01:00
Mateusz Guzik
2b68eb8e1d vfs: remove thread argument from VOP_STAT
and fo_stat.
2021-10-11 13:22:32 +00:00
Alex Richardson
d98f2712c7 linuxkpi: implement ida_alloc()
Needed for the virtio-gpu driver.

Reviewed By:	#linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366
2021-10-11 11:51:44 +01:00
Alex Richardson
6d15ccde4d linuxkpi: Allow BUILD_BUG_ON in if statements without braces
I got a compilation failure in virtio-gpu without this change.

Reviewed By:	#linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366
2021-10-11 11:51:44 +01:00
Alex Richardson
ff479cc6c9 linuxkpi: add PAGE_ALIGNED macro
Needed for the virtio-gpu driver.

Reviewed By:	#linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366
2021-10-11 11:51:43 +01:00
Alex Richardson
2686b10db4 linuxkpi: Add sg_init_one
Needed for the virtio-gpu driver.

Reviewed By:	#linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366
2021-10-11 11:51:43 +01:00
Mark Johnston
a76de17715 linuxkpi: Handle a NULL cache pointer in kmem_cache_destroy()
This is compatible with Linux, and some driver error paths depend on it.

Reviewed by:	bz, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32337
2021-10-06 14:49:39 -04:00
Jessica Clarke
8167c92f65 LinuxKPI: Add more #ifdef VM_MEMATTR_WRITE_COMBINING guards
One of the three uses is already guarded; this guards the remaining ones
to support architectures like riscv that do not provide write-combining,
and is needed to build drm-kmod on riscv.

Reviewed by:	hselasky, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31999
2021-10-03 19:34:40 +01:00
Mateusz Guzik
69ab528386 linprocfs: find cwd and root handling
The code would incorrectly use curthread instead of the target proc to
resolve vnodes.

Fixes:	8d03b99b9d ("fd: move vnodes out of filedesc into a dedicated structure")
PR:	258729
Noted by:	 Damjan Jovanovic <damjan.jov@gmail.com>
2021-09-30 12:59:58 +02:00
Vladimir Kondratyev
062f15004f LinuxKPI: Remove vma argument from fault method of vm_operations_struct
It is removed from Linux since 4.11.
In FreeBSD it results in several #ifdefs in drm-kmod.

Reviewed by:	emaste, hselasky, manu
Differential revision:	https://reviews.freebsd.org/D32169
2021-09-29 23:26:32 +03:00
Vladimir Kondratyev
5ca1f3f5e3 LinuxKPI: Hide some internal symbols in linux_interrupt.c
Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D32168
2021-09-29 23:26:14 +03:00
Vladimir Kondratyev
c072f6e856 LinuxKPI: Import linux_page.c and some dependent code from drm-kmod
No functional changes intended

Reviewed by:	hselasky, manu, markj
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32167
2021-09-29 23:15:37 +03:00
Vladimir Kondratyev
88531adbfb LinuxKPI: Update pte_fn_t definition to match Linux 5.3
Reviewed by:	emaste, hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32166
2021-09-29 23:15:27 +03:00
Vladimir Kondratyev
b52e363840 LinuxKPI: Implement backlight_enable and backlight_disable functions
For now, disable backlight if brightness level is set to 0.
In the future we may implement separate knob in backlight(8).

Required by drm-kmod v5.6

Reviewed by:	hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32165
2021-09-29 23:15:12 +03:00
Vladimir Kondratyev
3d86f8f1d7 LinuxKPI: Add dummy pgprot_decrypted() implementation
to reduce number of #ifdefs in drm-kmod

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32094
2021-09-29 23:14:58 +03:00
Vladimir Kondratyev
37eba5b77a LinuxKPI: Cast offset_in_page() parameter to unsigned long
to reduce number of patches in drm-kmod

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32093
2021-09-29 23:14:47 +03:00
Vladimir Kondratyev
6efabdeede LinuxKPI: Import linux/poison.h header
Required by drm-kmod 5.6

Reviewed by:	hselasky, imp, manu
MFC after:	2 weeks
Obtained from:	OpenBSD
Differential revision:	https://reviews.freebsd.org/D32092
2021-09-29 23:14:34 +03:00
Vladimir Kondratyev
b59ffedae8 LinuxKPI: Add helper functions to store integers to linux/xarray.h
Required by drm-kmod.

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32091
2021-09-29 23:14:23 +03:00
Vladimir Kondratyev
62ff0566c9 LinuxKPI: Allow cdev_pager prefault handler to steal pages
from other vm_objects. This workarounds "Page already inserted" panic
in vm_page_insert routine triggered on attempt to mmap file created
with shmem_file_setup call. After introduction of "GTT mmap
interface v4" a.k.a. MMAP_OFFSET, vm_objects allocated by these calls
may try to own intersected sets of pages that leads to the assertion.

Reviewed by:	kib
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32090
2021-09-29 23:14:05 +03:00
Vladimir Kondratyev
bd6d55adb4 LinuxKPI: stub anon_inode_getfile
Although drm-kmod contains better implementation which is able to
allocate real entries on pseudofs, this feature has never been used.

Starting from drm-kmod v5.6 old implementation began to leak entries
on each drm device close(). Now just drop pseudofs support instead of
fixing it in drm-kmod and provide stub in base.

Reviewed by:	hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32069
2021-09-29 23:13:53 +03:00
Vladimir Kondratyev
f6823dac8f LinuxKPI: Factor out vmf_insert_pfn_prot() routine
from GEM and TTM page fault handlers and move it in to base system. This
code is tightly integrated with LKPI mmap support to belong to drm-kmod.

As this routine requires associated vm_object to be locked, it got
additional _locked suffix.

Reviewed by:	hselasky, markj
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32068
2021-09-29 23:13:41 +03:00
Vladimir Kondratyev
7d92d48358 LinuxKPI: Invoke release handler when file is destroyed by fput()
Required by drm_kmod 5.6

Reviewed by:	hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32067
2021-09-29 23:13:27 +03:00
Vladimir Kondratyev
2fe9ea5d3a LinuxKPI: allocate current before taking shrinkers lock
This fixes following warnings when shrinkers are invoked first time:

uma_zalloc_debug: zone "lkpicurr" with the following non-sleepable
locks held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)

uma_zalloc_debug: zone "lkpimm" with the following non-sleepable locks
held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker)

Reviewed by:	hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32066
2021-09-29 23:12:58 +03:00
Vladimir Kondratyev
b58c916f11 LinuxKPI: implement _IOC_TYPE and _IOC_NR macros in linux/ioctl.h
They are used by drm-kmod

Reviewed by:	emaste, hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D31674
2021-09-29 23:12:47 +03:00
Vladimir Kondratyev
66ea390652 LinuxKPI: Remove FreeBSD struct resource from all LKPI headers
except linux/pci.h to avoid conflicts with Linux version.
This allows to #define resource in drm-kmod globally and strip some #ifdef-s

Reviewed by:	hselasky, manu
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D31673
2021-09-29 23:12:36 +03:00
Vladimir Kondratyev
a81b36c6d3 LinuxKPI: Implement get_file_rcu()
get_file_rcu() grabs a file if the file->f_count is not zero.

Required by drm-kmod 5.6

Reviewed by:	hselasky, manu (previous version)
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D31672
2021-09-29 23:12:25 +03:00
Bjoern A. Zeeb
1269873159 LinuxKPI: fix build
Add a missing "static" for non-{i386,amd64,arm64} which was missed in
c39eefe715.   This should ifx the builds.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
X-MFC with:	c39eefe715
2021-09-29 13:50:12 +00:00