xen/arm: p2m: Introduce a function to resolve translation fault
authorJulien Grall <julien.grall@arm.com>
Mon, 16 Jul 2018 14:49:03 +0000 (15:49 +0100)
committerJulien Grall <julien.grall@arm.com>
Wed, 12 Dec 2018 16:06:52 +0000 (16:06 +0000)
commit70c92d989ea68ebb898b32e836ce6493b1197395
tree90a75572b349af34a02661bc4f378682e8ae9a19
parent6d6be98ca52ca977fb3deb4d6f665bcfb84a8ec7
xen/arm: p2m: Introduce a function to resolve translation fault

Currently a Stage-2 translation fault could happen:
    1) MMIO emulation
    2) Another pCPU was modifying the P2M using Break-Before-Make
    3) Guest Physical address is not mapped

A follow-up patch will re-purpose the valid bit in an entry to generate
translation fault. This would be used to do an action on each entry to
track pages used for a given period.

When receiving the translation fault, we would need to walk the pages
table to find the faulting entry and then toggle valid bit. We can't use
p2m_lookup() for this purpose as it only tells us the mapping exists.

So this patch adds a new function to walk the page-tables and updates
the entry. This function will also handle 2) as it also requires walking
the page-table.

The function is able to cope with both table and block entry having the
validate bit unset. This gives flexibility to the function clearing the
valid bits. To keep the algorithm simple, the fault will be propating
one-level down. This will be repeated until a block entry has been
reached.

At the moment, there are no action done when reaching a block/page entry
but setting the valid bit to 1.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/p2m.c
xen/arch/arm/traps.c
xen/include/asm-arm/p2m.h