Commit Graph
2586 Commits
Author SHA1 Message Date
Ed Schouten 9e46278001 MFC r321514, r322885, r323015, r323177
This brings the CloudABI code more or less in sync with HEAD.

r321514:
Upgrade to the latest sources generated from the CloudABI specification.

The CloudABI specification has had some minor changes over the last half
year. No substantial features have been added, but some features that
are deemed unnecessary in retrospect have been removed:

- mlock()/munlock():

  These calls tend to be used for two different purposes: real-time
  support and handling of sensitive (cryptographic) material that
  shouldn't end up in swap. The former use case is out of scope for
  CloudABI. The latter may also be handled by encrypting swap.

  Removing this has the advantage that we no longer need to worry about
  having resource limits put in place.

- SOCK_SEQPACKET:

  Support for SOCK_SEQPACKET is rather inconsistent across various
  operating systems. Some operating systems supported by CloudABI (e.g.,
  macOS) don't support it at all. Considering that they are rarely used,
  remove support for the time being.

- getsockname(), getpeername(), etc.:

  A shortcoming of the sockets API is that it doesn't allow you to
  create socket(pair)s, having fake socket addresses associated with
  them. This makes it harder to test applications or transparently
  forward (proxy) connections to them.

  With CloudABI, we're slowly moving networking connectivity into a
  separate daemon called Flower. In addition to passing around socket
  file descriptors, this daemon provides address information in the form
  of arbitrary string labels. There is thus no longer any need for
  requesting socket address information from the kernel itself.

This change also updates consumers of the generated code accordingly.
Even though system calls end up getting renumbered, this won't cause any
problems in practice. CloudABI programs always call into the kernel
through a kernel-supplied vDSO that has the numbers updated as well.

Obtained from:	https://github.com/NuxiNL/cloudabi

r322885:
Sync CloudABI compatibility against the latest upstream version (v0.13).

