Commit graph

36 commits

Author SHA1 Message Date
David van Moolenbroek bc2d75fa05 Rework getrusage(2) infrastructure
- the userland call is now made to PM only, and PM relays the call to
  other servers as appropriate; this is an ABI change that will
  ultimately allow us to add proper support for wait3() and the like;
  for the moment there is backward compatibility;
- the getrusage-specific kernel subcall has been removed, as it
  provided only redundant functionality, and did not provide the means
  to be extended correctly in the future - namely, allowing the kernel
  to return different values depending on whether resource usage of
  the caller (self) or its children was requested;
- VM is now told whether resource usage of the caller (self) or its
  children is requested, and it refrains from filling in wrong values
  for information it does not have;
- VM now uses the correct unit for the ru_maxrss values;
- VFS is cut out of the loop entirely, since it does not provide any
  values at the moment; a comment explains how it should be readded.

Change-Id: I27b0f488437dec3d8e784721c67b03f2f853120f
2015-09-28 14:06:59 +00:00
David van Moolenbroek cd27b2627a getrusage(2): zero out ru_i[xds]rss fields
The current values were both inaccurate (especially for dynamically
linked executables) and using the wrong unit (bytes, instead of
kilobytes times ticks-of-execution).  For now we are better off not
populating these fields at all.

Change-Id: I195a8fa8db909e64a833eec25f59c9ee0b89bdc5
2015-09-28 14:06:58 +00:00
Lionel Sambuc 81b1f87117 Fix noassert builds
Change-Id: I5626950ffa29afe7a0fb9e9144839b311824da92
2015-09-25 15:47:43 -07:00
David van Moolenbroek 20054ae93f Kernel: separate userland ABI on kernel page
Currently, the userland ABI uses a single field ('user_sp') far
into the very large 'kinfo' structure on the shared kernel
information page.  This precludes us from modifying or getting
rid of 'kinfo' in the future without breaking userland.  This
patch adds a separate 'kuserinfo' structure to the kernel
information page, with only information that is part of the
userland ABI, in an extensible manner.  Userland now uses this
field if it is present, and falls back to the old field if not.

Change-Id: Ib7b24b53a440f40a2edc28cdfa48447ac2179288
2015-09-23 12:01:15 +00:00
David van Moolenbroek 594df55e53 Abstract away minix_kerninfo access
Instead of importing an external _minix_kerninfo variable, any code
using the shared kernel page should now call get_minix_kerninfo(3).
Since this is the only logical name for such a function, rename the
previous get_minix_kerninfo call to ipc_minix_kerninfo.

Change-Id: I2e424b6fb55aa55d3da850187f1f7a0b7cbbf910
2015-09-21 15:09:04 +00:00
David van Moolenbroek ef52a26bab VFS/libblockdriver: enlarge threads stacks for ASR
Change-Id: If4e858bc2dbb2c69850cd265ff612bd5a6119bd3
2015-09-17 17:14:53 +00:00
David van Moolenbroek 5ba2e6e6e8 VM/VFS: align ELF header buffer
The libexec ELF parser expects to be given a word-aligned buffer,
but the ASR pass may cause VM and VFS to pass it an arbitrarily
aligned buffer, causing libexec to refuse loading the executable.
This patch aligns the buffers explicitly.

Change-Id: Ic2d5fd3a8f204c3e4f000cffdb7ac71c8339257a
2015-09-17 17:14:29 +00:00
David van Moolenbroek 728b0e5b34 VFS: suspend threads for live update
- do not allow live update for request and protocol free states if
  there are any worker threads that have pending or active work;
- destroy all worker threads before such live updates and recreate
  them afterwards, because transferring (the contents of) the
  thread stacks is not an option at this time;
- recreate worker threads in the new instance only if they were
  shut down before the state transfer, by letting RS provide the
  original preparation state as initialization information.

Change-Id: I846225f5b7281f19e69175485f2c88a4b4891dc2
2015-09-17 17:13:46 +00:00
David van Moolenbroek 129adfeb53 Annotations and tweaks for live update
This change is necessary for instrumentation-aided state transfer.

Change-Id: I24be938009f02e302a15083f9a7a11824975e42b
2015-09-17 17:13:38 +00:00
Cristiano Giuffrida 3f82ac6a4e services: Selectively enable stateful restart.
Change-Id: Ibf6afa3041013ca714e28b673abb1329cd72d2d5
2015-09-17 13:36:01 +00:00
Cristiano Giuffrida 0e78c0166c Switch to stateful restart.
The following services have been updated to support stateful restarts:
 - Drivers: tty
 - Filesystems: isofs, mfs, pfs, libvtreefs-based file servers
 - System servers: tty, ds, pm, vfs, vm

