mmu: Move code around

Move code that will be needed by unified page walker. No changes to
generated code.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: generic page table walker based on linear_map_level

This patch implements generic page table walker that traverse page table
levels in compile time. It accepts page_mapper class, that controls
various aspects of page traversing, as a parameter.  page_table_operation
controls whether non present intermediate page should be allocated,
how to handle leaf small/huge pages, whether to split huge pages, how to
handle sub area of a huge page in case splitting is disabled and whether
walker should loop over multiple page entries.

linear_map_level() is modified to use new page walker.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: convert populate/unpopulate/protect page walkers to the generic page walker

This is pretty straightforward: provide page_mapper variant for each of
those operations, remove unused pt walker.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: convert virt_to_phys_pt() page walker to generic one

Implement page_mapper variant for virt_to_phys mapping.  map_level class
now hold a reference to page_mapper since page_mapper state needs to be
preserved over function calls.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: add constexpr to some functions

Add constexpr to make sure they are evaluated in compile time if
possible. Compiler will probably do it anyway though.

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