trace: support time slicing options in `trace summary`

The summary will only include samples within the specified range.
Timed samples will be trimmed to the given time range.

Requested-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
fpu: early save/restore in interrupt/exception context

Since we cannot guarantee that the fpu will not be used in interrupts and
exceptions, we must save it earlier rather than later.

This was discovered with an fpu-based memcpy, but can be triggered in other
ways.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
elf: allow elf_resolve_pltgot() to use the fpu

elf_resolve_pltgot() can be called from anywhere, including with dirty fpu
state.  Ensure the fpu is not clobbered during its execution.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
rwlock: helpers for WITH_LOCK and friends

Implement facades for rwlock so it can be used with WITH_LOCK, specifying
whether we want a read lock or a write lock:

  rwlock my_rwlock;

  WITH_LOCK(my_rwlock.for_read()) {
    read stuff
  }

  WITH_LOCK(my_rwlock.for_write()) {
    write stuff
  }

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vitio::net: Fix the description of try_xmit_one_locked(net_req*)

try_xmit_one_locked(net_req*) doesn't return EINVAL anymore. The appropriate
code has moved to xmit_prep().

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
syscalls: implement getpeername()

getpeername() is required by iperf in client mode

without it iperf crashes as following:

[/]% run /tools/iperf.so -c 10.0.0.144
Failed looking up symbol getpeername

[backtrace]
0x00000000003326a2 <elf::object::resolve_pltgot(unsigned int)+82>
0x0000000000369b42 <__elf_resolve_pltgot+46>
0x0000100004207535 <Client::Client(thread_Settings*)+301>
0x0000100004208b44 <client_spawn+50>
0x000010000421323a <thread_stop+272>
0x0000000000412ca5 <sync+69>
0x00000000003b2eea <thread_main_c+26>
0x000000000036ae95 <thread_main+7>

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio::net: implement tx_xmit_iterator using boost::function_output_iterator

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Revert "Revert "memcpy: aggressive unrolling""

This reverts commit f931188409f028290ba090e82e759f06768e40b9.  The fpu
vulnerabilities have been fixed (202b2ccc, d9addd0b9), so fpu-based memcpy
should work now.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
release-ec2: always authenticate with AWS credentials

Avoid using X.509 keypair because it became deprecated
and not generally available to person doing release.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Add __h_errno_location

This is needed to run iperf3.

https://github.com/cloudius-systems/osv/issues/305

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: integrate memory-analyzer with trace.py

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: filter memory analyzer output by minimum allocation count

Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: sort memory allocations by given criteria

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: group memory allocations by given criteria

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: show backtraces in memory allocator

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: allow custom printers in memory analyzer

Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Add testcase to /dev/console

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Separate Capstan and VM image building

This separates Capstan and VM image building into two scripts. This is
needed to be able to drop useless VM images like "osv-base" or
"osv-openjdk" that only make sense as Capstan base images, not
standalone VM images that people boot to.

Cc: Tzach Livyatan <tzach@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: fix madvice(MADV_DONTNEED)

Fix madvice(MADV_DONTNEED) to use correct page ops for a VMA. Don't try
to use what we have today on mmaped files.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
rwlock: replace condition variables with waitqueues

Waitqueues fullfil the same role as condition variables, but are much lighter
since they rely on an external mutex, which is already provided by rwlock.

Replacing condvars by waitqueues significantly reduces the size of an rwlock,
and in addition reduces the number of atomic operations in contended cases
significantly.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>