Change-Id: Ie84baa3ba1774047b3ae519808fe4116928edabb
2015-09-17 13:26:22 +00:00
Cristiano Giuffrida 50b7f13f9f Add live update-friendly annotations.
Change-Id: I7d7d79893836a20799ca548a350f3288e92581f0
2015-09-17 13:25:38 +00:00
David van Moolenbroek de95c84d3e VFS: fix short select(2) timeouts
Some select queries require a response from device drivers.  If a
select call is nonblocking (with a zero timeout), the response to
the caller may have to be deferred until all involved drivers have
responded to the initial query.  This is handled just fine.

However, if the select call has a timeout that is so short that it
triggers before all the involved drivers have responded, the
resulting alarm would be discarded, possibly resulting in the call
blocking forever.  This fix changes the alarm handler such that if
the alarm triggers too early, the select call is further handled
as though it was nonblocking.

This fix resolves a test77 deadlock on really slow systems.

Change-Id: Ib487c8fe436802c3e11c57355ae0c8480721f06e
2015-09-16 10:41:46 +00:00
David van Moolenbroek 4b12166f26 VFS: workaround to allow TIOCSCTTY on PTYs
Fix /dev/tty-related issues in tmux(1) by hardcoding the PTY major
in VFS in addition to the TTY major.  Even though this is exactly
what we did NOT want to have to do, the actual fix for this issue
is going to take a little longer.

Change-Id: I24c75eaf688b9ebd28e931f2e445b8442cfdac78
2015-09-01 11:42:03 +00:00
David van Moolenbroek 29e004d23b VFS: make message pointer management more robust
The previous approach of storing pointers to messages structures for
thread-blocking sendrec operations relied on several assumptions,
which if violated could lead to odd cases of memory corruption.
With this patch, VFS resets pointers right after use, avoiding that
any dangling pointers are accidentally dereferenced later.  This
approach was already used in some cases, but not all of them.

Change-Id: I752d994ea847b46228bd2ccf4e537deceb78fbaf
2015-08-31 12:58:39 +00:00
David van Moolenbroek 56ac45c10b VFS: check X bit, not R bit, opening executables
For dynamically linked executables, the interpreter is passed a
file descriptor of the binary being executed.  To this end, VFS
opens the target executable, but opening the file fails if it is
not readable, even when it is executable.  With this patch, when
opening the executable, it verifies the X bit rather than the R
bit on the file, thus allowing the execution of dynamically
linked binaries that are executable but not readable.

Add test86 to verify correctness.

Change-Id: If3514add6a33b33d52c05a0a627d757bff118d77
2015-08-31 12:55:55 +00:00
David van Moolenbroek 9f15e7b366 VFS: tweak coredump wrapper code
Change-Id: I6c1f50910d906b25f6df2b48f2cbfb899850924e
2015-08-31 12:55:48 +00:00
David van Moolenbroek 253dbfc285 VFS: resolve noassert warning
Change-Id: I647f5a7b3c2935be3df032873705be83de9aaffb
2015-08-31 12:55:43 +00:00
David van Moolenbroek bd851af48f VFS: merge scratchpad into fproc
There is no reason to keep these tightly coupled data structures
separate.  Moreover, there is no reason to have a union of file
descriptor and file pointer, since the second can be derived from
the first.  The result are somewhat cleaner VFS internals.

Change-Id: I854da7d8291177878eecfc3077ef0a9e0cc82aaa
2015-08-13 13:45:02 +00:00
David van Moolenbroek 424cad2cd6 VFS: add support for F_DUPFD_CLOEXEC
Change-Id: Ibe422c6c99fe5fd1385884843ff9e15111810309
2015-07-20 13:55:10 +00:00
David van Moolenbroek 5055c7ea51 VFS: fix pipe resumption delay bug
Commit 723e513 erroneously removed a yield() call from VFS which was
necessary to get resumed pipe read/write threads to run before VFS
blocks on receive().  The removal caused those threads to run only
once VFS received another message, effectively slowing down activity
on pipes to a crawl in some cases.

Instead of readding the yield() call, this patch restructures the
get_work() code to go back through the main message loop even when no
new work is received, thus ensuring that newly started threads are
always activated without requiring a special case.

This fixes #65.

Change-Id: I59b7fb9e403d87dba1a5deecb04539cc37517742
2015-06-19 22:13:34 +00:00
David van Moolenbroek 7eb698ea4a VFS: during initial mount, receive but block work
For VFS, initialization is a special case for processing work: PFS
and the ramdisk MFS must be fully mounted before VFS can process any
other requests, in particular from init(8). This case was handled by
receiving reply messages only from the FS service being mounted, but
this effectively disallowed PFS from calling setuid(2) at startup.

This patch lets VFS receive all messages during the mounting process,
but defer processing any new requests. As a result, the FS services
have a bit more freedom in what they can do during startup.

Change-Id: I18275f458952a8d790736a9c9559b27bbef97b7b
2015-06-06 18:45:23 +00:00
David van Moolenbroek 179bddcf5d VFS: fix error behavior for partial pipe writes
This patch fixes two related issues:

