]> Zhao Yanbai Git Server - minix.git/log
minix.git
8 years agoNetBSD re-synchronization of the source tree 20/3220/2
Lionel Sambuc [Thu, 15 Oct 2015 15:01:16 +0000 (17:01 +0200)]
NetBSD re-synchronization of the source tree

This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0

8 years agoFix default partition in clientctl. 19/3219/1
Lionel Sambuc [Mon, 12 Oct 2015 18:49:00 +0000 (20:49 +0200)]
Fix default partition in clientctl.

The partition numbering has changed with the new image creation
framework.

Change-Id: I0644e5879913bee067bc31376f81bc5407f4c81f

8 years agoAdd boot menu entry to boot an ALIX SBC. 18/3218/1
rlfnb [Tue, 13 Oct 2015 10:00:09 +0000 (12:00 +0200)]
Add boot menu entry to boot an ALIX SBC.

closes #95

Change-Id: Ifb49cb8e4730d50d2d6a33fcb5e9f08ac790b512

8 years agolibc: fix needless malloc failures 17/3217/2
David van Moolenbroek [Wed, 28 Oct 2015 01:05:39 +0000 (01:05 +0000)]
libc: fix needless malloc failures

The NetBSD libc malloc implementation performs its own out-of-memory
check, presumably for performance reasons.  The check makes a strong
assumption about the address space layout, which is that memory-
mapped pages are always located above the heap.  However, this
assumption does not necessarily hold on MINIX3, thus resulting in
malloc reporting an out-of-memory condition without the system
actually being out of memory at all.  Evidence suggests that in
particular dynamically linked (i.e., pkgsrc) binaries were affected
by this issue - most notably git.

Change-Id: If542fbace0a1cce12aa9e075d51992cbbbf26e94

8 years agoSplit minix distribution set 16/3216/6
Jean-Baptiste Boric [Wed, 16 Sep 2015 14:00:24 +0000 (16:00 +0200)]
Split minix distribution set

The minix set is now divided into minix-base, minix-comp, minix-games,
minix-kernel, minix-man and minix-tests.

This allows massive space savings on the installlation CD because only
the base system used for installation is stored uncompressed. Also, it
makes the system more modular.

Change-Id: Ic8d168b4c3112204013170f07245aef98aaa51e7

8 years agoUpgrade releasetools/sort_set 15/3215/4
Lionel Sambuc [Fri, 9 Oct 2015 12:36:26 +0000 (14:36 +0200)]
Upgrade releasetools/sort_set

 - retire the old shell script
 - import perl script

The perl scripts has the following advantages:
 - The sorting should be more stable, even accross different OSes.
 - The sorted output is automatically formatted into columns
 - It is much faster, even on large inputs.

Change-Id: I1068b21fda981b4cf9eeea4af83165ec2968280b

8 years agoNew image framework generation 14/3214/2
Jean-Baptiste Boric [Mon, 14 Sep 2015 19:46:48 +0000 (21:46 +0200)]
New image framework generation

The CD now boots directly from the ISO 9660 filesystem instead of using
MBR partitioning with Minix file systems. This saves some space on the
CD and reduces memory requirements by some unknown amount as the root
ramdisk is completely eliminated.

The x86 hard drive image creation is also rewritten in the same
fashion.

The setup is modified to be more NetBSD-like (unpacking sets
tarballs instead of blindly copying the CD contents). Splitting MINIX
into sets is done in another commit due to it being a nightmare to
rebase.

Since MINIX lacks union mounts for now, a bunch of ramdisks are
generated at run-time to make parts of the filesystem writeable for the
CD. This solution isn't ideal, but it's enough for an installation CD.

Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd

8 years agopkg_install: Set default paths as expected on MINIX 13/3213/1
Lionel Sambuc [Fri, 9 Oct 2015 13:46:08 +0000 (15:46 +0200)]
pkg_install: Set default paths as expected on MINIX

Change-Id: I97568cb5c92d14b7175ba0ed0f3efb2009d0c455

8 years agoramdisk: fix command output to stdout 12/3212/1
Jean-Baptiste Boric [Tue, 15 Sep 2015 10:59:13 +0000 (12:59 +0200)]
ramdisk: fix command output to stdout

Change-Id: I58a8cf2cd05b71dbbc1784c7d5770279392e3a8b

8 years agoAdd installboot to host tools 11/3211/1
Jean-Baptiste Boric [Thu, 10 Sep 2015 22:02:37 +0000 (00:02 +0200)]
Add installboot to host tools

Change-Id: I5594cfdb13362b51f86b9ef76e82c21402c47f8d

8 years agoAdd makefs to host tools 10/3210/1
Jean-Baptiste Boric [Fri, 11 Sep 2015 09:48:57 +0000 (11:48 +0200)]
Add makefs to host tools

Change-Id: I217c0b6f1a78622636d541fa80b93b6d148e3681

8 years agoImport pkg_install from NetBSD 09/3209/1
Jean-Baptiste Boric [Fri, 11 Sep 2015 09:07:35 +0000 (11:07 +0200)]
Import pkg_install from NetBSD

Change-Id: I9a3071b94dd2e9bfe2e3b162994e06ae10077b5a

8 years agoImporting crypto libraries 08/3208/1
Lionel Sambuc [Wed, 7 Oct 2015 00:45:38 +0000 (00:45 +0000)]
Importing crypto libraries

 - crypto/external/bsd/heimdal
 - crypto/external/bsd/libsaslc
 - crypto/external/bsd/netpgp
 - crypto/external/bsd/openssl

