Commit Graph

2777 Commits

Author SHA1 Message Date
Dmitry Chagin
8e9e07e682 Style(9) whitespace fix.
MFC after:	1 week
2017-07-22 09:03:40 +00:00
Konstantin Belousov
5cead59181 Correct sysent flags for dynamically loaded syscalls.
Using the https://github.com/google/capsicum-test/ suite, the
PosixMqueue.CapModeForked test was failing due to an ECAPMODE after
calling kmq_notify(). On further inspection, the dynamically
loaded syscall entry was initialized with sy_flags zeroed out, since
SYSCALL_INIT_HELPER() left sysent.sy_flags with the default value.

Add a new helper SYSCALL{,32}_INIT_HELPER_F() which takes an
additional argument to specify the sy_flags value.

Submitted by:	Siva Mahadevan <smahadevan@freebsdfoundation.org>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D11576
2017-07-14 09:34:44 +00:00
Mark Johnston
8d92040b75 Add some functions to jiffies.h.
Also add some checks for overflow to existing functions.

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11533
2017-07-13 18:27:22 +00:00
Mark Johnston
70bb2cdb04 Add some functions to math64.h in the LinuxKPI, and fix nearby style.
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11535
2017-07-09 23:14:51 +00:00
Mark Johnston
7a2553d9d7 Add a few functions to ktime.h in the LinuxKPI, and fix nearby style.
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11534
2017-07-09 23:13:08 +00:00
Mark Johnston
abf5c031bb Free existing per-thread task structs when unloading linuxkpi.ko.
They are otherwise leaked.

Reported and tested by:	ae
MFC after:		1 week
2017-07-09 22:57:00 +00:00
Mark Johnston
dac6b88a20 Add some helper definitions to fs.h in the LinuxKPI.
Add a field to struct linux_file to allow the creation of anonymous
shmem objects.

MFC after:	1 week
2017-07-08 20:11:06 +00:00
Mark Johnston
e51dd47b08 Fix the definitions of pgprot_{noncached,writecombine} after r316562.
MFC after:	1 week
2017-07-08 19:22:29 +00:00
Mark Johnston
aa2b6b4957 Add device_is_registered() to the LinuxKPI.
MFC after:	1 week
2017-07-08 18:53:02 +00:00
Mark Johnston
8cd823ecf7 Add TASK_COMM_LEN to the LinuxKPI.
MFC after:	1 week
2017-07-08 18:52:29 +00:00
Hans Petter Selasky
611572285a Complete r320189 which allows a NULL VM fault handler in the LinuxKPI.
Instead of mapping a dummy page upon a page fault, map the page
pointed to by the physical address given by IDX_TO_OFF(vmap->vm_pfn).
To simplify the implementation use OBJT_DEVICE to implement our own
linux_cdev_pager_fault() instead of using the existing
linux_cdev_pager_populate().

Some minor code factoring while at it.

Reviewed by:	markj @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2017-07-07 13:44:14 +00:00
Hans Petter Selasky
ea16525413 Fix a bug in synchronize RCU when the calling thread is bound to a CPU.
Set "td_pinned" to zero after "sched_unbind()" to prevent "td_pinned"
from temporarily becoming negative during "sched_bind()". This can
happen if "sched_bind()" uses "sched_pin()" and "sched_unpin()".

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2017-07-07 13:15:00 +00:00
Mark Johnston
d34188a0e1 Invoke suspend/resume methods from the driver pmops if available.
Obtained from:	kmacy (original version)
MFC after:	1 week
2017-07-04 18:44:14 +00:00
Mark Johnston
88156ba581 Add some auxiliary types for device driver support.
MFC after:	1 week
2017-07-04 01:23:36 +00:00
Mark Johnston
6373e95eb6 Add a field for the class code to struct pci_driver.
Fill out some previously uninitialized fields as well.

MFC after:	1 week
2017-07-04 01:05:20 +00:00
Mark Johnston
ecf29cf148 Add some PCI class definitions.
MFC after:	1 week
2017-07-04 00:48:50 +00:00
Mark Johnston
b38dc0a16d Rename the "driver" field to "bsddriver" to avoid a name collision.
MFC after:	1 week
2017-07-04 00:30:48 +00:00
Mark Johnston
0a930cf078 Hold the PCI device list lock when removing an element.
MFC after:	1 week
2017-07-04 00:02:06 +00:00
Mark Johnston
4600d349be Let io_mapping_init_wc() fall back to an uncacheable mapping.
This allows usage of the function on architectures that don't support
write-combining.

