memory: poison newly allocator objects in the debug allocator

Fill newly allocated memory with a well known pattern (byte, byte+1,
byte+2, ...) to catch uses of uninitialized memory.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader: Enable debug allocator before ACPI init

The ACPI subsystem uses the memory allocator a lot so enable the debug
allocator before initializing it to detect boot-time problems.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
drivers/xenfront-xenbus: Fix condvar_wait() timeout

condvar_wait() expects an absolute time, not a duration.

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.

  SPECjvm 2008 (higher is better)

  Baseline:

  Score on compiler.compiler: 347.06 ops/m
  Score on compiler.sunflow: 132.17 ops/m
  Score on compress: 107.59 ops/m
  Score on crypto.aes: 41.92 ops/m
  Score on crypto.rsa: 217.27 ops/m
  Score on crypto.signverify: 201.62 ops/m
  Score on derby: 184.81 ops/m
  Score on mpegaudio: 78.86 ops/m
  Score on scimark.fft.large: 35.91 ops/m
  Score on scimark.lu.large: 14.36 ops/m
  Score on scimark.sor.large: 26.16 ops/m
  Score on scimark.sparse.large: 37.64 ops/m
  Score on scimark.fft.small: 176.99 ops/m
  Score on scimark.lu.small: 222.76 ops/m
  Score on scimark.sor.small: 115.81 ops/m
  Score on scimark.sparse.small: 119.97 ops/m
  Score on scimark.monte_carlo: 141.17 ops/m
  Score on serial: 100.48 ops/m
  Score on sunflow: 79.54 ops/m
  Score on xml.transform: 217.30 ops/m
  Score on xml.validation: 349.88 ops/m

  Demand paging:

  Score on compiler.compiler: 338.57 ops/m
  Score on compiler.sunflow: 119.20 ops/m
  Score on compress: 120.18 ops/m
  Score on crypto.aes: 43.16 ops/m
  Score on crypto.rsa: 211.69 ops/m
  Score on crypto.signverify: 203.66 ops/m
  Score on derby: 181.10 ops/m
  Score on mpegaudio: 80.90 ops/m
  Score on scimark.fft.large: 34.15 ops/m
  Score on scimark.lu.large: 11.19 ops/m
  Score on scimark.sor.large: 22.99 ops/m
  Score on scimark.sparse.large: 36.62 ops/m
  Score on scimark.fft.small: 203.09 ops/m
  Score on scimark.lu.small: 236.72 ops/m
  Score on scimark.sor.small: 116.75 ops/m
  Score on scimark.sparse.small: 126.98 ops/m
  Score on scimark.monte_carlo: 152.86 ops/m
  Score on serial: 98.28 ops/m
  Score on sunflow: 78.93 ops/m
  Score on xml.transform: 216.34 ops/m
  Score on xml.validation: 381.52 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() performance test

This adds a simple mmap + write performance test that can be run on both
OSv and Linux.

The numbers on 2-core Sandy Bridge i7 are as follows:

  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

  Linux host

       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

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>