Change-Id: I91dbf05f33e637edf5b9bb408d5baddd7ba8cf75

8 years agoisofs: reworked for better performance 89/2989/2
Jean-Baptiste Boric [Wed, 16 Sep 2015 12:36:11 +0000 (14:36 +0200)]
isofs: reworked for better performance

isofs now uses an in-memory directory listing built on-the-fly instead
of parsing the ISO 9660 data structures over and over for almost every
request. This yields huge performance improvements.

The directory listing is allocated dynamically, but Minix servers aren't
normally supposed to do that because critical servers would crash if the
system runs out of memory. isofs is quite frugal, won't allocate memory
after having the whole directory tree cached and is not that critical
(its most important job is to serve as a root file system during
installation).

The benefits and elegance of this scheme far outweights this small
problem in practice.

Change-Id: I13d070388c07d274cbee0645cbc50295c447c5b6

8 years agomakefs: apply NetBSD PR kern/48852 patch 88/2988/2
Jean-Baptiste Boric [Thu, 23 Apr 2015 15:30:57 +0000 (17:30 +0200)]
makefs: apply NetBSD PR kern/48852 patch

It's a fix for correcting cd9660 device node creation in makefs. This
fix was commited in NetBSD on May 30, 2014, after the current NetBSD
source code import, hence the cherrypicking.

Change-Id: Id3e05618688bbd6d07780f46f6ada90525556b5a

8 years agoImport makefs from NetBSD 87/2987/2
Jean-Baptiste Boric [Thu, 10 Sep 2015 21:45:24 +0000 (23:45 +0200)]
Import makefs from NetBSD

Change-Id: I0ebcc9d0168df9d26cfb0af0fce2bc894ce688af

8 years agolibutil: add getmaxpartitions() implementation 07/3207/1
Jean-Baptiste Boric [Fri, 11 Sep 2015 08:52:26 +0000 (10:52 +0200)]
libutil: add getmaxpartitions() implementation

Change-Id: I6f1d7838e10bcb079fb5b68ff513c3279fffb4f9

8 years agoFix gcc -O1 builds for ARM 06/3206/1
Lionel Sambuc [Sun, 4 Oct 2015 10:47:57 +0000 (03:47 -0700)]
Fix gcc -O1 builds for ARM

The builds are failing as GCC somehow thinks ino might be
uninitialized before use.

Change-Id: Id99fd5e46bcbaafd5001752e16c3f77c1d568556

8 years agoImport NetBSD time(1) 05/3205/2
David van Moolenbroek [Mon, 28 Sep 2015 11:41:16 +0000 (11:41 +0000)]
Import NetBSD time(1)

Change-Id: I035d21a926aa82434c24a84b914bd58ac064e66a

8 years agoImport NetBSD csh(1) 04/3204/2
David van Moolenbroek [Mon, 28 Sep 2015 11:36:43 +0000 (11:36 +0000)]
Import NetBSD csh(1)

Jobctl warning commented out.  Largely untested.

Change-Id: I4dffe23a2855a374628c820703b51591633aed64

8 years agoPM: add support for wait4(2) 03/3203/2
David van Moolenbroek [Mon, 28 Sep 2015 11:11:55 +0000 (11:11 +0000)]
PM: add support for wait4(2)

This patch adds support for the wait4 system call, and with that the
wait3 call as well.  The implementation is absolutely minimal: only
user and system times of the exited child are returned (with all other
rusage fields left zero), and there is no support for tracers.  Still,
this should cover the main use cases of wait4.

Change-Id: I7a04589a8423a23990ab39aa38e85d535556743a

8 years agoRework getrusage(2) infrastructure 02/3202/1
David van Moolenbroek [Sun, 27 Sep 2015 17:32:10 +0000 (17:32 +0000)]
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

8 years agogetrusage(2): zero out ru_nsignals field 01/3201/1
David van Moolenbroek [Sun, 27 Sep 2015 15:00:19 +0000 (15:00 +0000)]
getrusage(2): zero out ru_nsignals field

The current value was both wrong (counting spawned kernel signals
rather than delivered user signals) and returned for the calling
process even if the request was for the process's children.
For now we are better off not populating this field at all.

Change-Id: I6c660be266b5746b7c3db57ae88fa7f872961ee2

8 years agogetrusage(2): zero out ru_i[xds]rss fields 00/3200/1
David van Moolenbroek [Sun, 27 Sep 2015 11:28:56 +0000 (11:28 +0000)]
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

8 years agoPM: make child time accumulation POSIX compliant 99/3199/1
David van Moolenbroek [Sun, 27 Sep 2015 12:32:23 +0000 (12:32 +0000)]
PM: make child time accumulation POSIX compliant

POSIX states that times() and getrusage() should only return child
user and system times of terminated children for which wait*() has
returned their PIDs.

Change-Id: I38e19ad71543a3b91e944bef8e4e1bd903de51bf

8 years agocommands: move manpages into command directories 97/3197/4
David van Moolenbroek [Fri, 25 Sep 2015 12:15:49 +0000 (12:15 +0000)]
commands: move manpages into command directories

Change-Id: Icf8a2d26629a1822725022c9ee21c587d3c4c3b4

8 years agoFix noassert builds 98/3198/2
Lionel Sambuc [Fri, 25 Sep 2015 19:22:27 +0000 (12:22 -0700)]
Fix noassert builds

Change-Id: I5626950ffa29afe7a0fb9e9144839b311824da92