Reported by:	bz, emaste
X-MFC With:	r320196
2017-07-03 02:01:16 +00:00
Konstantin Belousov
aef2a6a75d Port PowerPC kqueue(2) compat32 fix in r320500 to MIPS.
All 32bit MIPS ABIs align uint64_t on 8-byte.  Since struct kevent32
is defined using 32bit types to avoid extra alignment on amd64/i386,
layout of the structure needs paddings on PowerPC and apparently MIPS.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D11434
2017-07-01 22:52:17 +00:00
Konstantin Belousov
cfb2d93ba6 Amend the layout of kevent32 on powerpc where uint64_t has 8-byte
alignment.

Reported,tested and assertion updates by:	andreast
Sponsored by:	The FreeBSD Foundation
2017-06-30 16:12:57 +00:00
John Baldwin
51645e836d Store a 32-bit PT_LWPINFO struct for 32-bit process core dumps.
Process core notes for a 32-bit process running on a 64-bit host need to
use 32-bit structures so that the note layout matches the layout of notes
of a core dump of a 32-bit process under a 32-bit kernel.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D11407
2017-06-29 21:31:13 +00:00
Justin Hibbits
b436609213 Update comments and simplify conditionals for compat32
Only amd64 (because of i386) needs 32-bit time_t compat now, everything else is
64-bit time_t.  Rather than checking on all 64-bit time_t archs, only check the
oddball amd64/i386.

Reviewed By: emaste, kib, andrew
Differential Revision: https://reviews.freebsd.org/D11364
2017-06-27 01:29:10 +00:00
Mark Johnston
9ea3e14182 Implement parts of the hrtimer API in the LinuxKPI.
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11359
2017-06-26 16:28:46 +00:00
Andriy Gapon
16454bee3a linux_getdents, linux_readdir: fix mismatch between malloc and free tags
MFC after:	3 days
2017-06-26 09:13:25 +00:00
Justin Hibbits
fbcf7bcdf4 Solve the y2038 problem for powerpc
AKA Make time_t 64 bits on powerpc(32).

PowerPC currently (until now) was one of two architectures with a 32-bit time_t
on 32-bit archs (the other being i386).  This is an ABI breakage, so all ports,
and all local binaries, *must* be recompiled.

Tested by:	andreast, others
MFC after:	Never
Relnotes:	Yes
2017-06-26 02:25:19 +00:00
Mark Johnston
ee7c3198cd Add u64_to_user_ptr() to the LinuxKPI.
MFC after:	1 week
2017-06-25 19:30:20 +00:00
Mark Johnston
1fde37964d Add ns_to_ktime() to the LinuxKPI.
MFC after:	1 week
2017-06-25 19:28:01 +00:00
Mark Johnston
934277c59c Add a couple of macros to lockdep.h in the LinuxKPI.
MFC after:	1 week
2017-06-25 19:23:14 +00:00
Mark Johnston
0bfde0a7c7 Add the thaw_early method to struct dev_pm_ops in the LinuxKPI.
MFC after:	1 week
2017-06-25 19:21:59 +00:00
Mark Johnston
4eb1bcfc62 Add noop_lseek() to the LinuxKPI.
MFC after:	1 week
2017-06-25 19:20:12 +00:00
Mahdi Mokhtari
4b36080668 Fix caveat in new implementation of linprocfs_docpuinfo():
Prevent kernel panic in case that extended-cpuid isn't supported by CPU

Reviewed by:	kib, ngie, trasz
Approved by:	trasz
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11294
2017-06-23 10:36:27 +00:00
Mark Johnston
c73cdca2c4 Update io-mapping.h in the LinuxKPI.
Add io_mapping_init_wc() and add a third (unused) parameter to
io_mapping_map_wc().

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11286
2017-06-21 18:20:17 +00:00
Mark Johnston
47d8a7d4d1 Add missing lock destructor invocations to the LinuxKPI unload handler.
MFC after:	1 week
2017-06-21 18:17:32 +00:00
Mark Johnston
9b6197df69 Include kmod.h from the LinuxKPI's module.h.
MFC after:	1 week
2017-06-21 18:15:47 +00:00
Mark Johnston
33baed9452 Add a lockdep macro to the LinuxKPI.
Also fix some nearby style issues.

