Exile spinlock to a separate file

In very early OSv history, the spinlock was used in the mutex's
implementation so it made sense to put it in mutex.cc and mutex.h.

But now that the spinlock is all that's left in mutex.cc (the real mutex
is in lfmutex.cc), rename this file spinlock.cc. Also, move the spinlock
definitions from <osv/mutex.h> to a new <osv/spinlock.h>, so if someone
wants to make the grave mistake of using a spinlock - they will at least
need to explicitly include this header file.

Currently, the only remaining user of the spinlock is the console.
Using a spinlock (and not a mutex) in the console allows printing debug
messages while preemption is disabled. Arguably, this use-case is no
longer important (we have tracepoints), so in the future we can consider
dropping the spinlock completely.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
OSv Coding Style

This document describe OSv coding style.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: Add size argument to vma::fault()

We need huge page detection in file_vma::fault() as well so move the
logic to vm_fault() and add a 'size' argument to vma::fault().

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: File-backed VMA dirty page tracking

This adds a dirty page tracking to file-backed vma.  Dirty pages are
tracked with 4K granularity in a std::vector<bool> bitmap in file_vma.
The file_vma::fault() handler updates the bitmap on write page faults
and then remaps the pages as read-write.  If we fault on a huge page, we
simply set bits for each of the 4K page in the huge page range.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mmu: Don't write out clean pages

Use the dirty page bitmap to avoid writing out VMAs that only contain
clean pages.

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