8 years agolibpuffs: clean up, unbreak 96/3196/1
David van Moolenbroek [Tue, 22 Sep 2015 12:41:58 +0000 (12:41 +0000)]
libpuffs: clean up, unbreak

- move MINIX3-specific files into minix/lib/libpuffs;
- resynchronize the remaining files with NetBSD code;
- remove a few unnecessary changes;
- put remaining MINIX3-specific changes in __minix blocks;
- sort out the source files being linked at all.

The result is that libpuffs now successfully links against FUSE
file system programs again.  It can successfully mount, perform
some of the most basic operations, and unmount the file system.

Change-Id: Ieac220f7ad8c4d1fa293abda81967e8045be0bb4

8 years agoResolve more warnings 95/3195/1
David van Moolenbroek [Mon, 21 Sep 2015 17:14:39 +0000 (17:14 +0000)]
Resolve more warnings

Change-Id: Ibc1b7f7cd45ad7295285e59c6ce55888266fece8

8 years agoImport NetBSD flock(1) 94/3194/1
David van Moolenbroek [Tue, 15 Sep 2015 20:42:11 +0000 (20:42 +0000)]
Import NetBSD flock(1)

Also fix the MINIX3 libc flock(3) implementation.

Change-Id: Ia80280029968786d7f029940ec02e942057701bd

8 years agoswifi: various improvements 93/3193/1
David van Moolenbroek [Tue, 2 Oct 2012 15:49:23 +0000 (15:49 +0000)]
swifi: various improvements

- no longer inject fewer faults than instructed;
- no longer apply a limit on the number of injected faults;
- refactory to allow for random faults (type 99);
- also allow for stop faults (type 50);
- massive dead code cleanup;
- move outdated test cruft into tests/ subdirectory; it is kept only
  as an example of how to use swifi.

Change-Id: I8a3cb71902dfaadb7bf785723b917307db83d0d5

8 years agoDeprivilege some network commands 92/3192/1
David van Moolenbroek [Sun, 20 Sep 2015 16:46:38 +0000 (16:46 +0000)]
Deprivilege some network commands

At the very least, these can be used to test for the existence of
files not normally accessible by unprivileged users.

Change-Id: I054cf6d033a1604bbbc871db37103a67067abe84

8 years agocommands: resolve compiler warnings 91/3191/3
David van Moolenbroek [Sun, 20 Sep 2015 12:13:58 +0000 (12:13 +0000)]
commands: resolve compiler warnings

Change-Id: I95f0d0c48f998d4d950a0800eedd5fbbf2e50423

8 years agoRetire decomp16(1) 90/3190/2
David van Moolenbroek [Sun, 20 Sep 2015 15:35:48 +0000 (15:35 +0000)]
Retire decomp16(1)

Change-Id: I455aac47b3efa4ffa5cc8305c6760f92e1e8642a

8 years agoRetire ci(1), co(1), svclog(1) 89/3189/2
David van Moolenbroek [Sun, 20 Sep 2015 15:33:41 +0000 (15:33 +0000)]
Retire ci(1), co(1), svclog(1)

Change-Id: I1bd1d92b9aacd4dfc4843c423862ae540fe2b557

8 years agofbdctl(8): move to proper location 88/3188/2
David van Moolenbroek [Sat, 19 Sep 2015 23:06:10 +0000 (23:06 +0000)]
fbdctl(8): move to proper location

- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: I1206b52e8804a68a3a80f6d7f63916e7fcdc9e3f

8 years agodiskctl(8): move to proper location 87/3187/2
David van Moolenbroek [Sat, 19 Sep 2015 22:39:59 +0000 (22:39 +0000)]
diskctl(8): move to proper location

- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: Iccb4a8b27ae220254bae19e9198478b40706f542

8 years agobtrace(8): move to proper location 86/3186/2
David van Moolenbroek [Sat, 19 Sep 2015 22:31:13 +0000 (22:31 +0000)]
btrace(8): move to proper location

- move from minix/commands to minix/usr.sbin;
- install into /usr/sbin instead of /usr/bin;
- move manual page into source directory;
- resolve compilation warning;
- convert to KNF.

Change-Id: I08c16998bd499a468799a6587f6fe45f42590461

8 years agoMove OpenBSD diff(1) into minix/usr.bin 85/3185/2
David van Moolenbroek [Sat, 19 Sep 2015 23:21:24 +0000 (23:21 +0000)]
Move OpenBSD diff(1) into minix/usr.bin

Editor's note: NetBSD uses GNU diff.

Change-Id: I15d4441c73e0c626d0e5fda8c8683d131fbcbc38

8 years agolibfetch: switch to external/bsd version 84/3184/2
David van Moolenbroek [Sat, 19 Sep 2015 23:46:56 +0000 (23:46 +0000)]
libfetch: switch to external/bsd version

Change-Id: I7eb6fbf0ae6c008e399fe9bffdfc2b98dfed3432

8 years agoUpdate, move NetBSD find(1) 83/3183/2
David van Moolenbroek [Sat, 19 Sep 2015 23:17:55 +0000 (23:17 +0000)]
Update, move NetBSD find(1)

Change-Id: Iccda44465d49dba407d1ac1b1ced8aa8b4e6d8aa

8 years agoImport NetBSD cmp 82/3182/2
David van Moolenbroek [Sun, 20 Sep 2015 11:18:45 +0000 (11:18 +0000)]
Import NetBSD cmp

Change-Id: I0e7f6c69742db475ddba6a9159f167a53d151169