MFC after:	1 week
2017-06-21 18:08:36 +00:00
Hans Petter Selasky
cde3f930bc Allow the VM fault handler to be NULL in the LinuxKPI when handling a
memory map request. When the VM fault handler is NULL a return code of
VM_PAGER_BAD is returned from the character device's pager populate
handler. This fixes compatibility with Linux.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2017-06-21 14:38:52 +00:00
Mark Johnston
8504aa9852 Add kthread parking support to the LinuxKPI.
Submitted by:	kmacy (original version)
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11264
2017-06-18 19:22:05 +00:00
Mark Johnston
4eb18346d1 Avoid including list.h in LinuxKPI headers.
list.h includes a number of FreeBSD headers as a workaround for the
LIST_HEAD name collision. To reduce pollution, avoid including list.h
in commonly used headers when it is not explicitly needed.

Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D11249
2017-06-18 16:43:57 +00:00
Ed Maste
dbaa9ebf1b Add ZFS to Linux statfs ftype
PR:		220086
Reviewed by:	cem
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11252
2017-06-18 11:51:03 +00:00
Mark Johnston
8239734079 Remove prototypes for unimplemented LinuxKPI functions.
MFC after:	1 week
2017-06-17 22:52:23 +00:00
Konstantin Belousov
eb84ca643c Regen. 2017-06-17 00:58:19 +00:00
Konstantin Belousov
2b34e84335 Add abstime kqueue(2) timers and expand struct kevent members.
This change implements NOTE_ABSTIME flag for EVFILT_TIMER, which
specifies that the data field contains absolute time to fire the
event.

To make this useful, data member of the struct kevent must be extended
to 64bit.  Using the opportunity, I also added ext members.  This
changes struct kevent almost to Apple struct kevent64, except I did
not changed type of ident and udata, the later would cause serious API
incompatibilities.

The type of ident was kept uintptr_t since EVFILT_AIO returns a
pointer in this field, and e.g. CHERI is sensitive to the type
(discussed with brooks, jhb).

Unlike Apple kevent64, symbol versioning allows us to claim ABI
compatibility and still name the new syscall kevent(2).  Compat shims
are provided for both host native and compat32.

Requested by:	bapt
Reviewed by:	bapt, brooks, ngie (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D11025
2017-06-17 00:57:26 +00:00
Konstantin Belousov
2d88da2f06 Move struct syscall_args syscall arguments parameters container into
struct thread.

For all architectures, the syscall trap handlers have to allocate the
structure on the stack.  The structure takes 88 bytes on 64bit arches
which is not negligible.  Also, it cannot be easily found by other
code, which e.g. caused duplication of some members of the structure
to struct thread already.  The change removes td_dbg_sc_code and
td_dbg_sc_nargs which were directly copied from syscall_args.

The structure is put into the copied on fork part of the struct thread
to make the syscall arguments information correct in the child after
fork.

This move will also allow several more uses shortly.

Reviewed by:	jhb (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
X-Differential revision:	https://reviews.freebsd.org/D11080
2017-06-12 21:03:23 +00:00
Dmitry Chagin
12bbbbb254 Remove the outdated definition.
MFC after:	1 week
2017-06-12 07:48:51 +00:00
Dmitry Chagin
ac1082e590 Since r318735 (ino64 project) the size of the native struct dirent is
equal or greater than the size of Linux struct dirent or struct dirent64.
So, remove LINUX_RECLEN_RATIO magic as useless.
2017-06-12 07:35:59 +00:00
Mark Johnston
f67b5de754 Implement pci_disable_device() in the LinuxKPI.
Submitted by:	kmacy
MFC after:	2 weeks
2017-06-09 19:57:27 +00:00
Mark Johnston
465659643b Augment wait queue support in the LinuxKPI.
In particular:
- Don't evaluate event conditions with a sleepqueue lock held, since such
  code may attempt to acquire arbitrary locks.
- Fix the return value for wait_event_interruptible() in the case that the
  wait is interrupted by a signal.
- Implement wait_on_bit_timeout() and wait_on_atomic_t().
- Implement some functions used to test for pending signals.
- Implement a number of wait_event_*() variants and unify the existing
  implementations.
- Unify the mechanism used by wait_event_*() and schedule() to put the
  calling thread to sleep.

This is required to support updated DRM drivers. Thanks to hselasky for
finding and fixing a number of bugs in the original revision.

Reviewed by:	hselasky
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10986
2017-06-09 19:41:12 +00:00
Konstantin Belousov
7abe0df223 Enhance vfs.ino64_trunc_error sysctl.
Provide a new mode "2" which returns a special overflow indicator in
the non-representable field instead of the silent truncation (mode
"0") or EOVERFLOW (mode "1").

In particular, the typical use of st_ino to detect hard links with
mode "2" reports false positives, which might be more suitable for
some uses.

Discussed with:	bde
Sponsored by:	The FreeBSD Foundation
2017-06-09 11:17:08 +00:00
Justin Hibbits
864092bcaa Remove ARM and MIPS from linuxkpi ioremap_attr definition
ARM and MIPS fail universe builds.

ARM and MIPS are missing the following:
* VM_MEMATTR_WRITE_THROUGH
* VM_MEMATTR_WRITE_COMBINING

Pointy-hat to:	jhibbits
2017-06-08 02:44:34 +00:00