x86/pagewalk: Consistently use guest_walk_*() helpers for translation
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 24 May 2016 14:46:01 +0000 (15:46 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 9 Mar 2017 17:01:05 +0000 (17:01 +0000)
commit9dc1e0cd81ee469d638d1962a92d9b4bd2972bfa
tree5a32a0aeceaab769b25b6d0f0b8468ec68007bdd
parentc632377810cc9b869c83629d32e1086c5d2ba8b1
x86/pagewalk: Consistently use guest_walk_*() helpers for translation

hap_p2m_ga_to_gfn() and sh_page_fault() currently use guest_l1e_get_gfn() to
obtain the translation of a pagewalk.  This is conceptually wrong (the
semantics of gw.l1e is an internal detail), and will actually be wrong when
PSE36 superpage support is fixed.  Switch them to using guest_walk_to_gfn().

guest_walk_tables() also uses guest_l1e_get_gfn(), and is updated for
consistency.

Take the opportunity to const-correct the walk_t parameter of the
guest_walk_to_*() helpers, and implement guest_walk_to_gpa() in terms of
guest_walk_to_gfn() to avoid duplicating the actual translation calculation.

While editing guest_walk_to_gpa(), fix a latent bug by causing it to return
INVALID_PADDR rather than 0 for a failed translation, as 0 is also a valid
successful result.  The sole caller, sh_page_fault(), has already confirmed
that the translation is valid, so this doesn't cause a behavioural change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/guest_walk.c
xen/arch/x86/mm/hap/guest_walk.c
xen/arch/x86/mm/shadow/multi.c
xen/include/asm-x86/guest_pt.h