8 years agoImport NetBSD rcmd, rcp, rsh, rshd 81/3181/2
David van Moolenbroek [Sat, 19 Sep 2015 17:12:39 +0000 (17:12 +0000)]
Import NetBSD rcmd, rcp, rsh, rshd

Change-Id: I83d908bbe17f04826e9b5c3a220a5bb2c3a51c80

8 years agolibc: support for deprecated FIO* ioctl(2) calls 80/3180/2
David van Moolenbroek [Sat, 19 Sep 2015 21:59:19 +0000 (21:59 +0000)]
libc: support for deprecated FIO* ioctl(2) calls

Various generic file IOCTL calls should be processed by VFS rather
than individual drivers.  For this reason, we rewrite them to use
fcntl(2) instead.

Change-Id: I38a5f3c7b21943a897114a51678a800f7e7f0a77

8 years agoKernel: separate userland ABI on kernel page 79/3179/2
David van Moolenbroek [Mon, 21 Sep 2015 14:52:29 +0000 (14:52 +0000)]
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

8 years agoKernel: store ARM frclock info in one structure 78/3178/2
David van Moolenbroek [Mon, 21 Sep 2015 14:17:11 +0000 (14:17 +0000)]
Kernel: store ARM frclock info in one structure

This change serves to reduce the clutter inside the top-level kerninfo
structure, and allows other ARM-specific values to be added on the
kernel page in one place.

Change-Id: I36a6aada9dbd1230b25014728be675d389088667

8 years agoKernel: export clock information on kernel page 77/3177/2
David van Moolenbroek [Mon, 21 Sep 2015 13:07:55 +0000 (13:07 +0000)]
Kernel: export clock information on kernel page

Please note that this information is for use by system services only!
The clock facility is not ready to be used directly by userland, and
thus, this kernel page extension is NOT part of the userland ABI.

For service programmers' convenience, change the prototype of the
getticks(3) to return the uptime clock value directly, since the call
can no longer fail.

Correct the sys_times(2) reply message to use the right field type
for the boot time.

Restructure the kernel internals a bit so as to have all the clock
stuff closer together.

Change-Id: Ifc050b7bd253aecbe46e3bd7d7cc75bd86e45555

9 years agoAbstract away minix_kerninfo access 76/3176/1
David van Moolenbroek [Sat, 19 Sep 2015 16:31:12 +0000 (16:31 +0000)]
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

9 years agoBasic live rerandomization infrastructure 75/3175/1
David van Moolenbroek [Sun, 6 Sep 2015 06:06:24 +0000 (08:06 +0200)]
Basic live rerandomization infrastructure

This commits adds a basic infrastructure to support Address Space
Randomization (ASR).  In a nutshell, using the already imported ASR
LLVM pass, multiple versions can be generated for the same system
service, each with a randomized, different address space layout.
Combined with the magic instrumentation for state transfer, a system
service can be live updated into another ASR-randomized version at
runtime, thus providing live rerandomization.

Since MINIX3 is not yet capable of running LLVM linker passes, the
ASR-randomized service binaries have to be pregenerated during
crosscompilation.  These pregenerated binaries can then be cycled
through at runtime.  This patch provides the basic proof-of-concept
infrastructure for both these parts.

In order to support pregeneration, the clientctl host script has
been extended with a "buildasr" command.  It is to be used after
building the entire system with bitcode and magic support, and will
produce a given number of ASR-randomized versions of all system
services.  These services are placed in /usr/service/asr in the
image that is generated as final step by the "buildasr" command.

In order to support runtime updating, a new update_asr(8) command
has been added to MINIX3.  This command attempts to live-update the
running system services into their next ASR-randomized versions.
For now, this command is not run automatically, and thus must be
invoked manually.

Technical notes:

- For various reasons, magic instrumentation is x86-only for now,
  and ASR functionality is therefore to be used on x86 only as well.
- The ASR-randomized binaries are placed in numbered subdirectories
  so as not to have to change their actual program names, which are
  assumed to be static in various places (system.conf, procfs).
- The root partition is typically too small to contain all the
  produced binaries, which is why we introduce /usr/service.  There
  is a symlink from /service/asr to /usr/service/asr for no other
  reason than to let userland continue to assume that all services
  are reachable through /service.
- The ASR count field (r_asr_count/ASRcount) maintained by RS is not
  used within RS in any way; it is only passed through procfs to
  userland in order to allow update_asr(8) to keep track of which
  version is currently loaded without having to maintain own state.
- Ideally, pre-instrumentation linking of a service would remove all
  its randomized versions.  Currently, the user is assumed not to
  perform ASR instrumentation and then recompile system services
  without performing ASR instrumentation again, as the randomized
  binaries included in the image would then be stale.  This aspect
  has to be improved later.
- Various other issues are flagged in the comments of the various
  parts of this patch.

Change-Id: I093ad57f31c18305591f64b2d491272288aa0937

9 years agoVM: hide harmless ACL warning for RS at startup 74/3174/1
David van Moolenbroek [Fri, 4 Sep 2015 23:10:41 +0000 (01:10 +0200)]
VM: hide harmless ACL warning for RS at startup

Change-Id: Ied8167bc44ffc336b4ab2478f11586b7d6ae0016

9 years agoVFS/libblockdriver: enlarge threads stacks for ASR 73/3173/1
David van Moolenbroek [Fri, 4 Sep 2015 01:24:52 +0000 (03:24 +0200)]
VFS/libblockdriver: enlarge threads stacks for ASR

Change-Id: If4e858bc2dbb2c69850cd265ff612bd5a6119bd3

