scripts/release-s3: Fix OSv QCOW2 image release script

As of commit 31fee0f ("build: Build images as QCOW2 files.") we no
longer build raw images.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader.py: fix indentation

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
script/imgedit.py: Remove the usage of O_DIRECT by qemu-nbd.

This prevented the script to work on tmpfs.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Use constants for CR0 and CR4 values

Replace magic numbers with constants for CR0 and CR4 control register
values in arch/x86/boot.S.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: Drop find_vma()

It's preferable to use equal_range() to do VMA lookups so drop the
unused find_vma() function.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
eventlist: remove

Dead code, and boost::signals2::signal<> does the job better.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Multiple NIC support

This patch adds to support multiple NIC initialization on loader.cc.

Signed-off-by: Takuya ASADA <syuu@dokukino.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Fix stack alignment in fault handlers

Make sure stack pointer is 16-byte aligned in fault handler as required
by x86-64 ABI. This is needed for the page fault handler to be able to
use stack for FPU state save/restore.

Spotted by Nadav.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: VMA permission flags

Add permission flags to VMAs. They will be used by mprotect() and the
page fault handler.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: Anonymous memory demand paging

Switch to demand paging for anonymous virtual memory.

I used SPECjvm2008 to verify performance impact. The numbers are mostly
the same with few exceptions, most visible in the 'serial' benchmark.
However, there's quite a lot of variance between SPECjvm2008 runs so I
wouldn't read too much into them.

As we need the demand paging mechanism and the performance numbers
suggest that the implementation is reasonable, I'd merge the patch as-is
and see optimize it later.

  Before:

    Running specJVM2008 benchmarks on an OSV guest.
    Score on compiler.compiler: 331.23 ops/m
    Score on compiler.sunflow: 131.87 ops/m
    Score on compress: 118.33 ops/m
    Score on crypto.aes: 41.34 ops/m
    Score on crypto.rsa: 204.12 ops/m
    Score on crypto.signverify: 196.49 ops/m
    Score on derby: 170.12 ops/m
    Score on mpegaudio: 70.37 ops/m
    Score on scimark.fft.large: 36.68 ops/m
    Score on scimark.lu.large: 13.43 ops/m
    Score on scimark.sor.large: 22.29 ops/m
    Score on scimark.sparse.large: 29.35 ops/m
    Score on scimark.fft.small: 195.19 ops/m
    Score on scimark.lu.small: 233.95 ops/m
    Score on scimark.sor.small: 90.86 ops/m
    Score on scimark.sparse.small: 64.11 ops/m
    Score on scimark.monte_carlo: 145.44 ops/m
    Score on serial: 94.95 ops/m
    Score on sunflow: 73.24 ops/m
    Score on xml.transform: 207.82 ops/m
    Score on xml.validation: 343.59 ops/m

  After:

    Score on compiler.compiler: 346.78 ops/m
    Score on compiler.sunflow: 132.58 ops/m
    Score on compress: 116.05 ops/m
    Score on crypto.aes: 40.26 ops/m
    Score on crypto.rsa: 206.67 ops/m
    Score on crypto.signverify: 194.47 ops/m
    Score on derby: 175.22 ops/m
    Score on mpegaudio: 76.18 ops/m
    Score on scimark.fft.large: 34.34 ops/m
    Score on scimark.lu.large: 15.00 ops/m
    Score on scimark.sor.large: 24.80 ops/m
    Score on scimark.sparse.large: 33.10 ops/m
    Score on scimark.fft.small: 168.67 ops/m
    Score on scimark.lu.small: 236.14 ops/m
    Score on scimark.sor.small: 110.77 ops/m
    Score on scimark.sparse.small: 121.29 ops/m
    Score on scimark.monte_carlo: 146.03 ops/m
    Score on serial: 87.03 ops/m
    Score on sunflow: 77.33 ops/m
    Score on xml.transform: 205.73 ops/m
    Score on xml.validation: 351.97 ops/m

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: MAP_POPULATE support for anon mmap()

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Anonymous mmap microbenchmark

This adds a simple mmap and write microbenchmark that can be run on both
OSv and Linux.  The same test is run for both demand paged and
pre-populated memory region using MAP_POPULATE flag with mmap().

The numbers on 2-core Sandy Bridge i7 are as follows in an OSv guest:

       time (seconds)
   MiB demand populate
     1 0.008  0.002
     2 0.001  0.001
     4 0.002  0.002
     8 0.004  0.004
    16 0.010  0.008
    32 0.018  0.017
    64 0.036  0.034
   128 0.074  0.068
   256 0.145  0.135
   512 0.406  0.271
  1024 0.792  0.541

For reference, running the same test on Linux host gives:

       time (seconds)
   MiB demand populate
     1 0.003  0.003
     2 0.006  0.005
     4 0.012  0.011
     8 0.023  0.023
    16 0.046  0.045
    32 0.091  0.085
    64 0.175  0.170
   128 0.350  0.340
   256 0.694  0.681
   512 1.384  1.361
  1024 2.888  2.732

The numbers suggest that there's room for improvement in OSv's demand
paging code but the overall performance is reasonable for now.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: mincore() tests for demand paging

As suggested by Nadav, add tests for mincore() interraction with demand
paging.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>