- If a large (>PIPE_BUF) pipe write is processed partially, only to be
  followed by a write error condition, then the process is left in an
  incorrect state, possibly causing VFS to crash on a subsequent call.

- If such a partially processed large pipe write ends up resulting in
  an EPIPE error, no corresponding SIGPIPE signal is generated.

The corrected behavior is tested in test68.

Change-Id: I5540e61ab6bcc60a31201485eda04bc49ece2ca8
2015-06-05 18:40:57 +00:00
Ben Gras 3c8950cce9 minix/ changes for arm llvm build
. fixes needed to build Minix/ARM with LLVM without errors,
	  mostly size_t cleanness

Change-Id: If4dd0a23bc5cb399296073920a8940c34b4caef4
2014-12-03 23:40:56 +01:00
David van Moolenbroek 1f945e8080 Fix fcntl(F_[GS]ETNOSIGPIPE) semantics
The new semantics should match those of NetBSD and other systems.

Change-Id: Ic9ca9d6b8c3e42d2a2953d9feea5f6bacaceb43c
2014-11-01 12:57:31 +00:00
David van Moolenbroek e296281ce2 VFS: do not make cloned devices setuid/setgid
Change-Id: Ifd97444dd54334ccbc8780df9473450998ab7489
2014-09-29 16:16:27 +00:00
David van Moolenbroek f737eea636 svrctl(2) update
- synchronize request type with ioctl by making it unsigned long;
- unbreak VFS requests, as they were being sent to PM;
- use proper ioctl direction flags (and new numbers) for requests;
- remove some needless header inclusions;
- svrctl is in libc, make its message name reflect this;
- keep backward compatibility: svrctl is part of the userland ABI.

Change-Id: I44902e8d0d11b8ebc1ef3bda94d2202481743c9b
2014-09-29 16:15:21 +00:00
David van Moolenbroek f859061eaf PFS: use libfsdriver
In order to avoid creating libfsdriver exceptions, two changes to VFS
are necessary:

- the returned position field for reads/writes is no longer abused to
  return the new pipe size; VFS is perfectly capable of updating the
  size itself;
- during system startup, PFS is now sent a mount request, just like all
  other file systems.

In proper "two steps forward, one step back" fashion, the latter point
has the consequence that PFS can no longer drop its privileges at
startup.  This is probably best resolved with a more general solution
for all boot image system services.  The upside is that PFS no longer
needs to be linked with libc.

Change-Id: I92e2410cdb0d93d0e6107bae10bc08efc2dbb8b3
2014-09-18 12:46:28 +00:00
David van Moolenbroek ad80a203db Move clock_time into libsys
Change-Id: Ibc5034617e6f6581de7c4a166ca075b3c357fa82
2014-09-18 12:46:26 +00:00
David van Moolenbroek e7b4aa7d99 VFS: provide correct root directory for lookups
This fixes a VFS panic and a chroot(2) security hole.

Change-Id: Ifd1923f886501cf3a73277aab89db974798c47dc
2014-09-18 12:46:23 +00:00
David van Moolenbroek 71cd1dd4b9 VFS: do not call REQ_FLUSH on the root file system
Change-Id: I15d29a6f3d198e604ea7f7a9db600d6d18b6994b
2014-09-18 12:46:22 +00:00
David van Moolenbroek d3434cb55b VFS: convert EINTR to EAGAIN for nonblocking I/O
The conversion was never properly implemented for asynchronous
character drivers, and got lost during the removal of the
synchronous character protocol.

Change-Id: Ib858806859aa7a52d6b391d4c6c521a2be361fdd
2014-08-31 17:29:47 +00:00
David van Moolenbroek 27d0ecdb62 VFS: unbreak select on /dev/tty
The remapping from /dev/tty to the real controlling terminal in the
device code was confusing the select code.  The latter is now aware
of this case and should handle it properly, at the cost of one extra
field in the filp structure.

There is a nasty, hopefully sufficiently rare case of /dev/tty being
kept open while controlling terminals are changing, that we are still
not handling.  Doing so would require more than just a few changes,
but the code should at least detect and cleanly fail on this case.

Test77 now has a basic test set for selecting on /dev/tty.

Change-Id: Iaedea449cdb728d0e66a9de8faacdfd9638dfe92
2014-08-28 16:30:48 +00:00
David van Moolenbroek 3b4688844f VFS: complete the devmajor_t/devminor_t switch
Change-Id: I9f809283f19d577cf7e02705fdbb2310ae2b6cba
2014-08-28 16:29:56 +00:00
Lionel Sambuc 50a1aef12b Move all services to /service
This concerns all services, a.k.a drivers, filesystem drivers, network
(inet, lwip, uds) servers, and the system servers.

Change-Id: I626fd15c795e15af42df2d10d47fb4a703665d63
2014-07-31 16:00:31 +02:00
Lionel Sambuc 433d6423c3 New sources layout
Change-Id: Ic716f336b7071063997cf5b4dae6d50e0b4631e9
2014-07-31 16:00:30 +02:00