9 years agolibmagic: fix ASR padding for memory mapping 72/3172/1
David van Moolenbroek [Fri, 4 Sep 2015 01:28:24 +0000 (03:28 +0200)]
libmagic: fix ASR padding for memory mapping

The code could not decide whether to apply the padding to the start
or the end of the region, resulting in strange behavior because part
of the returned range might not have the right properties.  With this
patch, padding is now consistently applied at the end of the region,
since virtual mmap addresses are allocated from high to low.

Also fix a few small related bugs in error handling code.

Change-Id: I327814bb3921d7982ffc1296a5bf365d9c79c1d9

9 years agoVM: align frame buffer 71/3171/1
David van Moolenbroek [Fri, 4 Sep 2015 01:19:59 +0000 (03:19 +0200)]
VM: align frame buffer

Lack of alignment causes minix_stack_fill to produce an incorrect
frame layout, subsequently resulting in a crash of the started
process.  For now, we assume that the other callers of
minix_stack_fill do get an aligned buffer through sbrk(3), but this
may have to be changed later as well.

Change-Id: I1575bd62b050749d1a1aae7417310c91713462c3

9 years agoVM/VFS: align ELF header buffer 70/3170/1
David van Moolenbroek [Thu, 3 Sep 2015 10:09:54 +0000 (12:09 +0200)]
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

9 years agoASR pass: disable caller padding by default 69/3169/1
David van Moolenbroek [Thu, 3 Sep 2015 04:17:52 +0000 (06:17 +0200)]
ASR pass: disable caller padding by default

The feature is fundamentally broken.  See the comment in the code.

Change-Id: If36b06b0732cc4d18f20240ed96d30a7959b0d21

9 years agoImport ASR pass from llvm-apps 68/3168/1
David van Moolenbroek [Tue, 11 Aug 2015 20:17:23 +0000 (22:17 +0200)]
Import ASR pass from llvm-apps

Change-Id: I106c5faf8d8f1af5d3f5542fe666532895413909

9 years agolibmagic: fail on all state transfer errors 67/3167/1
David van Moolenbroek [Wed, 2 Sep 2015 22:40:39 +0000 (00:40 +0200)]
libmagic: fail on all state transfer errors

Also do not report debugging information by default.

Change-Id: I5d80a3df3c3ecc16a577d88abe6e37a792add747

9 years agolibblockdriver: suspend threads for live update 66/3166/1
David van Moolenbroek [Tue, 25 Aug 2015 06:36:39 +0000 (08:36 +0200)]
libblockdriver: suspend threads for live update

Same as for VFS.

Change-Id: I0f09d43f24c32361af5e5658923140c79244d3d1

9 years agoVFS: suspend threads for live update 65/3165/1
David van Moolenbroek [Mon, 24 Aug 2015 20:44:26 +0000 (22:44 +0200)]
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

9 years agoAnnotations and tweaks for live update 64/3164/1
David van Moolenbroek [Mon, 10 Aug 2015 16:06:10 +0000 (18:06 +0200)]
Annotations and tweaks for live update

This change is necessary for instrumentation-aided state transfer.

Change-Id: I24be938009f02e302a15083f9a7a11824975e42b

9 years agoDS: workaround for weak symbol issue 63/3163/1
David van Moolenbroek [Mon, 24 Aug 2015 13:59:23 +0000 (15:59 +0200)]
DS: workaround for weak symbol issue

The bitcode file given to the instrumentation pass does not include
certain weak symbols, in particular regcomp and regfree, which are
required to be visible to the magic pass for state transfer to work
correctly.  This patch forces DS to make the calls using their actual
symbol names (with leading underscore), thus resolving the issue, but
this issue should really be solved in a cleaner and more generic way.

Change-Id: Iebee4341cc30ddabcf7593afb5c49d41c0839863

9 years agomagic pass: register additional compatible types 62/3162/1
David van Moolenbroek [Mon, 24 Aug 2015 06:22:02 +0000 (08:22 +0200)]
magic pass: register additional compatible types

This patch is a first step towards working around the larger problem of
LLVM 3.x's use of bitcasting between structures and their elements to
deal with opaque types, replacing LLVM 2.x's actual unification.  The
patch allows the pass to register a larger number of compatible types,
in particular for structure pointers passed through function calls.
A skeleton is provided for dealing with structure elements as well, but
that part requires much more work.  It remains to be seen whether a
more structural approach to dealing with this problem may be warranted.

For now, this change is necessary to allow instrumented state transfer
of various "minix_timer" structures and pointers in PM and VFS.

Change-Id: Ib717d86ccfced53387e72a92750d22ae980c3466

9 years agolibmagic: supply own ctype macros 61/3161/1
David van Moolenbroek [Mon, 24 Aug 2015 06:30:46 +0000 (08:30 +0200)]
libmagic: supply own ctype macros

Due to the current linker command line ordering, parts of lib(min)c
that are used exclusively by libmagic end up not being instrumented,
which then causes problems transferring pointers such as _ctype_tab_
and _tolower_tab_.  As a temporary workaround, we redefine the macros
that use those pointers.  A better long-term solution should
eventually render this patch obsolete.

Change-Id: Ice1d125ff6fb2f65ac6dcc6cf6eec7cd6176bee1

9 years agolibmagic: ignore kernel pointers on MINIX3 60/3160/1
David van Moolenbroek [Mon, 10 Aug 2015 13:45:35 +0000 (15:45 +0200)]
libmagic: ignore kernel pointers on MINIX3

