libc: implement stub function for execve

Porting CRuby now, and this is call execve and etc.  I won't support exec from
Ruby, so this function just need to fail.

Signed-off-by: KANATSU Minoru <icc.pot.tyew272@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
dhcp: Print IP address by default

Current OSv implementation suppress most of output when it's not verbose mode.

It may speed up bootup speed, but supress printing out IP address is
inconvenient for most of users.  So I added infof(), which acts like debugf()
but print out string even not on verbose mode, and use it in dhcp.cc to print
out IP address.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
README: Advertise need of tcpdump and gdb

They are needed by trace.py, which is now run as part of 'make check'
harness.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: Commit original BSD random files in their unmodified state

Glauber says:
I would advise commiting the original files from BSD in their unmodified state
(don't include them in the build), and in a different patch put on the changes
that OSv needs.
It has proven useful more than once for me in conjunction with git blame to
determine whether a snippet was already in the BSD code or was ours.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: crypto: Port rijndael to OSv

rijndael encryption algorithm is a dependency for porting the
random infrastructure from FreeBSD, so let's add it into our
BSD tree.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: Add snippets of code needed by random infrastructure

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: Port random infrastructure from FreeBSD

Simply put, FreeBSD-specific code such as SYSCTL API, etc, was disabled.
Besides, I had gone throughout the code, and made sure that the overall
semantics remained the same on OSv.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
drivers: Change random to use Yarrow CPRNG and add urandom as an alias

This patch changes the device behind /dev/random to start using FreeBSD Yarrow
CPRNG algorithm. Similar to FreeBSD, our /dev/urandom was created as an alias
to /dev/random.
The device operations are linked to Yarrow through the random adaptor API.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
drivers: Register virtio-rng as a hardware source of entropy

It will be used by random_kthread from Yarrow as a hardware source of entropy
whenever the thread wakes up, which happens around 10 times a second.

Systems that don't provide a hardware for rng will lack the property, then
should gather environmental noise from specific interrupts.
Systems that do provide will still gather environmental noise from interrupts
if available, and do 'one round' of gathering from the rng hardware.

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Add simple test case to /dev/urandom

Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pagecache: map zero page instead of ARC page for hole in a file

Attempt to get read ARC buffer for a hole in a file results in temporary
ARC buffer which is destroyed immediately after use. It means that
mapping such buffer is impossible, it is unmapped before page fault
handler return to application. The patch solves this by detecting that
hole in a file is accessed and mapping special zero page instead. It is
mapped as COW, so on write attempt new page is allocated.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: support tracepoint signatures of arbitrary length

Currently tracepoint's signature string is encoded into u64 which
gives 8 character limit to the signature. When signature does not fit
into that limit, only the first 8 characters are preserved.

This patch fixes the problem by storing the signature as a C string of
arbitrary length.

Fixes #288.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tests: add test for tracepoint with nine arguments

Exploits issue #288.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Update file API

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run.py: Add support VMware

This patch enables to run OSv on VMware using run.py.
Both serial console and VGA are supported.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio-vring: prevent delaying a kick() for more than half of a u16 range

(u16)_avail_added_since_kick wrap-around should be avoided since we may loose
an _avail_event update and thus miss the point where the HV should have
been woken (kicked).

We choose half a u16 range as a threshold since kick() is usually called for a
bulk of buffers and not for every separate buffer. Number of buffers in such a bulk is
limited by a size of a virtio ring. The virtio ring size is unlikely to have 32K
entries in the nearest future (it has 256 entries now) thus kicking() at least
every 32K buffers will ensure that we prevent the mentioned above wrap-around
as a result of such a bulking.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: get interval to correct field of itimerval

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
net: hide tcpcb.t_state behind setters and getter

This will allow to insert tracepoint invocation in the setter which
will cover all occurrences of TCP control block state change.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
net: add tcp_state tracepoint

This tracepoint is invoked whenever TCP state is changed.

Example output:

  tcp_state     tp=0xffffc0003dbb6c00, 6 -> 9

There is no pretty-printer yet for state numbers, they can be decoded
using defines from tcp_fsm.h.

It's useful when tracing reaction of the stack on particular network
packets, when used together with net_packet* tracepoints and 'trace
list --tcpdump'. We can also get information from which code location
given state was changed, by enabling backtrace collection and using
-b[-L][-F] flags to 'trace list'.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: cleanup packet tracing

The current tracepoint coverage does not handle all situations
well. In particular:

 * it does not cover link layer devices other than virtio-net. This
   change fixes that by tracing in more abstract layers.

 * it records incoming packets at enqueue time, whereas sometimes it's
   better to trace at handling time. This can be very useful when
   correlating TCP state changes with incoming packets. New tracepoint
   was introduced for that: net_packet_handling.

 * it does not record protocol of the buffer. For non-ethernet
   protocols we should set appropriate protocol type when
   reconstructing ethernet frame when dumping to PCAP.

We now have the following tracepoints:

 * net_packet_in - for incoming packets, enqueued or handled directly.

 * net_packet_out - for outgoing packets hitting link layer (not
   loopback).

 * net_packet_handling - for packets which have been queued and are
   now being handled.

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