With Flower (CloudABI's network connection daemon) becoming more
complete, there is no longer any need for creating any unconnected
sockets. Socket pairs in combination with file descriptor passing is all
that is necessary, as that is what is used by Flower to pass network
connections from the public internet to listening processes.

Remove all of the kernel bits that were used to implement socket(),
listen(), bindat() and connectat(). In principle, accept() and
SO_ACCEPTCONN may also be removed, but there are still some consumers
left.

Obtained from:	https://github.com/NuxiNL/cloudabi

r323015:
Complete the CloudABI networking refactoring.

Now that all of the packaged software has been adjusted to either use
Flower (https://github.com/NuxiNL/flower) for making incoming/outgoing
network connections or can have connections injected, there is no longer
need to keep accept() around. It is now a lot easier to write networked
services that are address family independent, dual-stack, testable, etc.

Remove all of the bits related to accept(), but also to
getsockopt(SO_ACCEPTCONN).

r323177:
Merge pipes and socket pairs.

Now that CloudABI's sockets API has been changed to be addressless and
only connected socket instances are used (e.g., socket pairs), they have
become fairly similar to pipes. The only differences on CloudABI is that
socket pairs additionally support shutdown(), send() and recv().

To simplify the ABI, we've therefore decided to remove pipes as a
separate file descriptor type and just let pipe() return a socket pair
of type SOCK_STREAM. S_ISFIFO() and S_ISSOCK() are now defined
identically.
2017-10-04 07:35:01 +00:00
Ryan Libby 70acc81dcd MFC r321376:
linuxkpi compiler.h: avoid gcc -Wunused-value in dummy expressions
2017-09-06 07:19:22 +00:00
Hans Petter Selasky f886bdd89d MFC r314878:
Add support for constant pointer constructs to READ_ONCE() in the
LinuxKPI. When the type of the argument is constant the temporary
variable cannot be assigned after the barrier. Instead assign the
temporary variable by initialization.

Sponsored by:		Mellanox Technologies
2017-08-14 12:45:55 +00:00
Dmitry Chagin 9937a40828 MFC r321366:
Style(9) whitespace fix.
2017-07-29 10:31:57 +00:00
Konstantin Belousov c7eae662bd MFC r319873:
Move struct syscall_args syscall arguments parameters container into
struct thread.
2017-07-21 18:06:57 +00:00
Konstantin Belousov bbc8dbb4ab MFC r320982:
Correct sysent flags for dynamically loaded syscalls.
2017-07-21 06:48:47 +00:00
Ed Maste ce02046419 MFC r320069: Add ZFS to Linux statfs ftype
PR:		220086
Sponsored by:	The FreeBSD Foundation
2017-07-09 00:24:52 +00:00
Mark Johnston 6e996e25ab MFC r309017 (partially):
Omit v_cache_count when computing the number of free pages, since its
value is always 0.
2017-07-03 16:40:05 +00:00
Andriy Gapon eb3a53979f MFC r320353: linux_getdents, linux_readdir: fix mismatch between malloc and free tags
Approved by:	re (gjb)
2017-06-29 12:49:03 +00:00
Dmitry Chagin 513cd95341 MFC r319571:
On success, getrandom() Linux system call returns the number of bytes that
were copied to the buffer supplied by the user.

PR:		219464
Submitted by:	Maciej Pasternacki
Reported by:	Maciej Pasternacki
Approved by:	re (kib)
2017-06-11 09:33:09 +00:00
Allan Jude 68c019041c MFC r318765:
Allow cpuset_{get,set}affinity in capabilities mode

Approved by:	re (marius)
2017-06-11 02:04:39 +00:00
Gleb Smirnoff 6355c5294d MFC r318677:
Fix regression in ndis(4) after r286410. This adds a bunch of checks for
  whether this is a Ethernet or 802.11 device and does proper dereferencing.

  PR:		213237
  Submitted by:	<ota j.email.ne.jp>
  Approved by:	re (marius)
2017-06-08 22:12:10 +00:00
Dmitry Chagin e44f400fac MFC r317601:
Fix symlinkat() which use the newdfd argument to look up the old path,
while it should use it for the new path instead.

Approved by:	re (kib)
2017-06-04 19:56:21 +00:00
Tai-hwa Liang 260d1ffa79 MFC 316658:
Adding SIOCGIFNAME support in Linuxulator.  This should silence the console warning associated
with linux-opera:
	linux: pid 23492 (opera): ioctl fd=5, cmd=0x8910 ('\M^I',16) is not implemented
	linux: pid 23492 (opera): ioctl fd=28, cmd=0x8910 ('\M^I',16) is not implemented
	...

Reviewed by:	kib, marcel, dchagin
Tested with:	linux-opera-12.16_3
2017-05-15 22:51:22 +00:00
Brooks Davis 6095ebde14 MFC r317845-r317846
r317845:
Provide a freebsd32 implementation of sigqueue()

The previous misuse of sys_sigqueue() was sending random register or
stack garbage to 64-bit targets.  The freebsd32 implementation preserves
the sival_int member of value when signaling a 64-bit process.

Document the mixed ABI implementation of union sigval and the
incompability of sival_ptr with pointer integrity schemes.

Reviewed by:	kib, wblock
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D10605

r317846:
Regen post r317845.

MFC with:	r317845
Sponsored by:	DARPA, AFRL
2017-05-12 17:40:34 +00:00
John Baldwin 67f8a82930 MFC 313564:
Drop the "created from" line from files generated by makesyscalls.sh.

This information is less useful when the generated files are included in
source control along with the source.  If needed it can be reconstructed
from the $FreeBSD$ tag in the generated file.  Removing this information
from the generated output permits committing the generated files along
with the change to the system call master list without having inconsistent
metadata in the generated files.

Regenerate the affected files along with the MFC.
2017-05-10 23:09:17 +00:00
Dmitry Chagin 3e8fe1c011 MFC r317645:
Fix NULL pointer dereference in futex_wake_op() in case when the same
address specified for arguments uaddr and uaddr2.

PR:		218987
2017-05-08 10:51:30 +00:00
Mark Johnston a27119dc27 MFC r317148:
Drop Giant before sleeping in linux_wait_for_{timeout_,}common().
2017-05-03 23:41:09 +00:00
Dmitry Chagin 9d9b6c64d0 MFC r316426:
Use the kern_clock_nanosleep() to implement Linux clock_nanosleep() with
the proper handling of the TIMER_ABSTIME flag.
2017-05-01 06:42:39 +00:00
Eric van Gyzen 3b3087ea27 MFC r315526
Add clock_nanosleep()

Add a clock_nanosleep() syscall, as specified by POSIX.
Make nanosleep() a wrapper around it.

Attach the clock_nanosleep test from NetBSD. Adjust it for the
FreeBSD behavior of updating rmtp only when interrupted by a signal.
I believe this to be POSIX-compliant, since POSIX mentions the rmtp
parameter only in the paragraph about EINTR. This is also what
Linux does. (NetBSD updates rmtp unconditionally.)

Copy the whole nanosleep.2 man page from NetBSD because it is complete
and closely resembles the POSIX description. Edit, polish, and reword it
a bit, being sure to keep any relevant text from the FreeBSD page.

Regenerate syscall files.

Relnotes:	yes
Sponsored by:	Dell EMC
2017-05-01 01:36:54 +00:00
Dmitry Chagin e396231cb1 MFC r317324:
Map Linux CLOCK_BOOTTIME to native CLOCK_UPTIME.
2017-04-30 06:15:56 +00:00
Dmitry Chagin 7e1bbf44dd MFC r317323:
Add Evdev ioctl handler to the Linuxulator.

PR:		218627
2017-04-30 06:14:57 +00:00
Dmitry Chagin 2742834a9d MFC r316776 (by cem@):
linux_ioctl: Refactor some v4l2 struct converters

According to the C standard, it is invalid to copy beyond the end of an
object, even if that object is obviously a member of a larger object (a
struct, in this case).

Appease the standard and Coverity by refactoring the copy in a
straightforward way.  No functional change.
2017-04-29 09:26:30 +00:00
Dmitry Chagin 5420a1bac4 MFC r316289:
Use kern_mincore() helper instead of abusing syscall entry.
2017-04-29 09:21:00 +00:00
Dmitry Chagin 9e509e15ab MFC r315957:
Implement Linux mincore() system call.
This is necessary for the upcoming drm-next.
2017-04-29 09:18:55 +00:00
Dmitry Chagin ad925f1784 MFC r315506:
Glibc get_nprocs() and get_nprocs_conf() uses the sysfs cpu infrastructure
to get number of processors. Implement /sys/devices/system/cpu/.
2017-04-23 06:45:21 +00:00
Dmitry Chagin 9cfc6ccfb2 MFC r315505:
Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.
2017-04-23 06:43:52 +00:00
Dmitry Chagin f428ede9f3 MFC r315501:
To reduce code duplication move socket defines to the MI path.
2017-04-15 15:38:15 +00:00
Dmitry Chagin 7cc63dab54 MFC r316395:
Remove excess tv_nsec test as this is done by linux_to_native_timespec().
2017-04-15 15:32:22 +00:00
Dmitry Chagin 1f8a8ca339 MFC r316394:
The value in the tv_nsec field should be in the range 0 to 999999999.
2017-04-15 15:31:28 +00:00
Dmitry Chagin 2d09930855 MFC r316393:
As noted by bde@ negative tv_sec values are not checked for overflow,
so overflow can still occur. Fix that. Also remove the extra check for
tv_sec size as under COMPAT_LINUX32 it is always true.
2017-04-15 15:30:28 +00:00
Dmitry Chagin 7833894202 MFC r315498:
Check for negative nanoseconds.
Linux do that in timespec_valid().
2017-04-15 15:29:16 +00:00
Dmitry Chagin 285ebf1c4f MFC r316599:
Prevent ushort values overflow when convert new Linux 64-bit ipc
struct to the old Linux ipc struct.
2017-04-15 15:15:42 +00:00
Dmitry Chagin 8051cdf041 MFC r314868:
Linux semop system call return EINVAL in case when the invalid nsops
or semid values specified.
2017-04-15 15:13:54 +00:00
Dmitry Chagin 81076ba179 MFC r314867:
Linux kernel does not export to the user space ipc_perm.mode values
other than S_IRWXUGO (0777).
2017-04-15 15:12:25 +00:00
Dmitry Chagin bde7e6f88b MFC r314866:
Reduce code duplication between MD Linux code by moving SYSV IPC 64-bit
related struct definitions out into the MI path.

Invert the native ipc structs to the Linux ipc structs convesion logic.
Since 64-bit variant of ipc structs has more precision convert native ipc
structs to the 64-bit Linux ipc structs and then truncate 64-bit values
into the non 64-bit if needed. Unlike Linux, return EOVERFLOW if the
values do not fit.

Fix SYSV IPC for 64-bit Linuxulator which never sets IPC_64 bit.
2017-04-15 15:11:23 +00:00
Dmitry Chagin b589ed098b MFC r314648:
Style(9).
2017-04-15 15:09:23 +00:00
Dmitry Chagin fc7c4917e5 MFC r314647:
Remove attribute __packed from some IPC struct definition since
Linuxulator is x86 only.
The only notable differences in algnment for an LP64 64-bit system
when compared to a 32-bit system is an eight or large byte types
alignment.
2017-04-15 15:08:23 +00:00
Mahdi Mokhtari 3352c3c8c2 MFC r314782:
Add UNIMPLEMENTED() placeholder macro for
the syscalls that are not implemented in Linux kernel itself.
Cleanup DUMMY() macros.

Approved by:	trasz
2017-04-11 12:49:25 +00:00
Ed Schouten aecf4bd520 Bring kernel space CloudABI code in sync with HEAD.
MFC r312353, r312354 and r312355:

  Sync in the latest CloudABI generated source files.

  Languages like C++17 and Go provide direct support for slice types:
  pointer/length pairs. The CloudABI generator now has more complete for
  this, meaning that for the C binding, pointer/length pairs now use an
  automatic naming scheme of ${name} and ${name}_len.

  Apart from this change and some reformatting, the ABI definitions are
  identical. Binary compatibility is preserved entirely.

MFC r315700:

  Make file descriptor passing work for CloudABI's sendmsg().

  Reduce the potential amount of code duplication between cloudabi32 and
  cloudabi64 by creating a cloudabi_sock_recv() utility function. The
  cloudabi32 and cloudabi64 modules will then only contain code to convert
  the iovecs to the native pointer size.

  In cloudabi_sock_recv(), we can now construct an SCM_RIGHTS cmsghdr in
  an mbuf and pass that on to kern_sendit().

MFC r315736:

  Make file descriptor passing for CloudABI's recvmsg() work.

  Similar to the change for sendmsg(), create a pointer size independent
  implementation of recvmsg() and let cloudabi32 and cloudabi64 call into
  it. In case userspace requests one or more file descriptors, call
  kern_recvit() in such a way that we get the control message headers in
  an mbuf. Iterate over all of the headers and copy the file descriptors
  to userspace.
2017-04-06 15:10:36 +00:00
Edward Tomasz Napierala f86ce637b9 MFC r314046:
Get rid of foo_sys() in linuxulator code.  It was commented out, and it
would be useless anyway - there is no point in pretending to have block
devices; our "block" devices are in fact character ones, and can only
be accessed as such.

Sponsored by:	DARPA, AFRL
2017-04-01 17:09:55 +00:00
Ed Schouten d94b5e92c5 MFC r315892:
Include <sys/systm.h> to obtain the memcpy() prototype.

  I got a report of this source file not building on Raspberry Pi. It's
  interesting that this only fails for that target and not for others.
  Again, that's no reason not to include the right headers.

PR:           217969
Reported by:  Johannes Jost Meixner
2017-03-31 08:43:07 +00:00
Dmitry Chagin fbc45fb4a7 MFC r314404:
Linux epoll return EEXIST on case when op is EPOLL_CTL_ADD, and the supplied
file descriptor fd is already registered with this epoll instance.
2017-03-30 20:14:43 +00:00
Dmitry Chagin 1c068cf36d MFC r314403:
Linux epoll return ENOENT error in case when op is EPOLL_CTL_MOD or
EPOLL_CTL_DEL, and fd is not registered with this epoll instance.
2017-03-30 20:13:47 +00:00
Dmitry Chagin 9b77ee070e MFC r314402:
FreeBSD does not have analgue for epoll EPOLLPRI event type.
So, do not set EPOLLPRI event acidently.
Also, do not set EPOLLWRNORM and EPOLLRDNORM events as epoll
do not set this events.
2017-03-30 20:12:23 +00:00
Dmitry Chagin c12b8cf65a MFC r314344:
Return EINVAL when an invalid file descriptor specified.
2017-03-30 20:10:57 +00:00
Dmitry Chagin a2709bf25d MFC r314343:
Unify eventfd ioctl method and use it for other similar interfaces.
2017-03-30 20:09:49 +00:00
Dmitry Chagin 3d1b3fd0aa MFC r314312:
Change Linux epoll_pwait syscall definition to match Linux actual one.

MFC r314313:

Regen for r314312 (Linux epoll_pwait).

MFC r314314:

Return EINVAL in case when an invalid size of signal mask specified.
2017-03-30 20:08:25 +00:00
Dmitry Chagin 188ffb81fb MFC r314311:
Restore signal mask in epoll_pwait.
2017-03-30 20:05:16 +00:00
Dmitry Chagin 8ce3c24be3 MFC r314309:
Return EINVAL when an invalid file descriptor is specified.
2017-03-30 20:04:28 +00:00