Change-Id: I8830cab3d6637bae6141dc2b0e209d319703787f

9 years agoMake more services use stateful live update 59/3159/1
David van Moolenbroek [Wed, 2 Sep 2015 02:49:18 +0000 (04:49 +0200)]
Make more services use stateful live update

Change-Id: If2e5b8e56fef633e471ec1cbb6e08ce3496ea755

9 years agotests: extend multicomponent live update test 58/3158/1
David van Moolenbroek [Fri, 17 Jul 2015 02:07:49 +0000 (04:07 +0200)]
tests: extend multicomponent live update test

- test multicomponent live update with and without rs and/or vm;
- retry the update a few times if the failure code suggests it might
  be a transient failure.

Change-Id: I5fce256bb418be257353ed21428f672d851d974d

9 years agotests: improve testrelpol.sh robustness 57/3157/1
David van Moolenbroek [Wed, 15 Jul 2015 11:04:40 +0000 (13:04 +0200)]
tests: improve testrelpol.sh robustness

- fix a TOCTOU bug;
- stop the script on permanent failure.

Change-Id: I570cce3427945ad34d283ded013219c93402ddf9

9 years agotests: remove VM exceptions from testrelpol.sh 56/3156/1
David van Moolenbroek [Wed, 15 Jul 2015 08:47:45 +0000 (10:47 +0200)]
tests: remove VM exceptions from testrelpol.sh

Change-Id: Ied1db7e77d1849ecb5e92fe9694bb395983c6122

9 years agoRS: remove support for unsafe updates 55/3155/1
David van Moolenbroek [Wed, 15 Jul 2015 08:46:04 +0000 (10:46 +0200)]
RS: remove support for unsafe updates

This feature should no longer be necessary.

Change-Id: I9bff628be020cf1741bffaeb3bb97e3660a54aea

9 years agoVM: allocate cache pages in mmap region 54/3154/1
David van Moolenbroek [Sun, 6 Sep 2015 14:56:30 +0000 (16:56 +0200)]
VM: allocate cache pages in mmap region

That way, these pages are transferred during live update, as they
should.  This resolves a mfs crash after a number of live updates.

Change-Id: Ia53bec2692b2114c29b96a453beb0f915f56453a

9 years agoImprove asynsend support for process swapping 53/3153/1
David van Moolenbroek [Sun, 6 Sep 2015 14:54:42 +0000 (16:54 +0200)]
Improve asynsend support for process swapping

This resolves various system stalls while running testrelpol.

Change-Id: Ie70fc2dbcdb0a8c9e3800cc0df564be747e111ec

9 years agoIgnore a new ARM driver entry for instrumentation 52/3152/1
David van Moolenbroek [Tue, 1 Sep 2015 09:50:20 +0000 (11:50 +0200)]
Ignore a new ARM driver entry for instrumentation

Change-Id: I710a7534d2ba41107641252b9f80f197d04ba107

