mmu: consolidate code in map_file_page_mmap alloc/free

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: split mmu-defs.hh header

arch-mmu.hh depend on mmu.hh currently which make it impossible to
include in header that mmu.hh itself includes. mmu.hh is pretty heavy
header containing many definitions and code, so move bare definitions
into separate header file.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: track mapping between ARC pages and ptep instead of virtual address

Currently we track mapping between ARC pages and virtual addresses which
require us to walk the page table to get to a pte pointer when invalidation
is required. Change that to track pointers to pte directly.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: constify hw_ptep methods that do not change pte it points to

This allows those function to be called on const object.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: map file private mappings with small pages too.

Private mapping are also done from ARC cache and have same problem as
shared mappings.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: save flags passed during file mapping in a vma.

Currently flags are saved for anon_vma, but not for file_vma. Examining
those flags in gdb proved to be helpful. Remove _shared since it no
longer needed, the information is in the flags.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: pass type of a page fault (r/w) to a page allocator

Page allocation may behave differently depending on a type of a fault.
Read fault may return ARC page, but write may do cow for instance.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: return COW status from page allocators

Page allocator may return shared page that needs to be COWed during
write access. There is not way to notify page mapper that such page
should be mapped read only currently. This patch allows page allocator
to control that.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: rename _map_offset into _foffset in map_file_page_mmap

It holds offset into file, not mapping. Also to be consistent with
map_file_page_read.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: pass fault type and shared status to fd->get_page() return cow status

File page allocator needs to know fault type (read/write) and mapping
type (shared/private) to handle page allocation correctly. It also needs
a way to communicate to a caller that some pages need to be mapped RO
for COW. This patch adds required functionality without using it yet.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
mmu: add write pagecache implementation on top of ARC

This patch adds write page cache implementation. On a read fault pages
are initially mapped from ARC directly, but they are marked as RO in a
page table. On a write fault pages are copied into small write page
cache for shared mapping, or into anonymous page for private mappings.
Pages are removed from write cache and written back into a file in FIFO
order.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Revert "uio: super structure around uio"

This reverts commit 64889277bc3c36dde9f8168642b85f37b5cd8f46.

The structure is not longer used.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Merge branch 'pagecache' of https://github.com/gleb-cloudius/osv

"
This is write page cache implemented on top of ARC read cache. On a
read fault pages are initially mapped from ARC directly, but they are
marked as RO in a page table. On a write fault pages are copied into
small write page cache for shared mapping, or into anonymous page for
private mappings.  Pages are removed from write cache and written back
into a file in a FIFO order.

This passes "make check", misc-mmap-big-file modified to do write in
addition to read and "cassandra-stress -d".
"

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>