9 years agoDisable malloc instrumentation for VM (#2) 51/3151/1
David van Moolenbroek [Sun, 6 Sep 2015 09:16:12 +0000 (11:16 +0200)]
Disable malloc instrumentation for VM (#2)

When the malloc code is instrumented, the global _brksize variable
should not be transferred.  However, when the malloc code is not
instrumented, failing to transfer _brksize would reset the heap
upon state transfer.  In this patch, the magic pass stores the flag
indicating whether memory function instrumentation is disabled, in
the target process.  This allows libmagic to check this flag during
state transfer, to see whether it should transfer _brksize or not.

Change-Id: Ia004651e21e08b0ed3f5305865c53c6659e18f38

9 years agoDisable malloc instrumentation for VM (#1) 50/3150/1
David van Moolenbroek [Tue, 1 Sep 2015 04:12:47 +0000 (06:12 +0200)]
Disable malloc instrumentation for VM (#1)

This patch changes the VM makefile to specify that the magic pass is
to skip memory function instrumentation, and to transfer the data
variables of the malloc code (thus overriding the exception we made
for all other system services).  We add two magic pass flags to
achieve this.  Since the magic pass is a big bowl of spaghetti code,
ignoring whitespace changes while viewing this patch is recommended.

Change-Id: I5ab83b23d8437b37c44dea99537bc202469c9df6

9 years agoFix mmap leak in malloc code upon state transfer 49/3149/1
David van Moolenbroek [Wed, 26 Aug 2015 05:57:03 +0000 (07:57 +0200)]
Fix mmap leak in malloc code upon state transfer

The NetBSD libc malloc implementation uses a memory-mapped area for
its page directory.  Since the process heap is reconstructed upon
state transfer for live update, this memory-mapped area must not be
transferred to the new process.  However, as the new instance of the
process being updated inherits all memory-mapped areas of the old
instance, it also automatically inherits the malloc implementation's
page directory.  Thus, we must explicitly free this area in order to
avoid a memory leak.

The magic pass already detects (de)allocation functions called from
within other (de)allocation functions, which is why the mmap(2) and
munmap(2) calls of the malloc code are not instrumented as it is.
This patch changes that particular case to allow a different hook
function to be called for such "nested" allocation calls, for a
particular set of nested calls.  In particular, the malloc(3) code's
mmap(2) and munmap(2) calls are replaced with magic_nested_mmap and
magic_nested_munmap calls, respectively.  The magic library then
tracks memory mapping allocations of the malloc code by providing an
implementation for these two wrappers, and frees the allocations upon
state transfer.

This approach was chosen over various alternatives:

- While it appears that nesting could be established by setting a
  flag while the malloc(3) wrapper is active, and testing the flag in
  the mmap(2)/munmap(2) wrappers, this approach would fail to detect
  memory-mapped allocations made from uninstrumented malloc(3) calls,
  and therefore not a viable option.
- It would be possible to obtain the value of the variables that
  store the information about the memory-mapped area in the malloc
  code.  However, this is rather difficult in practice due to the way
  the libc malloc implementation stores the size of the are, and it
  would make the solution more dependent on the specific libc malloc
  implementation.
- It would be possible to use the special "nested" instrumentation
  for allocations made from certain marked sections.  Since we mark
  the data section of the malloc code already, this would not be hard
  to do.  Switching to this alternative would change very little, and
  if for any reason this approach yields more advantages in the
  future, we can still choose to do so.

Change-Id: Id977405da86a72458dd10f18e076d8460fd2fb75

9 years agoDo not instrument malloc implementation variables 48/3148/1
David van Moolenbroek [Wed, 26 Aug 2015 05:33:06 +0000 (07:33 +0200)]
Do not instrument malloc implementation variables

Since the heap is reconstructed upon state transfer, the old malloc
state is discarded.  In order to avoid state transfer errors, we can
and in fact must discard the internal state of the malloc
implementation.  This patch achieves this by using the sectionify
pass to mark the variables in the libminc malloc object as state that
must be skipped during state transfer.

Change-Id: Ie330f582c8bd45f37a878ea41fa0f9d4a18045e1

9 years agoRS/VM: proper preparation for multi-VM live update 47/3147/1
David van Moolenbroek [Tue, 14 Jul 2015 05:42:48 +0000 (07:42 +0200)]
RS/VM: proper preparation for multi-VM live update

Due to changed VM internals, more elaborate preparation is required
before a live update with multiple components including VM can take
place.  This patch adds the essential preparation infrastructure to
VM and adapts RS to make use of it.  As a side effect, it is no
longer necessary to supply RS as the last component (if at all)
during the set-up of a multicomponent live update operation.

Change-Id: If069fd3f93f96f9d5433998e4615f861465ef448

9 years agoVM: undo actions after live-update rollback 46/3146/1
David van Moolenbroek [Tue, 14 Jul 2015 04:44:35 +0000 (06:44 +0200)]
VM: undo actions after live-update rollback

During live update, the new instance of VM may make changes that,
after a rollback, have to be undone by the old instance of VM, in
particular because both instances share (read-write) all dynamically
allocated pages.

Change-Id: I2bcfa8e627ca6084b1991e0af7cccecc683894a2

9 years agolibmagic: free actual dsentry rather than a copy 45/3145/1
David van Moolenbroek [Fri, 17 Jul 2015 19:36:58 +0000 (21:36 +0200)]
libmagic: free actual dsentry rather than a copy

This resolves an infinite loop during boot, in libblockdriver freeing
DMA memory at the end of a partition(3) call.

Change-Id: I0757aa48f769ea79eab7160f23ee4c97cf58e055

9 years agoBreak loose from llvm-apps entirely 44/3144/1
David van Moolenbroek [Sun, 5 Jul 2015 16:01:13 +0000 (18:01 +0200)]
Break loose from llvm-apps entirely

Change-Id: I532f5f44c785c1a72407b504568d54fc6cbabf8f

9 years agoImport magic library from llvm-apps 43/3143/1
David van Moolenbroek [Tue, 30 Jun 2015 16:19:11 +0000 (18:19 +0200)]
Import magic library from llvm-apps

Change-Id: Icfbcfae6afc731a23e71448a7a5d0045b2c219e5

9 years agoImport magic pass from llvm-apps 42/3142/1
David van Moolenbroek [Mon, 29 Jun 2015 23:25:43 +0000 (01:25 +0200)]
Import magic pass from llvm-apps

Change-Id: I19535b913b50f2ff24aeb80ddefc92e305c31fe8

9 years agoImport sectionify pass from llvm-apps 41/3141/1
David van Moolenbroek [Tue, 30 Jun 2015 15:58:12 +0000 (17:58 +0200)]
Import sectionify pass from llvm-apps

Change-Id: I3e3ac102b4898ca22ed1d9c25ec309d77bbe32de

9 years agoLLVM passes: centralize Makefile structure 40/3140/1
David van Moolenbroek [Mon, 31 Aug 2015 14:46:42 +0000 (16:46 +0200)]
LLVM passes: centralize Makefile structure

Make the passes we have so far, hello and WeakAliasModuleOverride,
use settings from a Makefile include file in the parent directory.
This change is in preparation of adding other passes.

Change-Id: Ib195ee7f5c7626f4975368b02c944382e87e3814

9 years agox86_hdimage: increase image size for bitcode build 39/3139/1
Erik van der Kouwe [Wed, 6 Aug 2014 13:11:22 +0000 (15:11 +0200)]
x86_hdimage: increase image size for bitcode build

Make disk image size sufficient for LLVM bitcode build with symbols.

Edited by David van Moolenbroek to do this only when -b is given.

Change-Id: I3bde164756c477b4af5ed9435ca03da3b186cf7e

9 years agoBitCode: Fix Dynamic Binaries 38/3138/1
Lionel Sambuc [Wed, 6 May 2015 14:53:33 +0000 (16:53 +0200)]
BitCode: Fix Dynamic Binaries

Change-Id: I7f3b775426a0c79969c7efc7a9970683b9dd950c

9 years agoSupport BUILDVARS from cmd line in configure.llvm 37/3137/1
Lionel Sambuc [Wed, 28 Jan 2015 14:04:27 +0000 (15:04 +0100)]
Support BUILDVARS from cmd line in configure.llvm

Change-Id: I59527c60cb34c12fd2bed449b37bb812a83c4e42

9 years agollvm: Never rebuild gold in configure.llvm. 36/3136/1
Cristiano Giuffrida [Wed, 28 Jan 2015 13:30:38 +0000 (14:30 +0100)]
llvm: Never rebuild gold in configure.llvm.

Change-Id: I7378ca38a5a9bf018823b6431d1a4ca8fbb10b58

9 years agollvm: Fix OPTFLAGS. 35/3135/1
Cristiano Giuffrida [Wed, 28 Jan 2015 12:40:19 +0000 (13:40 +0100)]
llvm: Fix OPTFLAGS.

Change-Id: Id35ac2821ad69825735c50a32bdd04d8453edb22

9 years agoQEMU default command lines updates 34/3134/1
Lionel Sambuc [Fri, 23 Jan 2015 17:30:39 +0000 (18:30 +0100)]
QEMU default command lines updates

 - Fix a bug in clientctl which tried to test for kvm. This simply
   remove this faulty test  as the kvm command has been deprecated by the
   QEMU project for a couple of years now.

 - Specify by default 256M of RAM as this is the minimal amount required
   for the whole-OS live update test to succeed.

 - Update the default command printed out at the end of the x86_hdimage
   script to be more generic, less focused on one use-case.

Change-Id: Ic555d50a3a1471f7d35cc7fd369f2292add6ac39

9 years agoreleasetools: Fix CREATE_IMAGE_ONLY in x86 hdimage script. 33/3133/1
Cristiano Giuffrida [Mon, 29 Dec 2014 02:07:57 +0000 (03:07 +0100)]
releasetools: Fix CREATE_IMAGE_ONLY in x86 hdimage script.

Change-Id: Ie1c8dbedc16b8edac16f5b76b36df30b3a4eddb1

9 years agollvm: Build scripts improvements. 32/3132/1
Cristiano Giuffrida [Sun, 28 Dec 2014 12:20:47 +0000 (13:20 +0100)]
llvm: Build scripts improvements.

Change-Id: I278cdebccdba18be7e264bfd240ff02d4480b33c

9 years agollvm: Extend clientctl with many features. 31/3131/1
Cristiano Giuffrida [Mon, 22 Sep 2014 06:24:01 +0000 (08:24 +0200)]
llvm: Extend clientctl with many features.

Change-Id: I739eefa46458e956cb79c42a8cbf880428eec794

9 years agollvm: Fix module map generation. 30/3130/1
Cristiano Giuffrida [Mon, 29 Sep 2014 07:36:13 +0000 (09:36 +0200)]
llvm: Fix module map generation.

Change-Id: If9c2bef4c0ef3d002ac65a2c66aabcf0cf99ff95

9 years agollvm: Improve error handling in configure.llvm. 29/3129/1
Cristiano Giuffrida [Wed, 10 Sep 2014 16:17:18 +0000 (18:17 +0200)]
llvm: Improve error handling in configure.llvm.

Change-Id: I9aa8f8a07a512f642447c70dca2e85d40ebe2b2a

9 years agoKernel: IPC filter support for VM memory requests 28/3128/1
David van Moolenbroek [Sun, 12 Jul 2015 05:58:07 +0000 (07:58 +0200)]
Kernel: IPC filter support for VM memory requests

The filtering also exposed the risk that a process be killed or
swapped while on the list of VM memory requests.  These cases are
now handled properly as well.

Change-Id: Ibd3897b34abdf33bce19d37b8e5f65fbd0fd9316

9 years agoVM: set recovery policy to restart 27/3127/1
Lionel Sambuc [Mon, 26 Jan 2015 14:09:05 +0000 (15:09 +0100)]
VM: set recovery policy to restart

 - Update proc to select restart policy for VM
 - Update testrelpol to test the supported modes of recovery for VM
 - Small code cleanups in testrelpol as well.

Change-Id: I6958e100865c2429b9435f3f7cc7d018046378c3

9 years agoVM: fix mmap region transfer range bug 26/3126/1
David van Moolenbroek [Sun, 12 Jul 2015 17:21:38 +0000 (19:21 +0200)]
VM: fix mmap region transfer range bug

A missing check to see whether the range being transferred is sane
(with a starting address lower than an ending address) caused extra
memory to be marked erroneously as copy-on-write for some processes,
ultimately resulting in pagefaults on the stack during live update
rollback.

Change-Id: I1516b509b485379606d8df05b8a0f514896a0f19

9 years agoVM: live update - check for regions above stack 25/3125/1
Dirk Vogt [Mon, 19 Jan 2015 14:20:30 +0000 (15:20 +0100)]
VM: live update - check for regions above stack

If the stack is not mapped at the VM_DATATOP (e.g. booted with
ac_layout = 1), there might be some more regions hiding above
the stack.  We also have to transfer those.

Change-Id: Idf3b94a36fcec8a10ace2f6dffe816faf0a88f60

9 years agoRS: synchronize priv from kernel after swap 24/3124/1
Ben Gras [Fri, 16 Jan 2015 13:24:24 +0000 (14:24 +0100)]
RS: synchronize priv from kernel after swap

. make sure the priv id etc is maintained so
  future privctl talk about the right thing
. solves broken IPC after update

Change-Id: I17ed0212c22d634e6db1e80f8dcb2fb8bffe82c6